From 05c78126859231a68e199dc34613689bd0978e2f Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Mon, 11 Apr 2016 19:44:54 +0300 Subject: Initial commit --- ihl/tunneling_shield/BlockItemRender.java | 206 ++++ ihl/tunneling_shield/DriverBlock.java | 109 ++ ihl/tunneling_shield/DriverContainer.java | 79 ++ ihl/tunneling_shield/DriverEntity.java | 69 ++ ihl/tunneling_shield/DriverGui.java | 102 ++ ihl/tunneling_shield/DriverModel.java | 161 +++ ihl/tunneling_shield/DriverRender.java | 50 + ihl/tunneling_shield/DriverRenderEntity.java | 150 +++ ihl/tunneling_shield/DriverTileEntity.java | 1138 ++++++++++++++++++++ ihl/tunneling_shield/HorizontalMiningPipe.java | 276 +++++ .../HydrotransportPulpRegeneratorContainer.java | 99 ++ .../HydrotransportPulpRegeneratorGui.java | 63 ++ .../HydrotransportPulpRegeneratorTileEntity.java | 273 +++++ ihl/tunneling_shield/IMultiBlock.java | 7 + ihl/tunneling_shield/MultiBlockSpacerBlock.java | 226 ++++ 15 files changed, 3008 insertions(+) create mode 100644 ihl/tunneling_shield/BlockItemRender.java create mode 100644 ihl/tunneling_shield/DriverBlock.java create mode 100644 ihl/tunneling_shield/DriverContainer.java create mode 100644 ihl/tunneling_shield/DriverEntity.java create mode 100644 ihl/tunneling_shield/DriverGui.java create mode 100644 ihl/tunneling_shield/DriverModel.java create mode 100644 ihl/tunneling_shield/DriverRender.java create mode 100644 ihl/tunneling_shield/DriverRenderEntity.java create mode 100644 ihl/tunneling_shield/DriverTileEntity.java create mode 100644 ihl/tunneling_shield/HorizontalMiningPipe.java create mode 100644 ihl/tunneling_shield/HydrotransportPulpRegeneratorContainer.java create mode 100644 ihl/tunneling_shield/HydrotransportPulpRegeneratorGui.java create mode 100644 ihl/tunneling_shield/HydrotransportPulpRegeneratorTileEntity.java create mode 100644 ihl/tunneling_shield/IMultiBlock.java create mode 100644 ihl/tunneling_shield/MultiBlockSpacerBlock.java (limited to 'ihl/tunneling_shield') diff --git a/ihl/tunneling_shield/BlockItemRender.java b/ihl/tunneling_shield/BlockItemRender.java new file mode 100644 index 0000000..27b0f04 --- /dev/null +++ b/ihl/tunneling_shield/BlockItemRender.java @@ -0,0 +1,206 @@ +package ihl.tunneling_shield; + +import ic2.core.block.RenderBlockDefault; +import ihl.items_blocks.IHLItemBlock; +import ihl.model.IHLModelRenderer; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.IItemRenderer; +import org.lwjgl.opengl.GL11; + +public class BlockItemRender implements IItemRenderer{ + private ModelBase model; + private ResourceLocation tex; + private int renderFrom=0; + private int renderTo=0; + private RenderBlockDefault rbd; + private float amendment=0.0F; + private float inventoryOffset=0.0F; + private boolean renderHand; + +public BlockItemRender() +{ + rbd=new RenderBlockDefault(); +} + +public BlockItemRender(ModelBase model1, ResourceLocation texture, int renderFrom1, int renderTo1, float amendment1, float inventoryOffset1) +{ + this.model=model1; + this.tex=texture; + this.renderFrom=renderFrom1; + this.renderTo=renderTo1; + this.amendment=amendment1; + this.inventoryOffset=inventoryOffset1; + this.renderHand=false; +} + +public BlockItemRender(ModelBase model1, ResourceLocation texture, int renderFrom1, int renderTo1, float amendment1, float inventoryOffset1, boolean renderHand1) +{ + this.model=model1; + this.tex=texture; + this.renderFrom=renderFrom1; + this.renderTo=renderTo1; + this.amendment=amendment1; + this.inventoryOffset=inventoryOffset1; + this.renderHand=renderHand1; +} + +@Override +public boolean handleRenderType(ItemStack item, ItemRenderType type) { + switch (type) { + case ENTITY: + return true; + case EQUIPPED: + return true; + case EQUIPPED_FIRST_PERSON: + return true; + case INVENTORY: + return true; + default: + return false; + } +} + +@Override +public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; +} + +@Override +public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + if(tex!=null) + { + Minecraft.getMinecraft().renderEngine.bindTexture(tex); + } + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + IHLItemBlock bItem =(IHLItemBlock) item.getItem(); + Block block = bItem.getBlockContained(); + GL11.glScalef(1F, -1F+amendment, -1F); + switch (type) { + case ENTITY: + GL11.glTranslatef(0,-1.5F,0); + if(model!=null) + { + for(int i = this.renderFrom;i>15) & Short.MAX_VALUE); + icrafting.sendProgressBarUpdate(this, 1, (short)(this.tileEntity.getStored() & Short.MAX_VALUE)); + + } + } + + this.lastStorage = this.tileEntity.getStored(); + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + + switch (index) + { + case 0: + this.tileEntity.setStored(value<<15); + break; + case 1: + this.tileEntity.setStored(this.tileEntity.getStored()+value); + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/tunneling_shield/DriverEntity.java b/ihl/tunneling_shield/DriverEntity.java new file mode 100644 index 0000000..e7e1c90 --- /dev/null +++ b/ihl/tunneling_shield/DriverEntity.java @@ -0,0 +1,69 @@ +package ihl.tunneling_shield; + +import net.minecraft.entity.Entity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; + +public class DriverEntity extends Entity { + + public DriverTileEntity parent; + + public DriverEntity(World arg0) + { + super(arg0); + this.ignoreFrustumCheck = true; + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.noClip=true; + } + + public DriverEntity(World arg0, DriverTileEntity te, int x, int y, int z) + { + super(arg0); + this.parent=te; + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.lastTickPosX = this.prevPosX = this.posX = x; + this.lastTickPosY = this.prevPosY = this.posY = y; + this.lastTickPosZ = this.prevPosZ = this.posZ = z; + this.ignoreFrustumCheck = true; + } + + @Override + public boolean isInRangeToRenderDist(double par1) + { + return true; + } + + + @Override + public void onUpdate() + { + super.onUpdate(); + + if(this.parent!=null) + { + this.motionX = 0.0D; + this.motionY = 0.0D; + this.motionZ = 0.0D; + this.lastTickPosX = this.prevPosX = this.posX =this.parent.xCoord+this.parent.getModelShiftAmount()*this.parent.mX(); + this.lastTickPosY = this.prevPosY = this.posY =(this.parent.yCoord); + this.lastTickPosZ = this.prevPosZ = this.posZ =this.parent.zCoord+this.parent.getModelShiftAmount()*this.parent.mZ(); + } + else + { + this.setDead(); + } + } + + @Override + protected void entityInit() {} + + @Override + protected void readEntityFromNBT(NBTTagCompound nbt) {} + + @Override + protected void writeEntityToNBT(NBTTagCompound nbt) {} +} diff --git a/ihl/tunneling_shield/DriverGui.java b/ihl/tunneling_shield/DriverGui.java new file mode 100644 index 0000000..c7c8664 --- /dev/null +++ b/ihl/tunneling_shield/DriverGui.java @@ -0,0 +1,102 @@ +package ihl.tunneling_shield; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.IC2; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.lwjgl.opengl.GL11; +import ic2.core.network.NetworkManager; + +@SideOnly(Side.CLIENT) +public class DriverGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIDriver.png"); + private DriverContainer container; + + public DriverGui (DriverContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + } + + @Override + public void initGui() + { + super.initGui(); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.buttonList.add(new GuiButton(0, x+6, y+62, 20, 20, "R")); + this.buttonList.add(new GuiButton(1, x+6, y+42, 20, 20, "A")); + } + + @Override + public void actionPerformed(GuiButton button) + { + super.actionPerformed(button); + if (button.id == 0) + { + IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, 0); + } + if (button.id == 1) + { + IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, 1); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int param1, int param2) { + //the parameters for drawString are: string, x, y, color + String title = StatCollector.translateToLocal("ihl.gui.ts02"); + fontRendererObj.drawStringWithShadow(title, 8, 8, 16767839); + String reverseModeOn; + if(this.container.tileEntity.reverseModeOn) + { + reverseModeOn = StatCollector.translateToLocal("ihl.gui.ts02reverse_on"); + fontRendererObj.drawStringWithShadow(reverseModeOn, 30, 68, 16767839); + } + else + { + reverseModeOn = StatCollector.translateToLocal("ihl.gui.ts02reverse_off"); + fontRendererObj.drawString(reverseModeOn, 30, 68, 8947848); + } + + String autoReverseModeOn; + if(this.container.tileEntity.autoReverseModeOn) + { + autoReverseModeOn = StatCollector.translateToLocal("ihl.gui.ts02auto_reverse_on"); + fontRendererObj.drawStringWithShadow(autoReverseModeOn, 30, 48, 16767839); + } + else + { + autoReverseModeOn = StatCollector.translateToLocal("ihl.gui.ts02auto_reverse_off"); + fontRendererObj.drawString(autoReverseModeOn, 30, 48, 8947848); + } + //draws "Inventory" or your regional equivalent + //fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + //charge + if (this.container.tileEntity.getStored() > 0) + { + int chargeLevel=Math.min(Math.round(this.container.tileEntity.getStored()*13.0F/this.container.tileEntity.maxStorage),13); + this.drawTexturedModalRect(11, 28+13-chargeLevel, xSize, 13-chargeLevel, 7, chargeLevel); + } + + + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} \ No newline at end of file diff --git a/ihl/tunneling_shield/DriverModel.java b/ihl/tunneling_shield/DriverModel.java new file mode 100644 index 0000000..edb8aa8 --- /dev/null +++ b/ihl/tunneling_shield/DriverModel.java @@ -0,0 +1,161 @@ +package ihl.tunneling_shield; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class DriverModel extends ModelBase { + //fields + ModelRenderer Shield; + ModelRenderer ShieldA; + ModelRenderer ShieldB; + ModelRenderer ShieldC; + ModelRenderer AdvancedShieldA; + + ModelRenderer Base; + ModelRenderer ShaftA; + ModelRenderer ShaftB; + + public DriverModel() + { + textureWidth = 512; + textureHeight = 256; + setTextureOffset("ShieldB.Shape1", 0, 84); + setTextureOffset("ShieldB.Shape2", 0, 84); + setTextureOffset("ShieldB.Shape3", 0, 84); + setTextureOffset("ShieldB.Shape4", 0, 84); + setTextureOffset("ShieldC.Shape1", 0, 84); + setTextureOffset("ShieldC.Shape2", 0, 84); + setTextureOffset("ShieldC.Shape3", 0, 84); + setTextureOffset("ShieldC.Shape4", 0, 84); + setTextureOffset("ShieldA.Shape1", 0, 132); + setTextureOffset("ShieldA.Shape2", 0, 132); + setTextureOffset("ShieldA.Shape3", 0, 132); + + setTextureOffset("AdvancedShieldA.Shape1", 173, 132); + setTextureOffset("AdvancedShieldA.Shape2", 173, 132); + setTextureOffset("AdvancedShieldA.Shape3", 173, 132); + + setTextureOffset("Shield.Shape1", 0, 0); + setTextureOffset("Shield.Shape2", 0, 0); + setTextureOffset("Shield.Shape3", 0, 0); + setTextureOffset("Shield.Shape4", 98, 84); + setTextureOffset("Shield.Shape5", 98, 84); + setTextureOffset("Shield.Shape6", 0, 0); + setTextureOffset("Shield.Shape7", 0, 0); + setTextureOffset("Shield.Shape8", 98, 84); + setTextureOffset("Shield.Shape9", 0, 0); + setTextureOffset("Shield.Shape10", 0, 0); + setTextureOffset("Shield.Shape11", 98, 84); + + setTextureOffset("Base.Base1", 80, 0); + setTextureOffset("Base.Base2", 83, 0); + setTextureOffset("Base.Base3", 98, 0); + setTextureOffset("Base.Base4", 98, 0); + setTextureOffset("Base.Base5", 98, 4); + setTextureOffset("Base.Base6", 98, 4); + setTextureOffset("Base.Base7", 103, 1); + setTextureOffset("Base.Base8", 98, 0); + setTextureOffset("Base.Base9", 98, 0); + setTextureOffset("Base.Base10", 98, 0); + setTextureOffset("Base.Base11", 98, 0); + setTextureOffset("Base.Base12", 98, 0); + setTextureOffset("Base.Base13", 99, 3); + setTextureOffset("ShaftA.ShapeA", 144, 0); + setTextureOffset("ShaftB.ShapeA", 144, 0); + + ShieldB = new ModelRenderer(this, "ShieldB"); + ShieldB.setRotationPoint(0F, 16F, 0F); + setRotation(ShieldB, 0F, 0F, 0F); + ShieldB.mirror = true; + ShieldB.addBox("Shape1", -7F, -36F, 9F, 14, 16, 12); + ShieldB.addBox("Shape2", 20F, -7F, 9F, 16, 14, 12); + ShieldB.addBox("Shape3", -36F, -7F, 9F, 16, 14, 12); + ShieldB.addBox("Shape4", -7F, 20F, 9F, 14, 16, 12); + ShieldC = new ModelRenderer(this, "ShieldB"); + ShieldC.setRotationPoint(0F, 16F, 0F); + setRotation(ShieldC, 0F, 0F, 0F); + ShieldC.mirror = true; + ShieldC.addBox("Shape1", -7F, -36F, 9F, 14, 16, 12); + ShieldC.addBox("Shape2", 20F, -7F, 9F, 16, 14, 12); + ShieldC.addBox("Shape3", -36F, -7F, 9F, 16, 14, 12); + ShieldC.addBox("Shape4", -7F, 20F, 9F, 14, 16, 12); + ShieldA = new ModelRenderer(this, "ShieldA"); + ShieldA.setRotationPoint(0F, 16F, 0F); + setRotation(ShieldA, 0F, 0F, 0F); + ShieldA.mirror = true; + ShieldA.addBox("Shape1", -36F, -8F, 10F, 72, 16, 12); + ShieldA.addBox("Shape2", -8F, -36F, 10F, 16, 28, 12); + ShieldA.addBox("Shape3", -8F, 8F, 10F, 16, 28, 12); + + AdvancedShieldA = new ModelRenderer(this, "AdvancedShieldA"); + AdvancedShieldA.setRotationPoint(0F, 16F, 0F); + setRotation(AdvancedShieldA, 0F, 0F, 0F); + AdvancedShieldA.mirror = true; + AdvancedShieldA.addBox("Shape1", -36F, -8F, 10F, 72, 16, 12); + AdvancedShieldA.addBox("Shape2", -8F, -36F, 10F, 16, 28, 12); + AdvancedShieldA.addBox("Shape3", -8F, 8F, 10F, 16, 28, 12); + + Shield = new ModelRenderer(this, "Shield"); + Shield.setRotationPoint(0F, 16F, 0F); + setRotation(Shield, 0F, 0F, 0F); + Shield.mirror = true; + Shield.addBox("Shape1", -6F, -6F, 8F, 12, 12, 2); + Shield.addBox("Shape2", -8F, -35F, 11F, 7, 70, 12); + Shield.addBox("Shape3", 1F, -35F, 11F, 7, 70, 12); + Shield.addBox("Shape4", -2F, -36F, 20F, 2, 36, 4); + Shield.addBox("Shape5", 0F, 0F, 20F, 2, 36, 4); + Shield.addBox("Shape6", -35F, 1F, 11F, 27, 7, 12); + Shield.addBox("Shape7", -35F, -8F, 11F, 27, 7, 12); + Shield.addBox("Shape8", -36F, 0F, 20F, 28, 2, 4); + Shield.addBox("Shape9", 8F, 1F, 11F, 27, 7, 12); + Shield.addBox("Shape10", 8F, -8F, 11F, 27, 7, 12); + Shield.addBox("Shape11", 8F, -2F, 20F, 28, 2, 4); + + Base = new ModelRenderer(this, "Base"); + Base.setRotationPoint(-8F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Base1", 0F, 7F, -8F, 16, 1, 16); + Base.addBox("Base2", 1F, -7F, -7F, 14, 13, 15); + Base.addBox("Base3", 0F, -6F, -6F, 1, 1, 13); + Base.addBox("Base4", 2F, -8F, -6F, 1, 1, 13); + Base.addBox("Base5", 0F, -4F, -6F, 1, 7, 14); + Base.addBox("Base6", 15F, -4F, -6F, 1, 7, 14); + Base.addBox("Base7", 5F, -8F, -6F, 6, 1, 14); + Base.addBox("Base8", 3F, 6F, -7F, 10, 1, 15); + Base.addBox("Base9", 0F, 4F, -6F, 1, 1, 13); + Base.addBox("Base10", 13F, -8F, -6F, 1, 1, 13); + Base.addBox("Base11", 15F, -6F, -6F, 1, 1, 13); + Base.addBox("Base12", 15F, 4F, -6F, 1, 1, 13); + Base.addBox("Base13", 3F, -5F, -8F, 10, 9, 1); + + ShaftA = new ModelRenderer(this, "ShaftA"); + ShaftA.setRotationPoint(0F, 16F, 0F); + setRotation(ShaftA, 0F, 0F, 0F); + ShaftA.mirror = true; + ShaftA.addBox("ShapeA", -5F, -5F, -0F, 10, 10, 8); + + ShaftB = new ModelRenderer(this, "ShaftB"); + ShaftB.setRotationPoint(0F, 16F, 0F); + setRotation(ShaftB, 0F, 0F, 0F); + ShaftB.mirror = true; + ShaftB.addBox("ShapeA", -5F, -5F, -8F, 10, 10, 8); + + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + @Override + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); + } +} + + diff --git a/ihl/tunneling_shield/DriverRender.java b/ihl/tunneling_shield/DriverRender.java new file mode 100644 index 0000000..e2c6802 --- /dev/null +++ b/ihl/tunneling_shield/DriverRender.java @@ -0,0 +1,50 @@ +package ihl.tunneling_shield; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import ihl.IHLModInfo; + +public class DriverRender extends TileEntitySpecialRenderer{ +private DriverModel model = new DriverModel(); +private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/shield.png"); + +public DriverRender(){} + +public void renderAModelAt(DriverTileEntity tile, double d, double d1, double d2, float f) { +int rotation = 0; +if(tile.getWorldObj() != null) +{ + switch (tile.getFacing()) + { + case 2: + rotation = 0; + break; + case 5: + rotation = 1; + break; + case 3: + rotation = 2; + break; + case 4: + rotation = 3; + break; + default: + rotation = 0; + } +} +bindTexture(tex); //texture +GL11.glPushMatrix(); +GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F); +GL11.glScalef(1.0F, -1F, -1F); +GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); +model.Base.render(1.0F/16.0F); +GL11.glPopMatrix(); //end +} + +@Override +public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) +{ +this.renderAModelAt((DriverTileEntity)par1TileEntity, par2, par4, par6, par8); +} +} \ No newline at end of file diff --git a/ihl/tunneling_shield/DriverRenderEntity.java b/ihl/tunneling_shield/DriverRenderEntity.java new file mode 100644 index 0000000..127c9a3 --- /dev/null +++ b/ihl/tunneling_shield/DriverRenderEntity.java @@ -0,0 +1,150 @@ +package ihl.tunneling_shield; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import ihl.IHLModInfo; + +public class DriverRenderEntity extends Render{ + + private DriverModel model = new DriverModel(); + private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/shield.png"); + private float rotationSpeed=0F; + private float rotationAmount=1F; + private float rotationAmount2=0F; + private float shiftCorrection=0F; + + public DriverRenderEntity() + { + super(); + } + + @Override + public void doRender(Entity entity, double x, double y, double z, float arg4, float arg5) + { + double d; + double d1; + double d2; + if(((DriverEntity)entity).parent!=null) + { + DriverTileEntity tile = ((DriverEntity)entity).parent; + float shift=tile.getModelShiftAmount(); + d=x-entity.lastTickPosX+tile.xCoord; + d1=y-entity.lastTickPosY+tile.yCoord; + d2=z-entity.lastTickPosZ+tile.zCoord; + int rotation = 0; + if(tile.getWorldObj() != null) + { + switch (tile.getFacing()) + { + case 2: + rotation = 0; + break; + case 5: + rotation = 1; + break; + case 3: + rotation = 2; + break; + case 4: + rotation = 3; + break; + default: + rotation = 0; + } + } + bindTexture(tex); + GL11.glPushMatrix(); + GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F); + GL11.glScalef(1.0F, -1F, -1F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F); + if(tile.hasShield && tile.getActive() && tile.shaftDestroyedAtA==0) + { + rotationAmount+=0.01F; + } + rotationAmount2 += 0.01F; + if(tile.hasShield) + { + if(tile.shaftDestroyedAtA==0) + { + model.ShieldB.rotateAngleZ=rotationAmount+(float)Math.PI/8.0F; + model.ShieldB.offsetZ=shift; + model.ShieldB.render(1.0F/16.0F); + + model.ShieldC.rotateAngleZ=rotationAmount+3*(float)Math.PI/8.0F; + model.ShieldC.offsetZ=shift; + model.ShieldC.render(1.0F/16.0F); + + if(tile.advancedShield) + { + model.AdvancedShieldA.rotateAngleZ=rotationAmount+(float)Math.PI/4.0F; + model.AdvancedShieldA.offsetZ=shift; + model.AdvancedShieldA.render(1.0F/16.0F); + } + else + { + model.ShieldA.rotateAngleZ=rotationAmount+(float)Math.PI/4.0F; + model.ShieldA.offsetZ=shift; + model.ShieldA.render(1.0F/16.0F); + } + + model.Shield.rotateAngleZ=rotationAmount; + model.Shield.offsetZ=shift; + model.Shield.render(1.0F/16.0F); + GL11.glScalef(1.0F, 1.0F, 1.0F + shift); + model.ShaftA.offsetZ=0.5F; + model.ShaftB.offsetZ=0.5F; + model.ShaftA.rotateAngleZ=rotationAmount; + model.ShaftB.rotateAngleZ=rotationAmount; + model.ShaftA.render(1.0F/16.0F); + model.ShaftB.render(1.0F/16.0F); + } + else + { + model.ShieldB.rotateAngleZ=rotationAmount+(float)Math.PI/8.0F; + model.ShieldC.rotateAngleZ=rotationAmount+3*(float)Math.PI/8.0F; + model.ShieldA.rotateAngleZ=rotationAmount+(float)Math.PI/4.0F; + model.AdvancedShieldA.rotateAngleZ=rotationAmount+(float)Math.PI/4.0F; + model.Shield.rotateAngleZ=rotationAmount; + model.ShaftA.rotateAngleZ=rotationAmount; + + model.ShieldB.offsetZ=shift; + model.ShieldB.render(1.0F/16.0F); + + model.ShieldC.offsetZ=shift; + model.ShieldC.render(1.0F/16.0F); + + if(tile.advancedShield) + { + model.AdvancedShieldA.offsetZ=shift; + model.AdvancedShieldA.render(1.0F/16.0F); + } + else + { + model.ShieldA.offsetZ=shift; + model.ShieldA.render(1.0F/16.0F); + } + + model.Shield.offsetZ=shift; + model.Shield.render(1.0F/16.0F); + GL11.glScalef(1.0F, 1.0F, tile.shaftDestroyedAtA*2); + model.ShaftB.offsetZ=0.5F-0.2F/tile.shaftDestroyedAtA; + model.ShaftB.rotateAngleZ=rotationAmount2; + model.ShaftB.render(1.0F/16.0F); + GL11.glScalef(1.0F, 1.0F, (shift-tile.shaftDestroyedAtB)/tile.shaftDestroyedAtA); + model.ShaftA.offsetZ=0.5F*(tile.shaftDestroyedAtB+0.5F)/(shift-tile.shaftDestroyedAtB); + model.ShaftA.render(1.0F/16.0F); + } + } + GL11.glPopMatrix(); //end + } + } + + @Override + protected ResourceLocation getEntityTexture(Entity arg0) { + return this.tex; + } +} \ No newline at end of file diff --git a/ihl/tunneling_shield/DriverTileEntity.java b/ihl/tunneling_shield/DriverTileEntity.java new file mode 100644 index 0000000..2c3f2d8 --- /dev/null +++ b/ihl/tunneling_shield/DriverTileEntity.java @@ -0,0 +1,1138 @@ +package ihl.tunneling_shield; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.item.IC2Items; +import ic2.api.network.INetworkClientTileEntityEventListener; +import ic2.api.recipe.RecipeOutput; +import ic2.api.recipe.Recipes; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.Ic2Items; +import ic2.core.audio.AudioSource; +import ic2.core.audio.PositionSpec; +import ic2.core.block.TileEntityInventory; +import ic2.core.block.invslot.InvSlotConsumableId; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotUpgrade; +import ic2.core.block.invslot.InvSlot.Access; +import ic2.core.network.NetworkManager; +import ic2.core.upgrade.IUpgradableBlock; +import ic2.core.upgrade.UpgradableProperty; +import ic2.core.util.StackUtil; +import ihl.IHLMod; +import ihl.utils.IHLInvSlotDischarge; +import ihl.utils.IHLUtils; +import net.minecraft.block.Block; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + +public class DriverTileEntity extends TileEntityInventory implements IEnergySink, IHasGui, INetworkClientTileEntityEventListener, IUpgradableBlock, IMultiBlock { + + private AudioSource audioSource; + private AudioSource startAS; + private AudioSource loopAS; + private AudioSource stopAS; + private int startUpCounter=0; + public final InvSlotConsumableId miningPipesSlot; + public final InvSlotUpgrade upgradeSlot; + public final IHLInvSlotDischarge dischargeSlot; + public int tier; + private int defaultTier; + public int maxStorage; + private int defaultMaxStorage; + public boolean hasShield=false; + private boolean prevHasShield=false; + public int shaftDestroyedAtA=0; + private int prevShaftDestroyedAtA=0; + public int shaftDestroyedAtB=0; + private int prevShaftDestroyedAtB=0; + public int modelShift=0; + public int modelShiftSpeed; + private int defaultModelShiftSpeed; + public int blockShift=1; + private int lastBlockShift=1; + private double energy = 0; + private double energyConsume; + private double defaultEnergyConsume; + private boolean addedToEnergyNet=false; + public int xShaftMin, xShaftMax, yShaft, zShaftMin, zShaftMax, xShieldMin, xShieldMax, yShieldMin, yShieldMax, zShieldMin, zShieldMax; + private int updateChecksum=0; + private boolean renderHelperExist=false; + public DriverEntity renderHelper; + public boolean reverseModeOn=false; + public boolean autoReverseModeOn=true; + private float lastModelShiftAmount=1F; + private List blockBlackList = new ArrayList(); + private List blockWhiteList = new ArrayList(); + public boolean advancedShield=false; + + public DriverTileEntity() + { + super(); + this.miningPipesSlot = new InvSlotConsumableId(this, "miningPipesSlot", 1, 12, new Item[] {Ic2Items.miningPipe.getItem()}); + this.upgradeSlot = new InvSlotUpgrade(this, "upgrade", 2, 4); + this.dischargeSlot = new IHLInvSlotDischarge(this, 1, Access.IO, this.tier, InvSlot.InvSide.BOTTOM); + this.defaultTier=IHLMod.config.ts02DefaultTier; + this.defaultMaxStorage=IHLMod.config.ts02DefaultMaxEnergyStorage; + this.defaultModelShiftSpeed=IHLMod.config.ts02DefaultSpeed; + this.defaultEnergyConsume=IHLMod.config.ts02DefaultOperationEUCost; + this.tier=this.defaultTier; + this.maxStorage=this.defaultMaxStorage; + this.modelShiftSpeed=this.defaultModelShiftSpeed; + this.energyConsume=this.defaultEnergyConsume; + for(int i6=0;i6 getNetworkedFields() + { + List fields = super.getNetworkedFields(); + fields.add("hasShield"); + fields.add("modelShift"); + fields.add("shaftDestroyedAtA"); + fields.add("shaftDestroyedAtB"); + fields.add("tier"); + fields.add("modelShiftSpeed"); + fields.add("maxStorage"); + fields.add("reverseModeOn"); + fields.add("autoReverseModeOn"); + fields.add("advancedShield"); + return fields; + } + + public String getShieldSoundFile() + { + return "Machines/MinerOp.ogg"; + } + + public String getStartSoundFile() + { + return "Machines/IHL Tunneling Shield/TS02Start.ogg"; + } + + public String getLoopSoundFile() + { + return "Machines/IHL Tunneling Shield/TS02Loop.ogg"; + } + + public String getStopSoundFile() + { + return "Machines/IHL Tunneling Shield/TS02Stop.ogg"; + } + + @Override + public void onLoaded() + { + super.onLoaded(); + if (IC2.platform.isSimulating()&&!this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + this.addedToEnergyNet = true; + } + if (IC2.platform.isRendering() && (this.startAS==null||this.loopAS==null||this.stopAS==null)) + { + this.startAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStartSoundFile(),false,false, 0.5F); + this.loopAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getLoopSoundFile(),true,false, 0.5F); + this.stopAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStopSoundFile(),false,false, 0.5F); + } + } + + @Override + public void onUnloaded() + { + super.onUnloaded(); + + if (IC2.platform.isRendering() && this.audioSource != null) + { + this.audioSource.stop(); + this.audioSource = null; + this.startAS.stop(); + this.loopAS.stop(); + this.stopAS.stop(); + this.startAS = null; + this.loopAS = null; + this.stopAS = null; + IC2.audioManager.removeSources(this); + } + + if (IC2.platform.isSimulating()&&this.addedToEnergyNet) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + this.addedToEnergyNet = false; + } + } + + + @Override + public void updateEntityClient() + { + super.updateEntityClient(); + updateEntityServer(); + if(!this.renderHelperExist) + { + List deList = this.worldObj.getEntitiesWithinAABB(DriverEntity.class, this.getOperationZone()); + if(deList.size()>0) + { + Iterator dei = deList.iterator(); + while(dei.hasNext()) + { + DriverEntity rh=dei.next(); + if(!rh.isDead) + { + this.renderHelper=rh; + rh.parent=this; + this.renderHelperExist=true; + break; + } + } + if(!this.renderHelperExist) + { + this.renderHelper=new DriverEntity(this.worldObj, this, this.xCoord+this.blockShift*this.mX(), this.yCoord, this.zCoord+this.blockShift*this.mZ()); + this.renderHelperExist=true; + } + } + else + { + this.renderHelper=new DriverEntity(this.worldObj, this, this.xCoord+this.blockShift*this.mX(), this.yCoord, this.zCoord+this.blockShift*this.mZ()); + this.renderHelper.parent=this; + this.renderHelperExist=true; + } + } + + if(this.renderHelper!=null && !this.renderHelper.isDead && !this.worldObj.loadedEntityList.contains(this.renderHelper)) + { + this.worldObj.spawnEntityInWorld(this.renderHelper); + } + if(this.audioSource==null && this.renderHelper!=null)this.audioSource = IC2.audioManager.createSource(this.renderHelper, PositionSpec.Center, this.getShieldSoundFile(),true,false, 1.0F); + if(this.audioSource!=null) + { + this.audioSource.updatePosition(); + } + if(this.audioSource!=null) + { + if(this.getActive()) + { + if(this.startUpCounter>62) + { + this.startUpCounter=0; + } + if(this.startUpCounter==0) + { + this.stopAS.stop(); + this.startAS.play(); + } + if(this.startUpCounter<60) + { + this.startUpCounter++; + } + else if(this.startUpCounter==60) + { + this.startAS.stop(); + this.loopAS.play(); + this.audioSource.play(); + this.startUpCounter++; + } + } + else if(this.startUpCounter>0) + { + this.startAS.stop(); + this.loopAS.stop(); + this.audioSource.stop(); + this.stopAS.play(); + if(this.startUpCounter<100) + { + this.startUpCounter++; + } + else + { + this.startUpCounter=0; + this.stopAS.stop(); + } + } + } + else if(!this.getActive() && this.audioSource!=null) + { + this.audioSource.stop(); + } + } + + @Override + public void updateEntityServer() + { + if (IC2.platform.isSimulating()) + { + this.setOverclockRates(); + } + if(this.dischargeSlot.tier!=this.tier) + { + this.dischargeSlot.tier=this.tier; + } + int xyz[]={0,0,1,0,-1,-1,1,1,-1,2,0,2,1,2,-1,-2,0,-2,1,-2,-1,0}; + boolean freeToDigForward = true; + boolean freeToMoveBack = true; + if(this.blockShift>=127) + { + freeToDigForward = false; + if(this.autoReverseModeOn && !this.reverseModeOn && this.worldObj.isRemote) + { + this.reverseModeOn=true; + IC2.network.get().initiateClientTileEntityEvent(this, 0); + } + } + else + { + for(int i = 0;i<21;i++) + { + Block block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift+1)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift+1)*this.mZ()); + if(this.blockBlackList.contains(block)) + { + freeToDigForward = false; + } + } + } + + if(this.blockShift<=3) + { + freeToMoveBack = false; + } + else + { + for(int i = 0;i<21;i++) + { + Block block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-3)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-3)*this.mZ()); + if(block.getCollisionBoundingBoxFromPool(worldObj, this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-3)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-3)*this.mZ())!=null && !block.getMaterial().isLiquid() && !this.blockWhiteList.contains(block)) + { + freeToMoveBack = false; + } + block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ()); + if(block.getCollisionBoundingBoxFromPool(worldObj, this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ())!=null && !block.getMaterial().isLiquid() && !this.blockWhiteList.contains(block)) + { + freeToMoveBack = false; + } + } + } + + if(IC2.platform.isSimulating()) + { + if(this.hasShield && this.shaftDestroyedAtA==0 && this.energy>=this.energyConsume) + { + if(this.reverseModeOn && freeToMoveBack) + { + this.energy-=this.energyConsume; + this.setActive(true); + } + else if((!this.reverseModeOn) && freeToDigForward && this.miningPipesSlot.get()!=null && this.miningPipesSlot.get().stackSize>=1) + { + this.energy-=this.energyConsume; + this.setActive(true); + } + else + { + this.setActive(false); + } + } + else + { + this.setActive(false); + } + } + if(this.getActive()) + { + double velocity; + if(this.reverseModeOn && this.modelShift>0) + { + this.modelShift--; + List entityList = this.worldObj.getEntitiesWithinAABB(Entity.class, this.getShieldBladesZone(0D)); + velocity = -0.5D; + if(entityList.size()>0) + { + for(int i0=0;i0 entityLivingList = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.getShieldBladesZone(2.5D)); + float damage = 800F/(this.modelShiftSpeed); + velocity = 0.1D*damage; + if(entityLivingList.size()>0) + { + for(int i1=0;i1 entityLivingList2 = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, this.getShieldBladesZone(2.5D)); + velocity*=0.1D; + if(entityLivingList2.size()>0) + { + for(int i2=0;i2 1.0D) + { + double amount = this.dischargeSlot.discharge(this.getDemandedEnergy(), false); + this.energy += amount; + } + if(this.energy>this.maxStorage) + { + this.energy=this.maxStorage; + } + } + + if(this.blockShift!=this.lastBlockShift) + { + if(this.getActive() && this.reverseModeOn && IC2.platform.isSimulating() && this.lastModelShiftAmount-this.getModelShiftAmount()<1F) + { + if(this.miningPipesSlot.get()==null) + { + this.miningPipesSlot.put(Ic2Items.miningPipe.copy()); + } + else if(this.miningPipesSlot.get().stackSize<64) + { + this.miningPipesSlot.get().stackSize++; + } + else + { + this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj,this.xCoord,this.yCoord+1,this.zCoord,this.miningPipesSlot.get())); + this.miningPipesSlot.put(Ic2Items.miningPipe.copy()); + } + this.lastModelShiftAmount-=1F; + } + else if(this.getActive() && IC2.platform.isSimulating() && this.getModelShiftAmount()-this.lastModelShiftAmount>1F) + { + this.miningPipesSlot.consume(1); + this.lastModelShiftAmount+=1F; + IC2.network.get().updateTileEntityField(this, "modelShift"); + } + this.defineTechBlockVariables(); + if(this.getActive() && IC2.platform.isSimulating()) + { + if(this.reverseModeOn) + { + for(int i = 0;i<21;i++) + { + if(this.blockShift>=2) + { + this.worldObj.setBlockToAir(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift)*this.mZ()); + } + if(this.blockShift>=3) + { + Block block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ()); + if(block!=IHLMod.multiBlockSpacerBlock && block!=IHLMod.horizontalMiningPipeX && block!=IHLMod.horizontalMiningPipeZ) + { + this.harvestDrops(block, this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ(), this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-3)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-3)*this.mZ(), IHLMod.multiBlockSpacerBlock); + } + else + { + this.worldObj.setBlock(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ(), IHLMod.multiBlockSpacerBlock); + } + } + } + } + else + { + for(int i = 0;i<21;i++) + { + Block block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+this.blockShift*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+this.blockShift*this.mZ()); + this.harvestMiningDrops(block, this.xCoord+xyz[i+1]*this.mZ()+this.blockShift*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+this.blockShift*this.mZ(), this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ(), IHLMod.multiBlockSpacerBlock); + if(this.blockShift>=3) + { + if(i!=0) + { + this.worldObj.setBlockToAir(this.xCoord+xyz[i+1]*this.mZ()+(this.blockShift-2)*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+(this.blockShift-2)*this.mZ()); + } + else + { + this.worldObj.setBlock(this.xCoord+(this.blockShift-2)*this.mX(), this.yCoord, this.zCoord+(this.blockShift-2)*this.mZ(), this.mX()!=0?IHLMod.horizontalMiningPipeZ:IHLMod.horizontalMiningPipeX); + } + } + + } + } + } + this.lastBlockShift=this.blockShift; + } + } + + private void harvestMiningDrops(Block block, int x, int y, int z, int x1, int y1, int z1, Block setToBlock) + { + if(block!=null && block!=Blocks.air && block!=Blocks.bedrock) + { + int meta = worldObj.getBlockMetadata(x, y, z); + ArrayList drops = block.getDrops(this.worldObj, x, y, z, meta, 0); + if(drops.size()>0) + { + if(!this.advancedShield || !this.handleDropsByHydrotransport(drops)) + { + for(int i1=0;i1=this.xShaftMin && x<=this.xShaftMax && z>=this.zShaftMin && z<=this.zShaftMax) + { + int sda = (x-this.xCoord)*this.mX()+(z-this.zCoord)*this.mZ(); + if(this.shaftDestroyedAtA==0 && this.shaftDestroyedAtB==0) + { + this.shaftDestroyedAtA=this.shaftDestroyedAtB=sda; + } + else if(sda>this.shaftDestroyedAtB) + { + for(int i4=this.shaftDestroyedAtB;i4=this.yShieldMin && y<=this.yShieldMax && x>=this.xShieldMin && x<=this.xShieldMax && z>=this.zShieldMin && z<=this.zShieldMax) + { + if(onBlockBeak) + { + this.hasShield=false; + this.advancedShield=false; + this.modelShift=0; + this.lastBlockShift=this.blockShift=1; + this.shaftDestroyedAtA=0; + IC2.network.get().updateTileEntityField(this, "modelShift"); + IC2.network.get().updateTileEntityField(this, "advancedShield"); + this.cleanUp(); + } + return true; + } + return false; + } + + public boolean isShaftCoordNN(int x, int y, int z) + { + if(y==this.yShaft && x>=this.xShaftMin && x<=this.xShaftMax && z>=this.zShaftMin && z<=this.zShaftMax) + { + return true; + } + return false; + } + + public void cleanUp() + { + int xyz[]={0,0,1,0,-1,-1,1,1,-1,2,0,2,1,2,-1,-2,0,-2,1,-2,-1,0}; + for(int shift = 0;shift<=this.blockShift+1;shift++) + { + for(int i = 0;i<21;i++) + { + Block block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+shift*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+shift*this.mZ()); + if(block instanceof HorizontalMiningPipe) + { + ArrayList drops = block.getDrops(this.worldObj, this.xCoord+xyz[i+1]*this.mZ()+shift*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+shift*this.mZ(), 0, 3); + if(drops.size()>0) + { + for(int i1=0;i1 drops) + { + ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing()).getOpposite(); + TileEntity te = worldObj.getTileEntity(xCoord+direction.offsetX, yCoord+direction.offsetY, zCoord+direction.offsetZ); + if(te instanceof HydrotransportPulpRegeneratorTileEntity) + { + HydrotransportPulpRegeneratorTileEntity hprte = (HydrotransportPulpRegeneratorTileEntity) te; + if(hprte.getActive()) + { + ArrayList drops1 = new ArrayList(); + Iterator dropsIterator = drops.iterator(); + while(dropsIterator.hasNext()) + { + ItemStack stack = dropsIterator.next(); + RecipeOutput maceratorOut = Recipes.macerator.getOutputFor(stack, false); + if(maceratorOut!=null && !maceratorOut.items.isEmpty()) + { + Iterator maceratorOutIterator = maceratorOut.items.iterator(); + while(maceratorOutIterator.hasNext()) + { + drops1.add(maceratorOutIterator.next().copy()); + } + } + else + { + drops1.add(stack); + } + } + if(hprte.outputSlot.canAdd(drops1)) + { + hprte.outputSlot.add(drops1); + } + else + { + for(int i1=0;i1 drops = block.getDrops(this.worldObj, x, y, z, meta, 0); + if(drops.size()>0) + { + for(int i1=0;i1= this.maxStorage) + { + return amount; + } + else + { + this.energy += amount; + return 0.0D; + } + } + + @Override + public double getEnergy() { + return this.energy; + } + + @Override + public boolean useEnergy(double amount) + { + if (this.energy >= amount) + { + this.energy -= amount; + return true; + } + else + { + return false; + } + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } + + @Override + public boolean getIsInvalid() + { + return this.isInvalid(); + } + + public void installAdvancedShield() + { + this.installShield(); + this.advancedShield=true; + IC2.network.get().updateTileEntityField(this, "advancedShield"); + } + + public ItemStack getOutput(int arg0) + { + return null; + } + + public int getOutputSize() { + return 0; + } + + public void setOutput(int arg0, ItemStack arg1) + { + } + + @Override + public Set getUpgradableProperties() + { + Set properties = new HashSet(); + properties.add(UpgradableProperty.EnergyStorage); + properties.add(UpgradableProperty.Processing); + properties.add(UpgradableProperty.Transformer); + return properties; + } +} diff --git a/ihl/tunneling_shield/HorizontalMiningPipe.java b/ihl/tunneling_shield/HorizontalMiningPipe.java new file mode 100644 index 0000000..8048d45 --- /dev/null +++ b/ihl/tunneling_shield/HorizontalMiningPipe.java @@ -0,0 +1,276 @@ +package ihl.tunneling_shield; +import ic2.core.IC2; +import ic2.core.Ic2Items; +import ic2.core.audio.PositionSpec; +import ic2.core.item.tool.ItemToolWrench; +import ihl.IHLMod; +import java.util.ArrayList; +import java.util.Random; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class HorizontalMiningPipe extends Block { + + public static ArrayList teList = new ArrayList(); + + public HorizontalMiningPipe() { + super(Material.iron); + this.setBlockBounds(0.1875F, 0.1875F, 0.1875F, 0.8125F, 0.8125F, 0.8125F); + } + + public HorizontalMiningPipe(int meta) { + super(Material.iron); + this.setBlockBounds(0.1875F*meta, 0.1875F, 0.1875F*(1-meta), 0.8125F+0.1875F*(1-meta), 0.8125F, 0.8125F+0.1875F*meta); + } + + @Override + public boolean canHarvestBlock(EntityPlayer player, int meta) + { + return true; + } + + @Override + public Item getItem(World world, int x, int y, int z) + { + return Ic2Items.miningPipe.getItem(); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Ic2Items.miningPipe.getItem(); + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + ItemStack result = Ic2Items.miningPipe; + result.stackSize=1; + this.dropBlockAsItem(world, x, y, z, result); + } + + + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon("ic2:machine/blockMiningPipe"); + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + return this.blockIcon; + } + + /** + * The type of render function that is called for this block + */ + @Override + public int getRenderType() + { + return -2; + } + + /** + * Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two + * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. + */ + @Override + public boolean isOpaqueCube() + { + return false; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + @Override + public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) + { + super.onBlockDestroyedByExplosion(world, x, y, z, explosion); + this.checkIfMachinePart(world, x, y, z); + } + + @Override + public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta) + { + super.onBlockDestroyedByPlayer(world, x, y, z, meta); + this.checkIfMachinePart(world, x, y, z); + } + + private void checkIfMachinePart(World world, int x, int y, int z) + { + if(teList.size()>0) + { + for (int i=0;i0) + { + for (int i=0;i0) + { + for (int i3=0;i3 fluidTankFluidList; + private final static int height=166; + + public HydrotransportPulpRegeneratorContainer(EntityPlayer entityPlayer, HydrotransportPulpRegeneratorTileEntity tileEntity1){ + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList=tileEntity.fluidTank.getFluidList(); + int col,row; + for (col = 0; col < 3; ++col) + { + for (int col1 = 0; col1 < 9; ++col1) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + for (col = 0; col < 9; ++col) + { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 32, 13)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 32, 51)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.engine, 0, 8, 32)); + for(col=0;col<4;col++) + { + for(row=0;row<3;row++) + { + this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, col+row*4, 92+col*18, 13+row*18)); + } + } + } + + @Override + public void detectAndSendChanges() + { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) + { + ICrafting icrafting = (ICrafting)this.crafters.get(i); + + if (this.tileEntity.fluidTank.getFluidAmount() != this.lastFluidAmount || this.tileEntity.fluidTank.getNumberOfFluids() != this.lastNumberOfFluids) + { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + if (this.tileEntity.progress != this.lastProgress) + { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + if (this.tileEntity.getEnergy() != this.lastEnergy ) + { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy()); + } + } + + this.lastNumberOfFluids = this.tileEntity.fluidTank.getNumberOfFluids(); + this.lastFluidAmount = this.tileEntity.fluidTank.getFluidAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastEnergy = this.tileEntity.getEnergy(); + } + + @Override + public void updateProgressBar(int index, int value) + { + super.updateProgressBar(index, value); + switch (index) + { + case 0: + this.tileEntity.progress=(short) value; + break; + case 1: + this.tileEntity.setEnergy(value); + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/tunneling_shield/HydrotransportPulpRegeneratorGui.java b/ihl/tunneling_shield/HydrotransportPulpRegeneratorGui.java new file mode 100644 index 0000000..263d2e1 --- /dev/null +++ b/ihl/tunneling_shield/HydrotransportPulpRegeneratorGui.java @@ -0,0 +1,63 @@ +package ihl.tunneling_shield; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import ihl.utils.IHLRenderUtils; + +@SideOnly(Side.CLIENT) +public class HydrotransportPulpRegeneratorGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIHydrotransportPulpRegenerator.png"); + private HydrotransportPulpRegeneratorContainer container; + + public HydrotransportPulpRegeneratorGui (HydrotransportPulpRegeneratorContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12); + this.drawTexturedModalRect(12, 16 + 12 - i1, 179, 13 - i1, 13, i1 + 1); + } + if (this.container.tileEntity.progress > 0) + { + i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); + this.drawTexturedModalRect(73, 34, 197, 0, i1 + 1, 13); + } + if (this.container.tileEntity.fluidTank.getFluidAmount() > 0) + { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTank, 57, 16, 69, 63, zLevel, par1, par2, xOffset, yOffset); + } + this.mc.renderEngine.bindTexture(background); + if(!this.container.tileEntity.engine.correctContent()) + { + IHLRenderUtils.instance.drawMissingEngineTooltip(this, par1, par2, 26, 33, xOffset, yOffset); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + //draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } +} \ No newline at end of file diff --git a/ihl/tunneling_shield/HydrotransportPulpRegeneratorTileEntity.java b/ihl/tunneling_shield/HydrotransportPulpRegeneratorTileEntity.java new file mode 100644 index 0000000..e1d2b39 --- /dev/null +++ b/ihl/tunneling_shield/HydrotransportPulpRegeneratorTileEntity.java @@ -0,0 +1,273 @@ +package ihl.tunneling_shield; + +import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.api.Direction; +import ic2.core.ContainerBase; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class HydrotransportPulpRegeneratorTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler +{ + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + public final InvSlotOutput outputSlot; + final IHLFluidTank fluidTank = new IHLFluidTank(2000); + private int timer=0; + + public HydrotransportPulpRegeneratorTileEntity() { + super(); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); + this.outputSlot = new InvSlotOutput(this, "output", 3, 12); + this.isGuiScreenOpened=true; + this.operationLength=26; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) + { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) + { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer player) + { + return IHLUtils.getThisModItemStack("hydrotransportPulpRegenerator"); + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing()); + TileEntity te = worldObj.getTileEntity(xCoord+direction.offsetX,yCoord+direction.offsetY,zCoord+direction.offsetZ); + if(!this.getActive() && this.fluidTank.getFluid()!=null && isMachineOperational()) + { + if(te instanceof DriverTileEntity) + { + this.setActive(true); + } + } + else if(this.getActive()) + { + timer++; + if(!(te instanceof DriverTileEntity) || this.fluidTank.getFluid()==null || !isMachineOperational()) + { + this.setActive(false); + } + } + if(timer>100) + { + this.fluidTank.drain(1, true); + this.energy-=1d; + timer=0; + } + if(timer%10==0) + { + if(te instanceof DriverTileEntity) + { + DriverTileEntity dte = (DriverTileEntity) te; + if(dte.getActive()) + { + this.fluidTank.drain(1, true); + } + } + } + IHLUtils.handleFluidSlotsBehaviour(null, drainInputSlot, emptyFluidItemsSlot, fluidTank); + } + + @Override + public void operate() + { + ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing()).getOpposite(); + TileEntity te = worldObj.getTileEntity(xCoord+direction.offsetX, yCoord+direction.offsetY,zCoord+direction.offsetZ); + int i0=0; + for(int i1=i0;i1si.getInventoryStackLimit()) + { + si.getStackInSlot(i).stackSize=si.getInventoryStackLimit(); + outputSlot.get(i0).stackSize-=si.getInventoryStackLimit()-stackSizeBefore; + if(outputSlot.get(i0).stackSize<=0) + { + outputSlot.put(i0,null); + } + } + else + { + outputSlot.put(i0,null); + } + } + + } + } + } + else if(te instanceof IInventory) + { + IInventory si = (IInventory)te; + for(int i=0;isi.getInventoryStackLimit()) + { + si.getStackInSlot(i).stackSize=si.getInventoryStackLimit(); + outputSlot.get(i0).stackSize-=si.getInventoryStackLimit()-stackSizeBefore; + if(outputSlot.get(i0).stackSize<=0) + { + outputSlot.put(i0,null); + } + } + else + { + outputSlot.put(i0,null); + } + } + } + } + } + else + { + for(int i1=i0;i1=this.energyConsume/this.engine.getEfficiency(); + } + + @Override + public List[] getInput() + { + return null; + } + + @Override + public boolean canOperate() + { + return !this.outputSlot.isEmpty(); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new HydrotransportPulpRegeneratorGui(new HydrotransportPulpRegeneratorContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + return new HydrotransportPulpRegeneratorContainer(player, this); + } + + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return false; + } + + @Override + public boolean canFill(ForgeDirection arg0, Fluid arg1) + { + return true; + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return null; + } + + @Override + public FluidStack drain(ForgeDirection arg0, int arg1, boolean arg2) { + return null; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack resource, boolean doFill) + { + return this.fluidTank.fill(resource, doFill); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) + { + return new FluidTankInfo[] {this.fluidTank.getInfo()}; + } + +} \ No newline at end of file diff --git a/ihl/tunneling_shield/IMultiBlock.java b/ihl/tunneling_shield/IMultiBlock.java new file mode 100644 index 0000000..e4d32d7 --- /dev/null +++ b/ihl/tunneling_shield/IMultiBlock.java @@ -0,0 +1,7 @@ +package ihl.tunneling_shield; + +public interface IMultiBlock +{ + public boolean isAPartOfStructure(int x, int y, int z, boolean onBlockBeak); + public boolean getIsInvalid(); +} diff --git a/ihl/tunneling_shield/MultiBlockSpacerBlock.java b/ihl/tunneling_shield/MultiBlockSpacerBlock.java new file mode 100644 index 0000000..511d8cd --- /dev/null +++ b/ihl/tunneling_shield/MultiBlockSpacerBlock.java @@ -0,0 +1,226 @@ +package ihl.tunneling_shield; + +import ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.audio.PositionSpec; +import ic2.core.item.tool.ItemToolWrench; +import ihl.utils.IHLUtils; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Random; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; + +public class MultiBlockSpacerBlock extends Block { + + public static Set teList = new HashSet(); + + public MultiBlockSpacerBlock() + { + super(Material.iron); + } + + /** + * The type of render function that is called for this block + */ + @Override + public int getRenderType() + { + return -2; + } + + @Override + public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) + { + super.onBlockDestroyedByExplosion(world, x, y, z, explosion); + this.checkIfMachinePart(world, x, y, z); + } + + @Override + public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta) + { + super.onBlockDestroyedByPlayer(world, x, y, z, meta); + this.checkIfMachinePart(world, x, y, z); + } + + private boolean checkIfMachinePart(World world, int x, int y, int z) + { + if(!teList.isEmpty()) + { + Iterator i = MultiBlockSpacerBlock.teList.iterator(); + while(i.hasNext()) + { + IMultiBlock te = i.next(); + if(te!=null && !te.getIsInvalid()) + { + if(te.isAPartOfStructure(x, y, z, true)) + { + return true; + } + } + else + { + teList.remove(i); + } + } + } + return false; + } + + private IMultiBlock getLinkedTileEntity(World world, int x, int y, int z) + { + if(!teList.isEmpty()) + { + Iterator i = MultiBlockSpacerBlock.teList.iterator(); + while(i.hasNext()) + { + IMultiBlock te = i.next(); + if(te!=null && !te.getIsInvalid()) + { + if(te.isAPartOfStructure(x, y, z, false)) + { + return te; + } + } + else + { + teList.remove(i); + } + } + } + return null; + } + + @Override + public ArrayList getDrops(World world,int x, int y, int z, int meta, int flag) + { + ArrayList nothing = new ArrayList(); + nothing.clear(); + return nothing; + } + + /** + * Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two + * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. + */ + @Override + public boolean isOpaqueCube() + { + return false; + } + + /** + * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) + */ + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + @Override + public void onBlockAdded(World world, int x, int y,int z) + { + world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world)); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y,int z, Block block) + { + this.updateTick(world, x, y, z, world.rand); + } + +@Override +public void updateTick(World world, int x, int y,int z, Random rand) +{ + world.scheduleBlockUpdate(x, y, z, this, this.tickRate(world)); + if(!world.isRemote) + { + boolean setToAir=true; + if(teList.size()>0) + { + if(!teList.isEmpty()) + { + Iterator i = MultiBlockSpacerBlock.teList.iterator(); + while(i.hasNext()) + { + IMultiBlock te = i.next(); + if(te!=null && !te.getIsInvalid()) + { + if(te.isAPartOfStructure(x, y, z, false)) + { + setToAir=false; + } + } + else + { + teList.remove(i); + } + } + } + } + if(setToAir) + { + world.setBlockToAir(x, y, z); + } + } +} + + @Override + public int tickRate(World world) + { + return 200; + } + + @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z) + { + IMultiBlock te = this.getLinkedTileEntity(world, x, y, z); + ItemStack currentIS = entityPlayer.inventory.getCurrentItem(); + if(currentIS!=null) + { + if(currentIS.getItem() instanceof ItemToolWrench) + { + if(((ItemToolWrench)currentIS.getItem()).canTakeDamage(currentIS, 10)) + { + if (IC2.platform.isRendering()) + { + IC2.audioManager.playOnce(entityPlayer, PositionSpec.Hand, "Tools/wrench.ogg", true, 1.0F); + } + else if(IC2.platform.isSimulating()) + { + if(te instanceof DriverTileEntity) + { + DriverTileEntity dte =(DriverTileEntity) te; + if(dte.hasShield) + { + if(dte.advancedShield) + { + world.spawnEntityInWorld(new EntityItem(world, x, y, z, IHLUtils.getThisModItemStack("advancedShieldAssemblyUnitBlock"))); + } + else + { + world.spawnEntityInWorld(new EntityItem(world, x, y, z, IHLUtils.getThisModItemStack("IHLShieldAssemblyUnitBlock"))); + } + } + dte.isAPartOfStructure(x, y, z, true); + world.setBlockToAir(x, y, z); + } + ((ItemToolWrench)currentIS.getItem()).damage(currentIS, 10, entityPlayer); + } + } + return true; + } + } + return te instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(entityPlayer, (IHasGui)te) : true) : false; + } +} \ No newline at end of file -- cgit v1.2.3