From 1fd02a68b56209057fa9174455b86e5791ba332a Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Fri, 2 Aug 2013 23:17:01 -0400 Subject: [PATCH 1/2] Come on, rotate! --- .../contractor/BlockEMContractor.java | 18 +++++++++++++++ .../contractor/TileEntityEMContractor.java | 3 ++- .../render/RenderEMContractor.java | 22 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/resonantinduction/contractor/BlockEMContractor.java b/src/resonantinduction/contractor/BlockEMContractor.java index 99db93f4e..f216588f3 100644 --- a/src/resonantinduction/contractor/BlockEMContractor.java +++ b/src/resonantinduction/contractor/BlockEMContractor.java @@ -2,8 +2,10 @@ package resonantinduction.contractor; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; import resonantinduction.ResonantInduction; import resonantinduction.base.BlockBase; import resonantinduction.render.BlockRenderingHandler; @@ -24,6 +26,22 @@ public class BlockEMContractor extends BlockBase implements ITileEntityProvider { return BlockRenderingHandler.INSTANCE.getRenderId(); } + + @Override + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) + { + if(par1World.isRemote) + { + //debug + TileEntityEMContractor contractor = (TileEntityEMContractor)par1World.getBlockTileEntity(par2, par3, par4); + int toSet = contractor.facing.ordinal() < 5 ? contractor.facing.ordinal()+1 : 0; + contractor.facing = ForgeDirection.getOrientation(toSet); + System.out.println(contractor.facing.ordinal()); + return true; + } + + return true; + } @Override public TileEntity createNewTileEntity(World world) diff --git a/src/resonantinduction/contractor/TileEntityEMContractor.java b/src/resonantinduction/contractor/TileEntityEMContractor.java index d6e610890..5ac6cfab0 100644 --- a/src/resonantinduction/contractor/TileEntityEMContractor.java +++ b/src/resonantinduction/contractor/TileEntityEMContractor.java @@ -1,8 +1,9 @@ package resonantinduction.contractor; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.ForgeDirection; public class TileEntityEMContractor extends TileEntity { - + public ForgeDirection facing = ForgeDirection.UP; } diff --git a/src/resonantinduction/render/RenderEMContractor.java b/src/resonantinduction/render/RenderEMContractor.java index 3b393958e..353805ef2 100644 --- a/src/resonantinduction/render/RenderEMContractor.java +++ b/src/resonantinduction/render/RenderEMContractor.java @@ -7,6 +7,7 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import resonantinduction.ResonantInduction; +import resonantinduction.contractor.TileEntityEMContractor; import resonantinduction.model.ModelEMContractor; public class RenderEMContractor extends TileEntitySpecialRenderer @@ -23,6 +24,27 @@ public class RenderEMContractor extends TileEntitySpecialRenderer this.func_110628_a(TEXTURE); MODEL.render(0.0625f); + + switch(((TileEntityEMContractor)t).facing) + { + case UP: + break; + case DOWN: + GL11.glRotatef(180, 0, 0, 1); + break; + case NORTH: + GL11.glRotatef(-90, 0, 0, 1); + break; + case SOUTH: + GL11.glRotatef(90, 0, 0, 1); + break; + case WEST: + GL11.glRotatef(-90, 1, 0, 0); + break; + case EAST: + GL11.glRotatef(90, 1, 0, 0); + break; + } GL11.glPopMatrix(); } From de2ac756c4b897406bd684005ebe9ac65e64deea Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Fri, 2 Aug 2013 23:30:08 -0400 Subject: [PATCH 2/2] Properly rotating! :) --- src/resonantinduction/render/RenderEMContractor.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/resonantinduction/render/RenderEMContractor.java b/src/resonantinduction/render/RenderEMContractor.java index 353805ef2..5855fbdeb 100644 --- a/src/resonantinduction/render/RenderEMContractor.java +++ b/src/resonantinduction/render/RenderEMContractor.java @@ -22,29 +22,34 @@ public class RenderEMContractor extends TileEntitySpecialRenderer GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - this.func_110628_a(TEXTURE); - MODEL.render(0.0625f); - switch(((TileEntityEMContractor)t).facing) { case UP: break; case DOWN: GL11.glRotatef(180, 0, 0, 1); + GL11.glTranslatef(0, -2, 0); break; case NORTH: + GL11.glTranslatef(-1, 1, 0); GL11.glRotatef(-90, 0, 0, 1); break; case SOUTH: + GL11.glTranslatef(1, 1, 0); GL11.glRotatef(90, 0, 0, 1); break; case WEST: + GL11.glTranslatef(0, 1, 1); GL11.glRotatef(-90, 1, 0, 0); break; case EAST: + GL11.glTranslatef(0, 1, -1); GL11.glRotatef(90, 1, 0, 0); break; } + + this.func_110628_a(TEXTURE); + MODEL.render(0.0625f); GL11.glPopMatrix(); }