From 499aabe952987c373f3e01ff1021d955005c6f4b Mon Sep 17 00:00:00 2001 From: Arthur Uzulin Date: Sun, 18 Aug 2013 19:58:36 -0700 Subject: [PATCH] Added frypan rotation --- tconstruct/blocks/EquipBlock.java | 38 ++++++++++++++++++----- tconstruct/client/block/FrypanRender.java | 24 ++++++++++++-- tconstruct/items/tools/FryingPan.java | 1 + 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/tconstruct/blocks/EquipBlock.java b/tconstruct/blocks/EquipBlock.java index 1955226b..4aaf4af7 100644 --- a/tconstruct/blocks/EquipBlock.java +++ b/tconstruct/blocks/EquipBlock.java @@ -1,6 +1,8 @@ package tconstruct.blocks; -import java.util.Random; +import java.util.*; + +import cpw.mods.fml.relauncher.*; import tconstruct.TConstruct; import tconstruct.blocks.logic.FrypanLogic; @@ -10,13 +12,12 @@ import tconstruct.library.blocks.InventoryBlock; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.*; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.*; +import net.minecraft.world.*; public class EquipBlock extends InventoryBlock { @@ -88,7 +89,30 @@ public class EquipBlock extends InventoryBlock world.spawnParticle("flame", f, f1, f2 + f4, 0.0D, 0.0D, 0.0D); } } - + + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { + super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); + int i3 = MathHelper.floor_double((par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + int newMeta = 0; + + switch(i3){ + case 3: + newMeta = 0; + break; + case 0: + newMeta = 3; + break; + case 1: + newMeta = 1; + break; + case 2: + newMeta = 2; + break; + } + par1World.setBlockMetadataWithNotify(par2, par3, par4, newMeta, 2); + } + public int getLightValue (IBlockAccess world, int x, int y, int z) { return !isActive(world, x, y, z) ? 0 : 9; diff --git a/tconstruct/client/block/FrypanRender.java b/tconstruct/client/block/FrypanRender.java index b5dd49bb..ffafa11b 100644 --- a/tconstruct/client/block/FrypanRender.java +++ b/tconstruct/client/block/FrypanRender.java @@ -29,11 +29,31 @@ public class FrypanRender implements ISimpleBlockRenderingHandler renderer.renderStandardBlock(block, x, y, z); renderer.setRenderBounds(0.125F, 0.125F, 0.0F, 0.875F, 0.25F, 0.125F); renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBounds(1F, 0.0F, 0.4375F, 2F, 0.125F, 0.5625F); - renderer.renderStandardBlock(block, x, y, z); +// renderer.setRenderBounds(1F, 0.0F, 0.4375F, 2F, 0.125F, 0.5625F); +// renderer.renderStandardBlock(block, x, y, z); + renderHandle(world, x, y, z, block, renderer); return true; } + public void renderHandle(IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer){ + switch(world.getBlockMetadata(x, y, z)){ + case 0: + renderer.setRenderBounds(1F, 0.0F, 0.4375F, 2F, 0.125F, 0.5625F); + break; + case 1: + renderer.setRenderBounds(-1F, 0.0F, 0.4375F, 0F, 0.125F, 0.5625F); + break; + case 2: + renderer.setRenderBounds(0.4375F, 0.0F, -1F, 0.5625F, 0.125F, 0F); + break; + case 3: + renderer.setRenderBounds(0.4375F, 0.0F, 1F, 0.5625F, 0.125F, 2F); + break; + } + + renderer.renderStandardBlock(block, x, y, z); + } + @Override public boolean shouldRender3DInInventory () { diff --git a/tconstruct/items/tools/FryingPan.java b/tconstruct/items/tools/FryingPan.java index d17f5f1c..3548d6b5 100644 --- a/tconstruct/items/tools/FryingPan.java +++ b/tconstruct/items/tools/FryingPan.java @@ -128,6 +128,7 @@ public class FryingPan extends Weapon else { world.setBlock(x, y, z, TContent.heldItemBlock.blockID, 0, 3); + TContent.heldItemBlock.onBlockPlacedBy(world, x, y, z, player, stack); world.playSoundEffect(x, y, z, "tinker:frypan_hit", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 0.65F); EquipLogic logic = (EquipLogic) world.getBlockTileEntity(x, y, z);