From f588cfc4af16a4027ea377b405561d3ada8bc262 Mon Sep 17 00:00:00 2001 From: makeo Date: Tue, 3 Nov 2015 23:53:09 +0100 Subject: [PATCH] Added ancient pedestal (will be removed in tc 5) --- .../makeo/gadomancy/client/ClientProxy.java | 2 + .../block/RenderBlockStoneMachine.java | 53 +++++++++++ .../common/blocks/BlockStoneMachine.java | 89 +++++++++++------- .../common/registration/RegisteredBlocks.java | 1 + .../assets/gadomancy/lang/en_US.lang | 1 + .../textures/blocks/ancient_pedestal_side.png | Bin 0 -> 585 bytes 6 files changed, 112 insertions(+), 34 deletions(-) create mode 100644 src/main/java/makeo/gadomancy/client/renderers/block/RenderBlockStoneMachine.java create mode 100644 src/main/resources/assets/gadomancy/textures/blocks/ancient_pedestal_side.png diff --git a/src/main/java/makeo/gadomancy/client/ClientProxy.java b/src/main/java/makeo/gadomancy/client/ClientProxy.java index 002bdb3..253e120 100644 --- a/src/main/java/makeo/gadomancy/client/ClientProxy.java +++ b/src/main/java/makeo/gadomancy/client/ClientProxy.java @@ -10,6 +10,7 @@ import makeo.gadomancy.client.events.RenderEventHandler; import makeo.gadomancy.client.events.ResourceReloadListener; import makeo.gadomancy.client.gui.InfusionClawGui; import makeo.gadomancy.client.renderers.block.BlockExtendedNodeJarRenderer; +import makeo.gadomancy.client.renderers.block.RenderBlockStoneMachine; import makeo.gadomancy.client.renderers.block.RenderBlockTransparent; import makeo.gadomancy.client.renderers.entity.RenderAdditionalGolemBase; import makeo.gadomancy.client.renderers.item.ItemExNodeRenderer; @@ -124,6 +125,7 @@ public class ClientProxy extends CommonProxy { //Blocks RegisteredBlocks.rendererTransparentBlock = registerBlockRenderer(new RenderBlockTransparent()); RegisteredBlocks.rendererExtendedNodeJarBlock = registerBlockRenderer(new BlockExtendedNodeJarRenderer()); + RegisteredBlocks.rendererBlockStoneMachine = registerBlockRenderer(new RenderBlockStoneMachine()); } @Override diff --git a/src/main/java/makeo/gadomancy/client/renderers/block/RenderBlockStoneMachine.java b/src/main/java/makeo/gadomancy/client/renderers/block/RenderBlockStoneMachine.java new file mode 100644 index 0000000..fd0ec65 --- /dev/null +++ b/src/main/java/makeo/gadomancy/client/renderers/block/RenderBlockStoneMachine.java @@ -0,0 +1,53 @@ +package makeo.gadomancy.client.renderers.block; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import makeo.gadomancy.common.blocks.BlockStoneMachine; +import makeo.gadomancy.common.registration.RegisteredBlocks; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.world.IBlockAccess; +import thaumcraft.client.renderers.block.BlockStoneDeviceRenderer; +import thaumcraft.common.blocks.BlockStoneDevice; + +/** + * This class is part of the Gadomancy Mod + * Gadomancy is Open Source and distributed under the + * GNU LESSER GENERAL PUBLIC LICENSE + * for more read the LICENSE file + *

+ * Created by makeo @ 03.11.2015 22:09 + */ +public class RenderBlockStoneMachine implements ISimpleBlockRenderingHandler { + private static final BlockStoneDeviceRenderer DEVICE_RENDERER = new BlockStoneDeviceRenderer(); + private static final BlockStoneDevice DEVICE_BLOCK = new BlockStoneDevice(); + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + if(metadata == 1) { + BlockStoneMachine blockStoneMachine = (BlockStoneMachine)block; + DEVICE_BLOCK.iconPedestal[0] = blockStoneMachine.pedestalSideIcon; + DEVICE_BLOCK.iconPedestal[1] = blockStoneMachine.pedestalTopIcon; + DEVICE_RENDERER.renderInventoryBlock(DEVICE_BLOCK, 1, modelId, renderer); + } + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + int metadata = world.getBlockMetadata(x, y, z); + if(metadata == 1) { + DEVICE_RENDERER.renderWorldBlock(world, x, y, z, block, modelId, renderer); + return true; + } + return false; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return RegisteredBlocks.rendererBlockStoneMachine; + } +} diff --git a/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java b/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java index 8cfa81c..bb49de6 100644 --- a/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java +++ b/src/main/java/makeo/gadomancy/common/blocks/BlockStoneMachine.java @@ -1,5 +1,6 @@ package makeo.gadomancy.common.blocks; +import makeo.gadomancy.common.Gadomancy; import makeo.gadomancy.common.blocks.tiles.TileManipulationFocus; import makeo.gadomancy.common.blocks.tiles.TileManipulatorPillar; import makeo.gadomancy.common.registration.RegisteredBlocks; @@ -19,6 +20,7 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import thaumcraft.common.config.ConfigBlocks; +import thaumcraft.common.tiles.TilePedestal; import java.util.List; import java.util.Random; @@ -43,19 +45,29 @@ public class BlockStoneMachine extends Block { private IIcon pillarIcon; private IIcon focusIcon; + public IIcon pedestalSideIcon; + public IIcon pedestalTopIcon; @Override public void registerBlockIcons(IIconRegister ir) { pillarIcon = ir.registerIcon("thaumcraft:es_1"); focusIcon = ir.registerIcon("thaumcraft:thaumiumblock"); + pedestalTopIcon = ir.registerIcon(Gadomancy.MODID + ":manipulator_bot"); + pedestalSideIcon = ir.registerIcon(Gadomancy.MODID + ":ancient_pedestal_side"); } @Override public IIcon getIcon(int side, int metadata) { - if(metadata == 11 || metadata == 15) { + if (metadata == 11 || metadata == 15) { return pillarIcon; - } else if(metadata == 0) { + } else if (metadata == 0) { return focusIcon; + } else if (metadata == 1) { + if (side > 1) { + return pedestalSideIcon; + } else { + return pedestalTopIcon; + } } return super.getIcon(side, metadata); @@ -63,18 +75,19 @@ public class BlockStoneMachine extends Block { @Override public boolean hasTileEntity(int metadata) { - return metadata == 15 || metadata == 0; + return metadata == 15 || metadata == 0 || metadata == 1; } @Override public void getSubBlocks(Item item, CreativeTabs tab, List list) { list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); } @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { int metadata = world.getBlockMetadata(x, y, z); - if(metadata == 11 || metadata == 15) { + if (metadata == 11 || metadata == 15) { return new ItemStack(getItemDropped(metadata, null, 0), 1, damageDropped(metadata)); } @@ -83,10 +96,12 @@ public class BlockStoneMachine extends Block { @Override public TileEntity createTileEntity(World world, int metadata) { - if(metadata == 15) { + if (metadata == 15) { return new TileManipulatorPillar(); - } else if(metadata == 0) { + } else if (metadata == 0) { return new TileManipulationFocus(); + } else if(metadata == 1) { + return new TilePedestal(); } return null; } @@ -98,7 +113,7 @@ public class BlockStoneMachine extends Block { @Override public Item getItemDropped(int metadata, Random random, int fortune) { - if(metadata == 11 || metadata == 15) { + if (metadata == 11 || metadata == 15) { return Item.getItemFromBlock(ConfigBlocks.blockCosmeticSolid); } @@ -107,7 +122,7 @@ public class BlockStoneMachine extends Block { @Override public boolean canReplace(World world, int x, int y, int z, int side, ItemStack stack) { - if(stack.getItemDamage() == 0 && (y < 1 || world.getBlock(x, y - 1, z) != RegisteredBlocks.blockNodeManipulator)) { + if (stack.getItemDamage() == 0 && (y < 1 || world.getBlock(x, y - 1, z) != RegisteredBlocks.blockNodeManipulator)) { return false; } return super.canReplace(world, x, y, z, side, stack); @@ -116,18 +131,18 @@ public class BlockStoneMachine extends Block { @Override public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { int metadata = world.getBlockMetadata(x, y, z); - if(metadata == 15) { - if(world.getBlock(x, y + 1, z) != this || world.getBlockMetadata(x, y + 1, z) != 11) { + if (metadata == 15) { + if (world.getBlock(x, y + 1, z) != this || world.getBlockMetadata(x, y + 1, z) != 11) { dropBlockAsItem(world, x, y, z, metadata, 0); world.setBlockToAir(x, y, z); } - } else if(metadata == 11) { - if(world.getBlock(x, y - 1, z) != this || world.getBlockMetadata(x, y - 1, z) != 15) { + } else if (metadata == 11) { + if (world.getBlock(x, y - 1, z) != this || world.getBlockMetadata(x, y - 1, z) != 15) { dropBlockAsItem(world, x, y, z, metadata, 0); world.setBlockToAir(x, y, z); } - } else if(metadata == 0) { - if(world.getBlock(x, y - 1, z) != RegisteredBlocks.blockNodeManipulator || world.getBlockMetadata(x, y - 1, z) != 5) { + } else if (metadata == 0) { + if (world.getBlock(x, y - 1, z) != RegisteredBlocks.blockNodeManipulator || world.getBlockMetadata(x, y - 1, z) != 5) { dropBlockAsItem(world, x, y, z, metadata, 0); world.setBlockToAir(x, y, z); } @@ -135,22 +150,31 @@ public class BlockStoneMachine extends Block { } @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { - if(world.getBlockMetadata(x, y, z) == 0 && world.getBlock(x, y - 1, z).equals(RegisteredBlocks.blockNodeManipulator) && world.getBlockMetadata(x, y - 1, z) == 5) { - world.getBlock(x, y - 1, z).onBlockActivated(world, x, y - 1, z, p_149727_5_, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_); + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + int metadata = world.getBlockMetadata(x, y, z); + + if(metadata == 0) { + if (world.getBlock(x, y - 1, z).equals(RegisteredBlocks.blockNodeManipulator) && world.getBlockMetadata(x, y - 1, z) == 5) { + return world.getBlock(x, y - 1, z).onBlockActivated(world, x, y - 1, z, player, side, hitX, hitY, hitZ); + } + } else if(metadata == 1) { + return ConfigBlocks.blockStoneDevice.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); } - return super.onBlockActivated(world, x, y, z, p_149727_5_, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_); + + return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ); } @Override public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { int metadata = world.getBlockMetadata(x, y, z); - if(metadata == 15) { + if (metadata == 15) { setBlockBounds(0, 0, 0, 1, 0.5f, 1); - } else if(metadata == 11) { + } else if (metadata == 11) { setBlockBounds(0.0F, -1.0F, 0.0F, 1.0F, -0.5F, 1.0F); - } else if(metadata == 0) { - setBlockBounds(3/16f, 0, 3/16f, 1-(3/16f), 6/16f, 1-(3/16f)); + } else if (metadata == 0) { + setBlockBounds(3 / 16f, 0, 3 / 16f, 1 - (3 / 16f), 6 / 16f, 1 - (3 / 16f)); + } else if(metadata == 1) { + setBlockBounds(0.25f, 0, 0.25f, 0.75f, 0.99f, 0.75f); } super.setBlockBoundsBasedOnState(world, x, y, z); } @@ -158,27 +182,24 @@ public class BlockStoneMachine extends Block { @Override public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List list, Entity entity) { int metadata = world.getBlockMetadata(x, y, z); - if(metadata == 11 || metadata == 15) { + if (metadata == 11 || metadata == 15 || metadata == 1) { setBlockBounds(0, 0, 0, 1, 1, 1); - } else if(metadata == 0) { + } else if (metadata == 0) { setBlockBoundsBasedOnState(world, x, y, z); } - super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, list, entity); } - public boolean isOpaqueCube() -/* 97: */ { -/* 98: 96 */ return false; -/* 99: */ } + public boolean isOpaqueCube() { + return false; + } - public boolean renderAsNormalBlock() -/* 102: */ { -/* 103:102 */ return false; -/* 104: */ } + public boolean renderAsNormalBlock() { + return false; + } @Override public int getRenderType() { - return -1; + return RegisteredBlocks.rendererBlockStoneMachine; } } diff --git a/src/main/java/makeo/gadomancy/common/registration/RegisteredBlocks.java b/src/main/java/makeo/gadomancy/common/registration/RegisteredBlocks.java index e570320..9f22f3f 100644 --- a/src/main/java/makeo/gadomancy/common/registration/RegisteredBlocks.java +++ b/src/main/java/makeo/gadomancy/common/registration/RegisteredBlocks.java @@ -46,6 +46,7 @@ public class RegisteredBlocks { public static int rendererTransparentBlock; public static int rendererExtendedNodeJarBlock; + public static int rendererBlockStoneMachine; public static BlockStickyJar blockStickyJar; public static BlockArcaneDropper blockArcaneDropper; diff --git a/src/main/resources/assets/gadomancy/lang/en_US.lang b/src/main/resources/assets/gadomancy/lang/en_US.lang index 5ce0bd4..0243078 100644 --- a/src/main/resources/assets/gadomancy/lang/en_US.lang +++ b/src/main/resources/assets/gadomancy/lang/en_US.lang @@ -110,6 +110,7 @@ tile.BlockNode.name=Aura Node tile.BlockExtendedNodeJar.name=Node in a Jar tile.BlockNodeManipulator.5.name=Node Manipulator tile.BlockStoneMachine.0.name=Randomization Focus +tile.BlockStoneMachine.1.name=Ancient Pedestal tile.BlockStoneMachine.11.name=Manipulation Pillar tile.BlockStoneMachine.15.name=Manipulation Pillar diff --git a/src/main/resources/assets/gadomancy/textures/blocks/ancient_pedestal_side.png b/src/main/resources/assets/gadomancy/textures/blocks/ancient_pedestal_side.png new file mode 100644 index 0000000000000000000000000000000000000000..526b7d0414498382cf5366905957511bc995e31e GIT binary patch literal 585 zcmV-P0=E5$P)CAHQ-p*BEB^lvKrCR% z4ydZqLen&p&WFc-EYcLDsLEMCU!8j`stUlz4{vlhF3Fw6c#nv(s#*ZXqa0NsbscSp ztXKDZ`tnTxG9IYgfXN%Cv**x9rjsd02hjB$F$DTPz<9*%ewC z%HdOI{|t)UQTPG%s=|0rx4wI<5K_0PP}dZGK+4l&fNVF|^7iaRj}B&7?`WEe&~;c9 zhSLevs^;_8P4^vx{~65+ym8Fu&&a*US>^lr1-7(1w>ujYWl4;NvMf1!eZsP;sN2Bd zbV47){(!yZ39iykfQE47~})mE)Y{hlQ5eeP}ggmb=+6${RUNiPs$SGQGs`s(6(g8 zkYeC!@p~sg-oJaL!(qwk=}W5R8dXJ9F}}c{7z0)SF^C9F2=pOwdw0j;<_3dU?z@_c zt84stfcF^@!HSYui?a@6EMf#}H%80VEmgI~WQHthB2zYr>l*JIxpx%B zaI=BS@XkN{6U06cV