diff options
| author | Foghrye4 <foghrye4@gmail.com> | 2016-04-11 19:44:54 +0300 |
|---|---|---|
| committer | Foghrye4 <foghrye4@gmail.com> | 2016-04-11 19:44:54 +0300 |
| commit | 05c78126859231a68e199dc34613689bd0978e2f (patch) | |
| tree | 050bea104a18c72905095d29f31bec2935a27a24 /ihl/tunneling_shield | |
Initial commit
Diffstat (limited to 'ihl/tunneling_shield')
| -rw-r--r-- | ihl/tunneling_shield/BlockItemRender.java | 206 | ||||
| -rw-r--r-- | ihl/tunneling_shield/DriverBlock.java | 109 | ||||
| -rw-r--r-- | ihl/tunneling_shield/DriverContainer.java | 79 | ||||
| -rw-r--r-- | ihl/tunneling_shield/DriverEntity.java | 69 | ||||
| -rw-r--r-- | ihl/tunneling_shield/DriverGui.java | 102 | ||||
| -rw-r--r-- | ihl/tunneling_shield/DriverModel.java | 161 | ||||
| -rw-r--r-- | ihl/tunneling_shield/DriverRender.java | 50 | ||||
| -rw-r--r-- | ihl/tunneling_shield/DriverRenderEntity.java | 150 | ||||
| -rw-r--r-- | ihl/tunneling_shield/DriverTileEntity.java | 1138 | ||||
| -rw-r--r-- | ihl/tunneling_shield/HorizontalMiningPipe.java | 276 | ||||
| -rw-r--r-- | ihl/tunneling_shield/HydrotransportPulpRegeneratorContainer.java | 99 | ||||
| -rw-r--r-- | ihl/tunneling_shield/HydrotransportPulpRegeneratorGui.java | 63 | ||||
| -rw-r--r-- | ihl/tunneling_shield/HydrotransportPulpRegeneratorTileEntity.java | 273 | ||||
| -rw-r--r-- | ihl/tunneling_shield/IMultiBlock.java | 7 | ||||
| -rw-r--r-- | ihl/tunneling_shield/MultiBlockSpacerBlock.java | 226 |
15 files changed, 3008 insertions, 0 deletions
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<model.boxList.size()-this.renderTo;i++)
+ {
+ if(model.boxList.get(i) instanceof ModelRenderer)
+ {
+ ModelRenderer piece = (ModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ else if(model.boxList.get(i) instanceof IHLModelRenderer)
+ {
+ IHLModelRenderer piece = (IHLModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ }
+ }
+ else
+ {
+ rbd.renderInventoryBlock(block, 3, 0, new RenderBlocks());
+ }
+ GL11.glPopMatrix();
+ break;
+ case EQUIPPED:
+ GL11.glTranslatef(0.25F,-2F,-0.75F);
+ if(model!=null)
+ {
+ for(int i = this.renderFrom;i<model.boxList.size()-this.renderTo;i++)
+ {
+ if(model.boxList.get(i) instanceof ModelRenderer)
+ {
+ ModelRenderer piece = (ModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ else if(model.boxList.get(i) instanceof IHLModelRenderer)
+ {
+ IHLModelRenderer piece = (IHLModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ }
+ }
+ else
+ {
+ rbd.renderInventoryBlock(block, 3, 0, new RenderBlocks());
+ }
+ GL11.glPopMatrix();
+ break;
+ case EQUIPPED_FIRST_PERSON:
+ if(this.renderHand)
+ {
+ RenderPlayer var25;
+ EntityClientPlayerMP var3 = Minecraft.getMinecraft().thePlayer;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(var3.getLocationSkin());
+ var25 = (RenderPlayer)RenderManager.instance.getEntityRenderObject(Minecraft.getMinecraft().thePlayer);
+ GL11.glRotatef(135F, 1.0F, 0.0F, 0.0F);
+ GL11.glRotatef(35F, 0.0F, 1.0F, 0.0F);
+ var25.renderFirstPersonArm(Minecraft.getMinecraft().thePlayer);
+ GL11.glRotatef(-35F, 0.0F, 1.0F, 0.0F);
+ GL11.glRotatef(-135F, 1.0F, 0.0F, 0.0F);
+ Minecraft.getMinecraft().renderEngine.bindTexture(tex);
+ GL11.glTranslatef(0.0F,0.2F,0F);
+ }
+ GL11.glTranslatef(-0.25F,-2.0F-amendment,0F);
+ if(model!=null)
+ {
+ for(int i = this.renderFrom;i<model.boxList.size()-this.renderTo;i++)
+ {
+ if(model.boxList.get(i) instanceof ModelRenderer)
+ {
+ ModelRenderer piece = (ModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ else if(model.boxList.get(i) instanceof IHLModelRenderer)
+ {
+ IHLModelRenderer piece = (IHLModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ }
+ }
+ else
+ {
+ rbd.renderInventoryBlock(block, 3, 0, new RenderBlocks());
+ }
+ GL11.glPopMatrix();
+ break;
+ case INVENTORY:
+ GL11.glRotatef(15F, 0F, 1F, 0F);
+ GL11.glTranslatef(0.0F,-1.0F+inventoryOffset,0F);
+ if(model!=null)
+ {
+ for(int i = this.renderFrom;i<model.boxList.size()-this.renderTo;i++)
+ {
+ if(model.boxList.get(i) instanceof ModelRenderer)
+ {
+ ModelRenderer piece = (ModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ else if(model.boxList.get(i) instanceof IHLModelRenderer)
+ {
+ IHLModelRenderer piece = (IHLModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ }
+ }
+ else
+ {
+
+ rbd.renderInventoryBlock(block, 3, 0, new RenderBlocks());
+ }
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glPopMatrix();
+ break;
+ default:
+ }
+}
+}
\ No newline at end of file diff --git a/ihl/tunneling_shield/DriverBlock.java b/ihl/tunneling_shield/DriverBlock.java new file mode 100644 index 0000000..e39205f --- /dev/null +++ b/ihl/tunneling_shield/DriverBlock.java @@ -0,0 +1,109 @@ +package ihl.tunneling_shield;
+import ic2.api.item.IC2Items;
+import ic2.core.IC2;
+import ihl.IHLModInfo;
+import java.util.Random;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.block.BlockContainer;
+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.tileentity.TileEntity;
+import net.minecraft.world.World;
+
+public class DriverBlock extends BlockContainer {
+
+ public DriverBlock(Material p_i45386_1_) {
+ super(p_i45386_1_);
+ }
+
+ @Override
+ public void onBlockPreDestroy(World world, int x, int y, int z, int meta)
+ {
+ if(IC2.platform.isSimulating())
+ {
+ DriverTileEntity te = (DriverTileEntity)world.getTileEntity(x,y,z);
+ te.cleanUp();
+ }
+ }
+
+ @Override
+ public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
+ {
+ return IC2Items.getItem("machine").getItem();
+ }
+
+ @Override
+ public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
+ {
+ ItemStack result = IC2Items.getItem("machine").copy();
+ this.dropBlockAsItem(world, x, y, z, result);
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int var2) {
+ return new DriverTileEntity();
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister)
+ {
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":driver");
+ }
+
+ @Override
+ public boolean hasTileEntity(int metadata)
+ {
+ return true;
+ }
+
+
+ @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){
+ if(world.getTileEntity(x,y,z) instanceof DriverTileEntity)
+ {
+ DriverTileEntity var10 = (DriverTileEntity)world.getTileEntity(x,y,z);
+ if (var10 == null || entityPlayer.isSneaking()) {
+ return false;
+ }
+ else
+ {
+ return var10.getGui(entityPlayer);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 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;
+ }
+}
\ No newline at end of file diff --git a/ihl/tunneling_shield/DriverContainer.java b/ihl/tunneling_shield/DriverContainer.java new file mode 100644 index 0000000..b7e8687 --- /dev/null +++ b/ihl/tunneling_shield/DriverContainer.java @@ -0,0 +1,79 @@ +package ihl.tunneling_shield;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class DriverContainer extends ContainerBase {
+
+ protected DriverTileEntity tileEntity;
+ public int lastStorage = -1;
+ private final static int height=166;
+
+ public DriverContainer(EntityPlayer entityPlayer, DriverTileEntity tileEntity1){
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ int col;
+
+ 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.dischargeSlot, 0, 26, 26));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.miningPipesSlot, 0, 48, 26));
+ for(int row=0;row<=3;row++)
+ {
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.upgradeSlot, row, 152, 8+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.getStored() != this.lastStorage)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, (this.tileEntity.getStored()>>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<Block> blockBlackList = new ArrayList();
+ private List<Block> 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<IHLMod.config.ts02BlockBlackListString.length;i6++)
+ {
+ String blockName = IHLMod.config.ts02BlockBlackListString[i6];
+ Block block = Block.getBlockFromName(blockName);
+ if(block==null)
+ {
+ ItemStack stack = IC2Items.getItem(blockName);
+ if(stack!=null)
+ {
+ block = StackUtil.getBlock(stack);
+ }
+ }
+ if(block!=null)
+ {
+ blockBlackList.add(block);
+ }
+ }
+ for(int i7=0;i7<IHLMod.config.ts02BlockWhiteListString.length;i7++)
+ {
+ String blockName = IHLMod.config.ts02BlockWhiteListString[i7];
+ Block block = Block.getBlockFromName(blockName);
+ if(block==null)
+ {
+ ItemStack stack = IC2Items.getItem(blockName);
+ if(stack!=null)
+ {
+ block = StackUtil.getBlock(stack);
+ }
+ }
+ if(block!=null)
+ {
+ blockWhiteList.add(block);
+ }
+
+ }
+ blockWhiteList.add(IHLMod.multiBlockSpacerBlock);
+ blockWhiteList.add(IHLMod.horizontalMiningPipeX);
+ blockWhiteList.add(IHLMod.horizontalMiningPipeZ);
+ blockWhiteList.add(Blocks.air);
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> 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<DriverEntity> deList = this.worldObj.getEntitiesWithinAABB(DriverEntity.class, this.getOperationZone());
+ if(deList.size()>0)
+ {
+ Iterator<DriverEntity> 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<Entity> entityList = this.worldObj.getEntitiesWithinAABB(Entity.class, this.getShieldBladesZone(0D));
+ velocity = -0.5D;
+ if(entityList.size()>0)
+ {
+ for(int i0=0;i0<entityList.size();i0++)
+ {
+ entityList.get(i0).addVelocity(velocity*mX(), 0.25D, velocity*mZ());
+ }
+ }
+ }
+ else
+ {
+ this.modelShift++;
+ List<EntityLivingBase> 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<entityLivingList.size();i1++)
+ {
+ entityLivingList.get(i1).attackEntityFrom(DamageSource.fallingBlock, damage);
+ entityLivingList.get(i1).addVelocity(velocity*mX(), 0.25D*velocity, velocity*mZ());
+ }
+ }
+ List<EntityLiving> entityLivingList2 = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, this.getShieldBladesZone(2.5D));
+ velocity*=0.1D;
+ if(entityLivingList2.size()>0)
+ {
+ for(int i2=0;i2<entityLivingList2.size();i2++)
+ {
+ entityLivingList2.get(i2).attackEntityFrom(DamageSource.fallingBlock, damage);
+ entityLivingList2.get(i2).addVelocity(velocity*mX(), 0.25D*velocity, velocity*mZ());
+ }
+ }
+ }
+ }
+ this.blockShift=Math.round(this.getModelShiftAmount()+1.0F+(this.reverseModeOn?2.0F:0));
+ if (IC2.platform.isSimulating())
+ {
+ if (this.prevHasShield!= this.hasShield)
+ {
+ IC2.network.get().updateTileEntityField(this, "hasShield");
+ this.prevHasShield = this.hasShield;
+ }
+ if (this.prevShaftDestroyedAtA!= this.shaftDestroyedAtA)
+ {
+ IC2.network.get().updateTileEntityField(this, "shaftDestroyedAtA");
+ this.prevShaftDestroyedAtA=this.shaftDestroyedAtA;
+ }
+ if (this.prevShaftDestroyedAtB!= this.shaftDestroyedAtB)
+ {
+ IC2.network.get().updateTileEntityField(this, "shaftDestroyedAtB");
+ this.prevShaftDestroyedAtB=this.shaftDestroyedAtB;
+ }
+ if(this.getDemandedEnergy() > 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<ItemStack> 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<drops.size();i1++)
+ {
+ this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, x1, y1, z1, drops.get(i1)));
+ }
+ }
+ }
+ }
+ this.worldObj.setBlock(x, y, z, setToBlock);
+ }
+
+ public void setOverclockRates()
+ {
+ int speedUp=0;
+ int tierUp=0;
+ int capacityUp=0;
+ int checksum=0;
+ for(int i=0;i<this.upgradeSlot.size();i++)
+ {
+ if(this.upgradeSlot.get(i)!=null)
+ {
+ if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("overclockerUpgrade").getItemDamage())
+ {
+ speedUp+=this.upgradeSlot.get(i).stackSize;
+ }
+ if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("transformerUpgrade").getItemDamage())
+ {
+ tierUp+=this.upgradeSlot.get(i).stackSize;
+ }
+ if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("energyStorageUpgrade").getItemDamage())
+ {
+ capacityUp+=this.upgradeSlot.get(i).stackSize;
+ }
+ }
+ }
+ checksum=speedUp*4096+tierUp*64+capacityUp;
+ if(this.updateChecksum!=checksum)
+ {
+ double correction = this.reverseModeOn?0.1D:1D;
+ float newModelShiftSpeed=(float)Math.max(correction*this.defaultModelShiftSpeed*Math.pow(0.7D, speedUp),10D);
+ this.modelShift=Math.round(this.modelShift*newModelShiftSpeed/this.modelShiftSpeed);
+ this.modelShiftSpeed=Math.round(newModelShiftSpeed);
+ this.tier=this.defaultTier+tierUp;
+ IC2.network.get().updateTileEntityField(this, "tier");
+ this.maxStorage=this.defaultMaxStorage + capacityUp*10000;
+ IC2.network.get().updateTileEntityField(this, "maxStorage");
+ this.energyConsume=Math.min(correction*this.defaultEnergyConsume*Math.pow(1.6D, speedUp),this.maxStorage);
+ IC2.network.get().updateTileEntityField(this, "modelShift");
+ IC2.network.get().updateTileEntityField(this, "modelShiftSpeed");
+ this.updateChecksum=checksum;
+ };
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound var1) {
+ super.writeToNBT(var1);
+ var1.setDouble("energy", this.energy);
+ var1.setBoolean("hasShield", this.hasShield);
+ var1.setBoolean("autoReverseModeOn", this.autoReverseModeOn);
+ var1.setBoolean("reverseModeOn", this.reverseModeOn);
+ var1.setBoolean("advancedShield", this.advancedShield);
+ var1.setInteger("modelShift", this.modelShift);
+ var1.setInteger("shaftDestroyedAtA", this.shaftDestroyedAtA);
+ var1.setInteger("shaftDestroyedAtB", this.shaftDestroyedAtB);
+ var1.setInteger("modelShiftSpeed", this.modelShiftSpeed);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound var1) {
+ super.readFromNBT(var1);
+ this.hasShield=var1.getBoolean("hasShield");
+ this.autoReverseModeOn=var1.getBoolean("autoReverseModeOn");
+ this.reverseModeOn=var1.getBoolean("reverseModeOn");
+ this.advancedShield=var1.getBoolean("advancedShield");
+ this.modelShift=var1.getInteger("modelShift");
+ this.modelShiftSpeed=var1.getInteger("modelShiftSpeed");
+ this.energy=var1.getDouble("energy");
+ this.shaftDestroyedAtA=var1.getInteger("shaftDestroyedAtA");
+ this.shaftDestroyedAtB=var1.getInteger("shaftDestroyedAtB");
+ if(this.hasShield)
+ {
+ if(!MultiBlockSpacerBlock.teList.contains(this))
+ {
+ MultiBlockSpacerBlock.teList.add(this);
+ }
+ if(this.mX()==0)
+ {
+ if(!HorizontalMiningPipe.teList.contains(this))
+ {
+ HorizontalMiningPipe.teList.add(this);
+ }
+ }
+ else
+ {
+ if(!HorizontalMiningPipe.teList.contains(this))
+ {
+ HorizontalMiningPipe.teList.add(this);
+ }
+ }
+ }
+ float shift=(float)this.modelShift/(float)this.modelShiftSpeed+1.0F;
+ this.lastBlockShift=this.blockShift=Math.round(shift);
+ this.defineTechBlockVariables();
+ this.lastModelShiftAmount=this.getModelShiftAmount();
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return !this.hasShield && this.getFacing()!=(short)side;
+ }
+
+ @Override
+ public short getFacing() {
+ return super.getFacing();
+ }
+
+ @Override
+ public void setFacing(short facing) {
+ short newFacing = (short) Math.max(2, facing);
+ super.setFacing(newFacing);
+ }
+
+ @Override
+ public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
+ return true;
+ }
+
+ @Override
+ public float getWrenchDropRate() {
+ return 1.0F;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ this.cleanUp();
+ if(this.hasShield)
+ {
+ if(this.advancedShield)
+ {
+ this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord+(this.blockShift-2)*this.mX(), this.yCoord, this.zCoord+(this.blockShift-2)*this.mZ(), IHLUtils.getThisModItemStack("advancedShieldAssemblyUnitBlock")));
+ }
+ else
+ {
+ this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord+(this.blockShift-2)*this.mX(), this.yCoord, this.zCoord+(this.blockShift-2)*this.mZ(), IHLUtils.getThisModItemStack("IHLShieldAssemblyUnitBlock")));
+ }
+ }
+ if(this.miningPipesSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.miningPipesSlot.get()));
+ if(this.dischargeSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.dischargeSlot.get()));
+ if(this.upgradeSlot.get(0)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(0)));
+ if(this.upgradeSlot.get(1)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(1)));
+ if(this.upgradeSlot.get(2)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(2)));
+ if(this.upgradeSlot.get(3)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(3)));
+ return new ItemStack(IHLMod.driverBlock,1);
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "IHL TS-002";
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer arg0, boolean arg1) {
+ return new DriverGui(new DriverContainer(arg0, this));
+ }
+
+ @Override
+ public ContainerBase getGuiContainer(EntityPlayer arg0) {
+ return new DriverContainer(arg0, this);
+ }
+
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
+ {
+ return true;
+ }
+
+ public boolean getGui(EntityPlayer player)
+ {
+ return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false;
+ }
+
+ public boolean canPlaceShield()
+ {
+ if(this.hasShield)
+ {
+ return false;
+ }
+ Block block;
+ 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 i = 0;i<21;i++)
+ {
+ block = this.worldObj.getBlock(this.xCoord+xyz[i+1]*this.mZ()+this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+this.mZ());
+ if(!block.isAir(this.worldObj, this.xCoord+xyz[i+1]*this.mZ()+this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+this.mZ()))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public int mX()
+ {
+ switch(this.getFacing())
+ {
+ case 4:
+ return -1;
+ case 5:
+ return 1;
+ default:
+ return 0;
+ }
+ }
+
+ public int mZ()
+ {
+ switch(this.getFacing())
+ {
+ case 3:
+ return 1;
+ case 2:
+ return -1;
+ case 4:
+ return 0;
+ case 5:
+ return 0;
+ default:
+ return -1;
+ }
+ }
+
+ public float getModelShiftAmount() {
+ return (float)this.modelShift/(float)this.modelShiftSpeed;
+ }
+
+ private AxisAlignedBB getOperationZone()
+ {
+ int x=this.xCoord;
+ int y=this.yCoord;
+ int z=this.zCoord;
+ double extension=this.getModelShiftAmount()+1.0D;
+ return AxisAlignedBB.getBoundingBox(x + extension*Math.min(this.mX(),0)-2.0D, y-2.0D, z + extension*Math.min(this.mZ(),0)-2.0D, x + 3.0D + extension*Math.max(this.mX(),0), y + 3.0D, z + 3.0D + extension*Math.max(this.mZ(),0));
+ }
+
+ private AxisAlignedBB getShieldBladesZone(double offset)
+ {
+ int x=this.xCoord;
+ int y=this.yCoord;
+ int z=this.zCoord;
+ double extension=this.getModelShiftAmount()+offset;
+ double xShieldMinD=this.xCoord+extension*this.mX()-1D*Math.max(this.mX(), 0)-2D*Math.abs(this.mZ());
+ double xShieldMaxD=this.xCoord+extension*this.mX()-1D*Math.min(this.mX(), 0)+3D*Math.abs(this.mZ());
+ double yShieldMinD=this.yCoord-2D;
+ double yShieldMaxD=this.yCoord+3D;
+ double zShieldMinD=this.zCoord+extension*this.mZ()-1D*Math.max(this.mZ(), 0)-2D*Math.abs(this.mX());
+ double zShieldMaxD=this.zCoord+extension*this.mZ()-1D*Math.min(this.mZ(), 0)+3D*Math.abs(this.mX());
+ return AxisAlignedBB.getBoundingBox(xShieldMinD, yShieldMinD, zShieldMinD, xShieldMaxD, yShieldMaxD, zShieldMaxD);
+ }
+
+ public int getStored() {
+ return Math.round((float)this.energy);
+ }
+
+ public void setStored(int value) {
+ this.energy=value;
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer arg0) {}
+
+ public void installShield() {
+ if(IC2.platform.isSimulating())
+ {
+ this.hasShield=true;
+ int x=this.xCoord;
+ int y=this.yCoord;
+ int z=this.zCoord;
+ MultiBlockSpacerBlock.teList.add(this);
+ this.defineTechBlockVariables();
+ if(this.mX()==0)
+ {
+ HorizontalMiningPipe.teList.add(this);
+ }
+ else
+ {
+ HorizontalMiningPipe.teList.add(this);
+ }
+
+ 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 i1 = 0;i1<21;i1++)
+ {
+ this.worldObj.setBlock(x+xyz[i1+1]*this.mZ()+this.mX(), y+xyz[i1], z+xyz[i1+1]*this.mX()+this.mZ(), IHLMod.multiBlockSpacerBlock, 0, 3);
+ }
+ }
+ }
+
+ public boolean isShaftCoord(int x, int y, int z)
+ {
+ if(IC2.platform.isSimulating() && y==this.yShaft && x>=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<sda;i4++)
+ {
+ int x1=this.xCoord+i4*mX();
+ int y1=this.yCoord;
+ int z1=this.zCoord+i4*mZ();
+ Block block=this.worldObj.getBlock(x1, y1, z1);
+ if(block instanceof HorizontalMiningPipe)
+ {
+ this.harvestDrops(block, x1, y1, z1, x1, y1, z1, Blocks.air);
+ }
+ }
+ this.shaftDestroyedAtB=sda;
+ }
+ else if(sda<this.shaftDestroyedAtA)
+ {
+ for(int i4=sda;i4<this.shaftDestroyedAtA;i4++)
+ {
+ int x1=this.xCoord+i4*mX();
+ int y1=this.yCoord;
+ int z1=this.zCoord+i4*mZ();
+ Block block=this.worldObj.getBlock(x1, y1, z1);
+ if(block instanceof HorizontalMiningPipe)
+ {
+ this.harvestDrops(block, x1, y1, z1, x1, y1, z1, Blocks.air);
+ }
+ }
+ this.shaftDestroyedAtA=sda;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isAPartOfStructure(int x, int y, int z, boolean onBlockBeak)
+ {
+ if(IC2.platform.isSimulating() && y>=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<ItemStack> 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.size();i1++)
+ {
+ this.worldObj.spawnEntityInWorld(new EntityItem(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(), drops.get(i1)));
+ }
+ }
+ this.worldObj.setBlockToAir(this.xCoord+xyz[i+1]*this.mZ()+shift*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+shift*this.mZ());
+ }
+ else if(block instanceof MultiBlockSpacerBlock)
+ {
+ this.worldObj.setBlockToAir(this.xCoord+xyz[i+1]*this.mZ()+shift*this.mX(), this.yCoord+xyz[i], this.zCoord+xyz[i+1]*this.mX()+shift*this.mZ());
+ }
+ }
+ }
+ }
+
+ private boolean handleDropsByHydrotransport(ArrayList<ItemStack> 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<ItemStack> drops1 = new ArrayList();
+ Iterator<ItemStack> dropsIterator = drops.iterator();
+ while(dropsIterator.hasNext())
+ {
+ ItemStack stack = dropsIterator.next();
+ RecipeOutput maceratorOut = Recipes.macerator.getOutputFor(stack, false);
+ if(maceratorOut!=null && !maceratorOut.items.isEmpty())
+ {
+ Iterator<ItemStack> 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<drops1.size();i1++)
+ {
+ this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, xCoord+direction.offsetX, yCoord+direction.offsetY, zCoord+direction.offsetZ, drops1.get(i1)));
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void onNetworkEvent(EntityPlayer player, int event)
+ {
+ switch(event)
+ {
+ case 0:
+ this.reverseModeOn=!this.reverseModeOn;
+ IC2.network.get().updateTileEntityField(this, "reverseModeOn");
+ this.updateChecksum=-1;
+ this.setOverclockRates();
+ break;
+ case 1:
+ this.autoReverseModeOn=!this.autoReverseModeOn;
+ IC2.network.get().updateTileEntityField(this, "autoReverseModeOn");
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void defineTechBlockVariables()
+ {
+ this.xShaftMin=this.xCoord+this.blockShift*Math.min(this.mX(), 0);
+ this.xShaftMax=this.xCoord+this.blockShift*Math.max(this.mX(), 0);
+ this.yShaft=this.yCoord;
+ this.zShaftMin=this.zCoord+this.blockShift*Math.min(this.mZ(), 0);
+ this.zShaftMax=this.zCoord+this.blockShift*Math.max(this.mZ(), 0);
+ this.xShieldMin=this.xCoord+this.blockShift*this.mX()-3*Math.max(this.mX(), 0)-2*Math.abs(this.mZ());
+ this.xShieldMax=this.xCoord+this.blockShift*this.mX()-3*Math.min(this.mX(), 0)+2*Math.abs(this.mZ());
+ this.yShieldMin=this.yCoord-2;
+ this.yShieldMax=this.yCoord+2;
+ this.zShieldMin=this.zCoord+this.blockShift*this.mZ()-3*Math.max(this.mZ(), 0)-2*Math.abs(this.mX());
+ this.zShieldMax=this.zCoord+this.blockShift*this.mZ()-3*Math.min(this.mZ(), 0)+2*Math.abs(this.mX());
+ }
+
+ public void harvestDrops(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<ItemStack> drops = block.getDrops(this.worldObj, x, y, z, meta, 0);
+ if(drops.size()>0)
+ {
+ for(int i1=0;i1<drops.size();i1++)
+ {
+ this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, x1, y1, z1, drops.get(i1)));
+ }
+ }
+ }
+ this.worldObj.setBlock(x, y, z, setToBlock);
+ }
+
+ //1.7.10 API
+ @Override
+ public double getDemandedEnergy()
+ {
+ return this.maxStorage - this.energy;
+ }
+
+ @Override
+ public int getSinkTier()
+ {
+ return this.tier;
+ }
+
+ @Override
+ public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
+ {
+ if (this.energy >= 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<UpgradableProperty> getUpgradableProperties()
+ {
+ Set<UpgradableProperty> properties = new HashSet<UpgradableProperty>();
+ 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<DriverTileEntity> 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;i<teList.size();i++)
+ {
+ if(teList.get(i)!=null && !teList.get(i).isInvalid())
+ {
+ if(teList.get(i).isShaftCoord(x, y, z))
+ {
+ return;
+ }
+ }
+ else
+ {
+ teList.remove(i);
+ i--;
+ }
+ }
+ }
+ }
+
+ private void checkIfMachinePartNN(World world, int x, int y, int z)
+ {
+ boolean setToAir=true;
+ if(teList.size()>0)
+ {
+ for (int i=0;i<teList.size();i++)
+ {
+ if(teList.get(i)!=null)
+ {
+ if(teList.get(i).isShaftCoordNN(x, y, z) && teList.get(i).hasShield)
+ {
+ setToAir=false;
+ }
+ }
+ else
+ {
+ teList.remove(i);
+ i--;
+ }
+ }
+ }
+ if(setToAir)
+ {
+ world.setBlockToAir(x, y, z);
+ }
+ }
+
+
+ @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));
+ this.checkIfMachinePartNN(world, 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)
+ {
+ ItemStack currentIS = entityPlayer.inventory.getCurrentItem();
+ if(currentIS!=null)
+ {
+ if(currentIS.getItem() instanceof ItemToolWrench && entityPlayer.inventory.hasItem(Ic2Items.miningPipe.getItem()))
+ {
+ if(((ItemToolWrench)currentIS.getItem()).canTakeDamage(currentIS, 10))
+ {
+ if (IC2.platform.isRendering())
+ {
+ IC2.audioManager.playOnce(entityPlayer, PositionSpec.Hand, "Tools/wrench.ogg", true, 1.0F);
+ }
+ if(IC2.platform.isSimulating())
+ {
+ if(teList.size()>0)
+ {
+ for (int i3=0;i3<teList.size();i3++)
+ {
+ DriverTileEntity t = teList.get(i3);
+ if(t!=null)
+ {
+ if(t.isShaftCoordNN(x, y, z) && t.hasShield)
+ {
+ int xA=t.xCoord+t.shaftDestroyedAtA*t.mX();
+ int zA=t.zCoord+t.shaftDestroyedAtA*t.mZ();
+ int xB=t.xCoord+t.shaftDestroyedAtB*t.mX();
+ int zB=t.zCoord+t.shaftDestroyedAtB*t.mZ();
+ if(t.shaftDestroyedAtA!=0 && t.shaftDestroyedAtA==t.shaftDestroyedAtB)
+ {
+ if(Math.abs(x-xA+z-zA)==1)
+ {
+ if(world.setBlock(xA, y, zA, t.mX()!=0?IHLMod.horizontalMiningPipeZ:IHLMod.horizontalMiningPipeX))
+ {
+ t.shaftDestroyedAtA=t.shaftDestroyedAtB=0;
+ entityPlayer.inventory.consumeInventoryItem(Ic2Items.miningPipe.getItem());
+ entityPlayer.inventoryContainer.detectAndSendChanges();
+ return true;
+ }
+ }
+ }
+ else if(t.shaftDestroyedAtA!=0)
+ {
+ if(Math.abs(x-xA+z-zA)==1)
+ {
+ if(world.setBlock(xA, y, zA, t.mX()!=0?IHLMod.horizontalMiningPipeZ:IHLMod.horizontalMiningPipeX))
+ {
+ t.shaftDestroyedAtA++;
+ entityPlayer.inventory.consumeInventoryItem(Ic2Items.miningPipe.getItem());
+ entityPlayer.inventoryContainer.detectAndSendChanges();
+ return true;
+ }
+ }
+ if(Math.abs(x-xB+z-zB)==1)
+ {
+ if(world.setBlock(xB, y, zB, t.mX()!=0?IHLMod.horizontalMiningPipeZ:IHLMod.horizontalMiningPipeX))
+ {
+ t.shaftDestroyedAtB--;
+ entityPlayer.inventory.consumeInventoryItem(Ic2Items.miningPipe.getItem());
+ entityPlayer.inventoryContainer.detectAndSendChanges();
+ return true;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ teList.remove(i);
+ i--;
+ }
+ }
+ }
+ ((ItemToolWrench)currentIS.getItem()).damage(currentIS, 10, entityPlayer);
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file diff --git a/ihl/tunneling_shield/HydrotransportPulpRegeneratorContainer.java b/ihl/tunneling_shield/HydrotransportPulpRegeneratorContainer.java new file mode 100644 index 0000000..fade7a0 --- /dev/null +++ b/ihl/tunneling_shield/HydrotransportPulpRegeneratorContainer.java @@ -0,0 +1,99 @@ +package ihl.tunneling_shield;
+
+import java.util.List;
+
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+import net.minecraftforge.fluids.FluidStack;
+
+public class HydrotransportPulpRegeneratorContainer extends ContainerBase {
+
+ protected HydrotransportPulpRegeneratorTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public int lastNumberOfFluids = -1;
+ public short lastProgress = -1;
+ public short lastTemperature = -1;
+ private int lastEnergy = -1;
+ private List<FluidStack> 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;i1<outputSlot.size();i1++)
+ {
+ if(outputSlot.get(i1)!=null)
+ {
+ i0=i1;
+ }
+ }
+ if(te instanceof ISidedInventory)
+ {
+ ISidedInventory si = (ISidedInventory)te;
+ for(int i=0;i<si.getSizeInventory();i++)
+ {
+ if(outputSlot.get(i0)==null)
+ {
+ break;
+ }
+ if(si.canInsertItem(i, outputSlot.get(i0), Direction.fromForgeDirection(direction).toSideValue()))
+ {
+ if(si.getStackInSlot(i)==null)
+ {
+ si.setInventorySlotContents(i, outputSlot.get(i0));
+ outputSlot.put(i0,null);
+ }
+ else if(IHLUtils.isItemStacksIsEqual(si.getStackInSlot(i),outputSlot.get(i0),true))
+ {
+ int stackSizeBefore = si.getStackInSlot(i).stackSize;
+ si.getStackInSlot(i).stackSize+=outputSlot.get(i0).stackSize;
+ if(si.getStackInSlot(i).stackSize>si.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;i<si.getSizeInventory();i++)
+ {
+ if(outputSlot.get(i0)==null)
+ {
+ break;
+ }
+ if(si.isItemValidForSlot(i, outputSlot.get(i0)))
+ {
+ if(si.getStackInSlot(i)==null)
+ {
+ si.setInventorySlotContents(i, outputSlot.get(i0));
+ outputSlot.put(i0,null);
+ }
+ else if(IHLUtils.isItemStacksIsEqual(si.getStackInSlot(i),outputSlot.get(i0),true))
+ {
+ int stackSizeBefore = si.getStackInSlot(i).stackSize;
+ si.getStackInSlot(i).stackSize+=outputSlot.get(i0).stackSize;
+ if(si.getStackInSlot(i).stackSize>si.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<outputSlot.size();i1++)
+ {
+ if(outputSlot.get(i1)!=null)
+ {
+ this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, xCoord+direction.offsetX+0.5d, yCoord+direction.offsetY+0.5d,zCoord+direction.offsetZ+0.5d, outputSlot.get(i1)));
+ outputSlot.put(i1, null);
+ break;
+ }
+ }
+ }
+ }
+
+ private boolean isMachineOperational()
+ {
+ return this.engine.correctContent() && this.energy>=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<IMultiBlock> 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<IMultiBlock> 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<IMultiBlock> 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<ItemStack> getDrops(World world,int x, int y, int z, int meta, int flag)
+ {
+ ArrayList<ItemStack> 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<IMultiBlock> 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 |
