diff options
author | â€huajijam <strhuaji@gmail.com> | 2019-03-18 20:52:30 +0800 |
---|---|---|
committer | â€huajijam <strhuaji@gmail.com> | 2019-03-18 20:52:30 +0800 |
commit | 8b090e1fd20eb4c301996b5e1dfeb78353e595e4 (patch) | |
tree | 52152dd767d195c76baa8fd8bacb14b105aaa146 /src/Java/gtPlusPlus/core/block | |
parent | 40d7e5da9f5b84213e2c3e4596fdc69b94bd523e (diff) | |
download | GT5-Unofficial-8b090e1fd20eb4c301996b5e1dfeb78353e595e4.tar.gz GT5-Unofficial-8b090e1fd20eb4c301996b5e1dfeb78353e595e4.tar.bz2 GT5-Unofficial-8b090e1fd20eb4c301996b5e1dfeb78353e595e4.zip |
fix a bug
Diffstat (limited to 'src/Java/gtPlusPlus/core/block')
5 files changed, 228 insertions, 55 deletions
diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index f95f8814a9..2b04356f52 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -1,23 +1,32 @@ package gtPlusPlus.core.block; -import cpw.mods.fml.common.registry.GameRegistry; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockJukebox; -import net.minecraft.block.material.Material; - import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; -import gtPlusPlus.core.block.base.BlockBaseOre; -import gtPlusPlus.core.block.general.*; +import gtPlusPlus.core.block.general.BlockCompressedObsidian; +import gtPlusPlus.core.block.general.BlockNet; +import gtPlusPlus.core.block.general.BlockTankXpConverter; +import gtPlusPlus.core.block.general.FirePit; +import gtPlusPlus.core.block.general.FluidTankInfinite; +import gtPlusPlus.core.block.general.HellFire; +import gtPlusPlus.core.block.general.LightGlass; +import gtPlusPlus.core.block.general.MiningExplosives; +import gtPlusPlus.core.block.general.PlayerDoors; import gtPlusPlus.core.block.general.antigrief.BlockWitherProof; -import gtPlusPlus.core.block.machine.*; +import gtPlusPlus.core.block.machine.CircuitProgrammer; +import gtPlusPlus.core.block.machine.DecayablesChest; +import gtPlusPlus.core.block.machine.FishTrap; +import gtPlusPlus.core.block.machine.HeliumGenerator; +import gtPlusPlus.core.block.machine.Machine_ModularityTable; +import gtPlusPlus.core.block.machine.Machine_PooCollector; +import gtPlusPlus.core.block.machine.Machine_ProjectTable; +import gtPlusPlus.core.block.machine.Machine_SuperJukebox; +import gtPlusPlus.core.block.machine.Machine_TradeTable; +import gtPlusPlus.core.block.machine.Machine_Workbench; +import gtPlusPlus.core.block.machine.Machine_WorkbenchAdvanced; import gtPlusPlus.core.block.machine.bedrock.Mining_Head_Fake; import gtPlusPlus.core.block.machine.bedrock.Mining_Pipe_Fake; import gtPlusPlus.core.fluids.FluidRegistryHandler; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.plugin.villagers.block.BlockGenericSpawner; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraftforge.fluids.Fluid; public final class ModBlocks { @@ -78,6 +87,8 @@ public final class ModBlocks { public static Block blockCustomMobSpawner; public static Block blockCustomSuperLight; public static Block blockCustomJukebox; + + public static Block blockPooCollector; public static void init() { Logger.INFO("Initializing Blocks."); @@ -127,6 +138,8 @@ public final class ModBlocks { //blockCustomSuperLight = new BlockSuperLight(); blockCustomJukebox = new Machine_SuperJukebox(); + + blockPooCollector = new Machine_PooCollector(); } diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java index 4d7478dbdd..e1bc3462be 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -113,7 +113,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { hiddenTextureArray = new IIconContainer[6]; } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + catch (IllegalArgumentException | IllegalAccessException e) { hiddenTextureArray = new IIconContainer[6]; } } @@ -216,7 +216,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { hiddenTextureArray = new IIconContainer[6]; } } - catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { + catch (IllegalArgumentException | IllegalAccessException e) { hiddenTextureArray = new IIconContainer[6]; } } diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_PooCollector.java b/src/Java/gtPlusPlus/core/block/machine/Machine_PooCollector.java new file mode 100644 index 0000000000..23fdfe9733 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_PooCollector.java @@ -0,0 +1,180 @@ +package gtPlusPlus.core.block.machine; + +import java.util.List; +import java.util.Random; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.machines.TileEntityAdvPooCollector; +import gtPlusPlus.core.tileentities.machines.TileEntityBaseFluidCollector; +import gtPlusPlus.core.tileentities.machines.TileEntityPooCollector; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class Machine_PooCollector extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureTop2; + @SideOnly(Side.CLIENT) + private IIcon textureSide; + @SideOnly(Side.CLIENT) + private IIcon textureSide2; + + public Machine_PooCollector() { + super(Material.iron); + this.setBlockName("blockPooCollector"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockMeta.class,"blockPooCollector"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int aSide, final int aMeta) { + if (aMeta <= 7) { + blockIcon = textureSide; + return aSide <= 1 ? this.textureTop : this.textureSide; + } + else { + blockIcon = textureSide2; + return aSide <= 1 ? this.textureTop2 : this.textureSide2; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_top"); + this.textureTop2 = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_adv_top"); + this.textureSide = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_sides"); + this.textureSide2 = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "sewer_adv_sides"); + } + + /** + * 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; + } else { + TileEntityBaseFluidCollector tank = (TileEntityBaseFluidCollector) world.getTileEntity(x, y, z); + if (tank != null) { + Item handItem; + try { + handItem = player.getHeldItem().getItem(); + } catch (Throwable t) { + handItem = null; + } + + //Fluid container code + /*if (handItem != null + && (handItem instanceof IFluidContainerItem || handItem instanceof ItemFluidContainer + || FluidContainerRegistry.isFilledContainer(player.getHeldItem()))) { + if (tank.tank.getFluid() == null) { + try { + if (!FluidContainerRegistry.isFilledContainer(player.getHeldItem())) { + ItemStack handItemStack = player.getHeldItem(); + IFluidContainerItem container = (IFluidContainerItem) handItem; + FluidStack containerFluid = container.getFluid(handItemStack); + container.drain(handItemStack, container.getFluid(handItemStack).amount, true); + tank.tank.setFluid(containerFluid); + } else { + ItemStack handItemStack = player.getHeldItem(); + FluidContainerRegistry.drainFluidContainer(handItemStack); + FluidStack containerFluid = FluidContainerRegistry.getFluidForFilledItem(handItemStack); + ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(handItemStack); + player.setItemInUse(emptyContainer, 0); + + tank.tank.setFluid(containerFluid); + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + + }*/ + + if (!tank.mInventory.isEmpty()) { + PlayerUtils.messagePlayer(player, "Inventory contains:"); + PlayerUtils.messagePlayer(player, ItemUtils.getArrayStackNames(tank.mInventory.getRealInventory())); + } + else { + PlayerUtils.messagePlayer(player, "No solids collected yet."); + } + if (tank.tank.getFluid() != null) { + PlayerUtils.messagePlayer(player, "Tank contains " + tank.tank.getFluidAmount() + "L of " + + tank.tank.getFluid().getLocalizedName()); + } + } + } + return true; + } + + @Override + public int getRenderBlockPass() { + return 0; + } + + @Override + public boolean isOpaqueCube() { + return super.isOpaqueCube(); + } + + @Override + public TileEntity createNewTileEntity(final World world, final int aMeta) { + return aMeta <= 7 ? new TileEntityPooCollector() : new TileEntityAdvPooCollector(); + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public int getBlockColor() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public int damageDropped(final int damage) { + return damage; + } + + @Override + public Item getItemDropped(final int meta, final Random rand, final int fortune) { + return Item.getItemFromBlock(this); + } + + @Override + public int getRenderColor(int aMeta) { + return super.getRenderColor(aMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { + aList.add(new ItemStack(aItem, 1, 0)); + aList.add(new ItemStack(aItem, 1, 8)); + } + +} diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java index eecc379290..fdb6b1a0a8 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java @@ -133,34 +133,24 @@ public class Machine_ProjectTable extends BlockContainer implements ITileTooltip } @Optional.Method(modid = "EnderIO") - private static boolean checkEnderIOWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")){ + private static boolean checkEnderIOWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { Class<?> wrenchClass; - try { - wrenchClass = Class.forName("crazypants.enderio.api.tool.ITool"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; } @Optional.Method(modid = "Buildcraft") - private static boolean checkBuildcraftWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")){ + private static boolean checkBuildcraftWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { Class<?> wrenchClass; - try { - wrenchClass = Class.forName("buildcraft.api.tools.IToolWrench"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java index 675aeaaf2b..5c08612042 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java @@ -121,34 +121,24 @@ public class Machine_Workbench extends BlockContainer } @Optional.Method(modid = "EnderIO") - private static boolean checkEnderIOWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")){ + private static boolean checkEnderIOWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("crazypants.enderio.api.tool.ITool")) { Class<?> wrenchClass; - try { - wrenchClass = Class.forName("crazypants.enderio.api.tool.ITool"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("crazypants.enderio.api.tool.ITool"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; } @Optional.Method(modid = "Buildcraft") - private static boolean checkBuildcraftWrench(final ItemStack item){ - if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")){ + private static boolean checkBuildcraftWrench(final ItemStack item) { + if (ReflectionUtils.doesClassExist("buildcraft.api.tools.IToolWrench")) { Class<?> wrenchClass; - try { - wrenchClass = Class.forName("buildcraft.api.tools.IToolWrench"); - if (wrenchClass.isInstance(item.getItem())){ - return true; - } - } - catch (final ClassNotFoundException e1) { - return false; + wrenchClass = ReflectionUtils.getClass("buildcraft.api.tools.IToolWrench"); + if (wrenchClass.isInstance(item.getItem())) { + return true; } } return false; |