From a641e66b8417ef72acca286a74b090ae759152d8 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 24 Dec 2018 14:55:21 +0000 Subject: + Added a storage container for radioactive materials. $ Fixed Decayable dusts not working as intended, Closes #393. $ Made recycling recipe generation less verbose & more readable. $ Fixed issue with the Advanced Mufflers onConfigLoad function. --- src/Java/gtPlusPlus/core/block/ModBlocks.java | 4 + .../core/block/machine/DecayablesChest.java | 151 +++++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 src/Java/gtPlusPlus/core/block/machine/DecayablesChest.java (limited to 'src/Java/gtPlusPlus/core/block') diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index 081ae3d347..eb40fd080e 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -28,6 +28,8 @@ public final class ModBlocks { public static Block blockFishTrap; public static Block blockWorkbench; public static Block blockWorkbenchAdvanced; + public static Block blockDecayablesChest; + //Blocks //public static Block blockBloodSteel; //public static Block blockStaballoy; @@ -112,6 +114,8 @@ public final class ModBlocks { blockCircuitProgrammer = new CircuitProgrammer(); + blockDecayablesChest = new DecayablesChest(); + blockPlayerDoorWooden = new PlayerDoors(Material.wood, "door_wood", true); blockPlayerDoorIron = new PlayerDoors(Material.iron, "door_iron", true); blockPlayerDoorCustom_Glass = new PlayerDoors(Material.glass, "door_glass", false); diff --git a/src/Java/gtPlusPlus/core/block/machine/DecayablesChest.java b/src/Java/gtPlusPlus/core/block/machine/DecayablesChest.java new file mode 100644 index 0000000000..5fb36e8189 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/DecayablesChest.java @@ -0,0 +1,151 @@ +package gtPlusPlus.core.block.machine; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.block.Block; +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.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import gtPlusPlus.GTplusplus; +import gtPlusPlus.api.interfaces.ITileTooltip; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.item.base.itemblock.ItemBlockBasicTile; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityDecayablesChest; +import gtPlusPlus.core.util.minecraft.InventoryUtils; + +public class DecayablesChest extends BlockContainer implements ITileTooltip +{ + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + /** + * Determines which tooltip is displayed within the itemblock. + */ + private final int mTooltipID = 5; + + @Override + public int getTooltipID() { + return this.mTooltipID; + } + + @SuppressWarnings("deprecation") + public DecayablesChest() + { + super(Material.iron); + this.setBlockName("blockDecayablesChest"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockBasicTile.class, "blockDecayablesChest"); + LanguageRegistry.addName(this, "Lead Lined Box"); + + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) + { + return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : this.textureFront); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) + { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_top"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_top"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_side"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "DecayablesChest_bottom"); + } + + /** + * Called upon block activation (right click on the block.) + */ + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz) + { + if (world.isRemote) { + return true; + } + + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileEntityDecayablesChest)){ + player.openGui(GTplusplus.instance, GuiHandler.GUI13, world, x, y, z); + return true; + } + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(final World world, final int p_149915_2_) { + return new TileEntityDecayablesChest(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int number) { + InventoryUtils.dropInventoryItems(world, x, y, z, block); + super.breakBlock(world, x, y, z, block, number); + } + + @Override + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityDecayablesChest) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); + } + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + /*@Override + public void breakBlock(World world, BlockPos pos, IBlockState blockstate) { + TileEntityFishTrap te = (TileEntityFishTrap) world.getTileEntity(pos); + InventoryHelper.dropInventoryItems(world, pos, te); + super.breakBlock(world, pos, blockstate); + } + + + @Override + public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { + if (stack.hasDisplayName()) { + ((TileEntityFishTrap) worldIn.getTileEntity(pos)).setCustomName(stack.getDisplayName()); + } + }*/ + +} \ No newline at end of file -- cgit