24/02/2015

This commit is contained in:
brandon3055 committed 2015-02-24 04:55:47 +11:00
1 parent dec86fad18
commit 02c15a1ddb
44 files changed
+931 -263

No files matched your search

@@ -30,7 +30,7 @@ public class DraconicEvolution { // TODO Update Licence and add change log to gi
public static final String networkChannelName = "DEvolutionNC";
public static SimpleNetworkWrapper network;
public static boolean debug = true;//todo
public static boolean debug = false;//todo
public static Enchantment reaperEnchant;
@@ -54,13 +54,6 @@ public class DraconicEvolution { // TODO Update Licence and add change log to gi
proxy.preInit(event);
/*
public static Achievement ultimatePower;
ultimatePower = new Achievement("achievment.ultimatePower", "Ultimate Power!!!", 1, -2, ModItems.draconicDestructionStaff, null).registerStat();
AchievementPage draconicEvolution = new AchievementPage("Draconic Evolution", ultimatePower);
AchievementPage.registerAchievementPage(draconicEvolution);
*/
}
@Mod.EventHandler
@@ -12,7 +12,7 @@ import com.brandon3055.draconicevolution.client.render.entity.RenderDragonHeart;
import com.brandon3055.draconicevolution.client.render.item.RenderBow;
import com.brandon3055.draconicevolution.client.render.item.RenderMobSoul;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyBeam;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyRing;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyField;
import com.brandon3055.draconicevolution.client.render.tile.*;
import com.brandon3055.draconicevolution.common.CommonProxy;
import com.brandon3055.draconicevolution.common.ModBlocks;
@@ -188,16 +188,16 @@ public class ClientProxy extends CommonProxy {
}
@Override
public ParticleEnergyRing energyRing(World worldObj, double x, double y, double z, int powerFlow, boolean advanced, ParticleEnergyRing oldBeam, boolean render) {
public ParticleEnergyField energyField(World worldObj, double x, double y, double z, int type, boolean advanced, ParticleEnergyField oldBeam, boolean render) {
if (!worldObj.isRemote) return null;
ParticleEnergyRing beam = oldBeam;
ParticleEnergyField beam = oldBeam;
boolean inRange = ParticleHandler.isInRange(x, y, z, 50);
if (beam == null || beam.isDead)
{
if (inRange)
{
beam = new ParticleEnergyRing(worldObj, x, y, z, 8, powerFlow, advanced);
beam = new ParticleEnergyField(worldObj, x, y, z, 8, type, advanced);
FMLClientHandler.instance().getClient().effectRenderer.addEffect(beam);
}
@@ -209,7 +209,7 @@ public class ClientProxy extends CommonProxy {
}
else
{
beam.update(powerFlow, render);
beam.update(render);
}
return beam;
}
@@ -34,7 +34,7 @@ public class HudHandler {
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void drawHUD(RenderGameOverlayEvent.Post event) {
if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
if (ConfigHandler.enableHudDisplay && event.type == RenderGameOverlayEvent.ElementType.ALL) {
if (hudList == null) return;
Minecraft mc = Minecraft.getMinecraft();
@@ -16,4 +16,6 @@ public class ConfigGUI extends GuiConfig {
configElements.addAll(new ConfigElement(ConfigHandler.config.getCategory("spawner")).getChildElements());
configElements.addAll(new ConfigElement(ConfigHandler.config.getCategory("long range dislocator")).getChildElements());
}
}
@@ -303,7 +303,7 @@ public class GUITeleporter extends GuiScreen
@SuppressWarnings("unchecked")
@Override
public void initGui(){
public void initGui(){//todo Localization
buttonList.clear();
int posX = (this.width - xSize) / 2;
int posY = (this.height - ySize) / 2;
@@ -314,13 +314,13 @@ public class GUITeleporter extends GuiScreen
buttonList.add(new GuiButtonAHeight(1, posX + 112, posY + 58, 66, 12, "Set Here"));
buttonList.add(new GuiButtonAHeight(2, posX + 112, posY + 71, 66, 12, "Remove"));
buttonList.add(new GuiButtonAHeight(3, posX + 112, posY + 99, 33, 12, "▲ ▲ ▲"));
buttonList.add(new GuiButtonAHeight(3, posX + 112, posY + 99, 33, 12, "UP"));
buttonList.add(new GuiButtonAHeight(4, posX + 112, posY + 112, 66, 12, "Add New"));
buttonList.add(new GuiButtonAHeight(5, posX + 112, posY + 125, 66, 12, "Add Fuel"));
buttonList.add(new GuiButtonAHeight(6, posX+xSize-63, posY-15, 60, 15, "Cancel"));
buttonList.add(new GuiButtonAHeight(7, posX + 112 + 34, posY + 99, 33, 12, "▼ ▼ ▼"));
buttonList.add(new GuiButtonAHeight(7, posX + 112 + 34, posY + 99, 33, 12, "DOWN"));
((GuiButton) buttonList.get(6)).visible = false;
textBeingEdited = new GuiTextField(fontRendererObj, posX+3, posY-14, xSize-67, 12);
@@ -7,6 +7,7 @@ import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.utills.IConfigurableItem;
import com.brandon3055.draconicevolution.common.utills.IInventoryTool;
import com.brandon3055.draconicevolution.common.utills.ItemConfigField;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
@@ -74,6 +75,18 @@ public class GUIToolConfig extends GUIBase {
setLevel(0);
}
public void updateItemButtons()
{
LogHelper.info("Update Buttons");
for (ComponentBase component : collection.getComponents())
{
if (component instanceof ComponentConfigItemButton)
{
((ComponentConfigItemButton) component).refreshState();
}
}
}
@Override
protected void mouseClicked(int x, int y, int button) {
super.mouseClicked(x, y, button);
@@ -53,6 +53,7 @@ public class GUIToolInventory extends GUIBase {
public void buttonClicked(int id) {
super.buttonClicked(id);
if (guiToolConfig == null) guiToolConfig = new GUIToolConfig(player, container);
guiToolConfig.updateItemButtons();
Minecraft.getMinecraft().displayGuiScreen(guiToolConfig);
guiToolConfig.setLevel(1);
container.setSlotsActive(false);
@@ -27,7 +27,12 @@ public class ComponentConfigItemButton extends ComponentBase {
super(x, y);
this.slot = slot;
this.inventory = player.inventory;
if (inventory.getStackInSlot(slot) != null && ((inventory.getStackInSlot(slot).getItem() instanceof IConfigurableItem && !((IConfigurableItem) inventory.getStackInSlot(slot).getItem()).getFields(inventory.getStackInSlot(slot), slot).isEmpty()) || inventory.getStackInSlot(slot).getItem() instanceof IInventoryTool)) hasValidItem = true;
refreshState();
}
public void refreshState()
{
hasValidItem = (inventory.getStackInSlot(slot) != null && ((inventory.getStackInSlot(slot).getItem() instanceof IConfigurableItem && !((IConfigurableItem) inventory.getStackInSlot(slot).getItem()).getFields(inventory.getStackInSlot(slot), slot).isEmpty()) || inventory.getStackInSlot(slot).getItem() instanceof IInventoryTool));
}
@Override
@@ -59,7 +59,7 @@ public class ModelTeleporterStand extends ModelBase {
}
public void render() {
final float scale = 1F / 16F;
final float scale = 1F / 16;
plate.render(scale);
holders.render(scale);
@@ -1,7 +1,7 @@
package com.brandon3055.draconicevolution.client.render.block;
import com.brandon3055.draconicevolution.common.utills.ICustomItemData;
import com.brandon3055.draconicevolution.common.tileentities.TileDraconiumChest;
import com.brandon3055.draconicevolution.common.utills.ICustomItemData;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;
@@ -140,7 +140,7 @@ public class ParticleEnergyBeam extends EntityFX {
if (!renderParticle) return;
tessellator.draw();
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ATTRIB_STACK_DEPTH);
//GL11.glPushAttrib(GL11.GL_ATTRIB_STACK_DEPTH);
float var9 = 1.0F;
float slide = (float) getPlayer().ticksExisted;
float size = (float) flow / 100f * 2f; //0.7F;
@@ -148,7 +148,7 @@ public class ParticleEnergyBeam extends EntityFX {
else Minecraft.getMinecraft().renderEngine.bindTexture(beamTextureBasic);
GL11.glTexParameterf(3553, 10242, 10497.0F);
GL11.glTexParameterf(3553, 10243, 10497.0F);
GL11.glDisable(2884);
GL11.glDisable(GL11.GL_CULL_FACE);
float var11 = slide + partialTick;
float var12 = -var11 * 0.2F - (float) MathHelper.floor_float(-var11 * 0.1F);
GL11.glBlendFunc(770, 1);
@@ -165,7 +165,7 @@ public class ParticleEnergyBeam extends EntityFX {
double var44 = -0.15D * (double)size;
double var17 = 0.15D * (double)size;
GL11.glTranslated(0.03, 0, 0);
for(int t = 0; t < 2; ++t) {
double var29 = (double)(this.length * var9);
double var31 = 0D;
@@ -190,6 +190,7 @@ public class ParticleEnergyBeam extends EntityFX {
var17 = 0.15D * (double)1;
//GL11.glColor4f(1f, 1f, 1f, 1f);
//GL11.glTranslated(0.1, 0, 0);
for(int t = 0; t < 2; ++t) {
double var29 = (double)(this.length * var9);
double var31 = 0D;
@@ -210,10 +211,10 @@ public class ParticleEnergyBeam extends EntityFX {
}
GL11.glDepthMask(true);
//GL11.glDepthMask(true);
GL11.glBlendFunc(770, 771);
GL11.glEnable(2884);
GL11.glPopAttrib();
GL11.glEnable(GL11.GL_CULL_FACE);
// GL11.glPopAttrib();
GL11.glPopMatrix();
@@ -0,0 +1,132 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
/**
* Created by Brandon on 9/02/2015.
*/
public class ParticleEnergyField extends EntityFX {//todo Fancy Animated Particle? Maby?
/**
* Particle Type 0 = Energy Ring, 1 = single particle
*/
private int type;
private boolean advanced;
private boolean renderParticle = true;
public ParticleEnergyField(World world, double x, double y, double z, int maxAge, int type, boolean advanced) {
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
this.particleRed = 1F;
this.particleGreen = 1F;
this.particleBlue = 1F;
this.noClip = true;
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
this.particleMaxAge = maxAge;
this.type = type;
this.advanced = advanced;
this.setSize(1F, 1F);
}
public void update(boolean render)
{
for (this.renderParticle = render; this.particleMaxAge - this.particleAge < 4; ++this.particleMaxAge) {}
}
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
}
@Override
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
if (!renderParticle) return;
tessellator.draw();
GL11.glPushMatrix();
//GL11.glPushAttrib(GL11.GL_ATTRIB_STACK_DEPTH);
GL11.glDepthMask(false);
ResourceHelper.bindParticles();
float minU = 0.0F + 0.125F * (advanced ? 4 : 3);
float maxU = 0.0F + 0.125F * (advanced ? 5 : 4);//minU + 0.124F;
float minV = 0F;//(float)this.particleTextureIndexY / 32.0F;
float maxV = 0.123F;//minV + 0.124F;
float drawScale = 0.2f;
if (this.particleIcon != null)
{
minU = this.particleIcon.getMinU();
maxU = this.particleIcon.getMaxU();
minV = this.particleIcon.getMinV();
maxV = this.particleIcon.getMaxV();
}
float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX);
float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY);
float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ);
if (type == 0)
{
tessellator.startDrawingQuads();
tessellator.setBrightness(200);
tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1f);
double pCount = Minecraft.getMinecraft().gameSettings.fancyGraphics ? 35 : 15;
for (int i = 0; i < pCount; i++)
{
double rot = i / pCount * (3.141 * 2D) + particleAge / 3D;//1D;//i / 10D;
double offset = 0.4;
double ox = Math.sin(rot) * offset;
double oz = Math.cos(rot) * offset;
float drawXX = drawX + (float) ox;
float drawZZ = drawZ + (float) oz;
tessellator.addVertexWithUV((double) (drawXX - rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZZ - rotZ * drawScale - rotXY * drawScale), (double) maxU, (double) maxV);
tessellator.addVertexWithUV((double) (drawXX - rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZZ - rotZ * drawScale + rotXY * drawScale), (double) maxU, (double) minV);
tessellator.addVertexWithUV((double) (drawXX + rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZZ + rotZ * drawScale + rotXY * drawScale), (double) minU, (double) minV);
tessellator.addVertexWithUV((double) (drawXX + rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZZ + rotZ * drawScale - rotXY * drawScale), (double) minU, (double) maxV);
}
tessellator.draw();
}
else
{
tessellator.startDrawingQuads();
tessellator.setBrightness(200);
tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1f);
tessellator.addVertexWithUV((double) (drawX - rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZ - rotZ * drawScale - rotXY * drawScale), (double) maxU, (double) maxV);
tessellator.addVertexWithUV((double) (drawX - rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZ - rotZ * drawScale + rotXY * drawScale), (double) maxU, (double) minV);
tessellator.addVertexWithUV((double) (drawX + rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZ + rotZ * drawScale + rotXY * drawScale), (double) minU, (double) minV);
tessellator.addVertexWithUV((double) (drawX + rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZ + rotZ * drawScale - rotXY * drawScale), (double) minU, (double) maxV);
tessellator.draw();
}
// GL11.glDepthMask(true);
//GL11.glPopAttrib();
GL11.glPopMatrix();
ResourceHelper.bindDefaultParticles();
tessellator.startDrawingQuads();
}
}
@@ -1,116 +0,0 @@
package com.brandon3055.draconicevolution.client.render.particle;
import com.brandon3055.draconicevolution.client.handler.ResourceHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
/**
* Created by Brandon on 9/02/2015.
*/
public class ParticleEnergyRing extends EntityFX {
/**
* Power flow integer Ranges from 0 to 100
*/
private int flow;
private boolean advanced;
private boolean renderParticle = true;
public ParticleEnergyRing(World world, double x, double y, double z, int maxAge, int flow, boolean advanced) {
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
this.particleRed = 1F;
this.particleGreen = 1F;
this.particleBlue = 1F;
this.noClip = true;
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
this.particleMaxAge = maxAge;
this.flow = flow;
this.advanced = advanced;
this.setSize(1F, 1F);
}
public void update(int flow, boolean render)
{
this.renderParticle = render;
for (this.flow = 100; this.particleMaxAge - this.particleAge < 4; ++this.particleMaxAge) {}
}
@Override
public void onUpdate() {
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();
}
}
@Override
public void renderParticle(Tessellator tessellator, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
if (!renderParticle) return;
tessellator.draw();
GL11.glPushMatrix();
//GL11.glPushAttrib(GL11.GL_ATTRIB_STACK_DEPTH);
GL11.glDepthMask(false);
ResourceHelper.bindParticles();
float minU = 0.0F + 0.125F * (advanced ? 4 : 3);
float maxU = 0.0F + 0.125F * (advanced ? 5 : 4);//minU + 0.124F;
float minV = 0F;//(float)this.particleTextureIndexY / 32.0F;
float maxV = 0.1245F;//minV + 0.124F;
float drawScale = 0.2f;
if (this.particleIcon != null)
{
minU = this.particleIcon.getMinU();
maxU = this.particleIcon.getMaxU();
minV = this.particleIcon.getMinV();
maxV = this.particleIcon.getMaxV();
}
float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX);
float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY);
float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ);
tessellator.startDrawingQuads();
tessellator.setBrightness(200);
tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, 1f);
double pCount = Minecraft.getMinecraft().gameSettings.fancyGraphics ? 35 : 15;
for (int i = 0; i < pCount; i++)
{
double rot = i / pCount * (3.141 * 2D) + particleAge / 3D;//1D;//i / 10D;
double offset = 0.4;
double ox = Math.sin(rot) * offset;
double oz = Math.cos(rot) * offset;
float drawXX = drawX + (float)ox;
float drawZZ = drawZ + (float)oz;
tessellator.addVertexWithUV((double) (drawXX - rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZZ - rotZ * drawScale - rotXY * drawScale), (double) maxU, (double) maxV);
tessellator.addVertexWithUV((double) (drawXX - rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZZ - rotZ * drawScale + rotXY * drawScale), (double) maxU, (double) minV);
tessellator.addVertexWithUV((double) (drawXX + rotX * drawScale + rotYZ * drawScale), (double) (drawY + rotXZ * drawScale), (double) (drawZZ + rotZ * drawScale + rotXY * drawScale), (double) minU, (double) minV);
tessellator.addVertexWithUV((double) (drawXX + rotX * drawScale - rotYZ * drawScale), (double) (drawY - rotXZ * drawScale), (double) (drawZZ + rotZ * drawScale - rotXY * drawScale), (double) minU, (double) maxV);
}
tessellator.draw();
GL11.glDepthMask(true);
//GL11.glPopAttrib();
GL11.glPopMatrix();
ResourceHelper.bindDefaultParticles();
tessellator.startDrawingQuads();
}
}
@@ -72,7 +72,8 @@ public class RenderTileCrystal extends TileEntitySpecialRenderer {
modelCrystal.renderAll();
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glAlphaFunc(GL11.GL_GREATER, 0f);
// GL11.glDisable(GL11.GL_ALPHA_TEST);
//--- Render Overlay ---//
@@ -84,6 +85,7 @@ public class RenderTileCrystal extends TileEntitySpecialRenderer {
//--- Post Render ---//
GL11.glDisable(GL11.GL_BLEND);
RenderHelper.enableStandardItemLighting();
GL11.glPopMatrix();
}
@@ -151,6 +153,7 @@ public class RenderTileCrystal extends TileEntitySpecialRenderer {
//--- Post Render ---//
GL11.glDisable(GL11.GL_BLEND);
RenderHelper.enableStandardItemLighting();
GL11.glPopMatrix();
}
}
@@ -24,11 +24,11 @@ public class RenderTileEnergyInfiser extends TileEntitySpecialRenderer
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, (float) z);
TileEnergyInfuser tile = (TileEnergyInfuser) tileEntity;
renderBlock(tile);
GL11.glPopMatrix();
}
@@ -40,19 +40,26 @@ public class RenderTileEnergyInfiser extends TileEntitySpecialRenderer
tessellator.setColorRGBA(255, 255, 255, 255);
//tessellator.setBrightness(200);
tessellator.setColorOpaque_F(1f, 1f, 1f);
//tessellator.setColorOpaque_F(1f, 1f, 1f);
//OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2);
// GL11.glEnable(GL11.GL_CULL_FACE);
// GL11.glDisable(GL11.GL_ALPHA_TEST);
// GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
// GL11.glDepthMask(true);
drawBase(tessellator);
drawWings(tessellator, tile);
renderChargingItem(tile);
GL11.glDisable(GL11.GL_ALPHA_TEST);
// GL11.glDepthMask(false);
}
private void drawBase(Tessellator tess){
GL11.glPushMatrix();
tess.startDrawingQuads();
tess.setNormal(0.0F, 0.0F, 1.0F);
tess.setNormal(0F, 0F, 1.0F);
double srcXMin = 0D;
double srcYMin = 0D;
@@ -98,10 +98,6 @@ public class RenderTileEnergyPylon extends TileEntitySpecialRenderer {
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_TEXTURE_2D);
@@ -4,7 +4,7 @@ import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.creativetab.DETab;
import com.brandon3055.draconicevolution.client.interfaces.GuiHandler;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyBeam;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyRing;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyField;
import com.brandon3055.draconicevolution.common.achievements.Achievements;
import com.brandon3055.draconicevolution.common.entity.*;
import com.brandon3055.draconicevolution.common.handler.ConfigHandler;
@@ -177,7 +177,7 @@ public abstract class CommonProxy {
return null;
}
public ParticleEnergyRing energyRing(World worldObj, double x, double y, double z, int powerFlow, boolean advanced, ParticleEnergyRing oldBeam, boolean render) {
public ParticleEnergyField energyField(World worldObj, double x, double y, double z, int type, boolean advanced, ParticleEnergyField oldBeam, boolean render) {
return null;
}
}
@@ -23,8 +23,7 @@ public abstract class BlockCustomDrop extends BlockContainerDE {
/**If true the tile will drop its inventory when broken*/
protected abstract boolean dropInventory();
/**If true the tile will a custom block with custom data when broken
* use getCustomTileEntityCrop to specify the lock that should be dropped*/
/**If true the tile will drop a custom block with custom data when broken*/
protected abstract boolean hasCustomDropps();
/**Use to specify custom drops*/
@@ -6,8 +6,8 @@ import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.blocks.itemblocks.DraconiumChestItemBlock;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.lib.Strings;
import com.brandon3055.draconicevolution.common.utills.ICustomItemData;
import com.brandon3055.draconicevolution.common.tileentities.TileDraconiumChest;
import com.brandon3055.draconicevolution.common.utills.ICustomItemData;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -39,6 +39,9 @@ import static net.minecraftforge.common.util.ForgeDirection.UP;
* Created by Brandon on 28/10/2014.
*/
public class DraconiumChest extends BlockCustomDrop {
private static final String[] STORAGE_BLACKLIST = new String[] {"tile.thermalexpansion.strongbox", "item.thermalexpansion.satchel", "tile.draconicevolution:draconiumChest"};
public DraconiumChest() {
super(Material.iron);
this.setBlockName(Strings.draconiumChestName);
@@ -49,11 +52,21 @@ public class DraconiumChest extends BlockCustomDrop {
ModBlocks.register(this, DraconiumChestItemBlock.class);
}
public static boolean isStackValid(ItemStack stack)
{
for (int i = 0; i < STORAGE_BLACKLIST.length; i++)
if (stack.getUnlocalizedName().contains(STORAGE_BLACKLIST[i])) return false;
return true;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float cx, float cy, float cz) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof TileDraconiumChest)) return false;
TileDraconiumChest te = (TileDraconiumChest) tileEntity;
if (player.isSneaking()) {
te.editMode = !te.editMode;
if (world.isRemote)player.addChatComponentMessage(new ChatComponentText(EnumChatFormatting.DARK_GREEN + "" + StatCollector.translateToLocal("msg.draconiumChestEditmode.txt") + EnumChatFormatting.DARK_AQUA + " " + String.valueOf(te.editMode)));
@@ -255,4 +268,6 @@ public class DraconiumChest extends BlockCustomDrop {
}
droppes.add(stack);
}
}
@@ -34,4 +34,14 @@ public class DraconiumChestItemBlock extends ItemBlockCustomData {
public boolean hasCustomEntity(ItemStack stack) {
return true;
}
@Override
public boolean getShareTag() {
return false;
}
@Override
public boolean isDamageable() {
return false;
}
}
@@ -18,7 +18,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -89,6 +91,66 @@ public class EnergyCrystal extends BlockDE implements IHudDisplayBlock
}
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 1 || meta == 0) return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.135F, z + 0.37F, x + 0.63F, y + 0.865F, z + 0.63F);
else if (meta == 2 || meta == 3)
{
TileEnergyTransceiver tile = world.getTileEntity(x, y, z) instanceof TileEnergyTransceiver ? (TileEnergyTransceiver) world.getTileEntity(x, y, z) : null;
if (tile != null)
{
switch (tile.facing)
{
case 0:
return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.59F, z + 0.37F, x + 0.63F, y + 1.0F, z + 0.63F);
case 1:
return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.0F, z + 0.37F, x + 0.63F, y + 0.41F, z + 0.63F);
case 2:
return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.37F, z + 0.59F, x + 0.63F, y + 0.63F, z + 1.0F);
case 3:
return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.37F, z + 0.0F, x + 0.63F, y + 0.63F, z + 0.41F);
case 4:
return AxisAlignedBB.getBoundingBox(x + 0.59F, y + 0.37F, z + 0.37F, x + 1.0F, y + 0.63F, z + 0.63F);
case 5:
return AxisAlignedBB.getBoundingBox(x + 0.0F, y + 0.37F, z + 0.37F, x + 0.41F, y + 0.63F, z + 0.63F);
}
}
}
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 1 || meta == 0) return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.135F, z + 0.37F, x + 0.63F, y + 0.865F, z + 0.63F);
else if (meta == 2 || meta == 3)
{
TileEnergyTransceiver tile = world.getTileEntity(x, y, z) instanceof TileEnergyTransceiver ? (TileEnergyTransceiver) world.getTileEntity(x, y, z) : null;
if (tile != null)
{
switch (tile.facing)
{
case 0:
return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.59F, z + 0.37F, x + 0.63F, y + 1.0F, z + 0.63F);
case 1:
return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.0F, z + 0.37F, x + 0.63F, y + 0.41F, z + 0.63F);
case 2:
return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.37F, z + 0.59F, x + 0.63F, y + 0.63F, z + 1.0F);
case 3:
return AxisAlignedBB.getBoundingBox(x + 0.37F, y + 0.37F, z + 0.0F, x + 0.63F, y + 0.63F, z + 0.41F);
case 4:
return AxisAlignedBB.getBoundingBox(x + 0.59F, y + 0.37F, z + 0.37F, x + 1.0F, y + 0.63F, z + 0.63F);
case 5:
return AxisAlignedBB.getBoundingBox(x + 0.0F, y + 0.37F, z + 0.37F, x + 0.41F, y + 0.63F, z + 0.63F);
}
}
}
return super.getSelectedBoundingBoxFromPool(world, x, y, z);
}
@Override
public boolean hasTileEntity(int metadata) {
return true;
@@ -136,7 +198,7 @@ public class EnergyCrystal extends BlockDE implements IHudDisplayBlock
}
@Override
public List<String> getDisplayData(World world, int x, int y, int z) {
public List<String> getDisplayData(World world, int x, int y, int z) {//todo Localization
List<String> list = new ArrayList<String>();
IRemoteEnergyHandler tile = world.getTileEntity(x, y, z) instanceof IRemoteEnergyHandler ? (IRemoteEnergyHandler) world.getTileEntity(x, y, z) : null;
if (tile != null)
@@ -144,6 +206,14 @@ public class EnergyCrystal extends BlockDE implements IHudDisplayBlock
list.add(InfoHelper.HITC()+getLocalizedName());
list.add("RF: " + tile.getEnergyStored(ForgeDirection.DOWN));
list.add("Cap: " + tile.getCapacity() + "%");
if (tile instanceof TileEnergyTransceiver) {
String x5 = ((TileEnergyTransceiver) tile).getPowerTier() > 0 && ((TileEnergyTransceiver) tile).transferBoost ? StatCollector.translateToLocal("info.de.5xTransfer.txt") : "";
list.add(((TileEnergyTransceiver)tile).getInput() ? StatCollector.translateToLocal("info.de.modeIn.txt") + x5 : StatCollector.translateToLocal("info.de.modeOut.txt") + x5);
}
if (tile instanceof TileRemoteEnergyBase) {
list.add(StatCollector.translateToLocal("info.de.connections.txt") + ": " + ((TileRemoteEnergyBase) tile).linkedDevices.size() + "/" + tile.getMaxConnections());
}
if (tile instanceof TileRemoteEnergyBase)
{
for (LinkedEnergyDevice l : ((TileRemoteEnergyBase) tile).linkedDevices)
@@ -155,4 +225,8 @@ public class EnergyCrystal extends BlockDE implements IHudDisplayBlock
return list;
}
@Override
public int damageDropped(int dmg) {
return dmg;
}
}
@@ -29,6 +29,7 @@ public class ContainerAdvTool extends ContainerDataSync {
this.inventoryTool = inventory;
this.inventoryTool.setContainer(this);
this.player = invPlayer.player;
setSlotsActive(false);
}
public void setSlotsActive(boolean active) {
@@ -56,6 +57,18 @@ public class ContainerAdvTool extends ContainerDataSync {
addSlotToContainer(new SlotEnchantment(inventoryTool, inventoryTool.size + y, 173, 19 + y * 21));
}
}
else
{
for (int x = 0; x < 9; x++) {
addSlotToContainer(new SlotPlayerInv(player.inventory, x, -1000 + 8 + 18 * x, -1000 + 103, inventoryItemSlot));
}
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 9; x++) {
addSlotToContainer(new SlotPlayerInv(player.inventory, x + y * 9 + 9, -1000 + 8 + 18 * x, -1000 + 45 + y * 18, inventoryItemSlot));
}
}
}
if (player.worldObj.isRemote)
{
@@ -1,6 +1,7 @@
package com.brandon3055.draconicevolution.common.container;
import cofh.api.energy.IEnergyContainerItem;
import com.brandon3055.draconicevolution.common.blocks.DraconiumChest;
import com.brandon3055.draconicevolution.common.inventory.InventoryCraftingChest;
import com.brandon3055.draconicevolution.common.inventory.InventoryCraftingChestResult;
import com.brandon3055.draconicevolution.common.tileentities.TileDraconiumChest;
@@ -54,7 +55,7 @@ public class ContainerDraconiumChest extends Container {
{
for (int chestCol = 0; chestCol < 26; chestCol++)
{
addSlotToContainer(new Slot(tile, chestCol + (chestRow * 26), 8 + chestCol * 18, 15 + chestRow * 18));
addSlotToContainer(new SlotDChest(tile, chestCol + (chestRow * 26), 8 + chestCol * 18, 15 + chestRow * 18));
}
}
@@ -88,7 +89,7 @@ public class ContainerDraconiumChest extends Container {
{
for (int gridRow = 0; gridRow < 3; ++gridRow)
{
addSlotToContainer(new Slot(craftMatrix, gridRow + (gridCol * 3), xOffset + (gridRow * 18), yOffset + (gridCol * 18)));
addSlotToContainer(new SlotDChest(craftMatrix, gridRow + (gridCol * 3), xOffset + (gridRow * 18), yOffset + (gridCol * 18)));
}
}
}
@@ -242,4 +243,20 @@ public class ContainerDraconiumChest extends Container {
return 1;
}
}
public class SlotDChest extends Slot {
public SlotDChest(IInventory inventory, int id, int x, int y) {
super(inventory, id, x, y);
}
@Override
public boolean isItemValid(ItemStack stack)
{
return DraconiumChest.isStackValid(stack);
}
}
}
@@ -48,8 +48,7 @@ public class EntityCustomDragon extends EntityDragon {
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(health);
this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(health);
this.attackDamage = attack;
//LogHelper.info(attackDamage);
this.addPotionEffect(new PotionEffect(10, 600, 10, false));;
this.addPotionEffect(new PotionEffect(10, 600, 10, false));
}
@Override
@@ -298,6 +297,7 @@ public class EntityCustomDragon extends EntityDragon {
@Override
protected void onDeathUpdate() {
if (deathTicks == 0 && !isUber)
{
for (int ix = -150; ix < 150; ix++) {
@@ -597,6 +597,9 @@ public class EntityCustomDragon extends EntityDragon {
super.writeToNBT(compound);
compound.setFloat("AttackDamage", attackDamage);
compound.setBoolean("IsUber", isUber);
compound.setInteger("PortalX", portalX);
compound.setInteger("PortalY", portalY);
compound.setInteger("PortalZ", portalZ);
}
@Override
@@ -605,6 +608,9 @@ public class EntityCustomDragon extends EntityDragon {
attackDamage = compound.getFloat("AttackDamage");
isUber = compound.getBoolean("IsUber");
this.dataWatcher.updateObject(12, isUber ? (byte)1: (byte)0);
portalX = compound.getInteger("PortalX");
portalY = compound.getInteger("PortalY");
portalZ = compound.getInteger("PortalZ");
}
@Override
@@ -625,4 +631,16 @@ public class EntityCustomDragon extends EntityDragon {
public boolean getIsUber(){
return isUber;
}
@Override
public boolean attackEntityFrom(DamageSource damageSource, float dmg) {
if (damageSource.getEntity() != null && getDistanceToEntity(damageSource.getEntity()) > 100) return false;
return super.attackEntityFrom(damageSource, dmg);
}
@Override
public boolean attackEntityFromPart(EntityDragonPart p_70965_1_, DamageSource damageSource, float p_70965_3_) {
if (damageSource.getEntity() != null && getDistanceSqToEntity(damageSource.getEntity()) > 100) return false;
return super.attackEntityFromPart(p_70965_1_, damageSource, p_70965_3_);
}
}
@@ -18,7 +18,6 @@ public class ConfigHandler {
public static int cometRarity;
public static int hudX;
public static int hudY;
public static String[] obliterationList;
public static boolean generateEnderComets;
public static boolean generateChaosIslands;
public static boolean pigmenBloodRage;
@@ -26,6 +25,10 @@ public class ConfigHandler {
public static boolean showUnlocalizedNames;
public static boolean disableLore;
public static boolean invertDPDSB;
public static boolean disableOreSpawnEnd;
public static boolean disableOreSpawnOverworld;
public static boolean disableOreSpawnNether;
public static boolean enableHudDisplay;
//spawner
public static String[] spawnerList;
@@ -46,7 +49,6 @@ public class ConfigHandler {
private static String[] defaultSpawnerList = new String[] {"ExampleMob1", "ExampleMob2", "ExampleMob3 (these examples can be deleted)"};
private static String[] defaultObliterationList = new String[] {"tile.stonebrick", "tile.gravel", "tile.dirt", "tile.stone", "tile.dirt", "tile.sandStone", "tile.sand", "tile.grass", "tile.hellrock"};
public static void init(File confFile) {
if (config == null) {
@@ -64,7 +66,6 @@ public class ConfigHandler {
disableXrayBlock = config.get(Configuration.CATEGORY_GENERAL, "Disable Xray Block", 0, "Disable Distortion Flame 0:Default, 1:Disable recipe, 2:Disable completely").getInt(0);
teleporterUsesPerPearl = config.get(Configuration.CATEGORY_GENERAL, "Teleporter Uses PerPearl", 1, "Charm of Dislocation uses per Ender pearl").getInt(1);
bowBlockDamage = config.get(Configuration.CATEGORY_GENERAL, "Bow Block Damage", true, "Dose Draconic bow explosion damage blocks").getBoolean(true);
obliterationList = config.getStringList("Oblit Mode List", Configuration.CATEGORY_GENERAL, defaultObliterationList, "List of block (unlocalized)names that will be destroyed by tools in obliteration mode. To find the unlocalized name of a block see the \"Show Unlocalized Names\" config option");
showUnlocalizedNames = config.get(Configuration.CATEGORY_GENERAL, "Show Unlocalized Names", false, "If set to true the unlocalized name of every block and item will be displayed in its tool tip").getBoolean(false);
soulDropChance = config.get(Configuration.CATEGORY_GENERAL, "soulDropChance", 1000, "Mobs have a 1 in this number chance to drop a soul", 1, Integer.MAX_VALUE).getInt(1000);
passiveSoulDropChance = config.get(Configuration.CATEGORY_GENERAL, "passiveSoulDropChance", 800, "Passive (Animals) Mobs have a 1 in this number chance to drop a soul", 1, Integer.MAX_VALUE).getInt(800);
@@ -76,7 +77,10 @@ public class ConfigHandler {
invertDPDSB = config.get(Configuration.CATEGORY_GENERAL, "InvertDPDSB", false, "Invert Dislocator Pedestal display name shift behavior").getBoolean(false);
hudX = config.get(Configuration.CATEGORY_GENERAL, "Hud Display X pos", 7).getInt(7);
hudY = config.get(Configuration.CATEGORY_GENERAL, "Hud Display Y pos", 874).getInt(874);
disableOreSpawnEnd = config.get(Configuration.CATEGORY_GENERAL, "Disable Ore Spawn (End)", false, "Set to true to prevent draconium ore from spawning in the end").getBoolean(false);
disableOreSpawnNether = config.get(Configuration.CATEGORY_GENERAL, "Disable Ore Spawn (Nether)", false, "Set to true to prevent draconium ore from spawning in the nether").getBoolean(false);
disableOreSpawnOverworld = config.get(Configuration.CATEGORY_GENERAL, "Disable Ore Spawn (Overworld)", false, "Set to true to prevent draconium ore from spawning in the overworld").getBoolean(false);
enableHudDisplay = config.get(Configuration.CATEGORY_GENERAL, "Enable HUD info", true, "Set to false to disable the HUD info for tools and blocks").getBoolean(true);
//Spawner
spawnerListType = config.get("spawner", "listType", false, "Sets weather the spawner list is a white list or a black list (true = white list false = black list)").getBoolean(false);
@@ -4,17 +4,30 @@ import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.common.ModItems;
import com.brandon3055.draconicevolution.common.items.ItemDE;
import com.brandon3055.draconicevolution.common.lib.Strings;
import com.brandon3055.draconicevolution.common.utills.IHudDisplayItem;
import com.brandon3055.draconicevolution.common.utills.ItemNBTHelper;
import com.brandon3055.draconicevolution.common.utills.UpdateChecker;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Brandon on 23/08/2014.
*/
public class Wrench extends ItemDE {
public class Wrench extends ItemDE implements IHudDisplayItem{
public static final String BIND_MODE = "bind";
public static final String UNBIND_MODE = "unBind";
public static final String CLEAR_BINDINGS = "unBindAll";
public static final String MODE_SWITCH = "modeSwitch";
public Wrench()
{
@@ -24,10 +37,66 @@ public class Wrench extends ItemDE {
ModItems.register(this);
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
new UpdateChecker();
if (player.isSneaking()) cycleMode(stack, world, player);
else if (ItemNBTHelper.getCompound(stack).hasKey("LinkData") && ItemNBTHelper.getCompound(stack).getCompoundTag("LinkData").getBoolean("Bound")) ItemNBTHelper.getCompound(stack).getCompoundTag("LinkData").setBoolean("Bound", false);
return super.onItemRightClick(stack, world, player);
}
static final String[] modes = new String[] {BIND_MODE, UNBIND_MODE, CLEAR_BINDINGS, MODE_SWITCH};
private static void cycleMode(ItemStack stack, World world, EntityPlayer player)
{
String currentMode = ItemNBTHelper.getString(stack, "Mode", "bind");
int mode = 0;
for (String s : modes)
{
if (s.equals(currentMode))
{
if (mode + 1 >= modes.length) currentMode = modes[0];
else currentMode = modes[mode + 1];
break;
}
mode++;
}
ItemNBTHelper.setString(stack, "Mode", currentMode);
if (world.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.wrenchMode." + currentMode + ".txt"));
}
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) {
//list.add(InfoHelper.ITC() + StatCollector.translateToLocal("info.de.safetyMatch.txt"));
public void addInformation(ItemStack stack, EntityPlayer p_77624_2_, List list, boolean bool) {
list.add(StatCollector.translateToLocal("msg.de.wrenchMode." + ItemNBTHelper.getString(stack, "Mode", "bind") + ".txt"));
NBTTagCompound linkDat = null;
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("LinkData")) linkDat = stack.getTagCompound().getCompoundTag("LinkData");
if (linkDat != null && linkDat.getBoolean("Bound"))
{
list.add(StatCollector.translateToLocal("msg.de.boundTo.txt") + ": [X:" + linkDat.getInteger("XCoord") + ", Y:" + linkDat.getInteger("YCoord") + ", Z:" + linkDat.getInteger("ZCoord") + "]");
list.add(StatCollector.translateToLocal("msg.de.rightClickUnbind.txt"));
}
}
@Override
public List<String> getDisplayData(ItemStack stack) {
List<String> list = new ArrayList<String>();
list.add(StatCollector.translateToLocal("msg.de.wrenchMode." + ItemNBTHelper.getString(stack, "Mode", "bind") + ".txt"));
NBTTagCompound linkDat = null;
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("LinkData")) linkDat = stack.getTagCompound().getCompoundTag("LinkData");
if (linkDat != null && linkDat.getBoolean("Bound"))
{
list.add(StatCollector.translateToLocal("msg.de.boundTo.txt") + ": [X:" + linkDat.getInteger("XCoord") + ", Y:" + linkDat.getInteger("YCoord") + ", Z:" + linkDat.getInteger("ZCoord") + "]");
list.add(StatCollector.translateToLocal("msg.de.rightClickUnbind.txt"));
}
return list;
}
public static String getMode(ItemStack stack)
{
return ItemNBTHelper.getString(stack, "Mode", "bind");
}
}
@@ -3,8 +3,8 @@ package com.brandon3055.draconicevolution.common.lib;
public final class References {
public static final String MODID = "DraconicEvolution";
public static final String MODNAME = "Draconic Evolution";
public static final String VERSION = "1.0.1-snapshot_3";
public static final String MCVERSION = "1.7.10";
public static final String VERSION = VersionHandler.FULL_VERSION;
public static final String MCVERSION = VersionHandler.MCVERSION;
public static final String CLIENTPROXYLOCATION = "com.brandon3055.draconicevolution.client.ClientProxy";
public static final String SERVERPROXYLOCATION = "com.brandon3055.draconicevolution.common.ServerProxy";
public static final String GUIFACTORY = "com.brandon3055.draconicevolution.client.interfaces.DEGUIFactory";
@@ -0,0 +1,13 @@
package com.brandon3055.draconicevolution.common.lib;
/**
* Created by Brandon on 24/02/2015.
*/
public class VersionHandler
{
public static final String VERSION = "1.0.1";
public static final int SNAPSHOT = 4;
public static final String MCVERSION = "1.7.10";
public static final String FULL_VERSION = VERSION + (SNAPSHOT > 0 ? "-snapshot_" + SNAPSHOT: "");
}
@@ -3,6 +3,7 @@ package com.brandon3055.draconicevolution.common.tileentities;
import cofh.api.energy.IEnergyContainerItem;
import cofh.api.energy.IEnergyHandler;
import com.brandon3055.draconicevolution.common.ModBlocks;
import com.brandon3055.draconicevolution.common.blocks.DraconiumChest;
import com.brandon3055.draconicevolution.common.container.ContainerDraconiumChest;
import com.brandon3055.draconicevolution.common.lib.OreDoublingRegistry;
import com.brandon3055.draconicevolution.common.utills.EnergyStorage;
@@ -13,6 +14,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
@@ -297,9 +299,21 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg
@Override
public Packet getDescriptionPacket() {
NBTTagCompound tagCompound = new NBTTagCompound();
this.writeToNBT(tagCompound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound);
NBTTagCompound compound = new NBTTagCompound();
compound.setByte("facing", (byte) facing);
compound.setInteger("Red", red);
compound.setInteger("Green", green);
compound.setInteger("Blue", blue);
compound.setBoolean("Edit", editMode);
compound.setByte("AutoFeed", (byte) smeltingAutoFeed);
if (customName != null && customName.length() > 0)compound.setString("CustomName", customName);
energy.writeToNBT(compound);
super.writeToNBT(compound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, compound);
// NBTTagCompound tagCompound = new NBTTagCompound();
// this.writeToNBT(tagCompound);
// return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound);
}
@Override
@@ -400,7 +414,7 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return true;
return DraconiumChest.isStackValid(itemstack);
}
@Override
@@ -465,28 +479,31 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg
@Override
public void writeDataToItem(NBTTagCompound compound, ItemStack stack) {
NBTTagCompound[] tag = new NBTTagCompound[items.length];
NBTTagList tagList = new NBTTagList();
for (int i = 0; i < items.length; i++) {
tag[i] = new NBTTagCompound();
if (items[i] != null) {
tag[i] = items[i].writeToNBT(tag[i]);
if (items[i] != null)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setShort("IS", (short)i);
items[i].writeToNBT(tag);
tagList.appendTag(tag);
}
compound.setTag("Item" + i, tag[i]);
}
for (int i = 0; i < itemsCrafting.length; i++) {
tag[i] = new NBTTagCompound();
if (itemsCrafting[i] != null) {
tag[i] = itemsCrafting[i].writeToNBT(tag[i]);
if (itemsCrafting[i] != null)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setShort("CS", (short)i);
itemsCrafting[i].writeToNBT(tag);
tagList.appendTag(tag);
}
compound.setTag("CraftingItem" + i, tag[i]);
}
compound.setTag("Inventory", tagList);
compound.setInteger("Red", red);
compound.setInteger("Green", green);
compound.setInteger("Blue", blue);
@@ -498,16 +515,22 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg
@Override
public void readDataFromItem(NBTTagCompound compound, ItemStack stack) {
NBTTagCompound[] tag = new NBTTagCompound[items.length];
for (int i = 0; i < items.length; i++) {
tag[i] = compound.getCompoundTag("Item" + i);
items[i] = ItemStack.loadItemStackFromNBT(tag[i]);
}
for (int i = 0; i < itemsCrafting.length; i++) {
tag[i] = compound.getCompoundTag("CraftingItem" + i);
itemsCrafting[i] = ItemStack.loadItemStackFromNBT(tag[i]);
if (compound.hasKey("Inventory"))
{
NBTTagList tagList = compound.getTagList("Inventory", 10);
for (int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound tag = tagList.getCompoundTagAt(i);
if (tag.hasKey("IS"))
{
items[tag.getShort("IS")] = ItemStack.loadItemStackFromNBT(tag);
}
else if (tag.hasKey("CS"))
{
itemsCrafting[tag.getShort("CS")] = ItemStack.loadItemStackFromNBT(tag);
}
}
}
red = compound.getInteger("Red");
@@ -518,6 +541,61 @@ public class TileDraconiumChest extends TileEntity implements IInventory, IEnerg
energy.readFromNBT(compound);
}
// @Override
// public void writeDataToItem(NBTTagCompound compound, ItemStack stack) {
// NBTTagCompound[] tag = new NBTTagCompound[items.length];
//
// for (int i = 0; i < items.length; i++) {
// tag[i] = new NBTTagCompound();
//
// if (items[i] != null) {
// tag[i] = items[i].writeToNBT(tag[i]);
// }
//
// compound.setTag("Item" + i, tag[i]);
// }
//
// for (int i = 0; i < itemsCrafting.length; i++) {
// tag[i] = new NBTTagCompound();
//
// if (itemsCrafting[i] != null) {
// tag[i] = itemsCrafting[i].writeToNBT(tag[i]);
// }
//
// compound.setTag("CraftingItem" + i, tag[i]);
// }
//
// compound.setInteger("Red", red);
// compound.setInteger("Green", green);
// compound.setInteger("Blue", blue);
// compound.setBoolean("Edit", editMode);
// compound.setByte("AutoFeed", (byte) smeltingAutoFeed);
// if (hasCustomInventoryName()) stack.setStackDisplayName(customName);
// energy.writeToNBT(compound);
// }
// @Override
// public void readDataFromItem(NBTTagCompound compound, ItemStack stack) {
// NBTTagCompound[] tag = new NBTTagCompound[items.length];
//
// for (int i = 0; i < items.length; i++) {
// tag[i] = compound.getCompoundTag("Item" + i);
// items[i] = ItemStack.loadItemStackFromNBT(tag[i]);
// }
//
// for (int i = 0; i < itemsCrafting.length; i++) {
// tag[i] = compound.getCompoundTag("CraftingItem" + i);
// itemsCrafting[i] = ItemStack.loadItemStackFromNBT(tag[i]);
// }
//
// red = compound.getInteger("Red");
// green = compound.getInteger("Green");
// blue = compound.getInteger("Blue");
// editMode = compound.getBoolean("Edit");
// smeltingAutoFeed = compound.getByte("AutoFeed");
// energy.readFromNBT(compound);
// }
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
return this.energy.receiveEnergy(maxReceive, simulate);
@@ -2,7 +2,7 @@ package com.brandon3055.draconicevolution.common.tileentities;
import cofh.api.energy.IEnergyHandler;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyBeam;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyRing;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyField;
import com.brandon3055.draconicevolution.common.utills.EnergyStorage;
import com.brandon3055.draconicevolution.common.utills.LogHelper;
import com.brandon3055.draconicevolution.common.utills.Utills;
@@ -26,14 +26,14 @@ public class TileTestBlock extends TileEntity implements IEnergyHandler {
public float modelRotation;
//Use a map for the beam to each target (Target, Beam)
private ParticleEnergyBeam beam = null;
private ParticleEnergyRing ring = null;
private ParticleEnergyField ring = null;
@Override
public void updateEntity() {
//beam = DraconicEvolution.proxy.energyBeam(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0.5, 4.5, 0.5, 100, true, beam);
//ring = DraconicEvolution.proxy.energyRing(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, ClientEventHandler.elapsedTicks % 100, true, ring);
//ring = DraconicEvolution.proxy.energyField(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, ClientEventHandler.elapsedTicks % 100, true, ring);
if (worldObj.isRemote) return;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
@@ -1,6 +1,7 @@
package com.brandon3055.draconicevolution.common.tileentities.energynet;
import cofh.api.energy.IEnergyHandler;
import com.brandon3055.draconicevolution.common.utills.EnergyStorage;
import net.minecraft.entity.player.EntityPlayer;
/**
@@ -24,4 +25,8 @@ public interface IRemoteEnergyHandler extends IEnergyHandler {
double getBeamY();
double getBeamZ();
EnergyStorage getStorage();
int getMaxConnections();
}
@@ -1,14 +1,14 @@
package com.brandon3055.draconicevolution.common.tileentities.energynet;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyRing;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyField;
import net.minecraft.nbt.NBTTagCompound;
/**
* Created by Brandon on 10/02/2015.
*/
public class TileEnergyRelay extends TileRemoteEnergyBase {
private ParticleEnergyRing ring;
private ParticleEnergyField ring;
public TileEnergyRelay(){}
@@ -20,17 +20,17 @@ public class TileEnergyRelay extends TileRemoteEnergyBase {
@Override
public int getCap() {
return 50000 + (powerTier * 450000);
return 50000 + (powerTier * 4500000);
}
@Override
public int getRec() {
return 50000 + (powerTier * 450000);
return 50000 + (powerTier * 4500000);
}
@Override
public int getExt() {
return 50000 + (powerTier * 450000);
return 50000 + (powerTier * 4500000);
}
@Override
@@ -39,7 +39,7 @@ public class TileEnergyRelay extends TileRemoteEnergyBase {
if (worldObj.isRemote)
{
ring = DraconicEvolution.proxy.energyRing(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0, powerTier == 1, ring, inView > 0);
ring = DraconicEvolution.proxy.energyField(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0, powerTier == 1, ring, inView > 0);
return;
}
}
@@ -66,7 +66,7 @@ public class TileEnergyRelay extends TileRemoteEnergyBase {
*return double between 0 to 100*/
public double getFlow(double localCap, double remoteCap)
{
return Math.max(0, Math.min(100, (localCap - remoteCap) * 10D/*Flow Multiplier*/));
return Math.max(0, Math.min(100, (localCap - remoteCap) * 100D/*Flow Multiplier*/));
}
@Override
@@ -83,4 +83,9 @@ public class TileEnergyRelay extends TileRemoteEnergyBase {
public double getBeamZ() {
return zCoord + 0.5D;
}
@Override
public int getMaxConnections() {
return powerTier == 0 ? 10 : 20;
}
}
@@ -1,6 +1,14 @@
package com.brandon3055.draconicevolution.common.tileentities.energynet;
import cofh.api.energy.IEnergyHandler;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.render.particle.ParticleEnergyField;
import com.brandon3055.draconicevolution.common.items.tools.Wrench;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
/**
* Created by Brandon on 16/02/2015.
@@ -8,6 +16,9 @@ import net.minecraft.nbt.NBTTagCompound;
public class TileEnergyTransceiver extends TileRemoteEnergyBase{
public int facing = 0;//0=up, 1=down, 3=north, 2=south, 4=east, 5=west
private boolean input = false;
public boolean transferBoost = false;
private ParticleEnergyField particle;
public TileEnergyTransceiver() {}
@@ -20,8 +31,62 @@ public class TileEnergyTransceiver extends TileRemoteEnergyBase{
@Override
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote)
{
ForgeDirection direction = ForgeDirection.getOrientation(facing).getOpposite();
TileEntity adjacentTile = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
if (!input && adjacentTile instanceof IEnergyHandler)
{
IEnergyHandler handler = (IEnergyHandler) adjacentTile;
storage.extractEnergy(handler.receiveEnergy(direction.getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false);
if (transferBoost)
{
for (int i = 0; i < 4; i++) storage.extractEnergy(handler.receiveEnergy(direction.getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false);
}
}
else if (input && adjacentTile instanceof IEnergyHandler)
{
IEnergyHandler handler = (IEnergyHandler) adjacentTile;
if (transferBoost)
{
for (int i = 0; i < 4; i++) storage.receiveEnergy(handler.extractEnergy(direction.getOpposite(), storage.receiveEnergy(storage.getMaxExtract(), true), false), false);
}
}
}
if (worldObj.isRemote) particle = DraconicEvolution.proxy.energyField(worldObj, getBeamX(), getBeamY(), getBeamZ(), 1, powerTier == 1, particle, inView > 0);
}
@Override
public boolean handleOther(EntityPlayer player, ItemStack wrench) {
String mode = Wrench.getMode(wrench);
if (mode.equals(Wrench.MODE_SWITCH))
{
if (powerTier == 0)
{
input = !input;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
else
{
if (!transferBoost) transferBoost = true;
else
{
input = !input;
transferBoost = false;
}
}
}
return true;
}
public boolean getInput() { return input; }
public void setInput(boolean input) { this.input = input;}
@Override
public double getBeamX() {
return xCoord + 0.5;
@@ -39,28 +104,60 @@ public class TileEnergyTransceiver extends TileRemoteEnergyBase{
@Override
public int getCap() {
return 50000 + (powerTier * 450000);
return powerTier == 0 ? 50000 : 10000000;
}
@Override
public int getRec() {
return 50000 + (powerTier * 450000);
return powerTier == 0 ? 50000 : 10000000;
}
@Override
public int getExt() {
return 50000 + (powerTier * 450000);
return powerTier == 0 ? 50000 : 10000000;
}
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
compound.setInteger("Facing", facing);
compound.setBoolean("Input", input);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
facing = compound.getInteger("Facing");
input = compound.getBoolean("Input");
}
@Override
public boolean canConnectEnergy(ForgeDirection from) {
return from == ForgeDirection.getOrientation(facing).getOpposite();
}
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
return from == ForgeDirection.getOrientation(facing).getOpposite() && input ? storage.receiveEnergy(maxReceive, simulate) : 0;
}
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
return from == ForgeDirection.getOrientation(facing).getOpposite() && !input ? storage.extractEnergy(maxExtract, simulate) : 0;
}
@Override
public int getEnergyStored(ForgeDirection from) {
return storage.getEnergyStored();
}
@Override
public int getMaxEnergyStored(ForgeDirection from) {
return storage.getMaxEnergyStored();
}
@Override
public int getMaxConnections() {
return powerTier == 0 ? 2 : 4;
}
}
@@ -2,19 +2,21 @@ package com.brandon3055.draconicevolution.common.tileentities.energynet;
import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.common.ModItems;
import com.brandon3055.draconicevolution.common.items.tools.Wrench;
import com.brandon3055.draconicevolution.common.lib.References;
import com.brandon3055.draconicevolution.common.tileentities.TileObjectSync;
import com.brandon3055.draconicevolution.common.utills.*;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
@@ -23,13 +25,14 @@ import java.util.List;
/**
* Created by Brandon on 10/02/2015.
*/
public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRemoteEnergyHandler {
public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRemoteEnergyHandler {//todo optimize (add cutoff, explore possible cach optimization)
/**The tier of the relay (0-1)*/
protected int powerTier;
protected EnergyStorage storage = new EnergyStorage(0);
public List<LinkedEnergyDevice> linkedDevices = new ArrayList<LinkedEnergyDevice>();
protected int lastTickEnergy;
private int tick = 0;
public byte inView = 0;
@@ -48,22 +51,42 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
@Override
public void updateEntity() {
tick++;
//worldObj.theProfiler.startSection("DE REB");
updateLinkedDevices();
if (linkedDevices.size() == 0) detectAndSendChanges(-1);
if (worldObj.isRemote && inView > 0) --inView;
//worldObj.theProfiler.endSection();
}
//**********Distribution Logic**********
private void updateLinkedDevices()
{
//LogHelper.info(storage.getEnergyStored());
boolean inView = false;
// if (worldObj.isRemote)
// {
// MovingObjectPosition mop = Minecraft.getMinecraft().thePlayer.rayTrace(5, 0);
// if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && mop.blockX == xCoord && mop.blockY == yCoord && mop.blockZ == zCoord) inView = true;//todo remove
// }
if (inView)LogHelper.info("######Start#######");
for (LinkedEnergyDevice device : linkedDevices)
{
if (!device.isValid(worldObj)) {
linkedDevices.remove(device);
updateLinkedDevices();
return;
if (worldObj.getChunkFromBlockCoords(device.xCoord, device.zCoord).isChunkLoaded)
{
linkedDevices.remove(device);
updateLinkedDevices();
return;
}
else
{
continue;
}
}
IRemoteEnergyHandler remoteTile = device.getEnergyTile(worldObj);
@@ -81,7 +104,7 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
if (remoteTile instanceof TileEnergyRelay) rType = 1;
else rType = 0;
}
if (inView) LogHelper.info(device.energyFlow);
device.beam = DraconicEvolution.proxy.energyBeam(worldObj, getBeamX(), getBeamY(), getBeamZ(), remoteTile.getBeamX(), remoteTile.getBeamY(), remoteTile.getBeamZ(), (int)device.energyFlow, getPowerTier() == 1, device.beam, true, rType);
}
else
@@ -91,15 +114,18 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
double difference = getCapacity() - remoteTile.getCapacity();
int energyToEqual = (int)(((difference / 100D) * (double)remoteTile.getMaxEnergyStored(ForgeDirection.UNKNOWN)) / 2.1D);
int energyToEqual = (int)(((difference / 100D) * (double)remoteTile.getStorage().getMaxEnergyStored()) / 2.1D);
double maxFlow = Math.min(energyToEqual, Math.min(transferCap, remoteTile.getMaxEnergyStored(ForgeDirection.UNKNOWN) - remoteTile.getEnergyStored(ForgeDirection.UNKNOWN)));
double maxFlow = Math.min(energyToEqual, Math.min(transferCap, remoteTile.getStorage().getMaxEnergyStored() - remoteTile.getStorage().getEnergyStored()));
device.energyFlow = getFlow(getCapacity(), remoteTile.getCapacity());
int flow = (int) ((device.energyFlow / 100D) * maxFlow);
storage.extractEnergy(remoteTile.receiveEnergy(ForgeDirection.UNKNOWN, storage.extractEnergy(flow, true), false), false);
int transfered = storage.extractEnergy(remoteTile.getStorage().receiveEnergy(storage.extractEnergy(flow, true), false), false);
if (inView)LogHelper.info(transfered);
device.energyFlow = Math.min(((double)transfered / 10000D) * 100D, 100D);
//LogHelper.info("dif:" + difference + " flow:" + getFlow(getCapacity(), remoteTile.getCapacity()) + " EtoE:" + energyToEqual + " tfrd:" + transfered + " X:" + xCoord + " lCap:" + getCapacity() + " rCap:" + remoteTile.getCapacity() + " strd:" + storage.getEnergyStored() + " T:" + type + " mxflw:" + maxFlow);
@@ -107,18 +133,21 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
//if (device.energyFlow > 0)LogHelper.info(device.energyFlow + " " + transfered);
//if (device.energyFlow == 0) LogHelper.info(device.getEnergyTile(worldObj));//todo clean up
detectAndSendChanges(linkedDevices.indexOf(device));
if (inView) LogHelper.info(device.energyFlow);
}
}
if (inView)LogHelper.info("#######END########");
}
protected void detectAndSendChanges(int index)
{
if (linkedDevices.get(index).energyFlow != linkedDevices.get(index).lastTickEnergyFlow) {
boolean forceSend = (tick + xCoord + yCoord + zCoord) % 100 == 0;
if (index >= 0 && (linkedDevices.get(index).energyFlow != linkedDevices.get(index).lastTickEnergyFlow || forceSend)) {
sendObject(References.TWO_INTS_ID, 0, new DataUtills.TwoXInteger(index, (int)linkedDevices.get(index).energyFlow));
linkedDevices.get(index).lastTickEnergyFlow = linkedDevices.get(index).energyFlow;
}
if (getEnergyStored(ForgeDirection.UNKNOWN) != lastTickEnergy) sendObject(References.INT_ID, 1, getEnergyStored(ForgeDirection.UNKNOWN));
if (storage.getEnergyStored() != lastTickEnergy || forceSend) sendObject(References.INT_ID, 1, storage.getEnergyStored());
}
@SideOnly(Side.CLIENT)
@@ -134,7 +163,7 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
@Override
public double getCapacity() {
return ((double) getEnergyStored(ForgeDirection.UNKNOWN) / (double) getMaxEnergyStored(ForgeDirection.UNKNOWN)) * 100D;
return ((double) storage.getEnergyStored() / (double) storage.getMaxEnergyStored()) * 100D;
}
/**Calculates the energy flow based on the local buffer
@@ -149,14 +178,25 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
return powerTier;
}
public void onBlockActivated(EntityPlayer player) {
public void onBlockActivated(EntityPlayer player)
{
ItemStack wrench = player.getHeldItem();
if (player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.wrench)
if (wrench != null && wrench.getItem() == Items.stick)
{
ItemStack wrench = player.getHeldItem();
NBTTagCompound linkDat = null;
if (wrench.hasTagCompound() && wrench.getTagCompound().hasKey("LinkData")) linkDat = wrench.getTagCompound().getCompoundTag("LinkData");
for (LinkedEnergyDevice ld : linkedDevices)
{
if (ld.beam != null) LogHelper.info(ld.beam.getFlow());
}
}
if (wrench == null || wrench.getItem() != ModItems.wrench) return;
String mode = Wrench.getMode(wrench);
NBTTagCompound linkDat = null;
if (wrench.hasTagCompound() && wrench.getTagCompound().hasKey("LinkData")) linkDat = wrench.getTagCompound().getCompoundTag("LinkData");
if (mode.equals(Wrench.BIND_MODE))
{
if (linkDat != null && linkDat.hasKey("Bound") && linkDat.getBoolean("Bound"))
{
handleBinding(player, linkDat.getInteger("XCoord"), linkDat.getInteger("YCoord"), linkDat.getInteger("ZCoord"), true);
@@ -170,34 +210,101 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
linkDat.setInteger("ZCoord", zCoord);
linkDat.setBoolean("Bound", true);
ItemNBTHelper.getCompound(wrench).setTag("LinkData", linkDat);
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentText("txt.posSaved"));
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.posSaved.txt"));
}
}
else {
if (!player.isSneaking())receiveEnergy(ForgeDirection.UNKNOWN, 100000, false);
else extractEnergy(ForgeDirection.UNKNOWN, 100000, false);
LogHelper.info(getEnergyStored(ForgeDirection.UNKNOWN));
else if (mode.equals(Wrench.UNBIND_MODE))
{
if (linkDat != null && linkDat.hasKey("Bound") && linkDat.getBoolean("Bound"))
{
for (LinkedEnergyDevice ld : linkedDevices)
{
if (ld.xCoord == linkDat.getInteger("XCoord") && ld.yCoord == linkDat.getInteger("YCoord") && ld.zCoord == linkDat.getInteger("ZCoord"))
{
if (!(ld.getTile(worldObj) instanceof TileRemoteEnergyBase))
{
LogHelper.error("TileRemoteEnergyBase - UNBIND - Remote tile invalid (This should be reported)");
break;
}
for (LinkedEnergyDevice rld : ((TileRemoteEnergyBase)ld.getTile(worldObj)).linkedDevices)
{
if (rld.xCoord == xCoord && rld.yCoord == yCoord && rld.zCoord == zCoord)
{
((TileRemoteEnergyBase)ld.getTile(worldObj)).linkedDevices.remove(rld);
break;
}
}
linkedDevices.remove(ld);
break;
}
}
linkDat.setBoolean("Bound", false);
}
else
{
linkDat = new NBTTagCompound();
linkDat.setInteger("XCoord", xCoord);
linkDat.setInteger("YCoord", yCoord);
linkDat.setInteger("ZCoord", zCoord);
linkDat.setBoolean("Bound", true);
ItemNBTHelper.getCompound(wrench).setTag("LinkData", linkDat);
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.posSaved.txt"));
}
}
else if (mode.equals(Wrench.CLEAR_BINDINGS))
{
for (LinkedEnergyDevice ld : linkedDevices)
{
if (!(ld.getTile(worldObj) instanceof TileRemoteEnergyBase))
{
LogHelper.error("TileRemoteEnergyBase - UNBIND - Remote tile invalid (This should be reported)");
break;
}
for (LinkedEnergyDevice rld : ((TileRemoteEnergyBase)ld.getTile(worldObj)).linkedDevices)
{
if (rld.xCoord == xCoord && rld.yCoord == yCoord && rld.zCoord == zCoord)
{
((TileRemoteEnergyBase)ld.getTile(worldObj)).linkedDevices.remove(rld);
break;
}
}
}
linkedDevices.clear();
}
else
{
handleOther(player, wrench);
}
}
@Override
public boolean handleBinding(EntityPlayer player, int x, int y, int z, boolean callOther)
{
int range = (powerTier + 1) * 10;
int range = (powerTier + 1) * 25;
IRemoteEnergyHandler tile = worldObj.getTileEntity(x, y, z) instanceof IRemoteEnergyHandler ? (IRemoteEnergyHandler) worldObj.getTileEntity(x, y, z) : null;
if (tile == null || (x == xCoord && y == yCoord && z == zCoord))
{
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentText("txt.invalidTile"));
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.invalidTile.txt"));
return false;
}
else if (Utills.getDistanceAtoB(xCoord, yCoord, zCoord, x, y, z) > range)
{
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentText("txt.outOfRange"));
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.outOfRange.txt"));
return false;
}
else if (linkedDevices.size() >= getMaxConnections())
{
if (worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.maxConnections.txt"));
return false;
}
if (callOther && !tile.handleBinding(player, xCoord, yCoord, zCoord, false))
{
@@ -205,7 +312,7 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
return false;
}
if (callOther && worldObj.isRemote) player.addChatComponentMessage(new ChatComponentText("txt.linked"));
if (callOther && worldObj.isRemote) player.addChatComponentMessage(new ChatComponentTranslation("msg.de.linked.txt"));
for (LinkedEnergyDevice ld : linkedDevices)
{
@@ -218,18 +325,23 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
return true;
}
public boolean handleOther(EntityPlayer player, ItemStack wrench) { return false; }
@Override
public EnergyStorage getStorage() {
return storage;
}
//**************************************
@Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
return storage.receiveEnergy(maxReceive, simulate);
return 0;
}
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
return storage.extractEnergy(maxExtract, simulate);
return 0;
}
@Override
@@ -224,8 +224,8 @@ public class TileEnergyStorageCore extends TileObjectSync {
break;
case 1:
if (!testForOrActivateDraconium(xCoord + 1, yCoord, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord - 1, yCoord, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord + 1, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord - 1, zCoord, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord, zCoord + 1, setBlocks, activate) || !testForOrActivateDraconium(xCoord, yCoord, zCoord - 1, setBlocks, activate)) return false;
if (!isAir(xCoord+1, yCoord+1, zCoord, setBlocks) || !isAir(xCoord, yCoord+1, zCoord+1, setBlocks) || !isAir(xCoord-1, yCoord+1, zCoord, setBlocks) || !isAir(xCoord, yCoord+1, zCoord-1, setBlocks) || !isAir(xCoord+1, yCoord-1, zCoord, setBlocks) || !isAir(xCoord, yCoord-1, zCoord+1, setBlocks) || !isAir(xCoord-1, yCoord-1, zCoord, setBlocks) || !isAir(xCoord, yCoord-1, zCoord-1, setBlocks) || !isAir(xCoord+1, yCoord, zCoord+1, setBlocks) || !isAir(xCoord-1, yCoord, zCoord-1, setBlocks) || !isAir(xCoord+1, yCoord, zCoord-1, setBlocks) || !isAir(xCoord-1, yCoord, zCoord+1, setBlocks)) return false;
if (!isAir(xCoord+1, yCoord+1, zCoord+1, setBlocks) || !isAir(xCoord-1, yCoord+1, zCoord-1, setBlocks) || !isAir(xCoord+1, yCoord+1, zCoord-1, setBlocks) || !isAir(xCoord-1, yCoord+1, zCoord+1, setBlocks) || !isAir(xCoord+1, yCoord-1, zCoord+1, setBlocks) || !isAir(xCoord-1, yCoord-1, zCoord-1, setBlocks) || !isAir(xCoord+1, yCoord-1, zCoord-1, setBlocks) || !isAir(xCoord-1, yCoord-1, zCoord+1, setBlocks)) return false;
if (!isReplacable(xCoord + 1, yCoord + 1, zCoord, setBlocks) || !isReplacable(xCoord, yCoord + 1, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord + 1, zCoord, setBlocks) || !isReplacable(xCoord, yCoord + 1, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord - 1, zCoord, setBlocks) || !isReplacable(xCoord, yCoord - 1, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord - 1, zCoord, setBlocks) || !isReplacable(xCoord, yCoord - 1, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord, zCoord - 1, setBlocks) || !isReplacable(xCoord - 1, yCoord, zCoord + 1, setBlocks)) return false;
if (!isReplacable(xCoord + 1, yCoord + 1, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord + 1, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord + 1, zCoord - 1, setBlocks) || !isReplacable(xCoord - 1, yCoord + 1, zCoord + 1, setBlocks) || !isReplacable(xCoord + 1, yCoord - 1, zCoord + 1, setBlocks) || !isReplacable(xCoord - 1, yCoord - 1, zCoord - 1, setBlocks) || !isReplacable(xCoord + 1, yCoord - 1, zCoord - 1, setBlocks) || !isReplacable(xCoord - 1, yCoord - 1, zCoord + 1, setBlocks)) return false;
break;
case 2:
if (!testOrActivateRect(1, 1, 1, "draconiumBlock", setBlocks, activate)) return false;
@@ -266,7 +266,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
for (int z = zCoord - zDim; z <= zCoord + zDim; z++){
if (block.equals("air")){
if (!(x == xCoord && y == yCoord && z == zCoord) && !isAir(x, y, z, set)) return false;
if (!(x == xCoord && y == yCoord && z == zCoord) && !isReplacable(x, y, z, set)) return false;
}
else if (block.equals("redstone")){
if (!(x == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(x, y, z, set, activate)) return false;
@@ -290,7 +290,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
if (y == yCoord-size || y == yCoord+size || z == zCoord-size || z==zCoord+size) {
if (block.equals("air")) {
if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !isAir(xCoord + dist, y, z, set))
if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !isReplacable(xCoord + dist, y, z, set))
return false;
} else if (block.equals("redstone")) {
if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord + dist, y, z, set, activate))
@@ -310,7 +310,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
if (y == yCoord-size || y == yCoord+size || z == zCoord-size || z==zCoord+size) {
if (block.equals("air")) {
if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !isAir(xCoord - dist, y, z, set))
if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !isReplacable(xCoord - dist, y, z, set))
return false;
} else if (block.equals("redstone")) {
if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord - dist, y, z, set, activate))
@@ -331,7 +331,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
if (x == xCoord-size || x == xCoord+size || z == zCoord-size || z == zCoord+size) {
if (block.equals("air")){
if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !isAir(x, yCoord + dist, z, set)) return false;
if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !isReplacable(x, yCoord + dist, z, set)) return false;
}
else if (block.equals("redstone")){
if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord + dist, z, set, activate)) return false;
@@ -351,7 +351,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
if (x == xCoord-size || x == xCoord+size || z == zCoord-size || z==zCoord+size) {
if (block.equals("air")){
if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !isAir(x, yCoord - dist, z, set)) return false;
if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !isReplacable(x, yCoord - dist, z, set)) return false;
}
else if (block.equals("redstone")){
if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord - dist, z, set, activate)) return false;
@@ -372,7 +372,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
if (y == yCoord-size || y == yCoord+size || x == xCoord-size || x == xCoord+size) {
if (block.equals("air")){
if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !isAir(x, y, zCoord + dist, set)) return false;
if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !isReplacable(x, y, zCoord + dist, set)) return false;
}
else if (block.equals("redstone")){
if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord + dist, set, activate)) return false;
@@ -392,7 +392,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
if (y == yCoord-size || y == yCoord+size || x == xCoord-size || x==xCoord+size) {
if (block.equals("air")){
if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !isAir(x, y, zCoord - dist, set)) return false;
if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !isReplacable(x, y, zCoord - dist, set)) return false;
}
else if (block.equals("redstone")){
if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord - dist, set, activate)) return false;
@@ -416,7 +416,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
for (int z=zCoord-1; z<=zCoord+1;z++){
if (block.equals("air")){
if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !isAir(xCoord + dist, y, z, set)) return false;
if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !isReplacable(xCoord + dist, y, z, set)) return false;
}
else if (block.equals("redstone")){
if (!(xCoord + dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord + dist, y, z, set, activate)) return false;
@@ -434,7 +434,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
for (int z=zCoord-1; z<=zCoord+1;z++){
if (block.equals("air")){
if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !isAir(xCoord - dist, y, z, set)) return false;
if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !isReplacable(xCoord - dist, y, z, set)) return false;
}
else if (block.equals("redstone")){
if (!(xCoord - dist == xCoord && y == yCoord && z == zCoord) && !testForOrActivateRedstone(xCoord - dist, y, z, set, activate)) return false;
@@ -453,7 +453,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
for (int z=zCoord-1; z<=zCoord+1;z++){
if (block.equals("air")){
if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !isAir(x, yCoord + dist, z, set)) return false;
if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !isReplacable(x, yCoord + dist, z, set)) return false;
}
else if (block.equals("redstone")){
if (!(x == xCoord && yCoord + dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord + dist, z, set, activate)) return false;
@@ -471,7 +471,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
for (int z=zCoord-1; z<=zCoord+1;z++){
if (block.equals("air")){
if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !isAir(x, yCoord - dist, z, set)) return false;
if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !isReplacable(x, yCoord - dist, z, set)) return false;
}
else if (block.equals("redstone")){
if (!(x == xCoord && yCoord - dist == yCoord && z == zCoord) && !testForOrActivateRedstone(x, yCoord - dist, z, set, activate)) return false;
@@ -490,7 +490,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
for (int x=xCoord-1; x<=xCoord+1;x++){
if (block.equals("air")){
if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !isAir(x, y, zCoord + dist, set)) return false;
if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !isReplacable(x, y, zCoord + dist, set)) return false;
}
else if (block.equals("redstone")){
if (!(x == xCoord && y == yCoord && zCoord + dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord + dist, set, activate)) return false;
@@ -508,7 +508,7 @@ public class TileEnergyStorageCore extends TileObjectSync {
for (int x=xCoord-1; x<=xCoord+1;x++){
if (block.equals("air")){
if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !isAir(x, y, zCoord - dist, set)) return false;
if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !isReplacable(x, y, zCoord - dist, set)) return false;
}
else if (block.equals("redstone")){
if (!(x == xCoord && y == yCoord && zCoord - dist == zCoord) && !testForOrActivateRedstone(x, y, zCoord - dist, set, activate)) return false;
@@ -574,12 +574,12 @@ public class TileEnergyStorageCore extends TileObjectSync {
return false;
}
private boolean isAir(int x, int y, int z, boolean set){
private boolean isReplacable(int x, int y, int z, boolean set){
if (set){
worldObj.setBlock(x, y, z, Blocks.air);
return true;
}else
return worldObj.getBlock(x, y, z) == Blocks.air;
return worldObj.getBlock(x, y, z).isReplaceable(worldObj, x, y, z);
}
public boolean isOnline(){
@@ -0,0 +1,43 @@
package com.brandon3055.draconicevolution.common.utills;
/**
* Created by Brandon on 24/02/2015.
*/
public class UpdateChecker
{
private final UpdateCheckThread thread;
public UpdateChecker()
{
thread = new UpdateCheckThread();
thread.start();
}
public class UpdateCheckThread extends Thread
{
private String version;
private int snapshot;
private String note;
private boolean checkComplete = false;
private boolean checkFaild = false;
@Override
public void run() {
LogHelper.info("Thread Run");
try
{
LogHelper.info("Thread going to sleep");
Thread.sleep(4000L);
LogHelper.info("Thread resuming");
}
catch (InterruptedException e)
{
checkFaild = true;
e.printStackTrace();
}
}
}
}
@@ -31,7 +31,7 @@ public class DraconicWorldGenerator implements IWorldGenerator {
}
public void generateSurface(Random random, int x, int z, World world) {// minVainSise, maxVainSize, spawnChance(Def2), minY, maxY
addOreSpawn(ModBlocks.draconiumOre, world, random, x, z, 3, 4, 2, 2, 8);
if (!ConfigHandler.disableOreSpawnOverworld) addOreSpawn(ModBlocks.draconiumOre, world, random, x, z, 3, 4, 2, 2, 8);
}
public void generateEnd(Random random, int x, int z, World world) {
@@ -42,11 +42,11 @@ public class DraconicWorldGenerator implements IWorldGenerator {
int cX = x/16;
int cZ = z/16;
if (ConfigHandler.generateChaosIslands && Math.sqrt(x*x + z*z) > 9000 && cX%625 == 0 && cZ%625 == 0) new WorldGenEnderIsland().generate(world, random, x1, 100 , z1);
addOreSpawn(ModBlocks.draconiumOre, world, random, x, z, 4, 5, 10, 1, 70);
if (!ConfigHandler.disableOreSpawnEnd) addOreSpawn(ModBlocks.draconiumOre, world, random, x, z, 4, 5, 10, 1, 70);
}
public void generateNether(final Random random, final int chunkX, final int chunkZ, final World world) {
addOreSpawn(ModBlocks.draconiumOre, world, random, chunkX, chunkZ, 3, 4, 5, 1, 125);
if (!ConfigHandler.disableOreSpawnNether) addOreSpawn(ModBlocks.draconiumOre, world, random, chunkX, chunkZ, 3, 4, 5, 1, 125);
}
/**Generate Ore
* Block to generate