diff options
| author | Lance5057 <Lance5057@gmail.com> | 2015-02-06 06:47:11 -0600 |
|---|---|---|
| committer | Lance5057 <Lance5057@gmail.com> | 2015-02-06 06:47:11 -0600 |
| commit | a7383ab4306123b4f3f6959cf2e71810e390a090 (patch) | |
| tree | 113430d523db108fbfa66568b76dde9ae7772f5b /src/main/java | |
| parent | 59cab61086e405e68f3449e35c22126bb26a3228 (diff) | |
Rotatable Crest Mount
Diffstat (limited to 'src/main/java')
4 files changed, 56 insertions, 26 deletions
diff --git a/src/main/java/gmail/Lance5057/blocks/CrestMount.java b/src/main/java/gmail/Lance5057/blocks/CrestMount.java index a318c77..66f0762 100644 --- a/src/main/java/gmail/Lance5057/blocks/CrestMount.java +++ b/src/main/java/gmail/Lance5057/blocks/CrestMount.java @@ -1,9 +1,17 @@ package gmail.Lance5057.blocks; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.WEST; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class CrestMount extends BlockContainer { @@ -40,4 +48,31 @@ public class CrestMount extends BlockContainer { public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { return new TileEntity_CrestMount(); } -} + + @Override + public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) + { + int j1 = p_149660_9_; + + if ((p_149660_9_ == 0 || p_149660_5_ == 2) && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ + 1, NORTH)) + { + j1 = 1; + } + + if ((j1 == 0 || p_149660_5_ == 3) && p_149660_1_.isSideSolid(p_149660_2_, p_149660_3_, p_149660_4_ - 1, SOUTH)) + { + j1 = 2; + } + + if ((j1 == 0 || p_149660_5_ == 4) && p_149660_1_.isSideSolid(p_149660_2_ + 1, p_149660_3_, p_149660_4_, WEST)) + { + j1 = 3; + } + + if ((j1 == 0 || p_149660_5_ == 5) && p_149660_1_.isSideSolid(p_149660_2_ - 1, p_149660_3_, p_149660_4_, EAST)) + { + j1 = 4; + } + + return j1; + }} diff --git a/src/main/java/gmail/Lance5057/blocks/ModelCrestMount.java b/src/main/java/gmail/Lance5057/blocks/ModelCrestMount.java index 5a5759d..4b3cbd2 100644 --- a/src/main/java/gmail/Lance5057/blocks/ModelCrestMount.java +++ b/src/main/java/gmail/Lance5057/blocks/ModelCrestMount.java @@ -4,11 +4,6 @@ // Keep in mind that you still need to fill in some blanks // - ZeuX - - - - - package gmail.Lance5057.blocks; import net.minecraft.client.model.ModelBase; @@ -35,24 +30,28 @@ public class ModelCrestMount extends ModelBase ShieldMount.setTextureSize(32, 32); ShieldMount.mirror = true; setRotation(ShieldMount, 0F, 0F, 0F); + Base = new ModelRenderer(this, 0, 6); Base.addBox(0F, 0F, 0F, 4, 4, 4); Base.setRotationPoint(-2F, 20F, -2F); Base.setTextureSize(32, 32); Base.mirror = true; setRotation(Base, 0F, 0F, 0F); + SwordMount1 = new ModelRenderer(this, 0, 0); SwordMount1.addBox(-5F, 0F, -2F, 10, 2, 4); SwordMount1.setRotationPoint(0F, 22F, 0F); SwordMount1.setTextureSize(32, 32); SwordMount1.mirror = true; setRotation(SwordMount1, 0F, 0.7853982F, 0F); + SwordMount2 = new ModelRenderer(this, 0, 0); SwordMount2.addBox(-5F, 0F, -2F, 10, 2, 4); SwordMount2.setRotationPoint(0F, 22F, 0F); SwordMount2.setTextureSize(32, 32); SwordMount2.mirror = true; setRotation(SwordMount2, 0F, -0.7853982F, 0F); + SwordMount3 = new ModelRenderer(this, 0, 0); SwordMount3.addBox(-5F, 0F, -2F, 10, 2, 4); SwordMount3.setRotationPoint(0F, 21.9F, 0F); diff --git a/src/main/java/gmail/Lance5057/blocks/Renderer_CrestMount.java b/src/main/java/gmail/Lance5057/blocks/Renderer_CrestMount.java index f7a542f..57921f8 100644 --- a/src/main/java/gmail/Lance5057/blocks/Renderer_CrestMount.java +++ b/src/main/java/gmail/Lance5057/blocks/Renderer_CrestMount.java @@ -21,30 +21,29 @@ public class Renderer_CrestMount extends TileEntitySpecialRenderer { this.model = new ModelCrestMount(); } - private void adjustRotatePivotViaMeta(World world, int x, int y, int z) { - int meta = world.getBlockMetadata(x, y, z); - GL11.glPushMatrix(); - GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F); - GL11.glPopMatrix(); - } - @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { - //The PushMatrix tells the renderer to "start" doing something. GL11.glPushMatrix(); - //This is setting the initial location. + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - //This is the texture of your block. It's pathed to be the same place as your other blocks here. - //Outdated bindTextureByName("/mods/roads/textures/blocks/TrafficLightPoleRed.png"); - //Use in 1.6.2 this + ResourceLocation textures = (new ResourceLocation("tinkersdefense:textures/blocks/CrestMount.png")); - //the ':' is very important - //binding the textures + Minecraft.getMinecraft().renderEngine.bindTexture(textures); - //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again! GL11.glPushMatrix(); - adjustRotatePivotViaMeta(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);//rotation 1 + + int meta = te.getBlockMetadata(); + float rotation = 0; + switch(meta) + { + case 1: rotation = 0; break; + case 2: rotation = 180; break; + case 3: rotation = 90; break; + case 4: rotation = -90; break; + } + GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(90F, 0.5F, 0.0F, 0.0F); GL11.glTranslatef(0, -1, -1); diff --git a/src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java b/src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java index 2ec7be6..929b307 100644 --- a/src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java +++ b/src/main/java/gmail/Lance5057/com/mod_TinkersDefense.java @@ -1,9 +1,5 @@ package gmail.Lance5057.com; - - - - import static net.minecraft.util.EnumChatFormatting.DARK_RED; import static net.minecraft.util.EnumChatFormatting.GOLD; import static net.minecraft.util.EnumChatFormatting.LIGHT_PURPLE; @@ -43,6 +39,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraftforge.common.config.*; @Mod(modid="tinkersdefense", version="1.0") public class mod_TinkersDefense |
