From e159f2466bea57b273187470473158a38e181599 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Fri, 21 Mar 2014 17:41:30 +0800 Subject: [PATCH] Fixed placer textures --- .../mechanical/process/edit/TilePlacer.java | 429 +++++++++--------- .../textures/blocks/placer.png | Bin 550 -> 897 bytes .../textures/blocks/placer_front.png | Bin 508 -> 762 bytes 3 files changed, 212 insertions(+), 217 deletions(-) diff --git a/mechanical/src/main/java/resonantinduction/mechanical/process/edit/TilePlacer.java b/mechanical/src/main/java/resonantinduction/mechanical/process/edit/TilePlacer.java index 9432b64c6..5554254c5 100644 --- a/mechanical/src/main/java/resonantinduction/mechanical/process/edit/TilePlacer.java +++ b/mechanical/src/main/java/resonantinduction/mechanical/process/edit/TilePlacer.java @@ -1,21 +1,5 @@ package resonantinduction.mechanical.process.edit; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.packet.Packet; -import net.minecraft.util.ChatMessageComponent; -import net.minecraft.util.Icon; -import net.minecraftforge.common.ForgeDirection; - -import org.lwjgl.opengl.GL11; - -import resonantinduction.core.Reference; -import resonantinduction.core.ResonantInduction; -import universalelectricity.api.vector.Vector3; import calclavia.lib.content.module.TileRender; import calclavia.lib.content.module.prefab.TileInventory; import calclavia.lib.network.IPacketReceiver; @@ -25,234 +9,245 @@ import calclavia.lib.render.RenderItemOverlayUtility; import calclavia.lib.utility.LanguageUtility; import calclavia.lib.utility.inventory.InternalInventoryHandler; import calclavia.lib.utility.inventory.InventoryUtility; - import com.google.common.io.ByteArrayDataInput; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.packet.Packet; +import net.minecraft.util.ChatMessageComponent; +import net.minecraft.util.Icon; +import net.minecraftforge.common.ForgeDirection; +import org.lwjgl.opengl.GL11; +import resonantinduction.core.ResonantInduction; +import universalelectricity.api.vector.Vector3; -/** @author tgame14 - * @since 18/03/14 */ +/** + * @author tgame14 + * @since 18/03/14 + */ public class TilePlacer extends TileInventory implements IRotatable, IPacketReceiver { - private boolean doWork = false; - private boolean autoPullItems = false; - private byte place_delay = 0; - private InternalInventoryHandler invHandler; - private ForgeDirection renderItemSide_a; - private ForgeDirection renderItemSide_b; + @SideOnly(Side.CLIENT) + private static Icon iconFront, iconBack; + private boolean doWork = false; + private boolean autoPullItems = false; + private byte place_delay = 0; + private InternalInventoryHandler invHandler; + private ForgeDirection renderItemSideA; + private ForgeDirection renderItemSideB; - @SideOnly(Side.CLIENT) - private Icon iconFront; + public TilePlacer() + { + super(Material.rock); + this.normalRender = false; + this.maxSlots = 1; + } - @SideOnly(Side.CLIENT) - private Icon iconBack; + public InternalInventoryHandler getInvHandler() + { + if (invHandler == null) + { + invHandler = new InternalInventoryHandler(this); + } + return invHandler; + } - public TilePlacer() - { - super(Material.rock); - this.normalRender = false; - this.maxSlots = 1; - } + @Override + public void onAdded() + { + work(); + } - public InternalInventoryHandler getInvHandler() - { - if (invHandler == null) - { - invHandler = new InternalInventoryHandler(this); - } - return invHandler; - } + @Override + public void onNeighborChanged() + { + work(); + } - @Override - public void onAdded() - { - work(); - } + @Override + public void initiate() + { + super.initiate(); + updateDirection(); + } - @Override - public void onNeighborChanged() - { - work(); - } + @Override + public void updateEntity() + { + if (autoPullItems && this.ticks % 5 == 0) + { + if (getStackInSlot(0) == null) + { + this.setInventorySlotContents(0, this.getInvHandler().tryGrabFromPosition(this.getDirection().getOpposite(), 1)); + } + } + if (doWork) + { + if (place_delay < Byte.MAX_VALUE) + { + place_delay++; + } - @Override - public void initiate() - { - super.initiate(); - updateDirection(); - } + if (place_delay >= 5) + {//TODO implement block break speed, and a minor delay + doWork(); + doWork = false; + } + } - @Override - public void updateEntity() - { - if (autoPullItems && this.ticks % 5 == 0) - { - if (getStackInSlot(0) == null) - { - this.setInventorySlotContents(0, this.getInvHandler().tryGrabFromPosition(this.getDirection().getOpposite(), 1)); - } - } - if (doWork) - { - if (place_delay < Byte.MAX_VALUE) - place_delay++; + } - if (place_delay >= 5) - {//TODO implement block break speed, and a minor delay - doWork(); - doWork = false; - } - } + public void work() + { + if (isIndirectlyPowered()) + { + doWork = true; + place_delay = 0; + } + } - } + public void doWork() + { + //Tries to place the item stack into the world + if (InventoryUtility.placeItemBlock(world(), x() + this.getDirection().offsetX, y() + this.getDirection().offsetY, z() + this.getDirection().offsetZ, this.getStackInSlot(0))) + { + decrStackSize(0, 1); + markUpdate(); + doWork = false; + } + } - public void work() - { - if (isIndirectlyPowered()) - { - doWork = true; - place_delay = 0; - } - } + @Override + protected boolean use(EntityPlayer player, int hitSide, Vector3 hit) + { + interactCurrentItem(this, 0, player); + return true; + } - public void doWork() - { - //Tries to place the item stack into the world - if (InventoryUtility.placeItemBlock(world(), x() + this.getDirection().offsetX, y() + this.getDirection().offsetY, z() + this.getDirection().offsetZ, this.getStackInSlot(0))) - { - decrStackSize(0, 1); - markUpdate(); - doWork = false; - } - } + protected boolean configure(EntityPlayer player, int side, Vector3 hit) + { + if (player.isSneaking()) + { + this.autoPullItems = !this.autoPullItems; + player.sendChatToPlayer(ChatMessageComponent.createFromText("AutoExtract: " + this.autoPullItems)); + return true; + } + return super.configure(player, side, hit); + } - @Override - protected boolean use(EntityPlayer player, int hitSide, Vector3 hit) - { - interactCurrentItem(this, 0, player); - return true; - } + @Override + public Packet getDescriptionPacket() + { + NBTTagCompound nbt = new NBTTagCompound(); + writeToNBT(nbt); + return ResonantInduction.PACKET_TILE.getPacket(this, nbt); + } - protected boolean configure(EntityPlayer player, int side, Vector3 hit) - { - if (player.isSneaking()) - { - this.autoPullItems = !this.autoPullItems; - player.sendChatToPlayer(ChatMessageComponent.createFromText("AutoExtract: " + this.autoPullItems)); - return true; - } - return super.configure(player, side, hit); - } + @Override + public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra) + { + try + { + readFromNBT(PacketHandler.readNBTTagCompound(data)); + } + catch (Exception e) + { + e.printStackTrace(); + } + } - @Override - public Packet getDescriptionPacket() - { - NBTTagCompound nbt = new NBTTagCompound(); - writeToNBT(nbt); - return ResonantInduction.PACKET_TILE.getPacket(this, nbt); - } + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + this.autoPullItems = nbt.getBoolean("autoPull"); + } - @Override - public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra) - { - try - { - readFromNBT(PacketHandler.readNBTTagCompound(data)); - } - catch (Exception e) - { - e.printStackTrace(); - } - } + /** + * Writes a tile entity to NBT. + */ + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + nbt.setBoolean("autoPull", this.autoPullItems); + } - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - this.autoPullItems = nbt.getBoolean("autoPull"); - } + @Override + public void setDirection(ForgeDirection direction) + { + super.setDirection(direction); + this.updateDirection(); + } - /** Writes a tile entity to NBT. */ - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - nbt.setBoolean("autoPull", this.autoPullItems); - } + @SuppressWarnings("incomplete-switch") + public void updateDirection() + { + switch (this.getDirection()) + { + case EAST: + case WEST: + this.renderItemSideA = ForgeDirection.NORTH; + this.renderItemSideB = ForgeDirection.SOUTH; + break; + case NORTH: + case SOUTH: + this.renderItemSideA = ForgeDirection.EAST; + this.renderItemSideB = ForgeDirection.WEST; + break; - @Override - public void setDirection(ForgeDirection direction) - { - super.setDirection(direction); - this.updateDirection(); - } + } + } - @SuppressWarnings("incomplete-switch") - public void updateDirection() - { - switch (this.getDirection()) - { - case EAST: - case WEST: - this.renderItemSide_a = ForgeDirection.NORTH; - this.renderItemSide_b = ForgeDirection.SOUTH; - break; - case NORTH: - case SOUTH: - this.renderItemSide_a = ForgeDirection.EAST; - this.renderItemSide_b = ForgeDirection.WEST; - break; + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon(int side, int meta) + { + if (side == meta) + { + return iconFront; + } + else if (ForgeDirection.getOrientation(meta).getOpposite().ordinal() == side) + { + return iconBack; + } + return super.getIcon(side, meta); + } - } - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister iconRegister) + { + super.registerIcons(iconRegister); + iconFront = iconRegister.registerIcon(getTextureName() + "_front"); + iconBack = iconRegister.registerIcon(getTextureName() + "_back"); + } - @Override - @SideOnly(Side.CLIENT) - public Icon getIcon(int side, int meta) - { - if (side == meta) - { - return iconFront; - } - else if (ForgeDirection.getOrientation(meta).getOpposite().ordinal() == side) - { - return iconBack; - } - return super.getIcon(side, meta); - } + @Override + @SideOnly(Side.CLIENT) + protected TileRender newRenderer() + { + return new TileRender() + { + @Override + public boolean renderDynamic(Vector3 position, boolean isItem, float frame) + { + if (!isItem) + { + if (TilePlacer.this.worldObj != null && (TilePlacer.this.renderItemSideA == null || TilePlacer.this.renderItemSideB == null)) + { + TilePlacer.this.updateDirection(); + } + GL11.glPushMatrix(); + RenderItemOverlayUtility.renderItemOnSides(TilePlacer.this, getStackInSlot(0), position.x, position.y, position.z, LanguageUtility.getLocal("tooltip.noOutput"), TilePlacer.this.renderItemSideA, TilePlacer.this.renderItemSideB); + GL11.glPopMatrix(); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) - { - super.registerIcons(iconRegister); - iconFront = iconRegister.registerIcon(getTextureName() + "_front"); - iconBack = iconRegister.registerIcon(getTextureName() + "_back"); - } - - @Override - @SideOnly(Side.CLIENT) - protected TileRender newRenderer() - { - return new TileRender() - { - @Override - public boolean renderDynamic(Vector3 position, boolean isItem, float frame) - { - if (!isItem) - { - if (TilePlacer.this.worldObj != null && (TilePlacer.this.renderItemSide_a == null || TilePlacer.this.renderItemSide_b == null)) - { - TilePlacer.this.updateDirection(); - } - GL11.glPushMatrix(); - RenderItemOverlayUtility.renderItemOnSides(TilePlacer.this, getStackInSlot(0), position.x, position.y, position.z, LanguageUtility.getLocal("tooltip.noOutput"), TilePlacer.this.renderItemSide_a, TilePlacer.this.renderItemSide_b); - GL11.glPopMatrix(); - } - - return false; - } - }; - } + return false; + } + }; + } } diff --git a/src/main/resources/assets/resonantinduction/textures/blocks/placer.png b/src/main/resources/assets/resonantinduction/textures/blocks/placer.png index a3a5a08557cdc2f77eb77d2c270853d5115d0a94..d7859930116148216963ded32b8ebc460e318b5a 100644 GIT binary patch literal 897 zcmV-{1AhF8P)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00QYrL_t(o!^KxIZ__{&{+wE^ zWH-J@s0wuli-EC$i679BzmT;ouv9Q~iCWA#f2QBLH% zsRsa26rm~*bDasKp-;A2Ef7M~6UXsfc{nT?(e+FwD5bz~sO;H5mjKw%5kf%w{rPw_ z0wDxZ6e+N};mKqIN~v-V0JPs<$ea~`84b@L6Wk(-ZA?}9Xe?UHHR@-1M5Y1Lcxk)x z_mbXy07!XtdI~RRVo~NxHV(542XTypf3Q;mpdZ1R7D>C^E=9ySFR?&IBOJsr7-Q%W zf*=U6e|fo(1uFwdk^lhGs;$YL+du?CfF2<@%rd-i9F<2^Th_28#;?IZjZ*+`!?2JG zI6ejd_`Y9ahB1c2EW@7T;6s)b@@ZvdrMeF2(Rtdtm+z^sF_N0j^&2lCm`NW6b zZd+%q1b}m{qLa=6C@MXDUeEU7uy9;^VTfKBs&x`-a&&|=P1P2cO0np?U*24 z+cA`j|DQazbWtXsl4w=(4Fky+d7Jw;W+yp7ATWUK0?<(gNdS}vt^{x$mx X8epZP<3p}r00000NkvXXu0mjf2HJ^T literal 550 zcmV+>0@?kEP)#nY@ zno+&Kzr$j&NSMuL7>!043^8rbc2D0R$fwOUxMR+vmCsCZE>ml26XkV>WC za=8!+h0tg;Bs?CEEQR6}3K0aCKtVE!OFOj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