diff options
Diffstat (limited to 'src/main/java/common/blocks/Block_ItemProxySource.java')
-rw-r--r-- | src/main/java/common/blocks/Block_ItemProxySource.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/main/java/common/blocks/Block_ItemProxySource.java b/src/main/java/common/blocks/Block_ItemProxySource.java new file mode 100644 index 0000000000..0158ae57e9 --- /dev/null +++ b/src/main/java/common/blocks/Block_ItemProxySource.java @@ -0,0 +1,69 @@ +package common.blocks; + +import common.tileentities.TE_ItemProxySource; +import cpw.mods.fml.common.registry.GameRegistry; +import itemBlocks.IB_ItemProxySource; +import items.Item_Configurator; +import kekztech.GuiHandler; +import kekztech.KekzCore; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class Block_ItemProxySource extends BlockContainer { + + private static Block_ItemProxySource instance = new Block_ItemProxySource(); + + private Block_ItemProxySource() { + super(Material.glass); + } + + public static Block_ItemProxySource getInstance() { + return instance; + } + + public void registerBlock() { + final String blockName = "kekztech_itemproxysource_block"; + super.setBlockName(blockName); + super.setCreativeTab(CreativeTabs.tabMisc); + super.setBlockTextureName(KekzCore.MODID + ":" + "ItemProxySource"); + super.setHardness(3.0f); + super.setResistance(2.0f); + GameRegistry.registerBlock(getInstance(), IB_ItemProxySource.class, blockName); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz) { + if(world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if(te != null && te instanceof TE_ItemProxySource) { + final TE_ItemProxySource source = (TE_ItemProxySource) te; + if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() instanceof Item_Configurator) { + + final NBTTagCompound configNBT = new NBTTagCompound(); + configNBT.setString("config", source.getChannel().toString()); + final ItemStack held = player.inventory.getCurrentItem(); + held.setTagCompound(configNBT); + + } else { + player.openGui(KekzCore.instance, GuiHandler.ITEM_PROXY_SOURCE, world, x, y, z); + } + return true; + } + return false; + } + + @Override + public TileEntity createNewTileEntity(World world, int p_149915_2_) { + return new TE_ItemProxySource(); + } + +} |