diff options
author | Alkalus <draknyte1@hotmail.com> | 2017-11-27 13:10:57 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-27 13:10:57 +1000 |
commit | a42842e4e93525a64d0b2efc0d68115a59acb20c (patch) | |
tree | 55f4c3c6635c1d94ff22abf90b486638661b930f /src/Java/gtPlusPlus/core | |
parent | 5d4d3fb679c8af83ed5ee14430c6cde0b16cfcc6 (diff) | |
parent | 066bd6475ce142f405d521975b1d4105ccaddf0d (diff) | |
download | GT5-Unofficial-a42842e4e93525a64d0b2efc0d68115a59acb20c.tar.gz GT5-Unofficial-a42842e4e93525a64d0b2efc0d68115a59acb20c.tar.bz2 GT5-Unofficial-a42842e4e93525a64d0b2efc0d68115a59acb20c.zip |
Merge pull request #156 from draknyte1/Multiblock-Fix
Multiblock fix for #141, other misc. fixes & a few new additions.
Diffstat (limited to 'src/Java/gtPlusPlus/core')
48 files changed, 3156 insertions, 450 deletions
diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java index a469acfc49..81d3a84dc9 100644 --- a/src/Java/gtPlusPlus/core/block/ModBlocks.java +++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java @@ -3,8 +3,22 @@ package gtPlusPlus.core.block; import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.block.base.BlockBaseOre; -import gtPlusPlus.core.block.general.*; -import gtPlusPlus.core.block.machine.*; +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.antigrief.BlockWitherProof; +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_ProjectTable; +import gtPlusPlus.core.block.machine.Machine_TradeTable; +import gtPlusPlus.core.block.machine.Machine_Workbench; +import gtPlusPlus.core.block.machine.Machine_WorkbenchAdvanced; import gtPlusPlus.core.fluids.FluidRegistryHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; @@ -37,15 +51,20 @@ public final class ModBlocks { public static Block blockFirePit; public static Block blockOreFluorite; - + public static Block blockMiningExplosive; - + public static Block blockHellfire; public static Block blockInfiniteFLuidTank; public static Block blockProjectTable; public static Block blockTradeTable; public static Block blockModularTable; + public static Block blockWitherGuard; + public static Block blockXpConverter; + public static Block blockCompressedObsidian; + public static Block blockNet; + public static void init() { Utils.LOG_INFO("Initializing Blocks."); //blockGriefSaver = new TowerDevice().setBlockName("blockGriefSaver").setCreativeTab(AddToCreativeTab.tabBlock).setBlockTextureName("blockDefault"); @@ -74,6 +93,10 @@ public final class ModBlocks { blockProjectTable = new Machine_ProjectTable(); blockTradeTable = new Machine_TradeTable(); blockModularTable = new Machine_ModularityTable(); + blockWitherGuard = new BlockWitherProof(); + blockXpConverter = new BlockTankXpConverter(); + blockCompressedObsidian = new BlockCompressedObsidian(); + blockNet = new BlockNet(); } diff --git a/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java b/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java index 7a0b715138..d8e59f96c8 100644 --- a/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java +++ b/src/Java/gtPlusPlus/core/block/base/AdvancedBlock.java @@ -4,7 +4,9 @@ import gtPlusPlus.core.lib.CORE; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class AdvancedBlock extends Block { @@ -28,4 +30,9 @@ public class AdvancedBlock extends Block { return false; } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } diff --git a/src/Java/gtPlusPlus/core/block/base/BasicBlock.java b/src/Java/gtPlusPlus/core/block/base/BasicBlock.java index 9e3a5fc37f..f97763dd54 100644 --- a/src/Java/gtPlusPlus/core/block/base/BasicBlock.java +++ b/src/Java/gtPlusPlus/core/block/base/BasicBlock.java @@ -5,7 +5,9 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BasicBlock extends BlockContainer { @@ -62,4 +64,9 @@ public class BasicBlock extends BlockContainer { return null; } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java index 3ecb556e09..da308e270b 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java @@ -9,10 +9,12 @@ import gtPlusPlus.core.item.base.itemblock.ItemBlockNBT; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public abstract class BlockBaseNBT extends BlockContainer @@ -25,7 +27,7 @@ public abstract class BlockBaseNBT extends BlockContainer private IIcon textureFront; @SuppressWarnings("deprecation") - public BlockBaseNBT(Material material, String unlocalName, String displayName){ + public BlockBaseNBT(final Material material, final String unlocalName, final String displayName){ super(material); this.setBlockName(unlocalName); this.setCreativeTab(AddToCreativeTab.tabMachines); @@ -46,28 +48,33 @@ public abstract class BlockBaseNBT extends BlockContainer public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + public void breakBlock(final World world, final int x, final int y, final int z, final Block block, final int meta) { super.breakBlock(world, x, y, z, block, meta); } @Override - public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta) { + public void onBlockDestroyedByPlayer(final World world, final int x, final int y, final int z, final int meta) { super.onBlockDestroyedByPlayer(world, x, y, z, meta); } @Override - public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) { + public void onBlockDestroyedByExplosion(final World world, final int x, final int y, final int z, final Explosion explosion) { super.onBlockDestroyedByExplosion(world, x, y, z, explosion); } @Override - public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) { + public void onBlockHarvested(final World world, final int x, final int y, final int z, final int meta, final EntityPlayer player) { super.onBlockHarvested(world, x, y, z, meta, player); } @Override - public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) { + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion) { super.onBlockExploded(world, x, y, z, explosion); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java index c1e58e9393..285f394971 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -6,6 +6,7 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; @@ -71,6 +72,11 @@ public class BlockBaseOre extends BlockBaseModular{ return this.blockColour; } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + diff --git a/src/Java/gtPlusPlus/core/block/base/MetaBlock.java b/src/Java/gtPlusPlus/core/block/base/MetaBlock.java index 3e116eeb7f..880bb3a597 100644 --- a/src/Java/gtPlusPlus/core/block/base/MetaBlock.java +++ b/src/Java/gtPlusPlus/core/block/base/MetaBlock.java @@ -4,8 +4,10 @@ import java.util.List; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.world.IBlockAccess; public class MetaBlock extends MultiTextureBlock { @@ -25,4 +27,9 @@ public class MetaBlock extends MultiTextureBlock { } } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java b/src/Java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java new file mode 100644 index 0000000000..853abe3edf --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/BlockCompressedObsidian.java @@ -0,0 +1,93 @@ +package gtPlusPlus.core.block.general; + +import java.util.ArrayList; +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 net.minecraft.block.BlockObsidian; +import net.minecraft.block.material.MapColor; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class BlockCompressedObsidian extends BlockObsidian { + + @SideOnly(Side.CLIENT) + private final IIcon textureArray[] = new IIcon[6]; + + public BlockCompressedObsidian() { + this.setBlockName("blockCompressedObsidian"); + this.setHardness(50.0F); + this.setResistance(2000.0F); + this.setStepSound(soundTypePiston); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockCompressedObsidian"); + } + + @Override + public MapColor getMapColor(final int meta) { + if (meta != 5) { + return MapColor.obsidianColor; + } + else { + return MapColor.sandColor; + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iicon) { + this.textureArray[0] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian1"); + this.textureArray[1] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian2"); + this.textureArray[2] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian3"); + this.textureArray[3] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian4"); + this.textureArray[4] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian5"); + this.textureArray[5] = iicon.registerIcon(CORE.MODID + ":" + "compressed/" + "obsidian_invert"); + } + + /** + * Gets the block's texture. Args: side, meta + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(final int side, final int meta) { + return this.textureArray[meta]; + } + + @Override + public int damageDropped(final int damage) { + return damage; + } + + @Override + public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { + for (int i = 0; i < 6; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + public Item getItemDropped(final int meta, final Random rand, final int fortune) { + return Item.getItemFromBlock(this); + } + + @Override + public ArrayList<ItemStack> getDrops(final World world, final int x, final int y, final int z, final int metadata, + final int fortune) { + int m = metadata; + if (m == 5) { + m = 1; + } + return super.getDrops(world, x, y, z, m, fortune); + } + +} diff --git a/src/Java/gtPlusPlus/core/block/general/BlockNet.java b/src/Java/gtPlusPlus/core/block/general/BlockNet.java new file mode 100644 index 0000000000..26871662b2 --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/BlockNet.java @@ -0,0 +1,35 @@ +package gtPlusPlus.core.block.general; +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.ModItems; +import gtPlusPlus.core.lib.CORE; +import net.minecraft.block.BlockWeb; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; + +public class BlockNet extends BlockWeb{ + + public BlockNet(){ + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setLightOpacity(1); + this.setHardness(4.0F); + this.setBlockName("blockNet"); + GameRegistry.registerBlock(this, "blockNet"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon){ + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "net"); + } + + @Override + public Item getItemDropped(final int p_149650_1_, final Random p_149650_2_, final int p_149650_3_){ + return ModItems.itemRope; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java new file mode 100644 index 0000000000..ea55a9177d --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -0,0 +1,283 @@ +package gtPlusPlus.core.block.general; + +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +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 gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.tileentities.general.TileEntityXpConverter; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.array.Triplet; +import gtPlusPlus.core.util.enchanting.EnchantingUtils; +import gtPlusPlus.core.util.player.PlayerUtils; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; +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.IBlockAccess; +import net.minecraft.world.World; + +public class BlockTankXpConverter extends BlockContainer { + + @SideOnly(Side.CLIENT) + private IIcon textureTop; + @SideOnly(Side.CLIENT) + private IIcon textureBottom; + @SideOnly(Side.CLIENT) + private IIcon textureFront; + + private int mRainbowTick = 0; + private int mRainbowTickMax = 0; + private final Map<Integer, Triplet<Integer, Integer, Integer>> mRainbowMap = new HashMap<Integer, Triplet<Integer, Integer, Integer>>(); + + @SuppressWarnings("deprecation") + public BlockTankXpConverter() { + super(Material.iron); + this.setBlockName("blockTankXpConverter"); + this.setCreativeTab(AddToCreativeTab.tabMachines); + GameRegistry.registerBlock(this, ItemBlockEntityBase.class, "blockTankXpConverter"); + LanguageRegistry.addName(this, "Xp Converter"); + this.generateRainbowMap(); + if (!this.getTickRandomly()) { + this.setTickRandomly(true); + } + } + + /** + * 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 + : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister p_149651_1_) { + this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlGray"); + } + + /** + * 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 { + boolean mDidScrewDriver = false; + // Check For Screwdriver + try { + final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName()); + final Item mHandItem = mHandStack.getItem(); + if (((mHandItem instanceof GT_MetaGenerated_Tool_01) + && ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)))) { + final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tile != null) { + mDidScrewDriver = true; + tile.onScrewdriverRightClick((byte) side, player, x, y, z); + } + + } + } + catch (final Throwable t) { + mDidScrewDriver = false; + } + + if (!mDidScrewDriver) { + + try { + final TileEntityXpConverter tile = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tile != null) { + tile.onRightClick((byte) side, player, x, y, z); + } + } + catch (final Throwable t) { + } + + final TileEntityXpConverter tank = (TileEntityXpConverter) world.getTileEntity(x, y, z); + if (tank != null) { + if (tank.tankEssence.getFluid() != null) { + PlayerUtils.messagePlayer(player, "This tank contains " + tank.tankEssence.getFluidAmount() + + "L of " + tank.tankEssence.getFluid().getLocalizedName()); + } + if (tank.tankLiquidXp.getFluid() != null) { + PlayerUtils.messagePlayer(player, "This tank contains " + tank.tankLiquidXp.getFluidAmount() + + "L of " + tank.tankLiquidXp.getFluid().getLocalizedName()); + } + if ((tank.tankEssence.getFluid() != null) && (tank.tankLiquidXp.getFluid() != null)) { + PlayerUtils.messagePlayer(player, "This is worth " + + EnchantingUtils.getLevelForLiquid(tank.tankLiquidXp.getFluidAmount()) + " levels."); + } + } + } + } + return true; + } + + @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 TileEntityXpConverter(); + } + + @Override + public void onBlockAdded(final World world, final int x, final int y, final int z) { + super.onBlockAdded(world, x, y, z); + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, + final int z) { + return false; + } + + private final boolean generateRainbowMap() { + int id = 0; + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 255, 0)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(51, 255, 0)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(102, 255, 0)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(153, 255, 0)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(204, 255, 0)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 255, 0)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 204, 0)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 153, 0)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 102, 0)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 51, 0)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 0, 0)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 0, 51)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 0, 102)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 0, 153)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 0, 204)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(255, 0, 255)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(204, 0, 255)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(153, 0, 255)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(102, 0, 255)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(51, 0, 255)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 0, 255)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 51, 255)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 102, 255)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 153, 255)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 204, 255)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 255, 255)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 255, 204)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 255, 153)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 255, 102)); + this.mRainbowMap.put(id++, new Triplet<Integer, Integer, Integer>(0, 255, 51)); + this.mRainbowTickMax = this.mRainbowMap.size(); + return true; + } + + @Override + public int getBlockColor() { + return Utils.rgbtoHexValue(0, 0, 0); + } + + @Override + public int colorMultiplier(final IBlockAccess p_149720_1_, final int p_149720_2_, final int p_149720_3_, + final int p_149720_4_) { + + if ((this.mRainbowTick < 0) || (this.mRainbowTick > this.mRainbowTickMax)) { + this.mRainbowTick = 0; + } + //Utils.LOG_INFO("x: "+this.mRainbowTick); + if (this.mRainbowTick <= this.mRainbowTickMax) { + Triplet<Integer, Integer, Integer> mT = this.mRainbowMap.get(this.mRainbowTick); + try { + return Utils.rgbtoHexValue(mT.getValue_1(), mT.getValue_1(), mT.getValue_1()); + } + catch (final Throwable t) { + try { + mT = this.mRainbowMap.get(this.mRainbowTick - 1); + return Utils.rgbtoHexValue(mT.getValue_1(), mT.getValue_1(), mT.getValue_1()); + } + catch (final Throwable t1) { + return Utils.rgbtoHexValue(0, 0, 0); + } + } + } + + return Utils.rgbtoHexValue(0, 0, 0); + } + + @Override + public void updateTick(final World world, final int x, final int y, final int z, final Random rand) { + // this.mRainbowTick++; + super.updateTick(world, x, y, z, rand); + } + + @Override + public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand) { + this.mRainbowTick++; + super.randomDisplayTick(world, x, y, z, rand); + } + + @Override + public int tickRate(final World p_149738_1_) { + return 20; + } + + @Override + public int getLightValue() { + final int mTicker = this.mRainbowTick; + if ((mTicker == 0) || (mTicker == 17)){ + return 1; + } + else if ((mTicker == 1) || (mTicker == 16)){ + return 2; + } + else if ((mTicker == 2) || (mTicker == 15)){ + return 3; + } + else if ((mTicker == 3) || (mTicker == 14)){ + return 4; + } + else if ((mTicker == 4) || (mTicker == 13)){ + return 6; + } + else if ((mTicker == 5) || (mTicker == 12)){ + return 8; + } + else if ((mTicker == 6) || (mTicker == 11)){ + return 10; + } + else if ((mTicker == 7) || (mTicker == 10)){ + return 12; + } + else if ((mTicker == 8) || (mTicker == 9)){ + return 14; + } + return 0; + + } + +} diff --git a/src/Java/gtPlusPlus/core/block/general/HellFire.java b/src/Java/gtPlusPlus/core/block/general/HellFire.java index 2adab5d5e7..d73d0eb085 100644 --- a/src/Java/gtPlusPlus/core/block/general/HellFire.java +++ b/src/Java/gtPlusPlus/core/block/general/HellFire.java @@ -1,6 +1,11 @@ package gtPlusPlus.core.block.general; -import static net.minecraftforge.common.util.ForgeDirection.*; +import static net.minecraftforge.common.util.ForgeDirection.DOWN; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.UP; +import static net.minecraftforge.common.util.ForgeDirection.WEST; import java.util.IdentityHashMap; import java.util.Map.Entry; @@ -21,6 +26,7 @@ import net.minecraft.block.BlockFire; import net.minecraft.block.material.MapColor; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; @@ -44,29 +50,29 @@ public class HellFire extends BlockFire { this.setCreativeTab(AddToCreativeTab.tabBlock); GameRegistry.registerBlock(this, "blockHellFire"); LanguageRegistry.addName(this, "Hellish Fire"); - enableBrutalFire(); + this.enableBrutalFire(); } private void enableBrutalFire() { - for (Object o : Block.blockRegistry.getKeys()) + for (final Object o : Block.blockRegistry.getKeys()) { - String name = (String)o; - Block b = Block.getBlockFromName(name); + final String name = (String)o; + final Block b = Block.getBlockFromName(name); - if (b == Blocks.grass || b == Blocks.mycelium){ - int spread = 3; - int flamm = 3; + if ((b == Blocks.grass) || (b == Blocks.mycelium)){ + final int spread = 3; + final int flamm = 3; this.setFireInfo(b, spread * 4, flamm * 4); } if (b != Blocks.air) { - int spread = Blocks.fire.getEncouragement(b); - int flamm = Blocks.fire.getFlammability(b); + final int spread = Blocks.fire.getEncouragement(b); + final int flamm = Blocks.fire.getFlammability(b); this.setFireInfo(b, spread * 4, flamm * 4); } } - + //Special Case madness this.setFireInfo(Blocks.brown_mushroom_block, 20, 100); this.setFireInfo(Blocks.red_mushroom_block, 20, 100); @@ -89,7 +95,7 @@ public class HellFire extends BlockFire { @Override public void updateTick(final World world, final int x, final int y, final int z, Random random) { - random = new XSTR(); + random = new XSTR(); if (world.getGameRules().getGameRuleBooleanValue("doFireTick")) { final boolean flag = world.getBlock(x, y - 1, z).isFireSource(world, x, y - 1, z, UP); @@ -296,13 +302,18 @@ public class HellFire extends BlockFire { //Burn @Override - public void onEntityWalking(World world, int i, int j, int k, Entity entity) { + public void onEntityWalking(final World world, final int i, final int j, final int k, final Entity entity) { entity.setFire(10); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + //Burn @Override - public void onEntityCollidedWithBlock(World world, int i, int j, int k, Entity entity) { + public void onEntityCollidedWithBlock(final World world, final int i, final int j, final int k, final Entity entity) { entity.setFire(10); } @@ -399,7 +410,7 @@ public class HellFire extends BlockFire { @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(final IIconRegister IIconRegister) { - this.IIconArray = new IIcon[] { + this.IIconArray = new IIcon[] { IIconRegister.registerIcon(CORE.MODID + ":" + "hellfire/" + "blockHellFire" + "_layer_0"), IIconRegister.registerIcon(CORE.MODID + ":" + "hellfire/" + "blockHellFire" + "_layer_1") }; } diff --git a/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java b/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java new file mode 100644 index 0000000000..d093bf2e2f --- /dev/null +++ b/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java @@ -0,0 +1,110 @@ +package gtPlusPlus.core.block.general.antigrief; + +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 gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.boss.IBossDisplayData; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class BlockWitherProof extends Block{ + + public BlockWitherProof(){ + super(Material.redstoneLight); + this.setBlockName(Utils.sanitizeString("blockBlackGate")); + this.setBlockTextureName(CORE.MODID + ":" + "blockFrameGt"); + this.setCreativeTab(AddToCreativeTab.tabBlock); + this.setHardness(-1F); + this.setResistance(5000.0F); + this.setHarvestLevel("pickaxe", 3); + this.setStepSound(soundTypeMetal); + LanguageRegistry.addName(this, "Wither Cage"); + GameRegistry.registerBlock(this, Utils.sanitizeString("blockBlackGate")); + + } + + public String GetProperName(){ + return "Wither Cage"; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass(){ + return 1; + } + + @Override + public boolean isOpaqueCube(){ + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister iIcon){ + this.blockIcon = iIcon.registerIcon(CORE.MODID + ":" + "blockFrameGt"); + } + + @Override + public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion){ + //prevent from being destroyed by wither and nukes. + } + + @Override + public void onBlockDestroyedByExplosion(final World p_149723_1_, final int p_149723_2_, + final int p_149723_3_, final int p_149723_4_, final Explosion p_149723_5_) { + + } + + @Override + public boolean canDropFromExplosion(final Explosion p_149659_1_) { + return false; + } + + @Override + public boolean canEntityDestroy(final IBlockAccess world, final int x, final int y, final int z, + final Entity entity) { + if ((entity == null) || !entity.isEntityAlive()){ + return false; + } + if ((entity instanceof EntityWither) || (entity instanceof EntityDragon) || (entity instanceof IBossDisplayData)){ + return false; + } + else { + return super.canEntityDestroy(world, x, y, z, entity); + } + } + + + //Colour Handling + private static final int mWitherColour = Utils.rgbtoHexValue(32, 32, 32); + + @Override + public int colorMultiplier(final IBlockAccess par1IBlockAccess, final int par2, final int par3, final int par4){ + return mWitherColour; + } + + @Override + public int getRenderColor(final int aMeta) { + return mWitherColour; + } + + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + + + +} diff --git a/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java b/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java index f40c1dbe7d..b87054748d 100644 --- a/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java +++ b/src/Java/gtPlusPlus/core/block/general/fluids/BlockFluidSludge.java @@ -6,6 +6,7 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -52,4 +53,9 @@ public class BlockFluidSludge extends BlockFluidClassic { return super.displaceIfPossible(world, x, y, z); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } diff --git a/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java index cab02f9db6..0ed3aa5afd 100644 --- a/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java +++ b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java @@ -4,6 +4,7 @@ import gtPlusPlus.core.block.base.BasicBlock.BlockTypes; import gtPlusPlus.core.block.base.MetaBlock; import gtPlusPlus.core.lib.CORE; import net.minecraft.block.material.Material; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.world.IBlockAccess; public class BlockGtFrameBox extends MetaBlock { @@ -32,4 +33,9 @@ public class BlockGtFrameBox extends MetaBlock { return super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + } diff --git a/src/Java/gtPlusPlus/core/block/machine/FishTrap.java b/src/Java/gtPlusPlus/core/block/machine/FishTrap.java index f2e15e24b6..fad1dff490 100644 --- a/src/Java/gtPlusPlus/core/block/machine/FishTrap.java +++ b/src/Java/gtPlusPlus/core/block/machine/FishTrap.java @@ -14,10 +14,12 @@ 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; public class FishTrap extends BlockContainer @@ -95,23 +97,28 @@ public class FishTrap extends BlockContainer } @Override - public void onBlockAdded(World world, int x, int y, int z) { + 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(World world, int x, int y, int z, Block block, int number) { - InventoryUtils.dropInventoryItems(world, x, y, z, block); - super.breakBlock(world, x, y, z, block, number); - } + 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(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack stack) { if (stack.hasDisplayName()) { - ((TileEntityFishTrap) world.getTileEntity(x,y,z)).setCustomName(stack.getDisplayName()); - } + ((TileEntityFishTrap) 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); diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java index 9a11c9dadc..1b4c5ebd01 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_ModularityTable.java @@ -12,9 +12,11 @@ import gtPlusPlus.core.util.Utils; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class Machine_ModularityTable extends BlockContainer @@ -67,9 +69,9 @@ public class Machine_ModularityTable extends BlockContainer } final TileEntity te = world.getTileEntity(x, y, z); if ((te != null) && (te instanceof TileEntityModularityTable)){ - player.openGui(GTplusplus.instance, 1, world, x, y, z); - Utils.LOG_INFO("Player opened GUI"); - return true; + player.openGui(GTplusplus.instance, 1, world, x, y, z); + Utils.LOG_INFO("Player opened GUI"); + return true; } return false; } @@ -79,4 +81,9 @@ public class Machine_ModularityTable extends BlockContainer return new TileEntityModularityTable(); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java index 2c742b99db..939015adf7 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_ProjectTable.java @@ -10,7 +10,6 @@ import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; -import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -18,10 +17,12 @@ import ic2.core.item.tool.ItemToolWrench; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +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; @Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO") @@ -151,4 +152,9 @@ public class Machine_ProjectTable extends BlockContainer return false; } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java b/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java index 540ba61837..724b438b13 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_TradeTable.java @@ -1,22 +1,19 @@ 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 gtPlusPlus.GTplusplus; import gtPlusPlus.core.block.base.BlockBaseNBT; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.itemblock.ItemBlockNBT; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; import gtPlusPlus.core.util.Utils; -import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class Machine_TradeTable extends BlockBaseNBT @@ -53,9 +50,9 @@ public class Machine_TradeTable extends BlockBaseNBT final TileEntity te = world.getTileEntity(x, y, z); if ((te != null) && (te instanceof TileEntityTradeTable)) { - //Utils.LOG_INFO("Clicked on TE - ok"); - player.openGui(GTplusplus.instance, 6, world, x, y, z); - return true; + //Utils.LOG_INFO("Clicked on TE - ok"); + player.openGui(GTplusplus.instance, 6, world, x, y, z); + return true; } else { Utils.LOG_INFO("Bad TE"); @@ -68,4 +65,9 @@ public class Machine_TradeTable extends BlockBaseNBT return new TileEntityTradeTable(); } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java index 64a5c5af8b..b5c54ad9a8 100644 --- a/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java +++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Workbench.java @@ -17,10 +17,12 @@ import ic2.core.item.tool.ItemToolWrench; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +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; @Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO") @@ -150,4 +152,9 @@ public class Machine_Workbench extends BlockContainer return false; } + @Override + public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, final int z) { + return false; + } + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/container/Container_Grindle.java b/src/Java/gtPlusPlus/core/container/Container_Grindle.java new file mode 100644 index 0000000000..8b218f5993 --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_Grindle.java @@ -0,0 +1,182 @@ +package gtPlusPlus.core.container; + +import gtPlusPlus.core.inventories.BaseInventoryGrindle; +import gtPlusPlus.core.slots.SlotDataStick; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class Container_Grindle extends Container +{ + /** The Item Inventory for this Container, only needed if you want to reference isUseableByPlayer */ + public final BaseInventoryGrindle inventory; + + /** Using these will make transferStackInSlot easier to understand and implement + * INV_START is the index of the first slot in the Player's Inventory, so our + * BaseInventoryBackpack's number of slots (e.g. 5 slots is array indices 0-4, so start at 5) + * Notice how we don't have to remember how many slots we made? We can just use + * BaseInventoryBackpack.INV_SIZE and if we ever change it, the Container updates automatically. */ + private static final int INV_START = BaseInventoryGrindle.INV_SIZE, INV_END = INV_START+0, + HOTBAR_START = INV_END, HOTBAR_END = HOTBAR_START+8; + + // If you're planning to add armor slots, put those first like this: + // ARMOR_START = BaseInventoryBackpack.INV_SIZE, ARMOR_END = ARMOR_START+3, + // INV_START = ARMOR_END+1, and then carry on like above. + + public Container_Grindle(final EntityPlayer par1Player, final InventoryPlayer inventoryPlayer, final BaseInventoryGrindle inventoryItem) + { + this.inventory = inventoryItem; + + int i; + + //Actual Scan Slot + this.addSlotToContainer(new SlotDataStick(this.inventory, 0, 152, 5)); + + for (i = 1; i < BaseInventoryGrindle.INV_SIZE; ++i){ + this.addSlotToContainer(new SlotDataStick(this.inventory, i, 153, 30+(18*i))); + } + + // PLAYER ACTION BAR - uses default locations for standard action bar texture file + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + (i * 18), 142)); + } + } + + @Override + public boolean canInteractWith(final EntityPlayer entityplayer) + { + // be sure to return the inventory's isUseableByPlayer method + // if you defined special behavior there: + return this.inventory.isUseableByPlayer(entityplayer); + } + + /** + * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. + */ + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int index) + { + ItemStack itemstack = null; + final Slot slot = (Slot) this.inventorySlots.get(index); + + if ((slot != null) && slot.getHasStack()) + { + final ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + // If item is in our custom Inventory or armor slot + if (index < INV_START) + { + // try to place in player inventory / action bar + if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END+1, true)) + { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + // Item is in inventory / hotbar, try to place in custom inventory or armor slots + else + { + /* + If your inventory only stores certain instances of Items, + you can implement shift-clicking to your inventory like this: + + // Check that the item is the right type + if (itemstack1.getItem() instanceof ItemCustom) + { + // Try to merge into your custom inventory slots + // We use 'BaseInventoryBackpack.INV_SIZE' instead of INV_START just in case + // you also add armor or other custom slots + if (!this.mergeItemStack(itemstack1, 0, BaseInventoryBackpack.INV_SIZE, false)) + { + return null; + } + } + // If you added armor slots, check them here as well: + // Item being shift-clicked is armor - try to put in armor slot + if (itemstack1.getItem() instanceof ItemArmor) + { + int type = ((ItemArmor) itemstack1.getItem()).armorType; + if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, false)) + { + return null; + } + } + Otherwise, you have basically 2 choices: + 1. shift-clicking between player inventory and custom inventory + 2. shift-clicking between action bar and inventory + + Be sure to choose only ONE of the following implementations!!! + */ + /** + * Implementation number 1: Shift-click into your custom inventory + */ + if (index >= INV_START) + { + // place in custom inventory + if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) + { + return null; + } + } + + /** + * Implementation number 2: Shift-click items between action bar and inventory + */ + // item is in player's inventory, but not in action bar + if ((index >= INV_START) && (index < HOTBAR_START)) + { + // place in action bar + if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END+1, false)) + { + return null; + } + } + // item in action bar - place in player inventory + else if ((index >= HOTBAR_START) && (index < (HOTBAR_END+1))) + { + if (!this.mergeItemStack(itemstack1, INV_START, INV_END+1, false)) + { + return null; + } + } + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + /** + * You should override this method to prevent the player from moving the stack that + * opened the inventory, otherwise if the player moves it, the inventory will not + * be able to save properly + */ + @Override + public ItemStack slotClick(final int slot, final int button, final int flag, final EntityPlayer player) { + // this will prevent the player from interacting with the item that opened the inventory: + if ((slot >= 0) && (this.getSlot(slot) != null) && (this.getSlot(slot).getStack() == player.getHeldItem())) { + return null; + } + return super.slotClick(slot, button, flag, player); + } +} diff --git a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java new file mode 100644 index 0000000000..c7c14e9103 --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java @@ -0,0 +1,140 @@ +package gtPlusPlus.core.gui.item; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GT_Utility.ItemNBT; +import gtPlusPlus.core.container.Container_BackpackBase; +import gtPlusPlus.core.container.Container_Grindle; +import gtPlusPlus.core.inventories.BaseInventoryBackpack; +import gtPlusPlus.core.inventories.BaseInventoryGrindle; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.nbt.NBTUtils; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.util.ResourceLocation; + +public class GuiBaseGrindle extends GuiContainer { + + /** The FontRenderer used by GuiScreen */ + protected FontRenderer fontRenderer; + + private static final ResourceLocation iconLocation = new ResourceLocation(CORE.MODID, "textures/gui/itemGrindle.png"); + + /** The inventory to render on screen */ + private final BaseInventoryGrindle inventory; + + public GuiBaseGrindle(final Container_Grindle containerItem){ + super(containerItem); + this.inventory = containerItem.inventory; + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(final int par1, final int par2, final float par3){ + super.drawScreen(par1, par2, par3); + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2){ + final String s = "Git"; + //Title + this.fontRendererObj.drawStringWithShadow(I18n.format("Gregtech Information Transponder", new Object[0]), 0, -12, Utils.rgbtoHexValue(255, 255, 255)); + + if (this.inventory.getStackInSlot(0) != null){ + this.fontRendererObj.drawString(I18n.format(""+NBTUtils.getBookTitle(this.inventory.getStackInSlot(0)), new Object[0]), 10, 8, Utils.rgbtoHexValue(125, 255, 125)); + + //if (!NBTUtils.tryIterateNBTData(this.inventory.getStackInSlot(0))){ + // this.fontRendererObj.drawString(I18n.format("Very Bad prospection data.", new Object[0]), 10, 38, Utils.rgbtoHexValue(255, 125, 125)); + //} + + NBTTagCompound tNBT = ItemNBT.getNBT(this.inventory.getStackInSlot(0)); + byte tTier = tNBT.getByte("prospection_tier"); + //List Tier + //this.fontRendererObj.drawStringWithShadow(I18n.format("Tier: "+tTier, new Object[0]), 10, 18, Utils.rgbtoHexValue(125, 255, 125)); + + if (tTier == 0) { // basic prospection data + String tData = tNBT.getString("prospection"); + //List prospection + //this.fontRendererObj.drawStringWithShadow(I18n.format("Prospection : "+tData, new Object[0]), 10, 28, Utils.rgbtoHexValue(125, 255, 125)); + + String[] tDataArray = tData.split(","); + if (tDataArray.length > 6) { + tNBT.setString("author", "X: " + tDataArray[0] + " Y: " + tDataArray[1] + " Z: " + tDataArray[2] + " Dim: " + tDataArray[3]); + //List prospection + this.fontRendererObj.drawString(I18n.format("X: " + tDataArray[0], new Object[0]), 10, 28, Utils.rgbtoHexValue(125, 125, 255)); + this.fontRendererObj.drawString(I18n.format("Y: " + tDataArray[1], new Object[0]), 10, 38, Utils.rgbtoHexValue(125, 125, 255)); + this.fontRendererObj.drawString(I18n.format("Z: " + tDataArray[2], new Object[0]), 10, 48, Utils.rgbtoHexValue(125, 125, 255)); + this.fontRendererObj.drawString(I18n.format("Dim: " + tDataArray[3], new Object[0]), 10, 58, Utils.rgbtoHexValue(125, 125, 255)); + + //Divider + this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 63, Utils.rgbtoHexValue(125, 125, 255)); + + NBTTagList tNBTList = new NBTTagList(); + String[] mOreTypes = new String[50]; + String tOres = " Prospected Ores: "; + for (int i = 6; tDataArray.length > i; i++) { + mOreTypes[i] = (tDataArray[i] + " "); + if ((68+(i-6)*8) < (68+56)){ + this.fontRendererObj.drawString(I18n.format(mOreTypes[i], new Object[0]), 10, 68+((i-6)*8), Utils.rgbtoHexValue(125, 255, 125)); + } + } + tNBTList.appendTag(new NBTTagString("Prospection Data From: X" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres)); + tNBT.setTag("pages", tNBTList); + + + //List prospection + this.fontRendererObj.drawString(I18n.format("Tier: "+tTier+ " | Pages: "+tNBTList.tagCount(), new Object[0]), 10, 18, Utils.rgbtoHexValue(125, 255, 125)); + //Divider + this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 23, Utils.rgbtoHexValue(125, 125, 255)); + + } + else { + this.fontRendererObj.drawString(I18n.format("Bad prospection data.", new Object[0]), 10, 68, Utils.rgbtoHexValue(255, 125, 125)); + } + } + } + else { + //Valid Datastick? + this.fontRendererObj.drawStringWithShadow(I18n.format("Insert device into port.", new Object[0]), 10, 8, Utils.rgbtoHexValue(255, 125, 125)); + } + + + + //Inventory Label + this.fontRendererObj.drawStringWithShadow(I18n.format("container.inventory", new Object[0]), 8, 131, Utils.rgbtoHexValue(255, 255, 255)); + + //this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 0, 4210752); + //this.fontRenderer.drawString(I18n.translate("container.inventory"), 26, this.ySize - 96 + 4, 4210752); + } + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + final int k = (this.width - this.xSize) / 2; + final int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + final int i1; + //drawPlayerModel(k + 51, l + 75, 30, k + 51 - this.xSize_lo, (l + 75) - 50 - this.ySize_lo, this.mc.thePlayer); + } +} diff --git a/src/Java/gtPlusPlus/core/gui/item/GuiScreenGrindle.java b/src/Java/gtPlusPlus/core/gui/item/GuiScreenGrindle.java new file mode 100644 index 0000000000..991937ff03 --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/item/GuiScreenGrindle.java @@ -0,0 +1,488 @@ +package gtPlusPlus.core.gui.item; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.container.Container_Grindle; +import gtPlusPlus.core.inventories.BaseInventoryGrindle; +import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.nbt.NBTUtils; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.minecraft.util.ChatAllowedCharacters; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; + +@SideOnly(Side.CLIENT) +public class GuiScreenGrindle extends GuiContainer { + private static final Logger logger = LogManager.getLogger(); + private static final ResourceLocation bookGuiTextures = new ResourceLocation("textures/gui/book.png"); + /** The player editing the book */ + private final EntityPlayer editingPlayer; + private final ItemStack bookObj; + /** Whether the book is signed or can still be edited */ + private final boolean bookIsUnsigned; + private boolean field_146481_r; + private boolean field_146480_s; + /** Update ticks since the gui was opened */ + private int updateCount; + private final int bookImageWidth = 192; + private final int bookImageHeight = 192; + private int bookTotalPages = 1; + private int currPage; + private NBTTagList bookPages; + private String bookTitle = ""; + private GuiScreenGrindle.NextPageButton buttonNextPage; + private GuiScreenGrindle.NextPageButton buttonPreviousPage; + private GuiButton buttonDone; + /** The GuiButton to sign this book. */ + private GuiButton buttonSign; + private GuiButton buttonFinalize; + private GuiButton buttonCancel; + + // Texture + private static final ResourceLocation iconLocation = new ResourceLocation(CORE.MODID, + "textures/gui/itemGrindle.png"); + + /** The inventory to render on screen */ + private final BaseInventoryGrindle inventory; + + public GuiScreenGrindle(final Container_Grindle containerItem, final EntityPlayer player) { + super(containerItem); + this.inventory = containerItem.inventory; + this.editingPlayer = player; + this.bookObj = this.inventory.getStackInSlot(0); + this.bookIsUnsigned = (this.bookObj == null ? true : false); + + if (this.bookObj != null) { + if (this.bookObj.hasTagCompound()) { + final NBTTagCompound nbttagcompound = this.bookObj.getTagCompound(); + this.bookPages = nbttagcompound.getTagList("pages", 8); + + if (this.bookPages != null) { + this.bookPages = (NBTTagList) this.bookPages.copy(); + this.bookTotalPages = this.bookPages.tagCount(); + + if (this.bookTotalPages < 1) { + this.bookTotalPages = 1; + } + } + } + + + if ((this.bookPages == null) && this.bookIsUnsigned) { this.bookPages = + new NBTTagList(); this.bookPages.appendTag(new NBTTagString("")); + this.bookTotalPages = 1; } + + } + } + + /** + * Called from the main game loop to update the screen. + */ + @Override + public void updateScreen() { + super.updateScreen(); + ++this.updateCount; + } + + /** + * Adds the buttons (and other controls) to the screen in question. + */ + @Override + @SuppressWarnings("unchecked") + public void initGui() { + this.buttonList.clear(); + Keyboard.enableRepeatEvents(true); + + if (this.bookIsUnsigned) { + this.buttonList.add(this.buttonSign = new GuiButton(3, (this.width / 2) - 100, 4 + this.bookImageHeight, 98, + 20, I18n.format("book.signButton", new Object[0]))); + this.buttonList.add(this.buttonDone = new GuiButton(0, (this.width / 2) + 2, this.bookImageHeight-4, 98, + 20, I18n.format("gui.close", new Object[0]))); + this.buttonList.add(this.buttonFinalize = new GuiButton(5, (this.width / 2) - 100, 4 + this.bookImageHeight, + 98, 20, I18n.format("book.finalizeButton", new Object[0]))); + this.buttonList.add(this.buttonCancel = new GuiButton(4, (this.width / 2) + 2, 4 + this.bookImageHeight, 98, + 20, I18n.format("gui.cancel", new Object[0]))); + } + else { + this.buttonList.add(this.buttonDone = new GuiButton(0, (this.width / 2) - 100, this.bookImageHeight+100, + 200, 20, I18n.format("gui.done", new Object[0]))); + } + + final int i = (this.width - this.bookImageWidth) / 2; + final byte b0 = 2; + this.buttonList.add(this.buttonNextPage = new GuiScreenGrindle.NextPageButton(1, i + 120, b0 + 154, true)); + this.buttonList.add(this.buttonPreviousPage = new GuiScreenGrindle.NextPageButton(2, i + 38, b0 + 154, false)); + this.updateButtons(); + } + + /** + * Called when the screen is unloaded. Used to disable keyboard repeat + * events + */ + @Override + public void onGuiClosed() { + Keyboard.enableRepeatEvents(false); + } + + private void updateButtons() { + this.buttonNextPage.visible = !this.field_146480_s + && ((this.currPage < (this.bookTotalPages - 1)) || this.bookIsUnsigned); + this.buttonPreviousPage.visible = !this.field_146480_s && (this.currPage > 0); + this.buttonDone.visible = !this.bookIsUnsigned || !this.field_146480_s; + + if (this.bookIsUnsigned) { + this.buttonSign.visible = !this.field_146480_s; + this.buttonCancel.visible = this.field_146480_s; + this.buttonFinalize.visible = this.field_146480_s; + this.buttonFinalize.enabled = this.bookTitle.trim().length() > 0; + } + } + + private void sendBookToServer(final boolean p_146462_1_) { + if (this.bookIsUnsigned && this.field_146481_r) { + if (this.bookPages != null) { + String s; + + while (this.bookPages.tagCount() > 1) { + s = this.bookPages.getStringTagAt(this.bookPages.tagCount() - 1); + + if (s.length() != 0) { + break; + } + + this.bookPages.removeTag(this.bookPages.tagCount() - 1); + } + + if (this.bookObj.hasTagCompound()) { + final NBTTagCompound nbttagcompound = this.bookObj.getTagCompound(); + nbttagcompound.setTag("pages", this.bookPages); + } + else { + this.bookObj.setTagInfo("pages", this.bookPages); + } + + s = "MC|BEdit"; + + if (p_146462_1_) { + s = "MC|BSign"; + this.bookObj.setTagInfo("author", new NBTTagString(this.editingPlayer.getCommandSenderName())); + this.bookObj.setTagInfo("title", new NBTTagString(this.bookTitle.trim())); + this.bookObj.func_150996_a(ModItems.itemGrindleTablet); + } + + final ByteBuf bytebuf = Unpooled.buffer(); + + try { + (new PacketBuffer(bytebuf)).writeItemStackToBuffer(this.bookObj); + this.mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload(s, bytebuf)); + } + catch (final Exception exception) { + logger.error("Couldn\'t send book info", exception); + } + finally { + bytebuf.release(); + } + } + } + } + + @Override + protected void actionPerformed(final GuiButton button) { + if (button.enabled) { + if (button.id == 0) { + this.mc.displayGuiScreen((GuiScreen) null); + this.sendBookToServer(false); + } + else if ((button.id == 3) && this.bookIsUnsigned) { + this.field_146480_s = true; + } + else if (button.id == 1) { + if (this.currPage < (this.bookTotalPages - 1)) { + ++this.currPage; + } + else if (this.bookIsUnsigned) { + this.addNewPage(); + + if (this.currPage < (this.bookTotalPages - 1)) { + ++this.currPage; + } + } + } + else if (button.id == 2) { + if (this.currPage > 0) { + --this.currPage; + } + } + else if ((button.id == 5) && this.field_146480_s) { + this.sendBookToServer(true); + this.mc.displayGuiScreen((GuiScreen) null); + } + else if ((button.id == 4) && this.field_146480_s) { + this.field_146480_s = false; + } + + this.updateButtons(); + } + } + + private void addNewPage() { + if ((this.bookPages != null) && (this.bookPages.tagCount() < 50)) { + this.bookPages.appendTag(new NBTTagString("")); + ++this.bookTotalPages; + this.field_146481_r = true; + } + } + + /** + * Fired when a key is typed. This is the equivalent of + * KeyListener.keyTyped(KeyEvent e). + */ + @Override + protected void keyTyped(final char p_73869_1_, final int p_73869_2_) { + super.keyTyped(p_73869_1_, p_73869_2_); + + if (this.bookIsUnsigned) { + if (this.field_146480_s) { + this.func_146460_c(p_73869_1_, p_73869_2_); + } + else { + this.keyTypedInBook(p_73869_1_, p_73869_2_); + } + } + } + + /** + * Processes keystrokes when editing the text of a book + */ + private void keyTypedInBook(final char p_146463_1_, final int p_146463_2_) { + switch (p_146463_1_) { + case 22: + this.func_146459_b(GuiScreen.getClipboardString()); + return; + default: + switch (p_146463_2_) { + case 14: + final String s = this.func_146456_p(); + + if (s.length() > 0) { + this.func_146457_a(s.substring(0, s.length() - 1)); + } + + return; + case 28: + case 156: + this.func_146459_b("\n"); + return; + default: + if (ChatAllowedCharacters.isAllowedCharacter(p_146463_1_)) { + this.func_146459_b(Character.toString(p_146463_1_)); + } + } + } + } + + private void func_146460_c(final char p_146460_1_, final int p_146460_2_) { + switch (p_146460_2_) { + case 14: + if (!this.bookTitle.isEmpty()) { + this.bookTitle = this.bookTitle.substring(0, this.bookTitle.length() - 1); + this.updateButtons(); + } + + return; + case 28: + case 156: + if (!this.bookTitle.isEmpty()) { + this.sendBookToServer(true); + this.mc.displayGuiScreen((GuiScreen) null); + } + + return; + default: + if ((this.bookTitle.length() < 16) && ChatAllowedCharacters.isAllowedCharacter(p_146460_1_)) { + this.bookTitle = this.bookTitle + Character.toString(p_146460_1_); + this.updateButtons(); + this.field_146481_r = true; + } + } + } + + private String func_146456_p() { + return (this.bookPages != null) && (this.currPage >= 0) && (this.currPage < this.bookPages.tagCount()) + ? this.bookPages.getStringTagAt(this.currPage) : ""; + } + + private void func_146457_a(final String p_146457_1_) { + if ((this.bookPages != null) && (this.currPage >= 0) && (this.currPage < this.bookPages.tagCount())) { + this.bookPages.func_150304_a(this.currPage, new NBTTagString(p_146457_1_)); + this.field_146481_r = true; + } + } + + private void func_146459_b(final String p_146459_1_) { + final String s1 = this.func_146456_p(); + final String s2 = s1 + p_146459_1_; + final int i = this.fontRendererObj.splitStringWidth(s2 + "" + EnumChatFormatting.BLACK + "_", 118); + + if ((i <= 118) && (s2.length() < 256)) { + this.func_146457_a(s2); + } + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(final int p_73863_1_, final int p_73863_2_, final float p_73863_3_) { + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + final int k = (this.width - this.xSize) / 2; + final int l2 = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l2, 0, 0, this.xSize, this.ySize); + + //GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + //this.mc.getTextureManager().bindTexture(iconLocation); + //final int k = (this.width - this.bookImageWidth) / 2; + //this.drawTexturedModalRect(k, b0, 0, 0, this.bookImageWidth, + // this.bookImageHeight); + + String s; + String s1; + int l; + final byte b0 = 2; + + if (this.inventory.getStackInSlot(0) != null) { + this.fontRendererObj.drawString( + I18n.format("" + NBTUtils.getBookTitle(this.inventory.getStackInSlot(0)), new Object[0]), 10, 8, + Utils.rgbtoHexValue(125, 255, 125)); + } + + if (this.field_146480_s) { + s = this.bookTitle; + + if (this.bookIsUnsigned) { + if (((this.updateCount / 6) % 2) == 0) { + s = s + "" + EnumChatFormatting.BLACK + "_"; + } + else { + s = s + "" + EnumChatFormatting.GRAY + "_"; + } + } + + s1 = I18n.format("book.editTitle", new Object[0]); + l = this.fontRendererObj.getStringWidth(s1); + this.fontRendererObj.drawString(s1, k + 36 + ((116 - l) / 2), b0 + 16 + 16, 0); + final int i1 = this.fontRendererObj.getStringWidth(s); + this.fontRendererObj.drawString(s, k + 36 + ((116 - i1) / 2), b0 + 48, 0); + final String s2 = I18n.format("book.byAuthor", new Object[] { this.editingPlayer.getCommandSenderName() }); + final int j1 = this.fontRendererObj.getStringWidth(s2); + this.fontRendererObj.drawString(EnumChatFormatting.DARK_GRAY + s2, k + 36 + ((116 - j1) / 2), b0 + 48 + 10, + 0); + final String s3 = I18n.format("book.finalizeWarning", new Object[0]); + this.fontRendererObj.drawSplitString(s3, k + 36, b0 + 80, 116, 0); + } + else { + s = I18n.format("book.pageIndicator", + new Object[] { Integer.valueOf(this.currPage + 1), Integer.valueOf(this.bookTotalPages) }); + s1 = ""; + + if ((this.bookPages != null) && (this.currPage >= 0) && (this.currPage < this.bookPages.tagCount())) { + s1 = this.bookPages.getStringTagAt(this.currPage); + } + + if (this.bookIsUnsigned) { + if (this.fontRendererObj.getBidiFlag()) { + s1 = s1 + "_"; + } + else if (((this.updateCount / 6) % 2) == 0) { + s1 = s1 + "" + EnumChatFormatting.BLACK + "_"; + } + else { + s1 = s1 + "" + EnumChatFormatting.GRAY + "_"; + } + } + + l = this.fontRendererObj.getStringWidth(s); + this.fontRendererObj.drawString(s, ((k - l) + this.bookImageWidth) - 44, b0 + 16, 0); + //this.fontRendererObj.drawString(s, k+36, b0 + 16, 0); + this.fontRendererObj.drawSplitString(s1, k + 36, b0 + 16 + 16, 116, 0); + //this.fontRendererObj.drawSplitString(s1, k, b0 + 16 + 16, 116, 0); + } + + super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_); + } + + @SideOnly(Side.CLIENT) + static class NextPageButton extends GuiButton { + private final boolean field_146151_o; + + public NextPageButton(final int p_i1079_1_, final int p_i1079_2_, final int p_i1079_3_, + final boolean p_i1079_4_) { + super(p_i1079_1_, p_i1079_2_, p_i1079_3_, 23, 13, ""); + this.field_146151_o = p_i1079_4_; + } + + /** + * Draws this button to the screen. + */ + @Override + public void drawButton(final Minecraft p_146112_1_, final int p_146112_2_, final int p_146112_3_) { + if (this.visible) { + final boolean flag = (p_146112_2_ >= this.xPosition) && (p_146112_3_ >= this.yPosition) + && (p_146112_2_ < (this.xPosition + this.width)) + && (p_146112_3_ < (this.yPosition + this.height)); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + p_146112_1_.getTextureManager().bindTexture(GuiScreenGrindle.bookGuiTextures); + int k = 0; + int l = 192; + + if (flag) { + k += 23; + } + + if (!this.field_146151_o) { + l += 13; + } + + this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13); + } + } + } + + /** + * Draw the background layer for the GuiContainer (everything behind the + * items) + */ + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + final int k = (this.width - this.xSize) / 2; + final int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + final int i1; + // drawPlayerModel(k + 51, l + 75, 30, k + 51 - this.xSize_lo, (l + 75) + // - 50 - this.ySize_lo, this.mc.thePlayer); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index 9236aa53e5..eecbcec9e9 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -6,7 +6,6 @@ import java.util.LinkedList; import java.util.Queue; import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.MultiblockRecipeMapHandler; import gtPlusPlus.core.common.compat.*; import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; @@ -55,7 +54,7 @@ public class COMPAT_HANDLER { to 868 --- - 886 + 890 to 950 */ @@ -97,7 +96,11 @@ public class COMPAT_HANDLER { GregtechIndustrialWashPlant.run(); GregtechSemiFluidgenerators.run(); GregtechAdvancedMixer.run(); - + GregtechWirelessChargers.run(); + GregtechIndustrialGeneratorArray.run(); + GregtechIndustrialCuttingFactory.run(); + GregtechMiniRaFusion.run(); + //New Horizons Content NewHorizonsAccelerator.run(); } diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java index b833ab023a..b534cd11cd 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java @@ -6,8 +6,7 @@ import gtPlusPlus.xmod.forestry.HANDLER_FR; import gtPlusPlus.xmod.gregtech.HANDLER_GT; import gtPlusPlus.xmod.growthcraft.HANDLER_GC; import gtPlusPlus.xmod.ic2.HANDLER_IC2; -import gtPlusPlus.xmod.mekanism.HANDLER_Mekanism; -import gtPlusPlus.xmod.rftools.HANDLER_RfTools; +import gtPlusPlus.xmod.thaumcraft.common.HANDLER_Thaumcraft; import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF; public class COMPAT_IntermodStaging { @@ -20,9 +19,8 @@ public class COMPAT_IntermodStaging { HANDLER_IC2.preInit(); HANDLER_Computronics.preInit(); HANDLER_BiomesOPlenty.preInit(); - HANDLER_RfTools.preInit(); - HANDLER_Mekanism.preInit(); - + //HANDLER_Mekanism.preInit(); + HANDLER_Thaumcraft.preInit(); } public static void init(){ @@ -33,8 +31,8 @@ public class COMPAT_IntermodStaging { HANDLER_IC2.init(); HANDLER_Computronics.init(); HANDLER_BiomesOPlenty.init(); - HANDLER_RfTools.init(); - HANDLER_Mekanism.init(); + //HANDLER_Mekanism.init(); + HANDLER_Thaumcraft.init(); } public static void postInit(){ @@ -45,8 +43,8 @@ public class COMPAT_IntermodStaging { HANDLER_IC2.postInit(); HANDLER_Computronics.postInit(); HANDLER_BiomesOPlenty.postInit(); - HANDLER_RfTools.postInit(); - HANDLER_Mekanism.postInit(); + //HANDLER_Mekanism.postInit(); + HANDLER_Thaumcraft.postInit(); } diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index 70e2934349..4b7e58cf70 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -3,13 +3,27 @@ package gtPlusPlus.core.handler; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; import gtPlusPlus.GTplusplus; -import gtPlusPlus.core.container.*; +import gtPlusPlus.core.container.Container_BackpackBase; +import gtPlusPlus.core.container.Container_FishTrap; +import gtPlusPlus.core.container.Container_Grindle; +import gtPlusPlus.core.container.Container_ModularityTable; +import gtPlusPlus.core.container.Container_ProjectTable; +import gtPlusPlus.core.container.Container_TradeTable; +import gtPlusPlus.core.container.Container_Workbench; +import gtPlusPlus.core.container.Container_WorkbenchAdvanced; import gtPlusPlus.core.gui.beta.Gui_ID_Registry; import gtPlusPlus.core.gui.beta.MU_GuiId; import gtPlusPlus.core.gui.item.GuiBaseBackpack; -import gtPlusPlus.core.gui.machine.*; +import gtPlusPlus.core.gui.item.GuiScreenGrindle; +import gtPlusPlus.core.gui.machine.GUI_FishTrap; +import gtPlusPlus.core.gui.machine.GUI_ModularityTable; +import gtPlusPlus.core.gui.machine.GUI_ProjectTable; +import gtPlusPlus.core.gui.machine.GUI_TradeTable; +import gtPlusPlus.core.gui.machine.GUI_Workbench; +import gtPlusPlus.core.gui.machine.GUI_WorkbenchAdvanced; import gtPlusPlus.core.interfaces.IGuiManager; import gtPlusPlus.core.inventories.BaseInventoryBackpack; +import gtPlusPlus.core.inventories.BaseInventoryGrindle; import gtPlusPlus.core.tileentities.base.TileEntityBase; import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; @@ -18,6 +32,9 @@ import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastAlchemyFurnace; +import gtPlusPlus.xmod.thaumcraft.gui.ContainerFastAlchemyFurnace; +import gtPlusPlus.xmod.thaumcraft.gui.GuiFastAlchemyFurnace; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; @@ -32,7 +49,8 @@ public class GuiHandler implements IGuiHandler { public static final int GUI5 = 4; //Workbench Adv public static final int GUI6 = 5; //Fish trap public static final int GUI7 = 6; //Trade table - public static final int GUI8 = 7; // + public static final int GUI8 = 7; //Alchemical Furnace + public static final int GUI9 = 8; //Grindle @@ -79,6 +97,13 @@ public class GuiHandler implements IGuiHandler { else if (ID == GUI7){ return new Container_TradeTable(player.inventory, (TileEntityTradeTable)te); } + else if (ID == GUI8){ + return new ContainerFastAlchemyFurnace(player.inventory, (TileFastAlchemyFurnace)te); + } + } + + if (ID == GUI9){ + return new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem())); } @@ -124,6 +149,13 @@ public class GuiHandler implements IGuiHandler { else if (ID == GUI7){ return new GUI_TradeTable(player.inventory, (TileEntityTradeTable)te, ((TileEntityBase) te).getOwner()); } + else if (ID == GUI8){ + return new GuiFastAlchemyFurnace(player.inventory, (TileFastAlchemyFurnace)te); + } + } + + if (ID == GUI9){ + return new GuiScreenGrindle(new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem())), player); } return null; diff --git a/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java b/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java new file mode 100644 index 0000000000..ca7fcd6d03 --- /dev/null +++ b/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java @@ -0,0 +1,240 @@ +package gtPlusPlus.core.inventories; + +import java.util.UUID; + +import gtPlusPlus.core.item.base.BaseItemBackpack; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.util.Constants; + +public class BaseInventoryGrindle implements IInventory{ + + private final String name = "Inventory Item"; + + /** Provides NBT Tag Compound to reference */ + private final ItemStack invItem; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 6; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private final ItemStack[] inventory = new ItemStack[INV_SIZE]; + + // declaration of variable: + protected String uniqueID; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public BaseInventoryGrindle(final ItemStack stack) + { + this.invItem = stack; + + /** initialize variable within the constructor: */ + this.uniqueID = ""; + + if (!stack.hasTagCompound()) + { + stack.setTagCompound(new NBTTagCompound()); + // no tag compound means the itemstack does not yet have a UUID, so assign one: + this.uniqueID = UUID.randomUUID().toString(); + } + + // Create a new NBT Tag Compound if one doesn't already exist, or you will crash + if (!stack.hasTagCompound()) { + stack.setTagCompound(new NBTTagCompound()); + } + // note that it's okay to use stack instead of invItem right there + // both reference the same memory location, so whatever you change using + // either reference will change in the other + + // Read the inventory contents from NBT + this.readFromNBT(stack.getTagCompound()); + } + @Override + public int getSizeInventory() + { + return this.inventory.length; + } + + @Override + public ItemStack getStackInSlot(final int slot) + { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) + { + ItemStack stack = this.getStackInSlot(slot); + if(stack != null) + { + if(stack.stackSize > amount) + { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) + { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) + { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) + { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() + { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() + { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() + { + return 1; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() + { + for (int i = 0; i < this.getSizeInventory(); ++i) + { + if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { + this.inventory[i] = null; + } + } + + // This line here does the work: + this.writeToNBT(this.invItem.getTagCompound()); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) + { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) + { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return !(itemstack.getItem() instanceof BaseItemBackpack); + } + + /** + * A custom method to read our inventory from an ItemStack's NBT compound + */ + public void readFromNBT(final NBTTagCompound compound) + { + // Gets the custom taglist we wrote to this compound, if any + // 1.7.2+ change to compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + final NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + + if ("".equals(this.uniqueID)) + { + // try to read unique ID from NBT + this.uniqueID = compound.getString("uniqueID"); + // if it's still "", assign a new one: + if ("".equals(this.uniqueID)) + { + this.uniqueID = UUID.randomUUID().toString(); + } + } + + for (int i = 0; i < items.tagCount(); ++i) + { + // 1.7.2+ change to items.getCompoundTagAt(i) + final NBTTagCompound item = items.getCompoundTagAt(i); + final int slot = item.getInteger("Slot"); + + // Just double-checking that the saved slot index is within our inventory array bounds + if ((slot >= 0) && (slot < this.getSizeInventory())) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(item); + } + } + } + + /** + * A custom method to write our inventory to an ItemStack's NBT compound + */ + public void writeToNBT(final NBTTagCompound tagcompound) + { + // Create a new NBT Tag List to store itemstacks as NBT Tags + final NBTTagList items = new NBTTagList(); + + for (int i = 0; i < this.getSizeInventory(); ++i) + { + // Only write stacks that contain items + if (this.getStackInSlot(i) != null) + { + // Make a new NBT Tag Compound to write the itemstack and slot index to + final NBTTagCompound item = new NBTTagCompound(); + item.setInteger("Slot", i); + // Writes the itemstack in slot(i) to the Tag Compound we just made + this.getStackInSlot(i).writeToNBT(item); + + // add the tag compound to our tag list + items.appendTag(item); + } + } + tagcompound.setString("uniqueID", this.uniqueID); + // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" + tagcompound.setTag("ItemInventory", items); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index ec0e21c7bb..5afd82b7d4 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -8,7 +8,12 @@ import gregtech.api.enums.Materials; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.core.common.compat.COMPAT_Baubles; import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.*; +import gtPlusPlus.core.item.base.BaseEuItem; +import gtPlusPlus.core.item.base.BaseItemBackpack; +import gtPlusPlus.core.item.base.BaseItemBurnable; +import gtPlusPlus.core.item.base.BaseItemDamageable; +import gtPlusPlus.core.item.base.BaseItemTCShard; +import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.item.base.dusts.decimal.BaseItemCentidust; import gtPlusPlus.core.item.base.dusts.decimal.BaseItemDecidust; import gtPlusPlus.core.item.base.foods.BaseItemFood; @@ -23,19 +28,36 @@ import gtPlusPlus.core.item.bauble.HealthBoostBauble; import gtPlusPlus.core.item.bauble.ModularBauble; import gtPlusPlus.core.item.chemistry.CoalTar; import gtPlusPlus.core.item.effects.RarityUncommon; -import gtPlusPlus.core.item.general.*; +import gtPlusPlus.core.item.general.BaseItemGrindle; +import gtPlusPlus.core.item.general.BufferCore; +import gtPlusPlus.core.item.general.ItemAirFilter; +import gtPlusPlus.core.item.general.ItemAreaClear; +import gtPlusPlus.core.item.general.ItemBasicFirestarter; +import gtPlusPlus.core.item.general.ItemBlueprint; +import gtPlusPlus.core.item.general.ItemEmpty; +import gtPlusPlus.core.item.general.ItemGemShards; +import gtPlusPlus.core.item.general.ItemHalfCompleteCasings; +import gtPlusPlus.core.item.general.ItemLavaFilter; +import gtPlusPlus.core.item.general.RF2EU_Battery; import gtPlusPlus.core.item.general.books.ItemBaseBook; -import gtPlusPlus.core.item.general.chassis.*; +import gtPlusPlus.core.item.general.chassis.itemBoilerChassis; +import gtPlusPlus.core.item.general.chassis.itemDehydratorCoil; +import gtPlusPlus.core.item.general.chassis.itemDehydratorCoilWire; import gtPlusPlus.core.item.general.throwables.ItemHydrofluoricAcidPotion; import gtPlusPlus.core.item.general.throwables.ItemSulfuricAcidPotion; import gtPlusPlus.core.item.init.ItemsFoods; import gtPlusPlus.core.item.init.ItemsMultiTools; import gtPlusPlus.core.item.tool.misc.SandstoneHammer; -import gtPlusPlus.core.item.tool.staballoy.*; +import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; +import gtPlusPlus.core.item.tool.staballoy.MultiSpadeBase; +import gtPlusPlus.core.item.tool.staballoy.StaballoyAxe; +import gtPlusPlus.core.item.tool.staballoy.StaballoyPickaxe; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.CORE.configSwitches; import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.material.*; +import gtPlusPlus.core.material.ALLOY; +import gtPlusPlus.core.material.ELEMENT; +import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.material.nuclear.NUCLIDE; import gtPlusPlus.core.util.StringUtils; @@ -44,12 +66,15 @@ import gtPlusPlus.core.util.debug.DEBUG_INIT; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.materials.MaterialUtils; -import net.minecraft.block.Block; -import net.minecraft.item.*; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; public final class ModItems { @@ -241,6 +266,11 @@ public final class ModItems { public static Item itemModularBauble; public static Item itemCustomBook; + public static Item itemGrindleTablet; + + public static Item itemRope; + public static Item itemFiber; + public static final void init(){ //Default item used when recipes fail, handy for debugging. @@ -263,20 +293,20 @@ public final class ModItems { GT_OreDictUnificator.registerOre("ingotRubber", ItemUtils.getItemStack(CORE.MODID+":itemStickyRubber", 1)); - - - //Register Hydrogen Blobs first, so we can replace old helium blobs. itemCoalCoke = new BaseItemBurnable("itemCoalCoke", "Coking Coal", tabMisc, 64, 0, "Used for metallurgy.", "fuelCoke", 3200, 0).setTextureName(CORE.MODID + ":itemCoalCoke"); //Register Hydrogen Blobs first, so we can replace old helium blobs. itemHydrogenBlob = new CoreItem("itemHydrogenBlob", "Mysterious Hydrogen Blob", tabMisc).setTextureName(CORE.MODID + ":itemHeliumBlob"); - //GT_OreDictUnificator.registerOre("dustHydrogen", new ItemStack(ModItems.itemHydrogenBlob)); //Register Old Helium Blob, this will be replaced when held by a player. itemHeliumBlob = new CoreItem("itemHeliumBlob", tabMisc, ItemUtils.getSimpleStack(itemHydrogenBlob)).setTextureName(CORE.MODID + ":itemHydrogenBlob"); //Register this neato device, for making some fires. itemBasicFireMaker = new ItemBasicFirestarter(); + //Register Rope + itemFiber = new CoreItem("itemFiber", "Plant Fiber", tabMisc); + itemRope = new CoreItem("itemRope", "Rope", tabMisc); + //Make some backpacks //Primary colours backpack_Red = new BaseItemBackpack("backpackRed", Utils.rgbtoHexValue(200, 0, 0)); @@ -307,7 +337,7 @@ public final class ModItems { itemHydrofluoricPotion = new ItemHydrofluoricAcidPotion("itemHydrofluoricPotion", "Thowable Vial of Hydrofluoric Acid", "They won't see this coming, nor anything after!").setTextureName(CORE.MODID + ":itemPotion"); //Start meta Item Generation ItemsFoods.load(); - + try{ @@ -588,6 +618,14 @@ public final class ModItems { //Create Multi-tools ItemsMultiTools.load(); + //Xp Fluids - Dev + if (!FluidRegistry.isFluidRegistered("mobessence")){ + FluidUtils.generateFluidNoPrefix("mobessence", "mobessence", 0, new short[]{125, 175, 125, 100}); + } + if (!FluidRegistry.isFluidRegistered("xpjuice")){ + FluidUtils.generateFluidNoPrefix("xpjuice", "xpjuice", 0, new short[]{50, 150, 50, 100}); + } + //Just an unusual plate needed for some black magic. itemPlateClay = new BaseItemPlate(MaterialUtils.generateMaterialFromGtENUM(Materials.Clay)); itemDoublePlateClay = new BaseItemPlateDouble(MaterialUtils.generateMaterialFromGtENUM(Materials.Clay)); @@ -603,10 +641,10 @@ public final class ModItems { } //A plate of Europium. - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateEuropium", 1) == null && CORE.configSwitches.enableCustom_Pipes){ + if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateEuropium", 1) == null) && CORE.configSwitches.enableCustom_Pipes){ itemPlateEuropium = new BaseItemPlate(MaterialUtils.generateMaterialFromGtENUM(Materials.Europium)); } - if (ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleEuropium", 1) == null && CORE.configSwitches.enableCustom_Pipes){ + if ((ItemUtils.getItemStackOfAmountFromOreDictNoBroken("plateDoubleEuropium", 1) == null) && CORE.configSwitches.enableCustom_Pipes){ itemDoublePlateEuropium = new BaseItemPlateDouble(MaterialUtils.generateMaterialFromGtENUM(Materials.Europium)); } @@ -617,6 +655,8 @@ public final class ModItems { itemAirFilter = new ItemAirFilter(); itemLavaFilter = new ItemLavaFilter(); + itemGrindleTablet = new BaseItemGrindle(); + //Chemistry CoalTar.run(); @@ -658,7 +698,7 @@ public final class ModItems { itemPlatePulsatingIron = ItemUtils.generateSpecialUsePlate("itemPlate"+"PhasedIron", "Phased Iron", new short[]{50, 91, 21}, 0); itemPlateEnergeticAlloy = ItemUtils.generateSpecialUsePlate("itemPlate"+"EnergeticAlloy", "Energetic Alloy", new short[]{252, 152, 45}, 0); itemPlateVibrantAlloy = ItemUtils.generateSpecialUsePlate("itemPlate"+"VibrantAlloy", "Vibrant Alloy", new short[]{204, 242, 142}, 0); - itemPlateConductiveIron = ItemUtils.generateSpecialUsePlate("itemPlate"+"ConductiveIron", "Conductive Iron", new short[]{164, 109, 100}, 0); + itemPlateConductiveIron = ItemUtils.generateSpecialUsePlate("itemPlate"+"ConductiveIron", "Conductive Iron", new short[]{164, 109, 100}, 0); //Register dumb naming conventions - Who chose fucking phased Iron/Gold? GT_OreDictUnificator.registerOre("dustPhasedGold", ItemUtils.getSimpleStack(itemDustVibrantAlloy)); @@ -673,7 +713,7 @@ public final class ModItems { //Big Reactors if (LoadedMods.Big_Reactors|| LOAD_ALL_CONTENT){ Utils.LOG_INFO("BigReactors Found - Loading Resources."); - //Item Init + //Item Init itemPlateBlutonium = ItemUtils.generateSpecialUsePlate("itemPlate"+"Blutonium", "Blutonium", new short[]{0, 0, 255}, 0); itemPlateBlutonium = ItemUtils.generateSpecialUsePlate("itemPlate"+"Cyanite", "Cyanite", new short[]{0, 191, 255}, 0); itemPlateLudicrite = ItemUtils.generateSpecialUsePlate("itemPlate"+"Ludicrite", "Ludicrite", new short[]{167, 5, 179}, 0); @@ -688,7 +728,7 @@ public final class ModItems { //Item Init try { ItemUtils.getItemForOreDict("Thaumcraft:ItemResource", "ingotVoidMetal", "Void Metal Ingot", 16); - itemPlateVoidMetal = ItemUtils.generateSpecialUsePlate("itemPlate"+"Void", "Void", new short[]{82, 17, 82}, 0); + itemPlateVoidMetal = ItemUtils.generateSpecialUsePlate("itemPlate"+"Void", "Void", new short[]{82, 17, 82}, 0); GT_OreDictUnificator.registerOre("plateVoidMetal", new ItemStack(ModItems.itemPlateVoidMetal)); } catch (final NullPointerException e){ e.getClass(); @@ -738,7 +778,7 @@ public final class ModItems { if (LoadedMods.RFTools|| LOAD_ALL_CONTENT){ Utils.LOG_INFO("rfTools Found - Loading Resources."); //Item Init - itemPlateDimensionShard = ItemUtils.generateSpecialUsePlate("itemPlate"+"DimensionShard", "Dimensional Shard", new short[]{170, 230, 230}, 0); + itemPlateDimensionShard = ItemUtils.generateSpecialUsePlate("itemPlate"+"DimensionShard", "Dimensional Shard", new short[]{170, 230, 230}, 0); } else { Utils.LOG_WARNING("rfTools not Found - Skipping Resources."); @@ -806,7 +846,7 @@ public final class ModItems { //ItemBlockGtFrameBox = new ItemBlockGtFrameBox(ModBlocks.blockGtFrameSet1); //GameRegistry.registerItem(ItemBlockGtFrameBox, "itemGtFrameBoxSet1"); - + itemCustomBook = new ItemBaseBook(); } } diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java deleted file mode 100644 index 372539ca7d..0000000000 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockBase.java +++ /dev/null @@ -1,21 +0,0 @@ -package gtPlusPlus.core.item.base.itemblock; - -import gtPlusPlus.core.creative.AddToCreativeTab; -import net.minecraft.block.Block; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; - -public class ItemBlockBase extends ItemBlock { - - public ItemBlockBase(final Block block) { - super(block); - this.setCreativeTab(AddToCreativeTab.tabBlock); - } - - @Override - public int getColorFromItemStack(final ItemStack p_82790_1_, final int p_82790_2_) { - return super.getColorFromItemStack(p_82790_1_, p_82790_2_); - } - - -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java new file mode 100644 index 0000000000..b13e6b22bc --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java @@ -0,0 +1,41 @@ +package gtPlusPlus.core.item.base.itemblock; + +import java.util.List; + +import gtPlusPlus.core.block.general.BlockTankXpConverter; +import gtPlusPlus.core.creative.AddToCreativeTab; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +public class ItemBlockEntityBase extends ItemBlock { + + public ItemBlockEntityBase(final Block block) { + super(block); + this.setMaxDamage(0); + this.setHasSubtypes(true); + this.setCreativeTab(AddToCreativeTab.tabMachines); + } + + @Override + public int getColorFromItemStack(final ItemStack p_82790_1_, final int p_82790_2_) { + return super.getColorFromItemStack(p_82790_1_, p_82790_2_); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public final void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter){ + list.add(EnumChatFormatting.GRAY+"Can convert Liquid Xp to Mob Essence and back."); + list.add(EnumChatFormatting.GRAY+"Right click with a Screwdriver to change mode."); + } + else if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter){ + //list.add(EnumChatFormatting.GRAY+"A pile of " + materialName + " dust."); + } + super.addInformation(stack, aPlayer, list, bool); + } + + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java new file mode 100644 index 0000000000..9cf3f796df --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockMeta.java @@ -0,0 +1,44 @@ +package gtPlusPlus.core.item.base.itemblock; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlockWithMetadata; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +public class ItemBlockMeta extends ItemBlockWithMetadata +{ + private final Block mBlock; + + public ItemBlockMeta(final Block p_i45326_1_) + { + super(p_i45326_1_, p_i45326_1_); + this.mBlock = p_i45326_1_; + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + /** + * Gets an icon index based on an item's damage value + */ + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage(final int p_77617_1_) + { + return this.mBlock.getIcon(2, p_77617_1_); + } + + /** + * Returns the metadata of the block which this Item (ItemBlock) can place + */ + @Override + public int getMetadata(final int p_77647_1_) + { + return p_77647_1_; + } + + @Override + public String getUnlocalizedName(final ItemStack stack) { + return this.getUnlocalizedName() + "." + stack.getItemDamage(); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockTileEntity.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockTileEntity.java deleted file mode 100644 index 7a5f20833f..0000000000 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockTileEntity.java +++ /dev/null @@ -1,43 +0,0 @@ -package gtPlusPlus.core.item.base.itemblock; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -public class ItemBlockTileEntity extends ItemBlock{ - - String[] description; - - public ItemBlockTileEntity(final Block block) { - super(block); - } - - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - for (int i =0; i< this.description.length; i++){ - if (!this.description[i].equals("")){ - list.add(this.description[i]); - } - } - - - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, final boolean p_77663_5_) { - - } - - public void setDecription(final String[] description){ - for (int i =0; i< description.length; i++){ - this.description[i] = description[i]; - } - } - -} diff --git a/src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java b/src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java index 0e7df1703c..de12a77c27 100644 --- a/src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java +++ b/src/Java/gtPlusPlus/core/item/bauble/ModularBauble.java @@ -36,7 +36,6 @@ public class ModularBauble extends BaseBauble { private IIcon mTextureRing; @SideOnly(Side.CLIENT) private IIcon mTextureBelt; - @SideOnly(Side.CLIENT) private IIcon iconArray[] = new IIcon[3]; @SideOnly(Side.CLIENT) private IIcon mfallback; @@ -342,6 +341,7 @@ public class ModularBauble extends BaseBauble { }*/ @Override + @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int meta) { if (meta < this.iconArray.length && this.iconArray[meta] != null){ return this.iconArray[meta]; diff --git a/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java b/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java new file mode 100644 index 0000000000..66fd6968e4 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java @@ -0,0 +1,87 @@ +package gtPlusPlus.core.item.general; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.ItemUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class BaseItemGrindle extends Item{ + + protected final String unlocalName; + + + public BaseItemGrindle(){ + this.unlocalName = "itemGrindleTablet"; + this.setUnlocalizedName("itemGrindleTablet"); + this.setTextureName(CORE.MODID + ":" + "itemTablet"); + GameRegistry.registerItem(this, "itemGrindleTablet"); + GT_OreDictUnificator.registerOre("tabletGit", ItemUtils.getSimpleStack(this)); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabOther); + } + + @Override + public int getMaxItemUseDuration(final ItemStack stack) { + return 1; + } + + @Override + public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) + { + if (!world.isRemote){ + if (!player.isSneaking()) { + player.openGui(GTplusplus.instance, GuiHandler.GUI9, world, 0, 0, 0); + } + } + + return itemstack; + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return ("Git"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + "itemTablet"); + } + + @Override + public String getPotionEffect(ItemStack p_150896_1_) { + // TODO Auto-generated method stub + return super.getPotionEffect(p_150896_1_); + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, + List p_77624_3_, boolean p_77624_4_) { + // TODO Auto-generated method stub + super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); + } + + @Override + public EnumRarity getRarity(ItemStack i) { + return EnumRarity.uncommon; + } + + @Override + public boolean isRepairable() { + return false; + } +} diff --git a/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java b/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java index 8c4a262c32..fe0405d175 100644 --- a/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java +++ b/src/Java/gtPlusPlus/core/item/general/books/ItemBaseBook.java @@ -2,18 +2,21 @@ package gtPlusPlus.core.item.general.books; import static gtPlusPlus.core.handler.BookHandler.mBookMap; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.nbt.NBTUtils; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreenBook; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -96,6 +99,7 @@ public class ItemBaseBook extends ItemWritableBook{ } @Override + @SideOnly(Side.CLIENT) public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { //player.displayGUIBook(item); int i = item.getItemDamage(); @@ -106,7 +110,16 @@ public class ItemBaseBook extends ItemWritableBook{ mBookMap.get(i).mPages); if (player.worldObj.isRemote){ - Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(player, bookstack, false)); + try { + Class<?> clazz = Class.forName("net.minecraft.client.gui.GuiScreenBook"); + Constructor<?> ctor = clazz.getConstructor(EntityPlayer.class, ItemStack.class, boolean.class); + Object object = ctor.newInstance(new Object[] { player, bookstack, false }); + Minecraft.getMinecraft().displayGuiScreen((GuiScreen) object); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(player, bookstack, false)); } return item; } diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index 95c4c7e84a..76a65ca4fe 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -1,6 +1,11 @@ package gtPlusPlus.core.lib; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import com.mojang.authlib.GameProfile; @@ -35,7 +40,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.6.70-release"; + public static final String VERSION = "1.6.97-release"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); @@ -77,7 +82,7 @@ public class CORE { //Book List public static final Map<String, ItemStack> sBookList = new ConcurrentHashMap<String, ItemStack>(); - + /** * File Paths and Resource Paths */ @@ -164,6 +169,7 @@ public class CORE { public static boolean enableMultiblock_IndustrialWashPlant = true; public static boolean enableMultiblock_LargeAutoCrafter = true; public static boolean enableMultiblock_ThermalBoiler = true; + public static boolean enableMultiblock_IndustrialCuttingMachine = true; //Visuals public static boolean enableTreeFarmerParticles = true; @@ -171,6 +177,7 @@ public class CORE { + } } diff --git a/src/Java/gtPlusPlus/core/lib/LoadedMods.java b/src/Java/gtPlusPlus/core/lib/LoadedMods.java index d97b41641d..dda50a0d84 100644 --- a/src/Java/gtPlusPlus/core/lib/LoadedMods.java +++ b/src/Java/gtPlusPlus/core/lib/LoadedMods.java @@ -45,6 +45,7 @@ public class LoadedMods { public static boolean PamsHarvestcraft = false; public static boolean GalacticraftCore = false; public static boolean Mekanism = false; + public static boolean RedTech = false; @@ -242,8 +243,13 @@ public class LoadedMods { Utils.LOG_INFO("Components disabled for: Computronics - This feature will enable itself if you remove Computronics."); totalMods++; } + if (Loader.isModLoaded("GTRedtech") == true){ + RedTech = true; + Utils.LOG_INFO("Components enabled for: GTRedtech"); + totalMods++; + } else { - Utils.LOG_INFO("Components enabled for: Computronics - This feature will disable itself if you add Computronics."); + Utils.LOG_INFO("Components enabled for: Computronics - This feature will disable itself if you add Computronics."); } Utils.LOG_INFO("Content found for "+totalMods+" mods"); diff --git a/src/Java/gtPlusPlus/core/material/MaterialGenerator.java b/src/Java/gtPlusPlus/core/material/MaterialGenerator.java index 0b6848846b..6e529b3e92 100644 --- a/src/Java/gtPlusPlus/core/material/MaterialGenerator.java +++ b/src/Java/gtPlusPlus/core/material/MaterialGenerator.java @@ -19,8 +19,15 @@ import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; -import gtPlusPlus.xmod.gregtech.loaders.*; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_AlloySmelter; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Assembler; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_BlastSmelter; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_DustGeneration; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Extruder; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Fluids; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Plates; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_ShapedCrafting; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -49,7 +56,7 @@ public class MaterialGenerator { } int sRadiation = 0; - if (ItemUtils.isRadioactive(materialName) || matInfo.vRadiationLevel != 0){ + if (ItemUtils.isRadioactive(materialName) || (matInfo.vRadiationLevel != 0)){ sRadiation = matInfo.vRadiationLevel; } @@ -121,7 +128,7 @@ public class MaterialGenerator { temp = new BaseItemNugget(matInfo); temp = new BaseItemPlate(matInfo); temp = new BaseItemPlateDouble(matInfo); - } + } else if (matInfo.getState() == MaterialState.PURE_LIQUID){ FluidUtils.generateFluidNoPrefix(unlocalizedName, materialName, matInfo.getMeltingPointK(), C); return true; @@ -138,8 +145,9 @@ public class MaterialGenerator { RecipeGen_Fluids.generateRecipes(matInfo); RecipeGen_Plates.generateRecipes(matInfo); RecipeGen_ShapedCrafting.generateRecipes(matInfo); + RecipeGen_Recycling.generateRecipes(matInfo); return true; - } catch (Throwable t) + } catch (final Throwable t) { Utils.LOG_INFO(""+matInfo.getLocalizedName()+" failed to generate."); return false; @@ -158,7 +166,7 @@ public class MaterialGenerator { } int sRadiation = 0; - if (ItemUtils.isRadioactive(materialName) || matInfo.vRadiationLevel != 0){ + if (ItemUtils.isRadioactive(materialName) || (matInfo.vRadiationLevel != 0)){ sRadiation = matInfo.vRadiationLevel; } @@ -172,6 +180,7 @@ public class MaterialGenerator { //Add A jillion Recipes - old code RecipeGen_DustGeneration.addMixerRecipe_Standalone(matInfo); RecipeGen_Fluids.generateRecipes(matInfo); + //RecipeGen_Recycling.generateRecipes(matInfo); } public static void generateNuclearMaterial(final Material matInfo){ @@ -209,7 +218,8 @@ public class MaterialGenerator { RecipeGen_Fluids.generateRecipes(matInfo); RecipeGen_Assembler.generateRecipes(matInfo); RecipeGen_DustGeneration.generateRecipes(matInfo, true); - } catch (Throwable t){ + RecipeGen_Recycling.generateRecipes(matInfo); + } catch (final Throwable t){ Utils.LOG_INFO(""+matInfo.getLocalizedName()+" failed to generate."); } } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index 427eb19c9a..365218e28e 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -1,8 +1,16 @@ package gtPlusPlus.core.recipe; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; -import gregtech.api.util.*; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.HotFuel; +import gregtech.api.util.ThermalFuel; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; @@ -52,8 +60,10 @@ public class RECIPES_GREGTECH { cyclotronRecipes(); blastSmelterRecipes(); advancedMixerRecipes(); + sifterRecipes(); + electroMagneticSeperatorRecipes(); addFuels(); - } + } private static void blastSmelterRecipes() { @@ -63,9 +73,9 @@ public class RECIPES_GREGTECH { ItemUtils.getGregtechCircuit(13), ItemUtils.getItemStackOfAmountFromOreDict("dustGold", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSilver", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 3), + ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 3), }, - FluidUtils.getFluidStack("molten.blackbronze", 5*144), + FluidUtils.getFluidStack("molten.blackbronze", 5*144), 0, MathUtils.findPercentageOfInt(200*20, 80), 120); @@ -78,9 +88,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustSteel", 15), ItemUtils.getItemStackOfAmountFromOreDict("dustGold", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSilver", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 3) + ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 3) }, - FluidUtils.getFluidStack("molten.blacksteel", 25*144), + FluidUtils.getFluidStack("molten.blacksteel", 25*144), 0, MathUtils.findPercentageOfInt(60*20, 80), 120); @@ -94,9 +104,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustZinc", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustBismuth", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSteel", 10), - ItemUtils.getItemStackOfAmountFromOreDict("dustBlackSteel", 20) + ItemUtils.getItemStackOfAmountFromOreDict("dustBlackSteel", 20) }, - FluidUtils.getFluidStack("molten.redsteel", 40*144), + FluidUtils.getFluidStack("molten.redsteel", 40*144), 0, MathUtils.findPercentageOfInt(65*20, 80), 120); @@ -109,10 +119,10 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustCopper", 18), ItemUtils.getItemStackOfAmountFromOreDict("dustZinc", 5), ItemUtils.getItemStackOfAmountFromOreDict("dustSteel", 30), - ItemUtils.getItemStackOfAmountFromOreDict("dustBlackSteel", 60) + ItemUtils.getItemStackOfAmountFromOreDict("dustBlackSteel", 60) }, - FluidUtils.getFluidStack("molten.bluesteel", 125*144), + FluidUtils.getFluidStack("molten.bluesteel", 125*144), 0, MathUtils.findPercentageOfInt(70*20, 80), 120); @@ -122,9 +132,9 @@ public class RECIPES_GREGTECH { new ItemStack[]{ ItemUtils.getGregtechCircuit(2), ItemUtils.getItemStackOfAmountFromOreDict("ingotTungsten", 1), - ItemUtils.getItemStackOfAmountFromOreDict("ingotSteel", 1) + ItemUtils.getItemStackOfAmountFromOreDict("ingotSteel", 1) }, - FluidUtils.getFluidStack("molten.tungstensteel", 2*144), + FluidUtils.getFluidStack("molten.tungstensteel", 2*144), 0, MathUtils.findPercentageOfInt(300*20, 80), 120); @@ -136,9 +146,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 6), ItemUtils.getItemStackOfAmountFromOreDict("dustNickel", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustManganese", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 1) + ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 1) }, - FluidUtils.getFluidStack("molten.stainlesssteel", 9*144), + FluidUtils.getFluidStack("molten.stainlesssteel", 9*144), 0, MathUtils.findPercentageOfInt(85*20, 80), 120); @@ -153,9 +163,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSulfur", 3), ItemUtils.getItemStackOfAmountFromOreDict("dustCarbon", 3), - ItemUtils.getItemStackOfAmountFromOreDict("dustSilicon", 12) + ItemUtils.getItemStackOfAmountFromOreDict("dustSilicon", 12) }, - FluidUtils.getFluidStack("molten.eglinsteel", 48*144), + FluidUtils.getFluidStack("molten.eglinsteel", 48*144), 0, MathUtils.findPercentageOfInt(30*20, 80), 120); @@ -167,9 +177,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustTungstenSteel", 5), ItemUtils.getItemStackOfAmountFromOreDict("dustVanadium", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustMolybdenum", 2), - ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 1) + ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 1) }, - FluidUtils.getFluidStack("molten.hssg", 9*144), + FluidUtils.getFluidStack("molten.hssg", 9*144), 0, MathUtils.findPercentageOfInt(450*20, 80), 120); @@ -182,9 +192,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustSteel", 5), ItemUtils.getItemStackOfAmountFromOreDict("dustVanadium", 2), ItemUtils.getItemStackOfAmountFromOreDict("dustMolybdenum", 4), - ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 2) + ItemUtils.getItemStackOfAmountFromOreDict("dustChrome", 2) }, - FluidUtils.getFluidStack("molten.hssg", 18*144), + FluidUtils.getFluidStack("molten.hssg", 18*144), 0, MathUtils.findPercentageOfInt(900*20, 80), 120); @@ -196,9 +206,9 @@ public class RECIPES_GREGTECH { ItemUtils.getItemStackOfAmountFromOreDict("dustHSSG", 6), ItemUtils.getItemStackOfAmountFromOreDict("dustCobalt", 1), ItemUtils.getItemStackOfAmountFromOreDict("dustSilicon", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustManganese", 1) + ItemUtils.getItemStackOfAmountFromOreDict("dustManganese", 1) }, - FluidUtils.getFluidStack("molten.hsse", 9*144), + FluidUtils.getFluidStack("molten.hsse", 9*144), 0, MathUtils.findPercentageOfInt(540*20, 80), 120); @@ -209,20 +219,158 @@ public class RECIPES_GREGTECH { ItemUtils.getGregtechCircuit(3), ItemUtils.getItemStackOfAmountFromOreDict("dustHSSG", 6), ItemUtils.getItemStackOfAmountFromOreDict("dustOsmium", 1), - ItemUtils.getItemStackOfAmountFromOreDict("dustIridium", 2) + ItemUtils.getItemStackOfAmountFromOreDict("dustIridium", 2) }, - FluidUtils.getFluidStack("molten.hsss", 9*144), + FluidUtils.getFluidStack("molten.hsss", 9*144), 0, MathUtils.findPercentageOfInt(810*20, 80), 120); + //Osmiridium + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustIridium", 3), + ItemUtils.getItemStackOfAmountFromOreDict("dustOsmium", 1) + }, + Materials.Helium.getGas(1000), + FluidUtils.getFluidStack("molten.osmiridium", 4*144), + 0, + MathUtils.findPercentageOfInt(500*20, 80), + 1920); + + //Naq Alloy + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustNaquadah", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustOsmiridium", 1) + }, + Materials.Argon.getGas(1000), + FluidUtils.getFluidStack("molten.naquadahalloy", 2*144), + 0, + MathUtils.findPercentageOfInt(500*20, 80), + 30720); + + //Nickel-Zinc-Ferrite + if (Materials.get("NickelZincFerrite") != null){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustFerriteMixture", 6) + }, + Materials.Oxygen.getGas(2000), + FluidUtils.getFluidStack("molten.nickelzincferrite", 2*144), + 0, + MathUtils.findPercentageOfInt(600*20, 80), + 120); + } + + //Gallium-Arsenide + if (Materials.get("GalliumArsenide") != null){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustGallium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustArsenic", 1) + }, + FluidUtils.getFluidStack("molten.galliumarsenide", 2*144), + 0, + MathUtils.findPercentageOfInt(600*20, 80), + 120); + } + + //TungstenCarbide + if (Materials.get("TungstenCarbide") != null){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(12), + ItemUtils.getItemStackOfAmountFromOreDict("dustTungsten", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustCarbon", 1) + }, + FluidUtils.getFluidStack("molten.tungstencarbide", 2*144), + 0, + MathUtils.findPercentageOfInt((int) Math.max(Materials.TungstenCarbide.getMass() / 40L, 1L) * Materials.TungstenCarbide.mBlastFurnaceTemp, 80), + 480); + } + + + //Vanadium-Gallium + if (Materials.get("VanadiumGallium") != null){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(12), + ItemUtils.getItemStackOfAmountFromOreDict("dustGallium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustVanadium", 3) + }, + FluidUtils.getFluidStack("molten.vanadiumgallium", 4*144), + 0, + MathUtils.findPercentageOfInt((int) Math.max(Materials.VanadiumGallium.getMass() / 40L, 1L) * Materials.VanadiumGallium.mBlastFurnaceTemp, 80), + 480); + } + + //EIO + //Dark Steel + if (ItemUtils.getItemStackOfAmountFromOreDict("dustElectricalSteel", 1) != ItemUtils.getSimpleStack(ModItems.AAA_Broken)){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustElectricalSteel", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustObsidian", 1) + }, + FluidUtils.getFluidStack("molten.darksteel", 2*144), + 0, + MathUtils.findPercentageOfInt(200*20, 80), + 120); + } + //Pulsating Iron + if (ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 1) != ItemUtils.getSimpleStack(ModItems.AAA_Broken)){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(2), + ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 1), + ItemUtils.getSimpleStack(Items.ender_pearl) + }, + FluidUtils.getFluidStack("molten.pulsatingiron", 2*144), + 0, + MathUtils.findPercentageOfInt(8*20, 80), + 120); + } + //Energetic Alloy + if (ItemUtils.getItemStackOfAmountFromOreDict("dustEnergeticAlloy", 1) != ItemUtils.getSimpleStack(ModItems.AAA_Broken)){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(12), + ItemUtils.getItemStackOfAmountFromOreDict("dustIron", 1), + ItemUtils.getSimpleStack(Items.glowstone_dust) + }, + FluidUtils.getFluidStack("molten.redstone", 144), + FluidUtils.getFluidStack("molten.energeticalloy", 144), + 0, + MathUtils.findPercentageOfInt(9*20, 80), + 120); + } + //Vibrant Alloy + if (ItemUtils.getItemStackOfAmountFromOreDict("dustVibrantAlloy", 1) != ItemUtils.getSimpleStack(ModItems.AAA_Broken)){ + CORE.RA.addBlastSmelterRecipe( + new ItemStack[]{ + ItemUtils.getGregtechCircuit(12), + ItemUtils.getItemStackOfAmountFromOreDict("dustEnergeticAlloy", 1), + ItemUtils.getSimpleStack(Items.ender_pearl) + }, + FluidUtils.getFluidStack("molten.vibrantalloy", 144), + 0, + MathUtils.findPercentageOfInt(16*20, 80), + 480); + } + } private static void fluidcannerRecipes() { //Sulfuric Acid GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), FluidUtils.getFluidStack("sulfuricacid", 250), null); - GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("sulfuricacid", 250)); - + GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemSulfuricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("sulfuricacid", 250)); + //Hydrofluoric Acid GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(Items.glass_bottle), ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), FluidUtils.getFluidStack("hydrofluoricacid", 250), null); GT_Values.RA.addFluidCannerRecipe(ItemUtils.getSimpleStack(ModItems.itemHydrofluoricPotion), ItemUtils.getSimpleStack(Items.glass_bottle), null, FluidUtils.getFluidStack("hydrofluoricacid", 250)); @@ -237,7 +385,7 @@ public class RECIPES_GREGTECH { 20, GT_ModHandler.getSteam(1000), GT_OreDictUnificator.get(OrePrefixes.gem, Materials.Charcoal, 24L), - FluidUtils.getFluidStack("fluid.coalgas", 1440), + FluidUtils.getFluidStack("fluid.coalgas", 1440), 60, 30); @@ -247,7 +395,7 @@ public class RECIPES_GREGTECH { 22, GT_ModHandler.getSteam(1000), ItemUtils.getItemStackOfAmountFromOreDict("fuelCoke", 10), - FluidUtils.getFluidStack("fluid.coalgas", 2880), + FluidUtils.getFluidStack("fluid.coalgas", 2880), 30, 120); @@ -608,12 +756,12 @@ public class RECIPES_GREGTECH { addAR(ItemUtils.getItemStackOfAmountFromOreDict("plateIncoloy020", 16), ItemUtils.getItemStackOfAmountFromOreDict("frameGtIncoloyMA956", 4), null, GregtechItemList.Casing_Power_SubStation.get(4), 80, 128); } - private static boolean addAR(ItemStack inputA, ItemStack inputB, ItemStack outputA, int seconds, int voltage){ + private static boolean addAR(final ItemStack inputA, final ItemStack inputB, final ItemStack outputA, final int seconds, final int voltage){ //return GT_Values.RA.addAssemblerRecipe(inputA, inputB, outputA, seconds*20, voltage); return addAR(inputA, inputB, null, outputA, seconds*20, voltage); } - private static boolean addAR(ItemStack inputA, ItemStack inputB, FluidStack inputFluidA, ItemStack outputA, int seconds, int voltage){ + private static boolean addAR(final ItemStack inputA, final ItemStack inputB, final FluidStack inputFluidA, final ItemStack outputA, final int seconds, final int voltage){ //return GT_Values.RA.addAssemblerRecipe(inputA, inputB, outputA, seconds*20, voltage); return GT_Values.RA.addAssemblerRecipe(inputA, inputB, inputFluidA, outputA, seconds*20, voltage); } @@ -702,6 +850,7 @@ public class RECIPES_GREGTECH { new int[]{}, 0);*/ + ThermalFuel.addSteamTurbineFuel(FluidUtils.getFluidStack("steam", 1024)); //CORE.RA.addFuel(UtilsItems.simpleMetaStack("EnderIO:bucketRocket_fuel", 0, 1), null, 112, 0); GT_Values.RA.addFuel(ItemUtils.getSimpleStack(Items.lava_bucket), null, 32, 2); @@ -950,12 +1099,55 @@ public class RECIPES_GREGTECH { FluidUtils.getFluidStack("molten.bismuth", 1), new ItemStack[]{GregtechItemList.Pellet_RTG_PO210.get(1)}, null, - new int[]{100}, - 20*300, - 2040, - 500*20); + new int[]{100}, + 20*300, + 2040, + 500*20); } - + + private static void sifterRecipes() { + //Zirconium + GT_Values.RA.addSifterRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedTin", 1), + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict("dustTin", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyZinc", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1) + }, + new int[]{10000, 5000, 1500, 1000, 500, 500}, + 20*30, + 60); + + //Zirconium + GT_Values.RA.addSifterRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedCassiterite", 1), + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDict("dustCassiterite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustTinyTin", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustZirconium", 1) + }, + new int[]{10000, 5000, 1500, 1000, 500, 500}, + 20*30, + 60); + } + + private static void electroMagneticSeperatorRecipes(){ + GT_Values.RA.addElectromagneticSeparatorRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("crushedPurifiedBauxite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustBauxite", 1), + ItemUtils.getItemStackOfAmountFromOreDict("dustSmallRutile", 1), + ItemUtils.getItemStackOfAmountFromOreDict("nuggetZirconium", 1), + new int[]{10000, 2500, 4000}, + 20*20, + 24); + } + private static void advancedMixerRecipes(){ //HgBa2Ca2Cu3O8 CORE.RA.addMixerRecipe( diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java index 67b9107b28..4304fdaff5 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_General.java @@ -1,28 +1,22 @@ package gtPlusPlus.core.recipe; +import static gtPlusPlus.core.util.item.ItemUtils.getSimpleStack; + import cpw.mods.fml.common.registry.GameRegistry; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.ModItems; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.recipe.RecipeUtils; -import gtPlusPlus.core.util.reflect.AddGregtechRecipe; -import gtPlusPlus.core.world.darkworld.Dimension_DarkWorld; import gtPlusPlus.xmod.bop.blocks.BOP_Block_Registrator; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; public class RECIPES_General { @@ -44,6 +38,7 @@ public class RECIPES_General { if (LoadedMods.Gregtech){ RECIPE_BasicCasingIC2 = ItemUtils.getItemStack("IC2:blockMachine", 1); run(); + addCompressedObsidian(); } } @@ -102,18 +97,18 @@ public class RECIPES_General { "stickWood", "treeSapling", "stickWood", "stickWood", "dustBone", "stickWood", ItemUtils.getSimpleStack(BOP_Block_Registrator.sapling_Rainforest))){ - Utils.LOG_INFO("Added a recipe for Rainforest oak Saplings."); + Utils.LOG_INFO("Added a recipe for Rainforest oak Saplings."); } //Iron bars - ItemStack ironBars = ItemUtils.getItemStack("minecraft:iron_bars", 1); + final ItemStack ironBars = ItemUtils.getItemStack("minecraft:iron_bars", 1); //Fish Trap if (RecipeUtils.recipeBuilder( ironBars, ironBars, ironBars, ironBars, "frameGtWroughtIron", ironBars, ironBars, ironBars, ironBars, ItemUtils.getSimpleStack(ModBlocks.blockFishTrap))){ - Utils.LOG_INFO("Added a recipe for the Fish Trap."); + Utils.LOG_INFO("Added a recipe for the Fish Trap."); } //Alkalus Coin @@ -122,17 +117,17 @@ public class RECIPES_General { "gemFlawlessRuby", ItemList.Credit_Greg_Naquadah.get(1), "gemFlawlessSapphire", "gemExquisiteEmerald", "gemFlawlessEmerald", "gemExquisiteSapphire", ItemUtils.getSimpleStack(ModItems.itemAlkalusDisk))){ - Utils.LOG_INFO("Added a recipe for The Alkalus Disk."); + Utils.LOG_INFO("Added a recipe for The Alkalus Disk."); } - String fancyGems[] = new String[]{"gemExquisiteDiamond", "gemExquisiteEmerald", "gemExquisiteRuby", "gemExquisiteSapphire"}; - ItemStack gemShards[] = new ItemStack[]{ItemUtils.simpleMetaStack(ModItems.itemGemShards, 0, 1), + final String fancyGems[] = new String[]{"gemExquisiteDiamond", "gemExquisiteEmerald", "gemExquisiteRuby", "gemExquisiteSapphire"}; + final ItemStack gemShards[] = new ItemStack[]{ItemUtils.simpleMetaStack(ModItems.itemGemShards, 0, 1), ItemUtils.simpleMetaStack(ModItems.itemGemShards, 1, 1), ItemUtils.simpleMetaStack(ModItems.itemGemShards, 2, 1), ItemUtils.simpleMetaStack(ModItems.itemGemShards, 3, 1)}; - + int l=0; - for (String gem : fancyGems){ + for (final String gem : fancyGems){ GameRegistry.addShapelessRecipe( gemShards[l], ItemUtils.getItemStackOfAmountFromOreDict(gem, 1), @@ -140,7 +135,19 @@ public class RECIPES_General { l++; } - //Alkalus Coin + RecipeUtils.addShapedGregtechRecipe( + "stickBlackSteel", "plateTungstenSteel", "stickBlackSteel", + "plateTungstenSteel", getSimpleStack(Items.nether_star), "plateTungstenSteel", + "stickBlackSteel", "plateTungstenSteel", "stickBlackSteel", + ItemUtils.getSimpleStack(ModBlocks.blockWitherGuard, 32)); + + RecipeUtils.addShapedGregtechRecipe( + getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 2, 1), getSimpleStack(Items.experience_bottle), + ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1), getSimpleStack(Items.nether_star), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1), + getSimpleStack(Items.experience_bottle), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 2, 1), getSimpleStack(Items.experience_bottle), + ItemUtils.getSimpleStack(ModBlocks.blockXpConverter, 1)); + + //Alkalus Coin /*AddGregtechRecipe.addAssemblylineRecipe( ItemUtils.getSimpleStack(ModItems.itemAlkalusDisk), 288000, @@ -154,16 +161,73 @@ public class RECIPES_General { GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Superconductor, 16L), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Superconductor, 16L), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Superconductor, 16L), - GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NiobiumTitanium, 2L)}, + GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.NiobiumTitanium, 2L)}, new FluidStack[]{ Materials.Osmium.getMolten(144*32), Materials.Europium.getFluid(144*8)}, ItemUtils.getSimpleStack(Dimension_DarkWorld.portalItem), 30*20*60, 100000);*/ - + + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDictNoBroken(CI.craftingToolKnife, 1), ItemUtils.getSimpleStack(Items.reeds)}, + ItemUtils.getSimpleStack(ModItems.itemFiber, 16) + ); + + RecipeUtils.addShapelessGregtechRecipe( + new ItemStack[]{ + ItemUtils.getItemStackOfAmountFromOreDictNoBroken(CI.craftingToolKnife, 1), ItemUtils.getSimpleStack(Blocks.sapling)}, + ItemUtils.getSimpleStack(ModItems.itemFiber, 32) + ); + + RecipeUtils.recipeBuilder( + null, ItemUtils.getSimpleStack(ModItems.itemFiber, 1), null, + ItemUtils.getSimpleStack(ModItems.itemFiber, 1), CI.craftingToolKnife, ItemUtils.getSimpleStack(ModItems.itemFiber, 1), + null, ItemUtils.getSimpleStack(ModItems.itemFiber, 1), null, + ItemUtils.getSimpleStack(ModItems.itemRope, 3)); + + RecipeUtils.recipeBuilder( + ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), + ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), ItemUtils.getSimpleStack(ModItems.itemRope, 1), + null, null, null, + ItemUtils.getSimpleStack(ModBlocks.blockNet, 2)); + + + } + + private static boolean addCompressedObsidian(){ + //Invert Obsidian + RecipeUtils.addShapedGregtechRecipe( + getSimpleStack(Items.redstone), getSimpleStack(Items.glowstone_dust), getSimpleStack(Items.redstone), + getSimpleStack(Items.glowstone_dust), ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 1, 1), getSimpleStack(Items.glowstone_dust), + getSimpleStack(Items.redstone), getSimpleStack(Items.glowstone_dust), getSimpleStack(Items.redstone), + ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, 5, 1)); + + final ItemStack[] mItems = new ItemStack[6]; + mItems[0] = ItemUtils.getSimpleStack(Blocks.obsidian); + for (int r=0;r<5;r++){ + mItems[r+1] = ItemUtils.simpleMetaStack(ModBlocks.blockCompressedObsidian, r, 1); } + //Compressed Obsidian 1-5 + for (int r=0;r<5;r++){ + + final ItemStack input = mItems[r]; + final ItemStack output = mItems[r+1]; + + RecipeUtils.addShapedGregtechRecipe( + input, input, input, + input, input, input, + input, input, input, + output); + + RecipeUtils.addShapelessGregtechRecipe(new ItemStack[]{output}, ItemUtils.getSimpleStack(input, 9)); + + } + return true; } +} + diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 5423dd24b3..2bc794de16 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -1062,6 +1062,53 @@ public class RECIPES_Machines { "plateStainlessSteel",CI.emitter_ULV,"plateStainlessSteel", ItemUtils.getSimpleStack(ModBlocks.blockProjectTable)); } + + //Wireless Chargers + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_LV, CI.circuitTier1, CI.emitter_LV, + CI.component_Plate[3], CI.machineHull_LV, CI.component_Plate[3], + CI.sensor_LV, CI.fieldGenerator_LV, CI.sensor_LV, + GregtechItemList.Charger_LV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_MV, CI.circuitTier2, CI.emitter_MV, + CI.component_Plate[4], CI.machineHull_MV, CI.component_Plate[4], + CI.sensor_MV, CI.fieldGenerator_MV, CI.sensor_MV, + GregtechItemList.Charger_MV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_HV, CI.circuitTier3, CI.emitter_HV, + CI.component_Plate[5], CI.machineHull_HV, CI.component_Plate[5], + CI.sensor_HV, CI.fieldGenerator_HV, CI.sensor_HV, + GregtechItemList.Charger_HV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_EV, CI.circuitTier4, CI.emitter_EV, + CI.component_Plate[6], CI.machineHull_EV, CI.component_Plate[6], + CI.sensor_EV, CI.fieldGenerator_EV, CI.sensor_EV, + GregtechItemList.Charger_EV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_IV, CI.circuitTier5, CI.emitter_IV, + CI.component_Plate[7], CI.machineHull_IV, CI.component_Plate[7], + CI.sensor_IV, CI.fieldGenerator_IV, CI.sensor_IV, + GregtechItemList.Charger_IV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_LuV, CI.circuitTier6, CI.emitter_LuV, + CI.component_Plate[8], CI.machineHull_LuV, CI.component_Plate[8], + CI.sensor_LuV, CI.fieldGenerator_LuV, CI.sensor_LuV, + GregtechItemList.Charger_LuV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_ZPM, CI.circuitTier7, CI.emitter_ZPM, + CI.component_Plate[9], CI.machineHull_ZPM, CI.component_Plate[9], + CI.sensor_ZPM, CI.fieldGenerator_ZPM, CI.sensor_ZPM, + GregtechItemList.Charger_ZPM.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_UV, CI.circuitTier8, CI.emitter_UV, + CI.component_Plate[10], CI.machineHull_UV, CI.component_Plate[10], + CI.sensor_UV, CI.fieldGenerator_UV, CI.sensor_UV, + GregtechItemList.Charger_UV.get(1)); + RecipeUtils.addShapedGregtechRecipe( + CI.emitter_MAX, CI.circuitTier9, CI.emitter_MAX, + CI.component_Plate[11], CI.machineHull_MAX, CI.component_Plate[11], + CI.sensor_MAX, CI.fieldGenerator_MAX, CI.sensor_MAX, + GregtechItemList.Charger_MAX.get(1)); } diff --git a/src/Java/gtPlusPlus/core/slots/SlotElectric.java b/src/Java/gtPlusPlus/core/slots/SlotElectric.java new file mode 100644 index 0000000000..6b11cf5264 --- /dev/null +++ b/src/Java/gtPlusPlus/core/slots/SlotElectric.java @@ -0,0 +1,43 @@ +package gtPlusPlus.core.slots; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GT_MetaGenerated_Tool; +import ic2.api.info.Info; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotElectric extends Slot { + + public SlotElectric(final IInventory inventory, final int x, final int y, final int z) { + super(inventory, x, y, z); + } + + public SlotElectric(IGregTechTileEntity mTileEntity, int i, int j, int k) { + this(mTileEntity.getIInventory(mTileEntity.getXCoord(), mTileEntity.getYCoord(), mTileEntity.getZCoord()), i, j, k); + } + + @Override + public boolean isItemValid(final ItemStack itemstack) { + if ((accepts(itemstack)) || (itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof IElectricItem)) { + return true; + } + return false; + } + + public boolean accepts(final ItemStack stack) { + if (stack == null) { + return false; + } + return (Info.itemEnergy.getEnergyValue(stack) > 0.0D) + || (ElectricItem.manager.discharge(stack, (1.0D / 0.0D), 4, true, true, true) > 0.0D); + } + + @Override + public int getSlotStackLimit() { + return 1; + } + +} diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java index 6dd948bcd1..87fb8ef76d 100644 --- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -1,26 +1,24 @@ package gtPlusPlus.core.tileentities; import cpw.mods.fml.common.registry.GameRegistry; -import gtPlusPlus.core.tileentities.general.*; +import gtPlusPlus.core.tileentities.general.TileEntityFirepit; +import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; +import gtPlusPlus.core.tileentities.general.TileEntityHeliumGenerator; +import gtPlusPlus.core.tileentities.general.TileEntityInfiniteFluid; +import gtPlusPlus.core.tileentities.general.TileEntityXpConverter; import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; import gtPlusPlus.core.tileentities.machines.TileEntityProjectTable; import gtPlusPlus.core.tileentities.machines.TileEntityTradeTable; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbench; import gtPlusPlus.core.tileentities.machines.TileEntityWorkbenchAdvanced; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastAlchemyFurnace; +import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastArcaneAlembic; public class ModTileEntities { public static void init() { Utils.LOG_INFO("Registering Tile Entities."); - // GameRegistry.registerTileEntity(TileEntityReverter.class, - // "TE_blockGriefSaver"); - // GameRegistry.registerTileEntity(TileEntityReverter.class, "Tower - // Reverter"); - // GameRegistry.registerTileEntity(TileEntityNHG.class, - // "NuclearFueledHeliumGenerator"); - // GameRegistry.registerTileEntity(TileEntityCharger.class, - // "TE_Charger"); GameRegistry.registerTileEntity(TileEntityHeliumGenerator.class, "HeliumGenerator"); GameRegistry.registerTileEntity(TileEntityWorkbench.class, "TileWorkbench"); GameRegistry.registerTileEntity(TileEntityWorkbenchAdvanced.class, "TileWorkbenchAdvanced"); @@ -30,6 +28,9 @@ public class ModTileEntities { GameRegistry.registerTileEntity(TileEntityProjectTable.class, "TileProjectTable"); GameRegistry.registerTileEntity(TileEntityTradeTable.class, "TileTradeTable"); GameRegistry.registerTileEntity(TileEntityModularityTable.class, "TileEntityModularityTable"); + GameRegistry.registerTileEntity(TileFastAlchemyFurnace.class, "TileFastAlchemyFurnace"); + GameRegistry.registerTileEntity(TileFastArcaneAlembic.class, "TileFastArcaneAlembic"); + GameRegistry.registerTileEntity(TileEntityXpConverter.class, "TileEntityXpConverter"); } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java index bd2f8b727c..d73de219e4 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java @@ -9,7 +9,6 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.xmod.gregtech.api.objects.XSTR; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -101,24 +100,24 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { int checkingSlot = 0; final ItemStack loot = this.generateLootForFishTrap().copy(); try { - //Utils.LOG_INFO("Trying to add "+loot.getDisplayName()+" | "+loot.getItemDamage()); + //Utils.LOG_WARNING("Trying to add "+loot.getDisplayName()+" | "+loot.getItemDamage()); for (final ItemStack contents : this.getInventory().getInventory()) { if (GT_Utility.areStacksEqual(loot, contents)){ if (contents.stackSize < contents.getMaxStackSize()) { - //Utils.LOG_INFO("3-Trying to add one more "+loot.getDisplayName()+"meta: "+loot.getItemDamage()+" to an existing stack of "+contents.getDisplayName()+" with a size of "+contents.stackSize); + //Utils.LOG_WARNING("3-Trying to add one more "+loot.getDisplayName()+"meta: "+loot.getItemDamage()+" to an existing stack of "+contents.getDisplayName()+" with a size of "+contents.stackSize); contents.stackSize++; this.markDirty(); - return true; + return true; } } checkingSlot++; } checkingSlot = 0; for (final ItemStack contents : this.getInventory().getInventory()) { - if (contents == null) { - //Utils.LOG_INFO("Adding Item To Empty Slot. "+(checkingSlot+1)); + if (contents == null) { + //Utils.LOG_WARNING("Adding Item To Empty Slot. "+(checkingSlot+1)); this.getInventory().setInventorySlotContents(checkingSlot, loot); this.markDirty(); return true; @@ -126,7 +125,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { checkingSlot++; } } - catch (NullPointerException n) { + catch (final NullPointerException n) { } } this.markDirty(); @@ -142,9 +141,12 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { else if (lootWeight <= 10) { loot = ItemUtils.getSimpleStack(Items.bone); } - else if (lootWeight <= 20) { + else if (lootWeight <= 15) { loot = ItemUtils.getSimpleStack(Blocks.sand); } + else if (lootWeight <= 20) { + loot = ItemUtils.simpleMetaStack(Items.dye, 0, 1); + } // Junk Loot else if (lootWeight <= 23) { if (LoadedMods.PamsHarvestcraft) { @@ -156,12 +158,12 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } // Pam Fish else if (lootWeight <= 99) { - Random xstr = new Random(); + final Random xstr = new Random(); loot = FishingHooks.getRandomFishable(xstr, 100); } else if (lootWeight == 100){ - int rareLoot = MathUtils.randInt(1, 10); + final int rareLoot = MathUtils.randInt(1, 10); if (rareLoot <= 4) { loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("nuggetIron", 1); if (loot == null){ @@ -173,7 +175,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { if (loot == null){ loot = ItemUtils.getItemStackOfAmountFromOreDictNoBroken("ingotGold", 1); } - } + } else if (rareLoot <= 9){ loot = ItemUtils.getSimpleStack(Items.emerald); } @@ -192,47 +194,47 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { @Override public void updateEntity() { try{ - if (!this.worldObj.isRemote) { - this.tickCount++; - // Utils.LOG_WARNING("Ticking "+this.tickCount); - // Check if the Tile is within water once per second. - if ((this.tickCount % 20) == 0) { - this.isInWater = this.isSurroundedByWater(); - } - else { - - } + if (!this.worldObj.isRemote) { + this.tickCount++; + // Utils.LOG_WARNING("Ticking "+this.tickCount); + // Check if the Tile is within water once per second. + if ((this.tickCount % 20) == 0) { + this.isInWater = this.isSurroundedByWater(); + } + else { - if (this.isInWater) { - this.calculateTickrate(); - } + } - // Try add some loot once every 30 seconds. - if ((this.tickCount % this.baseTickRate) == 0) { if (this.isInWater) { - // Add loot - // Utils.LOG_WARNING("Adding Loot to the fishtrap at - // x["+this.locationX+"] y["+this.locationY+"] - // z["+this.locationZ+"] (Ticking for loot every - // "+this.baseTickRate+" ticks)"); - this.tryAddLoot(); - this.markDirty(); + this.calculateTickrate(); } - else { - Utils.LOG_INFO("This Trap does not have enough water around it."); - Utils.LOG_WARNING("Not adding Loot to the fishtrap at x[" + this.locationX + "] y[" + this.locationY - + "] z[" + this.locationZ + "] (Ticking for loot every " + this.baseTickRate + " ticks)"); - this.markDirty(); + + // Try add some loot once every 30 seconds. + if ((this.tickCount % this.baseTickRate) == 0) { + if (this.isInWater) { + // Add loot + // Utils.LOG_WARNING("Adding Loot to the fishtrap at + // x["+this.locationX+"] y["+this.locationY+"] + // z["+this.locationZ+"] (Ticking for loot every + // "+this.baseTickRate+" ticks)"); + this.tryAddLoot(); + this.markDirty(); + } + else { + Utils.LOG_WARNING("This Trap does not have enough water around it."); + Utils.LOG_WARNING("Not adding Loot to the fishtrap at x[" + this.locationX + "] y[" + this.locationY + + "] z[" + this.locationZ + "] (Ticking for loot every " + this.baseTickRate + " ticks)"); + this.markDirty(); + } + this.tickCount = 0; + } + if (this.tickCount > (this.baseTickRate + 500)) { + this.tickCount = 0; } - this.tickCount = 0; - } - if (this.tickCount > (this.baseTickRate + 500)) { - this.tickCount = 0; - } + } } - } - catch (Throwable t){} + catch (final Throwable t){} } public void calculateTickrate() { @@ -293,13 +295,6 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { "Crayfish", "Eel", "Frog", "Grouper", "Herring", "Jellyfish", "Mudfish", "Octopus", "Perch", "Scallop", "Shrimp", "Snail", "Snapper", "Tilapia", "Trout", "Tuna", "Turtle", "Walleye" }; - private static final ItemStack[] minecraftFish = { - ItemUtils.simpleMetaStack(Items.fish, 0, 1).copy(), - ItemUtils.simpleMetaStack(Items.fish, 1, 1).copy(), - ItemUtils.simpleMetaStack(Items.fish, 2, 1).copy(), - ItemUtils.simpleMetaStack(Items.fish, 3, 1).copy() - }; - public static void pamsHarvestCraftCompat() { for (int i = 0; i < harvestcraftFish.length; i++) { @@ -312,22 +307,22 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } @Override - public ItemStack getStackInSlot(int slot) { + public ItemStack getStackInSlot(final int slot) { return this.getInventory().getStackInSlot(slot); } @Override - public ItemStack decrStackSize(int slot, int count) { + public ItemStack decrStackSize(final int slot, final int count) { return this.getInventory().decrStackSize(slot, count); } @Override - public ItemStack getStackInSlotOnClosing(int slot) { + public ItemStack getStackInSlotOnClosing(final int slot) { return this.getInventory().getStackInSlotOnClosing(slot); } @Override - public void setInventorySlotContents(int slot, ItemStack stack) { + public void setInventorySlotContents(final int slot, final ItemStack stack) { this.getInventory().setInventorySlotContents(slot, stack); } @@ -337,7 +332,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { + public boolean isUseableByPlayer(final EntityPlayer entityplayer) { return this.getInventory().isUseableByPlayer(entityplayer); } @@ -346,7 +341,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().openInventory(); + this.getInventory().openInventory(); } @Override @@ -354,17 +349,17 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1, 1); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType()); this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType()); - this.getInventory().closeInventory(); + this.getInventory().closeInventory(); } @Override - public boolean isItemValidForSlot(int slot, ItemStack itemstack) { + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) { return this.getInventory().isItemValidForSlot(slot, itemstack); } @Override - public int[] getAccessibleSlotsFromSide(int p_94128_1_) { - int[] accessibleSides = new int[this.getSizeInventory()]; + public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { + final int[] accessibleSides = new int[this.getSizeInventory()]; for (int r=0; r<this.getInventory().getSizeInventory(); r++){ accessibleSides[r]=r; } @@ -373,12 +368,12 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { } @Override - public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { return false; } @Override - public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { return true; } @@ -386,7 +381,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { return this.customName; } - public void setCustomName(String customName) { + public void setCustomName(final String customName) { this.customName = customName; } @@ -397,7 +392,7 @@ public class TileEntityFishTrap extends TileEntity implements ISidedInventory { @Override public boolean hasCustomInventoryName() { - return this.customName != null && !this.customName.equals(""); + return (this.customName != null) && !this.customName.equals(""); } } diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java new file mode 100644 index 0000000000..b886299afd --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java @@ -0,0 +1,317 @@ +package gtPlusPlus.core.tileentities.general; + +import org.lwjgl.input.Keyboard; + +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.enchanting.EnchantingUtils; +import gtPlusPlus.core.util.player.PlayerUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidEvent; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class TileEntityXpConverter extends TileEntity implements IFluidHandler { + + public FluidTank tankEssence = new FluidTank((int) (64000*EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)); + public FluidTank tankLiquidXp = new FluidTank(64000); + private boolean needsUpdate = false; + private boolean mConvertToEssence = true; + private int updateTimer = 0; + private long mTickTime = 0; + + public TileEntityXpConverter() { + } + + private void changeMode(){ + if (this.mConvertToEssence){ + this.mConvertToEssence = false; + return; + } + else { + this.mConvertToEssence = true; + return; + } + } + + private boolean isServerSide(){ + if (this.getWorldObj().isRemote){ + return false; + } + else { + return true; + } + } + + @Override + public int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) { + this.needsUpdate = true; + Utils.LOG_WARNING("Ticking. | mConvertToEssence: "+this.mConvertToEssence); + if (this.mConvertToEssence){ + if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){ + Utils.LOG_WARNING("fill(tankLiquidXp)"); + return this.tankLiquidXp.fill(resource, doFill); + } + else { + Utils.LOG_WARNING("Looking for Liquid Xp, Instead found "+resource.getLocalizedName()+"."); + } + } + else { + if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){ + Utils.LOG_WARNING("fill(tankEssence)"); + return this.tankEssence.fill(resource, doFill); + } + else { + Utils.LOG_WARNING("Looking for Essence, Instead found "+resource.getLocalizedName()+"."); + } + } + Utils.LOG_WARNING("fill(0)"); + return 0; + } + + @Override + public FluidStack drain(final ForgeDirection from, final FluidStack resource, final boolean doDrain) { + this.needsUpdate = true; + if (this.mConvertToEssence){ + if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){ + Utils.LOG_WARNING("drain(mConvertToEssence)"); + return this.tankEssence.drain(resource.amount, doDrain); + } + } + else { + if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){ + Utils.LOG_WARNING("drain(tankLiquidXp)"); + return this.tankLiquidXp.drain(resource.amount, doDrain); + } + } + Utils.LOG_WARNING("drain(null)"); + return null; + } + + @Override + public FluidStack drain(final ForgeDirection from, final int maxDrain, final boolean doDrain) { + this.needsUpdate = true; + Utils.LOG_WARNING("drain(Ex)"); + final FluidStack fluid_Essence = this.tankEssence.getFluid(); + final FluidStack fluid_Xp = this.tankLiquidXp.getFluid(); + if ((fluid_Essence == null) && (fluid_Xp == null)) { + return null; + } + + FluidStack fluid; + FluidTank tank; + + if (this.mConvertToEssence){ + fluid = fluid_Essence; + tank = this.tankEssence; + } + else { + fluid = fluid_Xp; + tank = this.tankLiquidXp; + } + + int drained = maxDrain; + if (fluid.amount < drained) { + drained = fluid.amount; + } + + final FluidStack stack = new FluidStack(fluid, drained); + if (doDrain) { + fluid.amount -= drained; + if (fluid.amount <= 0) { + fluid = null; + } + + if (this != null) { + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(fluid, this.getWorldObj(), this.xCoord, + this.yCoord, this.zCoord, tank, 0)); + } + } + + + if (this.mConvertToEssence){ + this.tankEssence = tank; + } + else { + this.tankLiquidXp = tank; + } + + Utils.LOG_WARNING("drain(Ex2)"); + return stack; + } + + @Override + public boolean canFill(final ForgeDirection from, final Fluid fluid) { + if (this.mConvertToEssence){ + if (this.tankEssence.getFluidAmount() < this.tankEssence.getCapacity()){ + Utils.LOG_WARNING("canFill(mConvertToEssence)"); + return true; + } + } + else { + if (this.tankLiquidXp.getFluidAmount() < this.tankLiquidXp.getCapacity()){ + Utils.LOG_WARNING("canFill(tankLiquidXp)"); + return true; + } + } + Utils.LOG_WARNING("canFill(false)"); + return false; + } + + @Override + public boolean canDrain(final ForgeDirection from, final Fluid fluid) { + if (this.mConvertToEssence){ + if (this.tankEssence.getFluidAmount() > 0){ + return true; + } + } + else { + if (this.tankLiquidXp.getFluidAmount() > 0){ + return true; + } + } + Utils.LOG_WARNING("canDrain(false)"); + return false; + } + + @Override + public FluidTankInfo[] getTankInfo(final ForgeDirection from) { + if (this.mConvertToEssence){ + return new FluidTankInfo[] { this.tankEssence.getInfo() }; + } + else { + return new FluidTankInfo[] { this.tankLiquidXp.getInfo() }; + } + } + + public float getAdjustedVolume() { + Utils.LOG_WARNING("AdjustedVolume()"); + this.needsUpdate = true; + final float amount = this.tankLiquidXp.getFluidAmount(); + final float capacity = this.tankLiquidXp.getCapacity(); + final float volume = (amount / capacity) * 0.8F; + return volume; + } + + @Override + public void updateEntity() { + + if (this.isServerSide()){ + this.mTickTime++; + + if (this.needsUpdate) { + if (this.updateTimer == 0) { + this.updateTimer = 10; // every 10 ticks it will send an update + } else { + --this.updateTimer; + if (this.updateTimer == 0) { + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + this.needsUpdate = false; + } + } + } + + + if (this.mConvertToEssence){ + if ((this.tankLiquidXp.getFluid() != null) && (this.tankLiquidXp.getFluidAmount() >= 100) && (this.tankEssence.getFluidAmount() <= (this.tankEssence.getCapacity()-(100*EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP)))){ + final FluidStack bigStorage = EnchantingUtils.getEssenceFromLiquidXp(100); + this.tankEssence.fill(bigStorage, true); + this.tankLiquidXp.drain(100, true); + this.needsUpdate = true; + Utils.LOG_WARNING("B->A"); + } + } + else { + final double rm = EnchantingUtils.RATIO_MOB_ESSENCE_TO_LIQUID_XP; + if ((this.tankEssence.getFluid() != null) && (this.tankEssence.getFluidAmount() >= rm) && (this.tankLiquidXp.getFluidAmount() <= (this.tankLiquidXp.getCapacity()-rm))){ + final FluidStack bigStorage = EnchantingUtils.getLiquidXP(1); + this.tankLiquidXp.fill(bigStorage, true); + this.tankEssence.drain((int) rm, true); + this.needsUpdate = true; + Utils.LOG_WARNING("A->B"); + } + } + } + else { + } + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + this.markDirty(); + + if ((this.mTickTime % 20) == 0){ + + } + + } + + @Override + public void readFromNBT(final NBTTagCompound tag) { + this.tankEssence.readFromNBT(tag); + this.tankLiquidXp.readFromNBT(tag); + this.mConvertToEssence = tag.getBoolean("mConvertToEssence"); + super.readFromNBT(tag); + } + + @Override + public void writeToNBT(final NBTTagCompound tag) { + this.tankEssence.writeToNBT(tag); + this.tankLiquidXp.writeToNBT(tag); + tag.setBoolean("mConvertToEssence", this.mConvertToEssence); + super.writeToNBT(tag); + } + + @Override + public Packet getDescriptionPacket() { + final NBTTagCompound tag = new NBTTagCompound(); + this.writeToNBT(tag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, tag); + } + + @Override + public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { + final NBTTagCompound tag = pkt.func_148857_g(); + this.readFromNBT(tag); + } + + public void onScrewdriverRightClick(final byte aSide, final EntityPlayer aPlayer, final float aX, final float aY, final float aZ) { + if (this.isServerSide()){ + if (this.mConvertToEssence){ + PlayerUtils.messagePlayer(aPlayer, "Converting from Mob Essence to Liquid Xp."); + } + else { + PlayerUtils.messagePlayer(aPlayer, "Converting from Liquid Xp to Mob Essence."); + } + //Mode Change + this.changeMode(); + } + } + + public void onRightClick(final byte aSide, final EntityPlayer aPlayer, final int aX, final int aY, final int aZ) { + + if ((Keyboard.isKeyDown(42)) || (Keyboard.isKeyDown(54))) { + String mInput; + String mOutput; + + if (this.mConvertToEssence){ + mInput = "Liquid Xp"; + mOutput = "Mob Essence"; + } + else { + mInput = "Mob Essence"; + mOutput = "Liquid Xp"; + } + + PlayerUtils.messagePlayer(aPlayer, "Input: "+mInput+"."); + PlayerUtils.messagePlayer(aPlayer, "Output: "+mOutput+"."); + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index f9315a2966..979c1f0287 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -1,12 +1,16 @@ package gtPlusPlus.core.util; -import static gtPlusPlus.core.handler.BookHandler.mBookKeeperCount; - import java.awt.Color; import java.awt.Graphics; import java.io.File; import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; import org.apache.commons.lang3.EnumUtils; import org.apache.logging.log4j.LogManager; @@ -15,7 +19,6 @@ import org.apache.logging.log4j.Logger; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.relauncher.FMLRelaunchLog; -import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.TC_Aspects.TC_AspectStack; @@ -23,7 +26,6 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gtPlusPlus.GTplusplus; -import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; @@ -38,7 +40,6 @@ import ic2.core.item.resources.ItemCell; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; -import net.minecraft.init.Items; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -49,7 +50,9 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; import net.minecraftforge.common.util.EnumHelper; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; public class Utils { @@ -183,8 +186,21 @@ public class Utils { // Non-Dev Comments public static void LOG_MACHINE_INFO(final String s) { - if (CORE.configSwitches.MACHINE_INFO || ClientProxy.playerName.toLowerCase().contains("draknyte1")) { - String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); + + boolean localPlayer = false; + try { + if (ClientProxy.playerName != null){ + if (ClientProxy.playerName.toLowerCase().contains("draknyte1")){ + localPlayer = true; + } + } + } + catch (final Throwable t){ + + } + + if (CORE.configSwitches.MACHINE_INFO || localPlayer) { + final String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); modLogger.info("Machine Info: " + s + " | " + name1); } } @@ -504,7 +520,7 @@ public class Utils { } public static File getMcDir() { - if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDedicatedServer()) { + if ((MinecraftServer.getServer() != null) && MinecraftServer.getServer().isDedicatedServer()) { return new File("."); } return Minecraft.getMinecraft().mcDataDir; @@ -604,7 +620,7 @@ public class Utils { } - public static int calculateVoltageTier(int Voltage) { + public static int calculateVoltageTier(final int Voltage) { int V; if (Voltage == 8) { V = 0; @@ -732,34 +748,39 @@ public class Utils { return sBookCount; } - public static ItemStack getWrittenBook(ItemStack aBook, int aID, String aMapping, String aTitle, String aAuthor, - String[] aPages) { - if (GT_Utility.isStringInvalid(aMapping)) + public static ItemStack getWrittenBook(final ItemStack aBook, final int aID, final String aMapping, final String aTitle, final String aAuthor, + final String[] aPages) { + if (GT_Utility.isStringInvalid(aMapping)) { return null; - ItemStack rStack = (ItemStack) CORE.sBookList.get(aMapping); - if (rStack != null) + } + ItemStack rStack = CORE.sBookList.get(aMapping); + if (rStack != null) { return GT_Utility.copyAmount(1L, new Object[] { rStack }); - if ((GT_Utility.isStringInvalid(aTitle)) || (GT_Utility.isStringInvalid(aAuthor)) || (aPages.length <= 0)) + } + if ((GT_Utility.isStringInvalid(aTitle)) || (GT_Utility.isStringInvalid(aAuthor)) || (aPages.length <= 0)) { return null; + } sBookCount += 1; - int vMeta = (aID == -1 ? sBookCount : aID); + final int vMeta = (aID == -1 ? sBookCount : aID); rStack = (aBook == null ? new ItemStack(ModItems.itemCustomBook, 1, vMeta) : aBook); - NBTTagCompound tNBT = new NBTTagCompound(); + final NBTTagCompound tNBT = new NBTTagCompound(); tNBT.setString("title", GT_LanguageManager.addStringLocalization( new StringBuilder().append("Book.").append(aTitle).append(".Name").toString(), aTitle)); tNBT.setString("author", aAuthor); - NBTTagList tNBTList = new NBTTagList(); + final NBTTagList tNBTList = new NBTTagList(); for (byte i = 0; i < aPages.length; i = (byte) (i + 1)) { aPages[i] = GT_LanguageManager .addStringLocalization(new StringBuilder().append("Book.").append(aTitle).append(".Page") .append((i < 10) ? new StringBuilder().append("0").append(i).toString() : Byte.valueOf(i)) .toString(), aPages[i]); if (i < 48) { - if (aPages[i].length() < 256) + if (aPages[i].length() < 256) { tNBTList.appendTag(new NBTTagString(aPages[i])); - else + } + else { GT_Log.err.println(new StringBuilder().append("WARNING: String for written Book too long! -> ") .append(aPages[i]).toString()); + } } else { GT_Log.err.println(new StringBuilder().append("WARNING: Too much Pages for written Book! -> ") .append(aTitle).toString()); diff --git a/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java b/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java new file mode 100644 index 0000000000..76336d4298 --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/enchanting/EnchantingUtils.java @@ -0,0 +1,102 @@ +package gtPlusPlus.core.util.enchanting; + +import gtPlusPlus.core.util.Utils; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class EnchantingUtils { + + + public static final int XP_PER_BOTTLE = 8; + public static final int RATIO = 20; + public static final int LIQUID_PER_XP_BOTTLE = 160; + public static final double RATIO_MOB_ESSENCE_TO_LIQUID_XP = 13.32; + + public static int liquidToXpRatio(final int liquid) { + return liquid / RATIO; + } + + public static int xpToLiquidRatio(final int xp) { + return xp * RATIO; + } + + public static FluidStack getEssenceFromLiquidXp(final int xpAmount){ + if (xpAmount <= 0){ + return null; + } + return getMobEssence((int) (xpAmount*RATIO_MOB_ESSENCE_TO_LIQUID_XP)); + } + + public static FluidStack getLiquidXpFromEssence(final int essenceAmount){ + if (essenceAmount <= 0){ + return null; + } + return getLiquidXP((int) (essenceAmount/RATIO_MOB_ESSENCE_TO_LIQUID_XP)); + } + + public static int getLiquidForLevel(final int level) { + final int xp = getExperienceForLevel(level); + return xpToLiquidRatio(xp); + } + + public static int getLevelForLiquid(final int liquid) { + final int xp = liquidToXpRatio(liquid); + return getLevelForExperience(xp); + } + + public static int getExperienceForLevel(final int level) { + if (level == 0) { + return 0; + } + if ((level > 0) && (level < 16)) { + return level * 17; + } + if ((level > 15) && (level < 31)) { + return (int) (((1.5 * Math.pow(level, 2.0)) - (29.5 * level)) + 360.0); + } + return (int) (((3.5 * Math.pow(level, 2.0)) - (151.5 * level)) + 2220.0); + } + + public static int getXpToNextLevel(final int level) { + final int levelXP = getLevelForExperience(level); + final int nextXP = getExperienceForLevel(level + 1); + return nextXP - levelXP; + } + + public static int getLevelForExperience(final int experience) { + int i; + for (i = 0; getExperienceForLevel(i) <= experience; ++i) { + } + return i - 1; + } + + + + + + + + //Xp Fluids + public static FluidStack getMobEssence(final int amount){ + Utils.LOG_WARNING("Trying to get a fluid stack of Mob Essence."); + try { + return FluidRegistry.getFluidStack("mobessence", amount).copy(); + } + catch (final Throwable e){ + return null; + } + + } + + public static FluidStack getLiquidXP(final int amount){ + Utils.LOG_WARNING("Trying to get a fluid stack of Liquid XP."); + try { + return FluidRegistry.getFluidStack("xpjuice", amount).copy(); + } + catch (final Throwable e){ + return null; + } + + } + +} diff --git a/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java b/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java index 47020b536b..611c7fe897 100644 --- a/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java +++ b/src/Java/gtPlusPlus/core/util/fluid/FluidUtils.java @@ -1,6 +1,8 @@ package gtPlusPlus.core.util.fluid; -import gregtech.api.enums.*; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; import gregtech.api.util.GT_LanguageManager; import gtPlusPlus.core.fluids.GenericFluid; import gtPlusPlus.core.item.base.BaseItemComponent; @@ -9,12 +11,17 @@ import gtPlusPlus.core.item.base.cell.BaseItemPlasmaCell; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.enchanting.EnchantingUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; public class FluidUtils { @@ -87,24 +94,24 @@ public class FluidUtils { public static Fluid generateFluid(final String displayName, final String fluidName, final int tempK, final short[] rgba ,final int aState){ Fluid generatedFluid = null; switch (aState) { - case 0: { - generatedFluid = new GenericFluid(displayName, fluidName, 0, 100, tempK, 10000, false, rgba); - break; - } - default: - case 1: - case 4: { - generatedFluid = new GenericFluid(displayName, fluidName, 0, 100, tempK, 1000, false, rgba); - break; - } - case 2: { - generatedFluid = new GenericFluid(displayName, fluidName, 0, -100, tempK, 200, true, rgba); - break; - } - case 3: { - generatedFluid = new GenericFluid(displayName, fluidName, 15, -10000, tempK, 10, true, rgba); - break; - } + case 0: { + generatedFluid = new GenericFluid(displayName, fluidName, 0, 100, tempK, 10000, false, rgba); + break; + } + default: + case 1: + case 4: { + generatedFluid = new GenericFluid(displayName, fluidName, 0, 100, tempK, 1000, false, rgba); + break; + } + case 2: { + generatedFluid = new GenericFluid(displayName, fluidName, 0, -100, tempK, 200, true, rgba); + break; + } + case 3: { + generatedFluid = new GenericFluid(displayName, fluidName, 15, -10000, tempK, 10, true, rgba); + break; + } } return generatedFluid; } @@ -122,24 +129,24 @@ public class FluidUtils { final int tempK = material.getMeltingPointC(); Fluid generatedFluid = null; switch (aState) { - case 0: { - generatedFluid = new GenericFluid(material, 0, 100, tempK, 10000, false); - break; - } - default: - case 1: - case 4: { - generatedFluid = new GenericFluid(material, 0, 100, tempK, 1000, false); - break; - } - case 2: { - generatedFluid = new GenericFluid(material, 0, -100, tempK, 200, true); - break; - } - case 3: { - generatedFluid = new GenericFluid(material, 15, -10000, tempK, 10, true); - break; - } + case 0: { + generatedFluid = new GenericFluid(material, 0, 100, tempK, 10000, false); + break; + } + default: + case 1: + case 4: { + generatedFluid = new GenericFluid(material, 0, 100, tempK, 1000, false); + break; + } + case 2: { + generatedFluid = new GenericFluid(material, 0, -100, tempK, 200, true); + break; + } + case 3: { + generatedFluid = new GenericFluid(material, 15, -10000, tempK, 10, true); + break; + } } return generatedFluid; } @@ -167,30 +174,30 @@ public class FluidUtils { GT_LanguageManager.addStringLocalization(rFluid.getUnlocalizedName(), (aLocalized == null) ? aName : aLocalized); if (FluidRegistry.registerFluid(rFluid)) { switch (aState) { - case 0: { - rFluid.setGaseous(false); - rFluid.setViscosity(10000); - break; - } - case 1: - case 4: { - rFluid.setGaseous(false); - rFluid.setViscosity(1000); - break; - } - case 2: { - rFluid.setGaseous(true); - rFluid.setDensity(-100); - rFluid.setViscosity(200); - break; - } - case 3: { - rFluid.setGaseous(true); - rFluid.setDensity(-10000); - rFluid.setViscosity(10); - rFluid.setLuminosity(15); - break; - } + case 0: { + rFluid.setGaseous(false); + rFluid.setViscosity(10000); + break; + } + case 1: + case 4: { + rFluid.setGaseous(false); + rFluid.setViscosity(1000); + break; + } + case 2: { + rFluid.setGaseous(true); + rFluid.setDensity(-100); + rFluid.setViscosity(200); + break; + } + case 3: { + rFluid.setGaseous(true); + rFluid.setDensity(-10000); + rFluid.setViscosity(10); + rFluid.setLuminosity(15); + break; + } } } else { @@ -201,18 +208,18 @@ public class FluidUtils { } if (aMaterial != null) { switch (aState) { - case 1: { - aMaterial.mFluid = (rFluid); - break; - } - case 2: { - aMaterial.mGas = (rFluid); - break; - } - case 3: { - aMaterial.mPlasma = (rFluid); - break; - } + case 1: { + aMaterial.mFluid = (rFluid); + break; + } + case 2: { + aMaterial.mGas = (rFluid); + break; + } + case 3: { + aMaterial.mPlasma = (rFluid); + break; + } } } if ((aFullContainer != null) && (aEmptyContainer != null) && !FluidContainerRegistry.registerFluidContainer(new FluidStack(rFluid, aFluidAmount), aFullContainer, aEmptyContainer)) { @@ -234,7 +241,7 @@ public class FluidUtils { } public static Fluid addGTPlasma(final Material aMaterial) { - if (aMaterial.getLocalizedName().toLowerCase().contains("clay") || aMaterial.getComposites().size()>1 || aMaterial.getLocalizedName().toLowerCase().contains("wrought")){ + if (aMaterial.getLocalizedName().toLowerCase().contains("clay") || (aMaterial.getComposites().size()>1) || aMaterial.getLocalizedName().toLowerCase().contains("wrought")){ return null; } Utils.LOG_INFO("Generating a "+aMaterial.getLocalizedName()+" Plasma Cell"); @@ -277,30 +284,30 @@ public class FluidUtils { GT_LanguageManager.addStringLocalization(rFluid.getUnlocalizedName(), (aLocalized == null) ? aName : aLocalized); if (FluidRegistry.registerFluid(rFluid)) { switch (aState) { - case 0: { - rFluid.setGaseous(false); - rFluid.setViscosity(10000); - break; - } - case 1: - case 4: { - rFluid.setGaseous(false); - rFluid.setViscosity(1000); - break; - } - case 2: { - rFluid.setGaseous(true); - rFluid.setDensity(-100); - rFluid.setViscosity(200); - break; - } - case 3: { - rFluid.setGaseous(true); - rFluid.setDensity(-10000); - rFluid.setViscosity(10); - rFluid.setLuminosity(15); - break; - } + case 0: { + rFluid.setGaseous(false); + rFluid.setViscosity(10000); + break; + } + case 1: + case 4: { + rFluid.setGaseous(false); + rFluid.setViscosity(1000); + break; + } + case 2: { + rFluid.setGaseous(true); + rFluid.setDensity(-100); + rFluid.setViscosity(200); + break; + } + case 3: { + rFluid.setGaseous(true); + rFluid.setDensity(-10000); + rFluid.setViscosity(10); + rFluid.setLuminosity(15); + break; + } } } else { @@ -435,8 +442,8 @@ public class FluidUtils { Utils.LOG_INFO("FLUID GENERATION FAILED FOR "+localizedName); return null; } - - public final static Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA, ItemStack dustStack, final ItemStack dustStack2){ + + public final static Fluid generateFluidNonMolten(final String unlocalizedName, final String localizedName, final int MeltingPoint, final short[] RGBA, final ItemStack dustStack, final ItemStack dustStack2){ return generateFluidNonMolten(unlocalizedName, localizedName, MeltingPoint, RGBA, dustStack, dustStack2, 144); } @@ -516,4 +523,13 @@ public class FluidUtils { } + public static FluidStack getMobEssence(final int amount){ + return EnchantingUtils.getMobEssence(amount); + } + + public static FluidStack getLiquidXP(final int amount){ + return EnchantingUtils.getLiquidXP(amount); + } + + } diff --git a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java index 337e301414..fb20c87bac 100644 --- a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java @@ -42,6 +42,9 @@ public class ItemUtils { public static ItemStack getSimpleStack(final Block x){ return getSimpleStack(Item.getItemFromBlock(x), 1); } + public static ItemStack getSimpleStack(final Block x, final int i){ + return getSimpleStack(Item.getItemFromBlock(x), i); + } public static ItemStack getSimpleStack(final Item x, final int i){ try { final ItemStack r = new ItemStack(x, i); @@ -61,8 +64,8 @@ public class ItemUtils { } public static final int WILDCARD_VALUE = Short.MAX_VALUE; - public static ItemStack getWildcardStack(Item x){ - ItemStack y = new ItemStack(x, 1, WILDCARD_VALUE); + public static ItemStack getWildcardStack(final Item x){ + final ItemStack y = new ItemStack(x, 1, WILDCARD_VALUE); return y; } @@ -160,7 +163,7 @@ public class ItemUtils { } @SuppressWarnings("unused") - public static ItemStack simpleMetaStack(final Item item, final int meta, final int itemstackSize){ + public static ItemStack simpleMetaStack(final Item item, final int meta, final int size){ try { if (item == null){ return null; @@ -173,7 +176,7 @@ public class ItemUtils { em = em1; } if (em != null){ - final ItemStack metaStack = new ItemStack(em,itemstackSize,meta); + final ItemStack metaStack = new ItemStack(em,size,meta); return metaStack; } } @@ -184,6 +187,10 @@ public class ItemUtils { } } + public static ItemStack simpleMetaStack(final Block block, final int meta, final int size) { + return simpleMetaStack(Item.getItemFromBlock(block), meta, size); + } + public static ItemStack getCorrectStacktype(final String fqrn, final int stackSize){ final String oreDict = "ore:"; ItemStack temp; @@ -265,8 +272,8 @@ public class ItemUtils { //Adds a check to grab dusts using GT methodology if possible. ItemStack returnValue = null; if (oredictName.toLowerCase().contains("dust")){ - String MaterialName = oredictName.toLowerCase().replace("dust", ""); - Materials m = Materials.get(MaterialName); + final String MaterialName = oredictName.toLowerCase().replace("dust", ""); + final Materials m = Materials.get(MaterialName); returnValue = getGregtechDust(m, amount); if (returnValue != null){ return returnValue; @@ -284,7 +291,7 @@ public class ItemUtils { Utils.LOG_WARNING(oredictName+" was not valid."); return null; } - catch (Throwable t){ + catch (final Throwable t){ return null; } } @@ -317,7 +324,7 @@ public class ItemUtils { return output; } - public static Item generateSpecialUsePlate(String internalName, String displayName, short[] rgb, int radioactivity){ + public static Item generateSpecialUsePlate(final String internalName, final String displayName, final short[] rgb, final int radioactivity){ return new BaseItemPlate_OLD(internalName, displayName, Utils.rgbtoHexValue(rgb[0], rgb[1], rgb[2]), radioactivity); } @@ -344,7 +351,7 @@ public class ItemUtils { public static MultiPickaxeBase generateMultiPick(final boolean GT_Durability, final Materials material){ final ToolMaterial customMaterial = Utils.generateToolMaterialFromGT(material); - int enchantLevel = material.mEnchantmentToolsLevel; + final int enchantLevel = material.mEnchantmentToolsLevel; final Object enchant = new Pair(material.mEnchantmentTools, enchantLevel); return generateMultiPick(GT_Durability, customMaterial, material.mDefaultLocalName, material.mDurability, material.mRGBa, enchant); } @@ -575,24 +582,24 @@ public class ItemUtils { return outputs; } - private static String getModId(Item item) { + private static String getModId(final Item item) { try { - GameRegistry.UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(item); - String modname = (id.modId == null ? id.name : id.modId); - return id == null || id.modId.equals("") ? "minecraft" : modname; - } catch (Throwable t){ + final GameRegistry.UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(item); + final String modname = (id.modId == null ? id.name : id.modId); + return (id == null) || id.modId.equals("") ? "minecraft" : modname; + } catch (final Throwable t){ try { - UniqueIdentifier t2 = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(item)); - String modname = (t2.modId == null ? t2.name : t2.modId); - return t2 == null || t2.modId.equals("") ? "minecraft" : modname; + final UniqueIdentifier t2 = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(item)); + final String modname = (t2.modId == null ? t2.name : t2.modId); + return (t2 == null) || t2.modId.equals("") ? "minecraft" : modname; } - catch (Throwable t3){ + catch (final Throwable t3){ return "bad modid"; } } } - public static String getModId(ItemStack key) { + public static String getModId(final ItemStack key) { return getModId(key.getItem()); } @@ -602,13 +609,13 @@ public class ItemUtils { if (!oreDictList.isEmpty()){ ItemStack returnvalue; for (int xrc=0;xrc<oreDictList.size();xrc++){ - String modid = getModId(oreDictList.get(xrc).getItem()); + final String modid = getModId(oreDictList.get(xrc).getItem()); if (modid.equals("gregtech") || modid.equals(CORE.MODID)){ returnvalue = oreDictList.get(xrc).copy(); returnvalue.stackSize = amount; return returnvalue; } - } + } } return getNonTinkersDust(oredictName, amount); } @@ -619,16 +626,17 @@ public class ItemUtils { if (!oreDictList.isEmpty()){ ItemStack returnvalue; for (int xrc=0;xrc<oreDictList.size();xrc++){ - String modid = getModId(oreDictList.get(xrc).getItem()); + final String modid = getModId(oreDictList.get(xrc).getItem()); if (!modid.equals("tconstruct")){ returnvalue = oreDictList.get(xrc).copy(); returnvalue.stackSize = amount; return returnvalue; } - } + } } //If only Tinkers dust exists, bow down and just use it. return getItemStackOfAmountFromOreDictNoBroken(oredictName, amount); } + } diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java index 543fd65b71..f1462ba51e 100644 --- a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java +++ b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java @@ -1,6 +1,9 @@ package gtPlusPlus.core.util.player; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -104,7 +107,7 @@ public class PlayerUtils { }catch(final NullPointerException e){ e.printStackTrace(); return null; - } + } if (heldItem != null){ return heldItem; } @@ -125,32 +128,32 @@ public class PlayerUtils { return null; } - - public static Item getItemInPlayersHand(EntityPlayer player){ + + public static Item getItemInPlayersHand(final EntityPlayer player){ Item heldItem = null; - try{heldItem = player.getHeldItem().getItem(); + try{ + heldItem = player.getHeldItem().getItem(); }catch(final NullPointerException e){return null;} if (heldItem != null){ return heldItem; } - return null; } - - public final static EntityPlayer getPlayerEntityByName(String aPlayerName){ - EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); + + public final static EntityPlayer getPlayerEntityByName(final String aPlayerName){ + final EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); if (player != null){ return player; - } + } return null; } - - public final static UUID getPlayersUUIDByName(String aPlayerName){ - EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); + + public final static UUID getPlayersUUIDByName(final String aPlayerName){ + final EntityPlayer player = PlayerUtils.getPlayer(aPlayerName); if (player != null){ return player.getUniqueID(); - } + } return null; } |