diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/thaumcraft')
9 files changed, 1570 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/HANDLER_Thaumcraft.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/HANDLER_Thaumcraft.java new file mode 100644 index 0000000000..7c5d2407cd --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/HANDLER_Thaumcraft.java @@ -0,0 +1,27 @@ +package gtPlusPlus.xmod.thaumcraft.common; + +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.xmod.thaumcraft.common.block.TC_BlockHandler; + +public class HANDLER_Thaumcraft { + + public static void preInit(){ + if (LoadedMods.Thaumcraft){ + TC_BlockHandler.run(); + } + } + + public static void init(){ + if (LoadedMods.Thaumcraft){ + + } + } + + public static void postInit(){ + if (LoadedMods.Thaumcraft){ + + } + } + + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/ItemBlockThaumcraft.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/ItemBlockThaumcraft.java new file mode 100644 index 0000000000..465f443906 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/ItemBlockThaumcraft.java @@ -0,0 +1,34 @@ +package gtPlusPlus.xmod.thaumcraft.common; + +import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class ItemBlockThaumcraft extends ItemBlockEntityBase{ + + public ItemBlockThaumcraft(final Block block) { + super(block); + } + + @Override + public int getMetadata(final int par1) { + return par1; + } + + @Override + public String getUnlocalizedName(final ItemStack par1ItemStack) { + return super.getUnlocalizedName() + "." + par1ItemStack.getItemDamage(); + } + + public boolean placeBlockAt(final ItemStack stack, final EntityPlayer player, final World world, final int x, + final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ, + final int metadata) { + final boolean ret = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + return ret; + } + + + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastAlchemyFurnace.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastAlchemyFurnace.java new file mode 100644 index 0000000000..bf4a61cfc9 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastAlchemyFurnace.java @@ -0,0 +1,250 @@ +package gtPlusPlus.xmod.thaumcraft.common.block; + +import java.util.List; +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 gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.xmod.thaumcraft.common.ItemBlockThaumcraft; +import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastAlchemyFurnace; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.common.lib.utils.InventoryUtils; + +public class BlockFastAlchemyFurnace extends BlockContainer { + + public IIcon[] iconFurnace; + public IIcon[] iconPedestal; + + public BlockFastAlchemyFurnace() { + super(Material.iron); + this.iconFurnace = new IIcon[5]; + this.iconPedestal = new IIcon[2]; + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setBlockName("blockFastAlchemyFurnace"); + this.setHardness(3.0f); + this.setResistance(25.0f); + this.setStepSound(Block.soundTypeStone); + this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + GameRegistry.registerBlock(this, ItemBlockThaumcraft.class, "blockFastAlchemyFurnace"); + LanguageRegistry.addName(this, "Upgraded Alchemical Furnace"); + } + + @Override + public int getLightValue(final IBlockAccess world, final int x, final int y, final int z) { + final Block block = world.getBlock(x, y, z); + if (block != this) + { + return block.getLightValue(world, x, y, z); + } + /** + * Gets the light value of the specified block coords. Args: x, y, z + */ + return this.getLightValue(); + } + + @Override + public int damageDropped(final int metadata) { + return 0; + } + + @Override + public TileEntity createTileEntity(final World world, final int metadata) { + if (metadata == 0){ + return new TileFastAlchemyFurnace(); + } + return null; + } + + @Override + public TileEntity createNewTileEntity(final World var1, final int md) { + return null; + } + + @Override + public int getComparatorInputOverride(final World world, final int x, final int y, final int z, final int rs) { + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileFastAlchemyFurnace)) { + return Container.calcRedstoneFromInventory((IInventory) te); + } + return 0; + } + + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float par7, final float par8, final float par9) { + + if (world.isRemote) { + return true; + } + + final int metadata = world.getBlockMetadata(x, y, z); + final TileEntity tileEntity = world.getTileEntity(x, y, z); + + if ((metadata == 0) && (tileEntity instanceof TileFastAlchemyFurnace) && !player.isSneaking()) { + player.openGui(GTplusplus.instance, GuiHandler.GUI8, world, x, y, z); + return true; + } + return false; + } + + + @Override + public void addCollisionBoxesToList(final World world, final int i, final int j, final int k, + final AxisAlignedBB axisalignedbb, final List arraylist, final Entity par7Entity) { + this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); + } + + @Override + public void setBlockBoundsBasedOnState(final IBlockAccess world, final int i, final int j, final int k) { + this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + super.setBlockBoundsBasedOnState(world, i, j, k); + } + + @Override + public boolean onBlockEventReceived(final World par1World, final int par2, final int par3, final int par4, + final int par5, final int par6) { + /*if (par5 == 1) { + if (par1World.isRemote) { + Thaumcraft.proxy.blockSparkle(par1World, par2, par3, par4, 11960575, 2); + par1World.playAuxSFX(2001, par2, par3, par4, Block.getIdFromBlock(Blocks.stonebrick) + 0); + } + return true; + }*/ + return super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean isSideSolid(final IBlockAccess world, final int x, final int y, final int z, + final ForgeDirection side) { + return super.isSideSolid(world, x, y, z, side); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public void breakBlock(final World par1World, final int par2, final int par3, final int par4, final Block par5, + final int par6) { + InventoryUtils.dropItems(par1World, par2, par3, par4); + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block par5) { + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileFastAlchemyFurnace)) { + ((TileFastAlchemyFurnace) te).getBellows(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World w, final int i, final int j, final int k, final Random r) { + final TileEntity te = w.getTileEntity(i, j, k); + if ((te != null) && (te instanceof TileFastAlchemyFurnace) && ((TileFastAlchemyFurnace) te).isBurning()) { + final float f = i + 0.5f; + final float f2 = j + 0.2f + ((r.nextFloat() * 5.0f) / 16.0f); + final float f3 = k + 0.5f; + final float f4 = 0.52f; + final float f5 = (r.nextFloat() * 0.5f) - 0.25f; + w.spawnParticle("smoke", f - f4, f2, f3 + f5, 0.0, 0.0, 0.0); + w.spawnParticle("flame", f - f4, f2, f3 + f5, 0.0, 0.0, 0.0); + w.spawnParticle("smoke", f + f4, f2, f3 + f5, 0.0, 0.0, 0.0); + w.spawnParticle("flame", f + f4, f2, f3 + f5, 0.0, 0.0, 0.0); + w.spawnParticle("smoke", f + f5, f2, f3 - f4, 0.0, 0.0, 0.0); + w.spawnParticle("flame", f + f5, f2, f3 - f4, 0.0, 0.0, 0.0); + w.spawnParticle("smoke", f + f5, f2, f3 + f4, 0.0, 0.0, 0.0); + w.spawnParticle("flame", f + f5, f2, f3 + f4, 0.0, 0.0, 0.0); + } + } + + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister ir) { + this.iconPedestal[0] = ir.registerIcon("thaumcraft:pedestal_side"); + this.iconPedestal[1] = ir.registerIcon("thaumcraft:pedestal_top"); + this.iconFurnace[0] = ir.registerIcon("thaumcraft:al_furnace_side"); + this.iconFurnace[1] = ir.registerIcon("thaumcraft:al_furnace_top"); + this.iconFurnace[2] = ir.registerIcon("thaumcraft:al_furnace_front_off"); + this.iconFurnace[3] = ir.registerIcon("thaumcraft:al_furnace_front_on"); + this.iconFurnace[4] = ir.registerIcon("thaumcraft:al_furnace_top_filled"); + } + + /*@Override + public int getRenderType() { + return ConfigBlocks.blockStoneDeviceRI; + }*/ + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public IIcon getIcon(final int side, final int md) { + if (md == 0) { + if (side == 1) { + return this.iconFurnace[1]; + } + if (side > 1) { + return this.iconFurnace[2]; + } + } else if (md == 1) { + if (side <= 1) { + return this.iconPedestal[1]; + } + if (side > 1) { + return this.iconPedestal[0]; + } + } + return this.iconPedestal[1]; + } + + @Override + public IIcon getIcon(final IBlockAccess iblockaccess, final int i, final int j, final int k, final int side) { + final int metadata = iblockaccess.getBlockMetadata(i, j, k); + if (metadata == 0) { + final TileEntity te = iblockaccess.getTileEntity(i, j, k); + if (side == 1) { + if ((te != null) && (te instanceof TileFastAlchemyFurnace) && (((TileFastAlchemyFurnace) te).vis > 0)) { + return this.iconFurnace[4]; + } + return this.iconFurnace[1]; + } else if (side > 1) { + if ((te != null) && (te instanceof TileFastAlchemyFurnace) && ((TileFastAlchemyFurnace) te).isBurning()) { + return this.iconFurnace[3]; + } + return this.iconFurnace[2]; + } + } + return this.iconFurnace[0]; + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastArcaneAlembic.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastArcaneAlembic.java new file mode 100644 index 0000000000..04c0673b49 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/BlockFastArcaneAlembic.java @@ -0,0 +1,373 @@ +package gtPlusPlus.xmod.thaumcraft.common.block; + +import java.util.List; +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 gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.xmod.thaumcraft.common.ItemBlockThaumcraft; +import gtPlusPlus.xmod.thaumcraft.common.tile.TileFastArcaneAlembic; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +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.AxisAlignedBB; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.api.aspects.IEssentiaContainerItem; +import thaumcraft.common.blocks.ItemJarFilled; +import thaumcraft.common.config.ConfigBlocks; +import thaumcraft.common.config.ConfigItems; +import thaumcraft.common.lib.utils.InventoryUtils; + +public class BlockFastArcaneAlembic extends BlockContainer { + public IIcon[] icon; + public IIcon iconGlow; + private final int delay; + + public BlockFastArcaneAlembic() { + super(Material.iron); + this.icon = new IIcon[23]; + this.delay = 0; + this.setStepSound(Block.soundTypeMetal); + this.setCreativeTab(AddToCreativeTab.tabMachines); + this.setBlockName("blockFastArcaneAlembic"); + this.setHardness(3.0f); + this.setResistance(25.0f); + this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + GameRegistry.registerBlock(this, ItemBlockThaumcraft.class, "blockFastArcaneAlembic"); + LanguageRegistry.addName(this, "Upgraded Arcane Alembic"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(final IIconRegister ir) { + this.icon[0] = ir.registerIcon("thaumcraft:metalbase"); + for (int a = 1; a <= 6; ++a) { + this.icon[a] = ir.registerIcon("thaumcraft:crucible" + a); + } + this.icon[7] = ir.registerIcon("thaumcraft:goldbase"); + this.iconGlow = ir.registerIcon("thaumcraft:animatedglow"); + } + + @Override + public IIcon getIcon(final int i, final int md) { + return ((md == 0) || (md == 1) || (md == 5) || (md == 6)) ? this.icon[0] : this.icon[7]; + } + + @Override + public IIcon getIcon(final IBlockAccess iblockaccess, final int i, final int j, final int k, final int side) { + if (side == 1) { + return this.icon[1]; + } + if (side == 0) { + return this.icon[2]; + } + return this.icon[3]; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) { + par3List.add(new ItemStack(par1, 1, 1)); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public void onEntityCollidedWithBlock(final World world, final int i, final int j, final int k, + final Entity entity) { + if (!world.isRemote) { + + } + } + + @Override + public void addCollisionBoxesToList(final World world, final int i, final int j, final int k, + final AxisAlignedBB axisalignedbb, final List arraylist, final Entity par7Entity) { + this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(final World w, final int i, final int j, final int k, final Random r) { + + } + + @Override + public int damageDropped(final int metadata) { + return metadata; + } + + @Override + public TileEntity createTileEntity(final World world, final int metadata) { + + if (metadata == 1) { + return new TileFastArcaneAlembic(); + } + return super.createTileEntity(world, metadata); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(final World world, final int x, final int y, final int z, final int rs) { + final TileEntity te = world.getTileEntity(x, y, z); + if ((te != null) && (te instanceof TileFastArcaneAlembic)) { + final float r = ((TileFastArcaneAlembic) te).amount / ((TileFastArcaneAlembic) te).maxAmount; + return MathHelper.floor_float(r * 14.0f) + ((((TileFastArcaneAlembic) te).amount > 0) ? 1 : 0); + } + return 0; + } + + @Override + public TileEntity createNewTileEntity(final World var1, final int md) { + return null; + } + + @Override + public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block nbid) { + final TileEntity te = world.getTileEntity(x, y, z); + if (!world.isRemote) { + if ((te != null) && (te instanceof TileFastArcaneAlembic)) { + world.markBlockForUpdate(x, y, z); + } + } + super.onNeighborBlockChange(world, x, y, z, nbid); + } + + @Override + public void breakBlock(final World par1World, final int par2, final int par3, final int par4, final Block par5, + final int par6) { + InventoryUtils.dropItems(par1World, par2, par3, par4); + final TileEntity te = par1World.getTileEntity(par2, par3, par4); + if ((te != null) && (te instanceof TileFastArcaneAlembic) && (((TileFastArcaneAlembic) te).aspectFilter != null)) { + par1World.spawnEntityInWorld(new EntityItem(par1World, par2 + 0.5f, + par3 + 0.5f, par4 + 0.5f, new ItemStack(ConfigItems.itemResource, 1, 13))); + } + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, + final int side, final float par7, final float par8, final float par9) { + final int metadata = world.getBlockMetadata(x, y, z); + + if ((metadata == 1) && !world.isRemote && !player.isSneaking() && (player.getHeldItem() == null)) { + final TileEntity te2 = world.getTileEntity(x, y, z); + if ((te2 != null) && (te2 instanceof TileFastArcaneAlembic)) { + final TileFastArcaneAlembic tile2 = (TileFastArcaneAlembic) te2; + String msg = ""; + if ((tile2.aspect == null) || (tile2.amount == 0)) { + msg = StatCollector.translateToLocal("tile.alembic.msg.1"); + } else if (tile2.amount < (tile2.maxAmount * 0.4)) { + msg = StatCollector.translateToLocal("tile.alembic.msg.2"); + } else if (tile2.amount < (tile2.maxAmount * 0.8)) { + msg = StatCollector.translateToLocal("tile.alembic.msg.3"); + } else if (tile2.amount < tile2.maxAmount) { + msg = StatCollector.translateToLocal("tile.alembic.msg.4"); + } else if (tile2.amount == tile2.maxAmount) { + msg = StatCollector.translateToLocal("tile.alembic.msg.5"); + } + player.addChatMessage(new ChatComponentTranslation("ยง3" + msg, new Object[0])); + world.playSoundEffect(x, y, z, "thaumcraft:alembicknock", 0.2f, 1.0f); + } + } + if (metadata == 1) { + final TileEntity te2 = world.getTileEntity(x, y, z); + if ((te2 != null) && (te2 instanceof TileFastArcaneAlembic)) { + if (player.isSneaking() && (((TileFastArcaneAlembic) te2).aspectFilter != null)) { + ((TileFastArcaneAlembic) te2).aspectFilter = null; + world.markBlockForUpdate(x, y, z); + te2.markDirty(); + if (world.isRemote) { + world.playSound(x + 0.5f, y + 0.5f, z + 0.5f, + "thaumcraft:page", 1.0f, 1.1f, false); + } else { + final ForgeDirection fd = ForgeDirection.getOrientation(side); + world.spawnEntityInWorld(new EntityItem(world, x + 0.5f + (fd.offsetX / 3.0f), + y + 0.5f, z + 0.5f + (fd.offsetZ / 3.0f), + new ItemStack(ConfigItems.itemResource, 1, 13))); + } + return true; + } + if (player.isSneaking() && (player.getHeldItem() == null)) { + ((TileFastArcaneAlembic) te2).amount = 0; + ((TileFastArcaneAlembic) te2).aspect = null; + if (world.isRemote) { + world.playSound(x + 0.5f, y + 0.5f, z + 0.5f, + "thaumcraft:alembicknock", 0.2f, 1.0f, false); + world.playSound(x + 0.5f, y + 0.5f, z + 0.5f, + "game.neutral.swim", 0.5f, + 1.0f + ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.3f), false); + } + } else if ((player.getHeldItem() != null) && (((TileFastArcaneAlembic) te2).aspectFilter == null) + && (player.getHeldItem().getItem() == ConfigItems.itemResource) + && (player.getHeldItem().getItemDamage() == 13)) { + if ((((TileFastArcaneAlembic) te2).amount == 0) && (((IEssentiaContainerItem) player.getHeldItem().getItem()) + .getAspects(player.getHeldItem()) == null)) { + return true; + } + if ((((TileFastArcaneAlembic) te2).amount == 0) && (((IEssentiaContainerItem) player.getHeldItem().getItem()) + .getAspects(player.getHeldItem()) != null)) { + ((TileFastArcaneAlembic) te2).aspect = ((IEssentiaContainerItem) player.getHeldItem().getItem()) + .getAspects(player.getHeldItem()).getAspects()[0]; + } + final ItemStack heldItem = player.getHeldItem(); + --heldItem.stackSize; + ((TileFastArcaneAlembic) te2).aspectFilter = ((TileFastArcaneAlembic) te2).aspect; + world.markBlockForUpdate(x, y, z); + te2.markDirty(); + if (world.isRemote) { + world.playSound(x + 0.5f, y + 0.5f, z + 0.5f, + "thaumcraft:page", 1.0f, 0.9f, false); + } + return true; + } else if ((player.getHeldItem() != null) && (((TileFastArcaneAlembic) te2).amount > 0) + && ((player.getHeldItem().getItem() == ConfigItems.itemJarFilled) + || player.getHeldItem().isItemEqual(new ItemStack(ConfigBlocks.blockJar, 1, 0)) + || player.getHeldItem().isItemEqual(new ItemStack(ConfigBlocks.blockJar, 1, 3)))) { + boolean doit = false; + ItemStack drop = null; + if (player.getHeldItem().isItemEqual(new ItemStack(ConfigBlocks.blockJar, 1, 0)) + || player.getHeldItem().isItemEqual(new ItemStack(ConfigBlocks.blockJar, 1, 3))) { + drop = new ItemStack(ConfigItems.itemJarFilled, 1, player.getHeldItem().getItemDamage()); + doit = true; + ((ItemJarFilled) drop.getItem()).setAspects(drop, + new AspectList().add(((TileFastArcaneAlembic) te2).aspect, ((TileFastArcaneAlembic) te2).amount)); + ((TileFastArcaneAlembic) te2).amount = 0; + ((TileFastArcaneAlembic) te2).aspect = null; + final ItemStack heldItem2 = player.getHeldItem(); + --heldItem2.stackSize; + if (!player.inventory.addItemStackToInventory(drop) && !world.isRemote) { + world.spawnEntityInWorld( + new EntityItem(world, player.posX, player.posY, player.posZ, drop)); + } + } else { + drop = player.getHeldItem(); + if (((((ItemJarFilled) drop.getItem()).getAspects(drop) == null) + || (((ItemJarFilled) drop.getItem()).getAspects(drop).visSize() == 0) + || (((ItemJarFilled) drop.getItem()).getAspects(drop) + .getAmount(((TileFastArcaneAlembic) te2).aspect) > 0)) + && ((((ItemJarFilled) drop.getItem()).getFilter(drop) == null) + || (((ItemJarFilled) drop.getItem()) + .getFilter(drop) == ((TileFastArcaneAlembic) te2).aspect))) { + int amount = Math.min( + (((ItemJarFilled) drop.getItem()).getAspects(drop) == null) + ? 64 + : (64 - ((ItemJarFilled) drop.getItem()).getAspects(drop).visSize()), + ((TileFastArcaneAlembic) te2).amount); + if (drop.getItemDamage() == 3) { + amount = ((TileFastArcaneAlembic) te2).amount; + } + if (amount > 0) { + final TileFastArcaneAlembic TileFastArcaneAlembic = (TileFastArcaneAlembic) te2; + TileFastArcaneAlembic.amount -= amount; + AspectList as = ((ItemJarFilled) drop.getItem()).getAspects(drop); + if (as == null) { + as = new AspectList(); + } + as.add(((TileFastArcaneAlembic) te2).aspect, amount); + if (as.getAmount(((TileFastArcaneAlembic) te2).aspect) > 64) { + final int q = as.getAmount(((TileFastArcaneAlembic) te2).aspect) - 64; + as.reduce(((TileFastArcaneAlembic) te2).aspect, q); + } + ((ItemJarFilled) drop.getItem()).setAspects(drop, as); + if (((TileFastArcaneAlembic) te2).amount <= 0) { + ((TileFastArcaneAlembic) te2).aspect = null; + } + doit = true; + player.setCurrentItemOrArmor(0, drop); + } + } + } + if (doit) { + te2.markDirty(); + world.markBlockForUpdate(x, y, z); + if (world.isRemote) { + world.playSound(x + 0.5f, y + 0.5f, z + 0.5f, + "game.neutral.swim", 0.5f, + 1.0f + ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.3f), false); + } + } + return true; + } + } + } + + if (world.isRemote) { + return true; + } + + return super.onBlockActivated(world, x, y, z, player, side, par7, par8, par9); + } + + public void onPoweredBlockChange(final World par1World, final int par2, final int par3, final int par4, + final boolean flag) { + final int l = par1World.getBlockMetadata(par2, par3, par4); + if ((l == 5) && flag) { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 6, 2); + par1World.playAuxSFXAtEntity((EntityPlayer) null, 1003, par2, par3, par4, 0); + } else if ((l == 6) && !flag) { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2); + par1World.playAuxSFXAtEntity((EntityPlayer) null, 1003, par2, par3, par4, 0); + } + } + + @Override + public void onBlockPlacedBy(final World world, final int par2, final int par3, final int par4, + final EntityLivingBase ent, final ItemStack stack) { + final int l = MathHelper.floor_double(((ent.rotationYaw * 4.0f) / 360.0f) + 0.5) & 0x3; + if (stack.getItemDamage() == 1) { + final TileEntity tile = world.getTileEntity(par2, par3, par4); + if (tile instanceof TileFastArcaneAlembic) { + if (l == 0) { + ((TileFastArcaneAlembic) tile).facing = 2; + } + if (l == 1) { + ((TileFastArcaneAlembic) tile).facing = 5; + } + if (l == 2) { + ((TileFastArcaneAlembic) tile).facing = 3; + } + if (l == 3) { + ((TileFastArcaneAlembic) tile).facing = 4; + } + } + } + } + + @Override + public int getLightValue(final IBlockAccess world, final int x, final int y, final int z) { + return super.getLightValue(world, x, y, z); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/TC_BlockHandler.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/TC_BlockHandler.java new file mode 100644 index 0000000000..0b8d18f7d2 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/block/TC_BlockHandler.java @@ -0,0 +1,15 @@ +package gtPlusPlus.xmod.thaumcraft.common.block; + +import net.minecraft.block.Block; + +public class TC_BlockHandler { + + public static Block blockFastAlchemyFurnace; + public static Block blockFastArcaneAlembic; + + public static void run(){ + blockFastAlchemyFurnace = new BlockFastAlchemyFurnace(); + blockFastArcaneAlembic = new BlockFastArcaneAlembic(); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java b/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java new file mode 100644 index 0000000000..756578a536 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/common/tile/TileFastAlchemyFurnace.java @@ -0,0 +1,425 @@ +package gtPlusPlus.xmod.thaumcraft.common.tile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.world.EnumSkyBlock; +import net.minecraftforge.common.util.ForgeDirection; +import thaumcraft.api.TileThaumcraft; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; +import thaumcraft.common.config.ConfigItems; +import thaumcraft.common.lib.crafting.ThaumcraftCraftingManager; +import thaumcraft.common.tiles.TileAlembic; +import thaumcraft.common.tiles.TileBellows; + +public class TileFastAlchemyFurnace extends TileThaumcraft implements ISidedInventory { + private static final int[] slots_bottom; + private static final int[] slots_top; + private static final int[] slots_sides; + public AspectList aspects; + public int vis; + private final int maxVis; + public int smeltTime; + int bellows; + boolean speedBoost; + private ItemStack[] furnaceItemStacks; + public int furnaceBurnTime; + public int currentItemBurnTime; + public int furnaceCookTime; + private String customName; + int count; + + public TileFastAlchemyFurnace() { + this.aspects = new AspectList(); + this.maxVis = 150; + this.smeltTime = 100; + this.bellows = -1; + this.speedBoost = true; + this.furnaceItemStacks = new ItemStack[2]; + this.count = 0; + } + + @Override + public int getSizeInventory() { + return this.furnaceItemStacks.length; + } + + @Override + public ItemStack getStackInSlot(final int par1) { + return this.furnaceItemStacks[par1]; + } + + @Override + public ItemStack decrStackSize(final int par1, final int par2) { + if (this.furnaceItemStacks[par1] == null) { + return null; + } + if (this.furnaceItemStacks[par1].stackSize <= par2) { + final ItemStack itemstack = this.furnaceItemStacks[par1]; + this.furnaceItemStacks[par1] = null; + return itemstack; + } + final ItemStack itemstack = this.furnaceItemStacks[par1].splitStack(par2); + if (this.furnaceItemStacks[par1].stackSize == 0) { + this.furnaceItemStacks[par1] = null; + } + return itemstack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int par1) { + if (this.furnaceItemStacks[par1] != null) { + final ItemStack itemstack = this.furnaceItemStacks[par1]; + this.furnaceItemStacks[par1] = null; + return itemstack; + } + return null; + } + + @Override + public void setInventorySlotContents(final int par1, final ItemStack par2ItemStack) { + this.furnaceItemStacks[par1] = par2ItemStack; + if ((par2ItemStack != null) && (par2ItemStack.stackSize > this.getInventoryStackLimit())) { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + } + + @Override + public String getInventoryName() { + return this.hasCustomInventoryName() ? this.customName : "container.alchemyfurnace"; + } + + @Override + public boolean hasCustomInventoryName() { + return (this.customName != null) && (this.customName.length() > 0); + } + + public void setGuiDisplayName(final String par1Str) { + this.customName = par1Str; + } + + @Override + public void readCustomNBT(final NBTTagCompound nbttagcompound) { + this.furnaceBurnTime = nbttagcompound.getShort("BurnTime"); + this.vis = nbttagcompound.getShort("Vis"); + } + + @Override + public void writeCustomNBT(final NBTTagCompound nbttagcompound) { + nbttagcompound.setShort("BurnTime", (short) this.furnaceBurnTime); + nbttagcompound.setShort("Vis", (short) this.vis); + } + + @Override + public void readFromNBT(final NBTTagCompound nbtCompound) { + super.readFromNBT(nbtCompound); + final NBTTagList nbttaglist = nbtCompound.getTagList("Items", 10); + this.furnaceItemStacks = new ItemStack[this.getSizeInventory()]; + for (int i = 0; i < nbttaglist.tagCount(); ++i) { + final NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); + final byte b0 = nbttagcompound1.getByte("Slot"); + if ((b0 >= 0) && (b0 < this.furnaceItemStacks.length)) { + this.furnaceItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); + } + } + this.speedBoost = nbtCompound.getBoolean("speedBoost"); + this.furnaceCookTime = nbtCompound.getShort("CookTime"); + this.currentItemBurnTime = TileEntityFurnace.getItemBurnTime(this.furnaceItemStacks[1]); + if (nbtCompound.hasKey("CustomName")) { + this.customName = nbtCompound.getString("CustomName"); + } + this.aspects.readFromNBT(nbtCompound); + this.vis = this.aspects.visSize(); + } + + @Override + public void writeToNBT(final NBTTagCompound nbtCompound) { + super.writeToNBT(nbtCompound); + nbtCompound.setBoolean("speedBoost", this.speedBoost); + nbtCompound.setShort("CookTime", (short) this.furnaceCookTime); + final NBTTagList nbttaglist = new NBTTagList(); + for (int i = 0; i < this.furnaceItemStacks.length; ++i) { + if (this.furnaceItemStacks[i] != null) { + final NBTTagCompound nbttagcompound1 = new NBTTagCompound(); + nbttagcompound1.setByte("Slot", (byte) i); + this.furnaceItemStacks[i].writeToNBT(nbttagcompound1); + nbttaglist.appendTag(nbttagcompound1); + } + } + nbtCompound.setTag("Items", nbttaglist); + if (this.hasCustomInventoryName()) { + nbtCompound.setString("CustomName", this.customName); + } + this.aspects.writeToNBT(nbtCompound); + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @SideOnly(Side.CLIENT) + public int getCookProgressScaled(final int par1) { + if (this.smeltTime <= 0) { + this.smeltTime = 1; + } + return (this.furnaceCookTime * par1) / this.smeltTime; + } + + @SideOnly(Side.CLIENT) + public int getContentsScaled(final int par1) { + return (this.vis * par1) / this.maxVis; + } + + @SideOnly(Side.CLIENT) + public int getBurnTimeRemainingScaled(final int par1) { + if (this.currentItemBurnTime == 0) { + this.currentItemBurnTime = 200; + } + return (this.furnaceBurnTime * par1) / this.currentItemBurnTime; + } + + public boolean isBurning() { + return this.furnaceBurnTime > 0; + } + + @Override + public void onDataPacket(final NetworkManager net, final S35PacketUpdateTileEntity pkt) { + super.onDataPacket(net, pkt); + if (this.worldObj != null) { + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord); + } + } + + @Override + public boolean canUpdate() { + return true; + } + |
