commit 37dbadc0a500689dfee77ae2d6651a42c1fec911 Author: Aidan Brady Date: Wed Aug 15 16:41:41 2012 -0400 Rebase for 1.3.2 Updated Methods to work with 1.3.2 diff --git a/bin/minecraft/armor/glowstone_1.png b/bin/minecraft/armor/glowstone_1.png new file mode 100755 index 000000000..8a963db49 Binary files /dev/null and b/bin/minecraft/armor/glowstone_1.png differ diff --git a/bin/minecraft/armor/glowstone_2.png b/bin/minecraft/armor/glowstone_2.png new file mode 100755 index 000000000..69ba88e4f Binary files /dev/null and b/bin/minecraft/armor/glowstone_2.png differ diff --git a/bin/minecraft/armor/lazuli_1.png b/bin/minecraft/armor/lazuli_1.png new file mode 100755 index 000000000..c09f87191 Binary files /dev/null and b/bin/minecraft/armor/lazuli_1.png differ diff --git a/bin/minecraft/armor/lazuli_2.png b/bin/minecraft/armor/lazuli_2.png new file mode 100755 index 000000000..7f298cf1f Binary files /dev/null and b/bin/minecraft/armor/lazuli_2.png differ diff --git a/bin/minecraft/armor/obsidian_1.png b/bin/minecraft/armor/obsidian_1.png new file mode 100755 index 000000000..483cd21b6 Binary files /dev/null and b/bin/minecraft/armor/obsidian_1.png differ diff --git a/bin/minecraft/armor/obsidian_2.png b/bin/minecraft/armor/obsidian_2.png new file mode 100755 index 000000000..f67a15a85 Binary files /dev/null and b/bin/minecraft/armor/obsidian_2.png differ diff --git a/bin/minecraft/armor/platinum_1.png b/bin/minecraft/armor/platinum_1.png new file mode 100755 index 000000000..e7f9ec0d6 Binary files /dev/null and b/bin/minecraft/armor/platinum_1.png differ diff --git a/bin/minecraft/armor/platinum_2.png b/bin/minecraft/armor/platinum_2.png new file mode 100755 index 000000000..b1bc421dd Binary files /dev/null and b/bin/minecraft/armor/platinum_2.png differ diff --git a/bin/minecraft/armor/redstone_1.png b/bin/minecraft/armor/redstone_1.png new file mode 100755 index 000000000..de670b471 Binary files /dev/null and b/bin/minecraft/armor/redstone_1.png differ diff --git a/bin/minecraft/armor/redstone_2.png b/bin/minecraft/armor/redstone_2.png new file mode 100755 index 000000000..ba788fe65 Binary files /dev/null and b/bin/minecraft/armor/redstone_2.png differ diff --git a/bin/minecraft/gui/GuiChamber.png b/bin/minecraft/gui/GuiChamber.png new file mode 100755 index 000000000..2aa3abd7a Binary files /dev/null and b/bin/minecraft/gui/GuiChamber.png differ diff --git a/bin/minecraft/gui/GuiCombiner.png b/bin/minecraft/gui/GuiCombiner.png new file mode 100755 index 000000000..4bba6646a Binary files /dev/null and b/bin/minecraft/gui/GuiCombiner.png differ diff --git a/bin/minecraft/gui/GuiCompressor.png b/bin/minecraft/gui/GuiCompressor.png new file mode 100755 index 000000000..2e94d61de Binary files /dev/null and b/bin/minecraft/gui/GuiCompressor.png differ diff --git a/bin/minecraft/gui/GuiCrusher.png b/bin/minecraft/gui/GuiCrusher.png new file mode 100755 index 000000000..9e716c1a7 Binary files /dev/null and b/bin/minecraft/gui/GuiCrusher.png differ diff --git a/bin/minecraft/gui/GuiStopwatch.png b/bin/minecraft/gui/GuiStopwatch.png new file mode 100644 index 000000000..472ed095e Binary files /dev/null and b/bin/minecraft/gui/GuiStopwatch.png differ diff --git a/bin/minecraft/gui/GuiWeatherOrb.png b/bin/minecraft/gui/GuiWeatherOrb.png new file mode 100644 index 000000000..c52900b4a Binary files /dev/null and b/bin/minecraft/gui/GuiWeatherOrb.png differ diff --git a/bin/minecraft/obsidian/Combiner.png b/bin/minecraft/obsidian/Combiner.png new file mode 100644 index 000000000..51d504670 Binary files /dev/null and b/bin/minecraft/obsidian/Combiner.png differ diff --git a/bin/minecraft/obsidian/Compressor.png b/bin/minecraft/obsidian/Compressor.png new file mode 100644 index 000000000..bd8962f36 Binary files /dev/null and b/bin/minecraft/obsidian/Compressor.png differ diff --git a/bin/minecraft/obsidian/Knife.png b/bin/minecraft/obsidian/Knife.png new file mode 100755 index 000000000..3d1be0953 Binary files /dev/null and b/bin/minecraft/obsidian/Knife.png differ diff --git a/bin/minecraft/obsidian/ObsidianArrows.png b/bin/minecraft/obsidian/ObsidianArrows.png new file mode 100644 index 000000000..78bc25250 Binary files /dev/null and b/bin/minecraft/obsidian/ObsidianArrows.png differ diff --git a/bin/minecraft/obsidian/items.png b/bin/minecraft/obsidian/items.png new file mode 100644 index 000000000..2a8632077 Binary files /dev/null and b/bin/minecraft/obsidian/items.png differ diff --git a/bin/minecraft/obsidian/terrain.png b/bin/minecraft/obsidian/terrain.png new file mode 100755 index 000000000..3f8663cea Binary files /dev/null and b/bin/minecraft/obsidian/terrain.png differ diff --git a/src/common/net/uberkat/obsidian/common/BlockBase.java b/src/common/net/uberkat/obsidian/common/BlockBase.java new file mode 100644 index 000000000..9c0a02ad3 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/BlockBase.java @@ -0,0 +1,68 @@ +package net.uberkat.obsidian.common; +import java.util.ArrayList; +import java.util.Random; + +import cpw.mods.fml.common.registry.BlockProxy; + +import net.minecraft.src.*; + +public class BlockBase extends Block implements BlockProxy +{ + public BlockBase(int i, int j) + { + super(i, j, Material.iron); + + if(blockID == ObsidianIngots.platinumOreID) + { + setHardness(3F); + setResistance(5F); + } + if(blockID == ObsidianIngots.refinedGlowstoneID || blockID == ObsidianIngots.refinedObsidianID || blockID == ObsidianIngots.coalBlockID || blockID == ObsidianIngots.redstoneBlockID || blockID == ObsidianIngots.platinumBlockID) + { + setHardness(5F); + setResistance(10F); + if(blockID == ObsidianIngots.refinedObsidianID) + { + setLightValue(0.5F); + } + if(blockID == ObsidianIngots.refinedGlowstoneID) + { + setLightValue(0.875F); + } + } + } + + public int idDropped(int i, Random random) + { + return this.blockID; + } + + public int quantityDropped(Random random) + { + return 1; + } + + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3) + { + if(blockID == ObsidianIngots.refinedObsidianID) + { + entityplayer.openGui(ObsidianIngots.instance, 19, world, x, y, z); + } + return false; + } + + public void addCreativeItems(ArrayList itemList) + { + if(blockID != ObsidianIngots.platinumOreID) + { + itemList.add(new ItemStack(this)); + } + else { + //Do nothing + } + } + + public String getTextureFile() { + return "/obsidian/terrain.png"; + } +} \ No newline at end of file diff --git a/src/common/net/uberkat/obsidian/common/BlockCombiner.java b/src/common/net/uberkat/obsidian/common/BlockCombiner.java new file mode 100644 index 000000000..dbcbea098 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/BlockCombiner.java @@ -0,0 +1,265 @@ +package net.uberkat.obsidian.common; + +import java.util.ArrayList; +import java.util.Random; + +import cpw.mods.fml.common.registry.BlockProxy; +import net.minecraft.src.*; + +public class BlockCombiner extends BlockContainer implements BlockProxy +{ + private Random combinerRand = new Random(); + + private static boolean keepCombinerInventory = false; + private static int currentTextureIndex = 0; + + public BlockCombiner(int par1) + { + super(par1, Material.iron); + } + + private void setDefaultDirection(World par1World, int par2, int par3, int par4) + { + if (!par1World.isRemote) + { + int var5 = par1World.getBlockId(par2, par3, par4 - 1); + int var6 = par1World.getBlockId(par2, par3, par4 + 1); + int var7 = par1World.getBlockId(par2 - 1, par3, par4); + int var8 = par1World.getBlockId(par2 + 1, par3, par4); + byte var9 = 3; + + if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6]) + { + var9 = 3; + } + + if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5]) + { + var9 = 2; + } + + if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8]) + { + var9 = 5; + } + + if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7]) + { + var9 = 4; + } + + par1World.setBlockMetadataWithNotify(par2, par3, par4, var9); + } + } + + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) + { + int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + if (var6 == 0) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 2); + } + + if (var6 == 1) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 5); + } + + if (var6 == 2) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 3); + } + + if (var6 == 3) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 4); + } + } + + public int idDropped(int par1, Random par2Random, int par3) + { + return ObsidianIngots.combinerID; + } + + public int getLightValue(IBlockAccess world, int x, int y, int z) + { + int metadata = world.getBlockMetadata(x, y, z); + if(metadata > 5) return 14; + else return 0; + } + + public void onBlockAdded(World par1World, int par2, int par3, int par4) + { + setDefaultDirection(par1World, par2, par3, par4); + super.onBlockAdded(par1World, par2, par3, par4); + } + + public int getBlockTexture(IBlockAccess world, int x, int y, int z, int side) + { + int metadata = world.getBlockMetadata(x, y, z); + int sideMeta = (metadata > 5 ? metadata - 8 : metadata); + return side != sideMeta ? 16 : (metadata > 5 ? currentTextureIndex : 17); + } + + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) + { + if(currentTextureIndex < 15 && currentTextureIndex > -1) + { + currentTextureIndex++; + par1World.markBlockAsNeedsUpdate(par2, par3, par4); + } + else if(currentTextureIndex == 15) + { + currentTextureIndex = 0; + par1World.markBlockAsNeedsUpdate(par2, par3, par4); + } + + int var6 = par1World.getBlockMetadata(par2, par3, par4); + if (var6 > 5) + { + int metadata = (var6 - 8); + float var7 = (float)par2 + 0.5F; + float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F; + float var9 = (float)par4 + 0.5F; + float var10 = 0.52F; + float var11 = par5Random.nextFloat() * 0.6F - 0.3F; + + if (metadata == 4) + { + par1World.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + } + else if (metadata == 5) + { + par1World.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + } + else if (metadata == 2) + { + par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D); + } + else if (metadata == 3) + { + par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D); + } + } + } + + public int getBlockTextureFromSideAndMetadata(int side, int meta) + { + return side != 3 ? 16 : (meta > 5 ? 0 : 17); + } + + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int i1, float f1, float f2, float f3) + { + if (par1World.isRemote) + { + return true; + } + else + { + TileEntityCombiner var6 = (TileEntityCombiner)par1World.getBlockTileEntity(par2, par3, par4); + + if (var6 != null) + { + par5EntityPlayer.openGui(ObsidianIngots.instance, 23, par1World, par2, par3, par4); + } + + return true; + } + } + + public static void updateCombinerBlockState(boolean par0, World par1World, int par2, int par3, int par4) + { + int var5 = par1World.getBlockMetadata(par2, par3, par4); + TileEntity var6 = par1World.getBlockTileEntity(par2, par3, par4); + keepCombinerInventory = true; + + if (par0) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, var5+8); + par1World.markBlockAsNeedsUpdate(par2, par3, par4); + par1World.updateAllLightTypes(par2, par3, par4); + } + else + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, var5-8); + par1World.markBlockAsNeedsUpdate(par2, par3, par4); + par1World.updateAllLightTypes(par2, par3, par4); + } + + keepCombinerInventory = false; + + if (var6 != null) + { + var6.validate(); + par1World.setBlockTileEntity(par2, par3, par4, var6); + } + } + + public void breakBlock(World par1World, int par2, int par3, int par4, int i1, int i2) + { + if (!keepCombinerInventory) + { + TileEntityCombiner var5 = (TileEntityCombiner)par1World.getBlockTileEntity(par2, par3, par4); + + if (var5 != null) + { + for (int var6 = 0; var6 < var5.getSizeInventory(); ++var6) + { + ItemStack var7 = var5.getStackInSlot(var6); + + if (var7 != null) + { + float var8 = this.combinerRand.nextFloat() * 0.8F + 0.1F; + float var9 = this.combinerRand.nextFloat() * 0.8F + 0.1F; + float var10 = this.combinerRand.nextFloat() * 0.8F + 0.1F; + + while (var7.stackSize > 0) + { + int var11 = this.combinerRand.nextInt(21) + 10; + + if (var11 > var7.stackSize) + { + var11 = var7.stackSize; + } + + var7.stackSize -= var11; + EntityItem var12 = new EntityItem(par1World, (double)((float)par2 + var8), (double)((float)par3 + var9), (double)((float)par4 + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage())); + + if (var7.hasTagCompound()) + { + var12.item.setTagCompound((NBTTagCompound)var7.getTagCompound().copy()); + } + + float var13 = 0.05F; + var12.motionX = (double)((float)this.combinerRand.nextGaussian() * var13); + var12.motionY = (double)((float)this.combinerRand.nextGaussian() * var13 + 0.2F); + var12.motionZ = (double)((float)this.combinerRand.nextGaussian() * var13); + par1World.spawnEntityInWorld(var12); + } + } + } + } + } + + super.breakBlock(par1World, par2, par3, par4, i1, i2); + } + + public void addCreativeItems(ArrayList itemList) + { + itemList.add(new ItemStack(this)); + } + + public String getTextureFile() + { + return "/obsidian/Combiner.png"; + } + + public TileEntity createNewTileEntity(World var1) { + return new TileEntityCombiner(); + } +} diff --git a/src/common/net/uberkat/obsidian/common/BlockCrusher.java b/src/common/net/uberkat/obsidian/common/BlockCrusher.java new file mode 100644 index 000000000..cc8145ade --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/BlockCrusher.java @@ -0,0 +1,249 @@ +package net.uberkat.obsidian.common; + +import java.util.ArrayList; +import java.util.Random; + +import cpw.mods.fml.common.registry.BlockProxy; +import net.minecraft.src.*; + +public class BlockCrusher extends BlockObsidianContainer implements BlockProxy +{ + private Random crusherRand = new Random(); + + private static boolean keepCrusherInventory = false; + + public BlockCrusher(int par1) + { + super(par1, Material.iron); + } + + private void setDefaultDirection(World par1World, int par2, int par3, int par4) + { + if (!par1World.isRemote) + { + int var5 = par1World.getBlockId(par2, par3, par4 - 1); + int var6 = par1World.getBlockId(par2, par3, par4 + 1); + int var7 = par1World.getBlockId(par2 - 1, par3, par4); + int var8 = par1World.getBlockId(par2 + 1, par3, par4); + byte var9 = 3; + + if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6]) + { + var9 = 3; + } + + if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5]) + { + var9 = 2; + } + + if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8]) + { + var9 = 5; + } + + if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7]) + { + var9 = 4; + } + + par1World.setBlockMetadataWithNotify(par2, par3, par4, var9); + } + } + + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) + { + int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + if (var6 == 0) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 2); + } + + if (var6 == 1) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 5); + } + + if (var6 == 2) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 3); + } + + if (var6 == 3) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 4); + } + } + + public int idDropped(int par1, Random par2Random, int par3) + { + return ObsidianIngots.crusherID; + } + + public void onBlockAdded(World par1World, int par2, int par3, int par4) + { + setDefaultDirection(par1World, par2, par3, par4); + super.onBlockAdded(par1World, par2, par3, par4); + } + + public int getLightValue(IBlockAccess world, int x, int y, int z) + { + int metadata = world.getBlockMetadata(x, y, z); + if(metadata > 5) return 14; + else return 0; + } + + public int getBlockTexture(IBlockAccess world, int x, int y, int z, int side) + { + int metadata = world.getBlockMetadata(x, y, z); + int sideMeta = (metadata > 5 ? metadata - 8 : metadata); + return side != sideMeta ? 2 : (metadata > 5 ? 16 : 17); + } + + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) + { + int var6 = par1World.getBlockMetadata(par2, par3, par4); + if (var6 > 5) + { + int metadata = (var6 - 8); + float var7 = (float)par2 + 0.5F; + float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F; + float var9 = (float)par4 + 0.5F; + float var10 = 0.52F; + float var11 = par5Random.nextFloat() * 0.6F - 0.3F; + + if (metadata == 4) + { + par1World.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + } + else if (metadata == 5) + { + par1World.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + } + else if (metadata == 2) + { + par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D); + } + else if (metadata == 3) + { + par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D); + } + } + } + + public int getBlockTextureFromSideAndMetadata(int side, int meta) + { + return side != 3 ? 2 : (meta > 5 ? 16 : 17); + } + + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int i1, float f1, float f2, float f3) + { + if (par1World.isRemote) + { + return true; + } + else + { + TileEntityCrusher var6 = (TileEntityCrusher)par1World.getBlockTileEntity(par2, par3, par4); + + if (var6 != null) + { + par5EntityPlayer.openGui(ObsidianIngots.instance, 24, par1World, par2, par3, par4); + } + + return true; + } + } + + public static void updateCrusherBlockState(boolean par0, World par1World, int par2, int par3, int par4) + { + int var5 = par1World.getBlockMetadata(par2, par3, par4); + TileEntity var6 = par1World.getBlockTileEntity(par2, par3, par4); + keepCrusherInventory = true; + + if (par0) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, var5+8); + par1World.markBlockAsNeedsUpdate(par2, par3, par4); + par1World.updateAllLightTypes(par2, par3, par4); + } + else + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, var5-8); + par1World.markBlockAsNeedsUpdate(par2, par3, par4); + par1World.updateAllLightTypes(par2, par3, par4); + } + + keepCrusherInventory = false; + + if (var6 != null) + { + var6.validate(); + par1World.setBlockTileEntity(par2, par3, par4, var6); + } + } + + public TileEntity getBlockEntity() + { + return new TileEntityCrusher(); + } + + public void breakBlock(World par1World, int par2, int par3, int par4, int i1, int i2) + { + if (!keepCrusherInventory) + { + TileEntityCrusher var5 = (TileEntityCrusher)par1World.getBlockTileEntity(par2, par3, par4); + + if (var5 != null) + { + for (int var6 = 0; var6 < var5.getSizeInventory(); ++var6) + { + ItemStack var7 = var5.getStackInSlot(var6); + + if (var7 != null) + { + float var8 = this.crusherRand.nextFloat() * 0.8F + 0.1F; + float var9 = this.crusherRand.nextFloat() * 0.8F + 0.1F; + float var10 = this.crusherRand.nextFloat() * 0.8F + 0.1F; + + while (var7.stackSize > 0) + { + int var11 = this.crusherRand.nextInt(21) + 10; + + if (var11 > var7.stackSize) + { + var11 = var7.stackSize; + } + + var7.stackSize -= var11; + EntityItem var12 = new EntityItem(par1World, (double)((float)par2 + var8), (double)((float)par3 + var9), (double)((float)par4 + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage())); + + if (var7.hasTagCompound()) + { + var12.item.setTagCompound((NBTTagCompound)var7.getTagCompound().copy()); + } + + float var13 = 0.05F; + var12.motionX = (double)((float)this.crusherRand.nextGaussian() * var13); + var12.motionY = (double)((float)this.crusherRand.nextGaussian() * var13 + 0.2F); + var12.motionZ = (double)((float)this.crusherRand.nextGaussian() * var13); + par1World.spawnEntityInWorld(var12); + } + } + } + } + } + + super.breakBlock(par1World, par2, par3, par4, i1, i2); + } + + public void addCreativeItems(ArrayList itemList) + { + itemList.add(new ItemStack(this)); + } +} diff --git a/src/common/net/uberkat/obsidian/common/BlockEnrichmentChamber.java b/src/common/net/uberkat/obsidian/common/BlockEnrichmentChamber.java new file mode 100644 index 000000000..16030ff83 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/BlockEnrichmentChamber.java @@ -0,0 +1,250 @@ +package net.uberkat.obsidian.common; + +import java.util.ArrayList; +import java.util.Random; + +import cpw.mods.fml.common.registry.BlockProxy; +import net.minecraft.src.*; + +public class BlockEnrichmentChamber extends BlockObsidianContainer implements BlockProxy +{ + private Random chamberRand = new Random(); + + private static boolean keepChamberInventory = false; + + public BlockEnrichmentChamber(int par1) + { + super(par1, Material.iron); + } + + public int getLightValue(IBlockAccess world, int x, int y, int z) + { + int metadata = world.getBlockMetadata(x, y, z); + if(metadata > 5) return 14; + else return 0; + } + + /** + * Called when the block is placed in the world. + */ + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) + { + int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + if (var6 == 0) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 2); + } + + if (var6 == 1) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 5); + } + + if (var6 == 2) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 3); + } + + if (var6 == 3) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 4); + } + } + + private void setDefaultDirection(World par1World, int par2, int par3, int par4) + { + if (!par1World.isRemote) + { + int var5 = par1World.getBlockId(par2, par3, par4 - 1); + int var6 = par1World.getBlockId(par2, par3, par4 + 1); + int var7 = par1World.getBlockId(par2 - 1, par3, par4); + int var8 = par1World.getBlockId(par2 + 1, par3, par4); + byte var9 = 3; + + if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6]) + { + var9 = 3; + } + + if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5]) + { + var9 = 2; + } + + if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8]) + { + var9 = 5; + } + + if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7]) + { + var9 = 4; + } + + par1World.setBlockMetadataWithNotify(par2, par3, par4, var9); + } + } + + public int idDropped(int par1, Random par2Random, int par3) + { + return ObsidianIngots.enrichmentChamberID; + } + + public void onBlockAdded(World par1World, int par2, int par3, int par4) + { + setDefaultDirection(par1World, par2, par3, par4); + super.onBlockAdded(par1World, par2, par3, par4); + } + + public int getBlockTexture(IBlockAccess world, int x, int y, int z, int side) + { + int metadata = world.getBlockMetadata(x, y, z); + int sideMeta = (metadata > 5 ? metadata - 8 : metadata); + return side != sideMeta ? 2 : (metadata > 5 ? 8 : 9); + } + + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) + { + int var6 = par1World.getBlockMetadata(par2, par3, par4); + if (var6 > 5) + { + int metadata = (var6 - 8); + float var7 = (float)par2 + 0.5F; + float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F; + float var9 = (float)par4 + 0.5F; + float var10 = 0.52F; + float var11 = par5Random.nextFloat() * 0.6F - 0.3F; + + if (metadata == 4) + { + par1World.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + } + else if (metadata == 5) + { + par1World.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + } + else if (metadata == 2) + { + par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D); + } + else if (metadata == 3) + { + par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D); + } + } + } + + public int getBlockTextureFromSideAndMetadata(int side, int meta) + { + return side != 3 ? 2 : (meta > 5 ? 8 : 9); + } + + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int i1, float f1, float f2, float f3) + { + if (par1World.isRemote) + { + return true; + } + else + { + TileEntityEnrichmentChamber var6 = (TileEntityEnrichmentChamber)par1World.getBlockTileEntity(par2, par3, par4); + + if (var6 != null) + { + par5EntityPlayer.openGui(ObsidianIngots.instance, 21, par1World, par2, par3, par4); + } + + return true; + } + } + + public static void updateChamberBlockState(boolean par0, World par1World, int par2, int par3, int par4) + { + int var5 = par1World.getBlockMetadata(par2, par3, par4); + TileEntity var6 = par1World.getBlockTileEntity(par2, par3, par4); + keepChamberInventory = true; + + if (par0) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, var5+8); + par1World.markBlockAsNeedsUpdate(par2, par3, par4); + par1World.updateAllLightTypes(par2, par3, par4); + } + else + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, var5-8); + par1World.markBlockAsNeedsUpdate(par2, par3, par4); + par1World.updateAllLightTypes(par2, par3, par4); + } + + keepChamberInventory = false; + if (var6 != null) + { + var6.validate(); + par1World.setBlockTileEntity(par2, par3, par4, var6); + } + } + + public TileEntity getBlockEntity() + { + return new TileEntityEnrichmentChamber(); + } + + public void onBlockRemoval(World par1World, int par2, int par3, int par4, int i1, int i2) + { + if(!keepChamberInventory) + { + TileEntityEnrichmentChamber var5 = (TileEntityEnrichmentChamber)par1World.getBlockTileEntity(par2, par3, par4); + + if (var5 != null) + { + for (int var6 = 0; var6 < var5.getSizeInventory(); ++var6) + { + ItemStack var7 = var5.getStackInSlot(var6); + + if (var7 != null) + { + float var8 = this.chamberRand.nextFloat() * 0.8F + 0.1F; + float var9 = this.chamberRand.nextFloat() * 0.8F + 0.1F; + float var10 = this.chamberRand.nextFloat() * 0.8F + 0.1F; + + while (var7.stackSize > 0) + { + int var11 = this.chamberRand.nextInt(21) + 10; + + if (var11 > var7.stackSize) + { + var11 = var7.stackSize; + } + + var7.stackSize -= var11; + EntityItem var12 = new EntityItem(par1World, (double)((float)par2 + var8), (double)((float)par3 + var9), (double)((float)par4 + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage())); + + if (var7.hasTagCompound()) + { + var12.item.setTagCompound((NBTTagCompound)var7.getTagCompound().copy()); + } + + float var13 = 0.05F; + var12.motionX = (double)((float)this.chamberRand.nextGaussian() * var13); + var12.motionY = (double)((float)this.chamberRand.nextGaussian() * var13 + 0.2F); + var12.motionZ = (double)((float)this.chamberRand.nextGaussian() * var13); + par1World.spawnEntityInWorld(var12); + } + } + } + } + } + super.breakBlock(par1World, par2, par3, par4, i1, i2); + } + + public void addCreativeItems(ArrayList itemList) + { + itemList.add(new ItemStack(this)); + } +} diff --git a/src/common/net/uberkat/obsidian/common/BlockLife.java b/src/common/net/uberkat/obsidian/common/BlockLife.java new file mode 100644 index 000000000..bbaf7b8a8 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/BlockLife.java @@ -0,0 +1,66 @@ +package net.uberkat.obsidian.common; + +import java.util.ArrayList; +import java.util.Random; + +import cpw.mods.fml.common.registry.BlockProxy; + +import net.minecraft.src.*; + +public class BlockLife extends Block implements BlockProxy +{ + private Random lifeRand; + + public BlockLife(int i, int j) + { + super(i, j, Material.iron); + lifeRand = new Random(); + setHardness(1F); + setResistance(3F); + setLightValue(2F); + } + + public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) + { + if(!world.isRemote) + { + int random = lifeRand.nextInt(3); + world.spawnParticle("hugeexplosion", i, j, k, 0.0D, 0.0D, 0.0D); + switch(random) + { + case 0: + entityplayer.inventory.addItemStackToInventory(new ItemStack(ObsidianIngots.Stopwatch, 1)); + world.setBlock(i, j, k, 0); + break; + case 1: + entityplayer.inventory.addItemStackToInventory(new ItemStack(ObsidianIngots.LightningRod, 1)); + world.setBlock(i, j, k, 0); + break; + case 2: + entityplayer.inventory.addItemStackToInventory(new ItemStack(ObsidianIngots.WeatherOrb, 1)); + world.setBlock(i, j, k, 0); + break; + } + } + return true; + } + + public int idDropped(int i, Random random) + { + return 0; + } + + public int quantityDropped(Random random) + { + return 0; + } + + public void addCreativeItems(ArrayList itemList) + { + itemList.add(new ItemStack(this)); + } + + public String getTextureFile() { + return "/obsidian/terrain.png"; + } +} diff --git a/src/common/net/uberkat/obsidian/common/BlockObsidianContainer.java b/src/common/net/uberkat/obsidian/common/BlockObsidianContainer.java new file mode 100644 index 000000000..1a234fdbf --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/BlockObsidianContainer.java @@ -0,0 +1,25 @@ +package net.uberkat.obsidian.common; + +import java.util.ArrayList; + +import cpw.mods.fml.common.registry.BlockProxy; + +import net.minecraft.src.*; + +public class BlockObsidianContainer extends BlockContainer implements BlockProxy +{ + public BlockObsidianContainer(int i, Material material) + { + super(i, material); + } + + public TileEntity createNewTileEntity(World world) + { + return null; + } + + public String getTextureFile() + { + return "/obsidian/terrain.png"; + } +} diff --git a/src/common/net/uberkat/obsidian/common/BlockObsidianTNT.java b/src/common/net/uberkat/obsidian/common/BlockObsidianTNT.java new file mode 100644 index 000000000..de6ea06a2 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/BlockObsidianTNT.java @@ -0,0 +1,149 @@ +package net.uberkat.obsidian.common; + +import java.util.ArrayList; +import java.util.Random; + +import cpw.mods.fml.common.registry.BlockProxy; +import net.minecraft.src.*; + +public class BlockObsidianTNT extends Block implements BlockProxy +{ + public BlockObsidianTNT(int par1) + { + super(par1, Material.tnt); + setStepSound(Block.soundGrassFootstep); + setHardness(0.0F); + setResistance(0.0F); + } + + /** + * Returns the block texture based on the side being looked at. Args: side + */ + public int getBlockTextureFromSide(int par1) + { + if(par1 == 1) + { + return 5; + } + if(par1 == 0) + { + return 7; + } + else { + return 6; + } + } + + /** + * Called whenever the block is added into the world. Args: world, x, y, z + */ + public void onBlockAdded(World par1World, int par2, int par3, int par4) + { + super.onBlockAdded(par1World, par2, par3, par4); + + if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) + { + this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1); + par1World.setBlockWithNotify(par2, par3, par4, 0); + } + } + + /** + * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are + * their own) Args: x, y, z, neighbor blockID + */ + public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) + { + if (par5 > 0 && Block.blocksList[par5].canProvidePower() && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) + { + this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1); + par1World.setBlockWithNotify(par2, par3, par4, 0); + } + } + + /** + * Returns the quantity of items to drop on block destruction. + */ + public int quantityDropped(Random par1Random) + { + return 0; + } + + /** + * Called upon the block being destroyed by an explosion + */ + public void onBlockDestroyedByExplosion(World par1World, int par2, int par3, int par4) + { + if (!par1World.isRemote) + { + EntityObsidianTNT var5 = new EntityObsidianTNT(par1World, (double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F)); + var5.fuse = par1World.rand.nextInt(var5.fuse / 4) + var5.fuse / 8; + par1World.spawnEntityInWorld(var5); + } + } + + /** + * Called right before the block is destroyed by a player. Args: world, x, y, z, metaData + */ + public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) + { + if (!par1World.isRemote) + { + if ((par5 & 1) == 0) + { + this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(ObsidianIngots.ObsidianTNT, 1, 0)); + } + else + { + EntityObsidianTNT var6 = new EntityObsidianTNT(par1World, (double)((float)par2 + 0.5F), (double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F)); + par1World.spawnEntityInWorld(var6); + par1World.playSoundAtEntity(var6, "random.fuse", 1.0F, 1.0F); + } + } + } + + /** + * Called when the block is clicked by a player. Args: x, y, z, entityPlayer + */ + public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) + { + super.onBlockClicked(par1World, par2, par3, par4, par5EntityPlayer); + } + + /** + * Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the + * block. + */ + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int i1, float f1, float f2, float f3) + { + if (par5EntityPlayer.getCurrentEquippedItem() != null && par5EntityPlayer.getCurrentEquippedItem().itemID == Item.flintAndSteel.shiftedIndex) + { + this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1); + par1World.setBlockWithNotify(par2, par3, par4, 0); + return true; + } + else + { + return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, i1, f1, f2, f3); + } + } + + /** + * Returns an item stack containing a single instance of the current block type. 'i' is the block's subtype/damage + * and is ignored for blocks which do not support subtypes. Blocks which cannot be harvested should return null. + */ + protected ItemStack createStackedBlock(int par1) + { + return null; + } + + public void addCreativeItems(ArrayList itemList) + { + itemList.add(new ItemStack(this)); + } + + public String getTextureFile() + { + return "/obsidian/terrain.png"; + } +} diff --git a/src/common/net/uberkat/obsidian/common/BlockPlatinumCompressor.java b/src/common/net/uberkat/obsidian/common/BlockPlatinumCompressor.java new file mode 100644 index 000000000..0c3b66761 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/BlockPlatinumCompressor.java @@ -0,0 +1,267 @@ +package net.uberkat.obsidian.common; + +import java.util.ArrayList; +import java.util.Random; + +import cpw.mods.fml.common.registry.BlockProxy; +import net.minecraft.src.*; + +public class BlockPlatinumCompressor extends BlockContainer implements BlockProxy +{ + private Random compressorRand = new Random(); + + private static boolean keepCompressorInventory = false; + + private static int currentTextureIndex; + + public BlockPlatinumCompressor(int par1) + { + super(par1, Material.iron); + } + + private void setDefaultDirection(World par1World, int par2, int par3, int par4) + { + if (!par1World.isRemote) + { + int var5 = par1World.getBlockId(par2, par3, par4 - 1); + int var6 = par1World.getBlockId(par2, par3, par4 + 1); + int var7 = par1World.getBlockId(par2 - 1, par3, par4); + int var8 = par1World.getBlockId(par2 + 1, par3, par4); + byte var9 = 3; + + if (Block.opaqueCubeLookup[var5] && !Block.opaqueCubeLookup[var6]) + { + var9 = 3; + } + + if (Block.opaqueCubeLookup[var6] && !Block.opaqueCubeLookup[var5]) + { + var9 = 2; + } + + if (Block.opaqueCubeLookup[var7] && !Block.opaqueCubeLookup[var8]) + { + var9 = 5; + } + + if (Block.opaqueCubeLookup[var8] && !Block.opaqueCubeLookup[var7]) + { + var9 = 4; + } + + par1World.setBlockMetadataWithNotify(par2, par3, par4, var9); + } + } + + public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) + { + int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + + if (var6 == 0) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 2); + } + + if (var6 == 1) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 5); + } + + if (var6 == 2) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 3); + } + + if (var6 == 3) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, 4); + } + } + + public int idDropped(int par1, Random par2Random, int par3) + { + return ObsidianIngots.platinumCompressorID; + } + + public void onBlockAdded(World par1World, int par2, int par3, int par4) + { + setDefaultDirection(par1World, par2, par3, par4); + super.onBlockAdded(par1World, par2, par3, par4); + } + + public int getLightValue(IBlockAccess world, int x, int y, int z) + { + int metadata = world.getBlockMetadata(x, y, z); + if(metadata > 5) return 14; + else return 0; + } + + public int getBlockTexture(IBlockAccess world, int x, int y, int z, int side) + { + int metadata = world.getBlockMetadata(x, y, z); + int sideMeta = (metadata > 5 ? metadata - 8 : metadata); + return side != sideMeta ? 16 : (metadata > 5 ? currentTextureIndex : 17); + } + + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) + { + if(currentTextureIndex < 15 && currentTextureIndex > -1) + { + currentTextureIndex++; + par1World.markBlockAsNeedsUpdate(par2, par3, par4); + } + else if(currentTextureIndex == 15) + { + currentTextureIndex = 0; + par1World.markBlockAsNeedsUpdate(par2, par3, par4); + } + + int var6 = par1World.getBlockMetadata(par2, par3, par4); + if (var6 > 5) + { + int metadata = (var6 - 8); + float var7 = (float)par2 + 0.5F; + float var8 = (float)par3 + 0.0F + par5Random.nextFloat() * 6.0F / 16.0F; + float var9 = (float)par4 + 0.5F; + float var10 = 0.52F; + float var11 = par5Random.nextFloat() * 0.6F - 0.3F; + + if (metadata == 4) + { + par1World.spawnParticle("smoke", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 - var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + } + else if (metadata == 5) + { + par1World.spawnParticle("smoke", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 + var10), (double)var8, (double)(var9 + var11), 0.0D, 0.0D, 0.0D); + } + else if (metadata == 2) + { + par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 + var11), (double)var8, (double)(var9 - var10), 0.0D, 0.0D, 0.0D); + } + else if (metadata == 3) + { + par1World.spawnParticle("smoke", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D); + par1World.spawnParticle("reddust", (double)(var7 + var11), (double)var8, (double)(var9 + var10), 0.0D, 0.0D, 0.0D); + } + } + } + + public int getBlockTextureFromSideAndMetadata(int side, int meta) + { + return side != 3 ? 16 : (meta > 5 ? 0 : 17); + } + + public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int i1, float f1, float f2, float f3) + { + if (par1World.isRemote) + { + return true; + } + else + { + TileEntityPlatinumCompressor var6 = (TileEntityPlatinumCompressor)par1World.getBlockTileEntity(par2, par3, par4); + + if (var6 != null) + { + par5EntityPlayer.openGui(ObsidianIngots.instance, 22, par1World, par2, par3, par4); + } + + return true; + } + } + + public static void updateCompressorBlockState(boolean par0, World par1World, int par2, int par3, int par4) + { + int var5 = par1World.getBlockMetadata(par2, par3, par4); + TileEntity var6 = par1World.getBlockTileEntity(par2, par3, par4); + keepCompressorInventory = true; + + if (par0) + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, var5+8); + par1World.markBlockAsNeedsUpdate(par2, par3, par4); + par1World.updateAllLightTypes(par2, par3, par4); + } + else + { + par1World.setBlockMetadataWithNotify(par2, par3, par4, var5-8); + par1World.markBlockAsNeedsUpdate(par2, par3, par4); + par1World.updateAllLightTypes(par2, par3, par4); + } + + keepCompressorInventory = false; + + if (var6 != null) + { + var6.validate(); + par1World.setBlockTileEntity(par2, par3, par4, var6); + } + } + + public TileEntity createNewTileEntity(World world) + { + return new TileEntityPlatinumCompressor(); + } + + public void breakBlock(World par1World, int par2, int par3, int par4, int i1, int i2) + { + if (!keepCompressorInventory) + { + TileEntityPlatinumCompressor var5 = (TileEntityPlatinumCompressor)par1World.getBlockTileEntity(par2, par3, par4); + + if (var5 != null) + { + for (int var6 = 0; var6 < var5.getSizeInventory(); ++var6) + { + ItemStack var7 = var5.getStackInSlot(var6); + + if (var7 != null) + { + float var8 = this.compressorRand.nextFloat() * 0.8F + 0.1F; + float var9 = this.compressorRand.nextFloat() * 0.8F + 0.1F; + float var10 = this.compressorRand.nextFloat() * 0.8F + 0.1F; + + while (var7.stackSize > 0) + { + int var11 = this.compressorRand.nextInt(21) + 10; + + if (var11 > var7.stackSize) + { + var11 = var7.stackSize; + } + + var7.stackSize -= var11; + EntityItem var12 = new EntityItem(par1World, (double)((float)par2 + var8), (double)((float)par3 + var9), (double)((float)par4 + var10), new ItemStack(var7.itemID, var11, var7.getItemDamage())); + + if (var7.hasTagCompound()) + { + var12.item.setTagCompound((NBTTagCompound)var7.getTagCompound().copy()); + } + + float var13 = 0.05F; + var12.motionX = (double)((float)this.compressorRand.nextGaussian() * var13); + var12.motionY = (double)((float)this.compressorRand.nextGaussian() * var13 + 0.2F); + var12.motionZ = (double)((float)this.compressorRand.nextGaussian() * var13); + par1World.spawnEntityInWorld(var12); + } + } + } + } + } + + super.breakBlock(par1World, par2, par3, par4, i1, i2); + } + + public void addCreativeItems(ArrayList itemList) + { + itemList.add(new ItemStack(this)); + } + + public String getTextureFile() + { + return "/obsidian/Compressor.png"; + } +} diff --git a/src/common/net/uberkat/obsidian/common/CombinerRecipes.java b/src/common/net/uberkat/obsidian/common/CombinerRecipes.java new file mode 100644 index 000000000..36b97cf80 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/CombinerRecipes.java @@ -0,0 +1,86 @@ +package net.uberkat.obsidian.common; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import net.minecraft.src.*; + +public class CombinerRecipes +{ + private static final CombinerRecipes smeltingBase = new CombinerRecipes(); + + /** The list of smelting results. */ + private Map smeltingList = new HashMap(); + private Map metaSmeltingList = new HashMap(); + + /** + * Used to call methods addSmelting and getSmeltingResult. + */ + public static final CombinerRecipes smelting() + { + return smeltingBase; + } + + private CombinerRecipes() + { + addSmelting(Item.redstone.shiftedIndex, new ItemStack(Block.oreRedstone, 1)); + addSmelting(ObsidianIngots.ObsidianDust.shiftedIndex, new ItemStack(Block.obsidian, 1)); + addSmelting(ObsidianIngots.IronDust.shiftedIndex, new ItemStack(Block.oreIron, 1)); + addSmelting(ObsidianIngots.GoldDust.shiftedIndex, new ItemStack(Block.oreGold, 1)); + addSmelting(Item.diamond.shiftedIndex, new ItemStack(Block.oreDiamond, 1)); + addSmelting(new ItemStack(Item.dyePowder, 1, 4).getItem().shiftedIndex, new ItemStack(Block.oreLapis, 1)); + } + + /** + * Adds a smelting recipe. + */ + public void addSmelting(int par1, ItemStack par2ItemStack) + { + this.smeltingList.put(Integer.valueOf(par1), par2ItemStack); + } + + /** + * Returns the smelting result of an item. + * Deprecated in favor of a metadata sensitive version + */ + @Deprecated + public ItemStack getSmeltingResult(int par1) + { + return (ItemStack)this.smeltingList.get(Integer.valueOf(par1)); + } + + public Map getSmeltingList() + { + return this.smeltingList; + } + + /** + * Add a metadata-sensitive furnace recipe + * @param itemID The Item ID + * @param metadata The Item Metadata + * @param itemstack The ItemStack for the result + */ + public void addSmelting(int itemID, int metadata, ItemStack itemstack) + { + metaSmeltingList.put(Arrays.asList(itemID, metadata), itemstack); + } + + /** + * Used to get the resulting ItemStack form a source ItemStack + * @param item The Source ItemStack + * @return The result ItemStack + */ + public ItemStack getSmeltingResult(ItemStack item) + { + if (item == null) + { + return null; + } + ItemStack ret = (ItemStack)metaSmeltingList.get(Arrays.asList(item.itemID, item.getItemDamage())); + if (ret != null) + { + return ret; + } + return (ItemStack)smeltingList.get(Integer.valueOf(item.itemID)); + } +} diff --git a/src/common/net/uberkat/obsidian/common/CommonGuiHandler.java b/src/common/net/uberkat/obsidian/common/CommonGuiHandler.java new file mode 100644 index 000000000..6bfeb3f80 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/CommonGuiHandler.java @@ -0,0 +1,16 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.World; +import cpw.mods.fml.common.network.IGuiHandler; + +public class CommonGuiHandler implements IGuiHandler +{ + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + return ObsidianIngots.proxy.getServerGui(ID, player, world, x, y, z); + } + + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + return ObsidianIngots.proxy.getClientGui(ID, player, world, x, y, z); + } +} diff --git a/src/common/net/uberkat/obsidian/common/CommonProxy.java b/src/common/net/uberkat/obsidian/common/CommonProxy.java new file mode 100644 index 000000000..7dc2499a8 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/CommonProxy.java @@ -0,0 +1,76 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.Container; +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.World; +import cpw.mods.fml.common.network.IGuiHandler; + +/** + * Common proxy for Obsidian Ingots mod. + * @author AidanBrady + * + */ +public abstract class CommonProxy +{ + /** + * Register and load client-only render information. + */ + public abstract void registerRenderInformation(); + + /** + * Set and load the default properties for the mod. + */ + public abstract void setProperties(); + + /** + * Load and initiate utilities for the mod. + */ + public abstract void loadUtilities(); + + /** + * Set up and load the client-only tick handler. + */ + public abstract void loadTickHandler(); + + /** + * Get the actual interface for a GUI. Client-only. + * @param ID - gui ID + * @param player - player that opened the GUI + * @param world - world the GUI was opened in + * @param x - gui's x position + * @param y - gui's y position + * @param z - gui's z position + * @return the GuiScreen of the interface + */ + public abstract Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z); + + /** + * Get the container for a GUI. Common. + * @param ID - gui ID + * @param player - player that opened the GUI + * @param world - world the GUI was opened in + * @param x - gui's x position + * @param y - gui's y position + * @param z - gui's z position + * @return the Container of the interface + */ + public Container getServerGui(int ID, EntityPlayer player, World world, int x, int y, int z) + { + switch(ID) + { + case 21: + TileEntityEnrichmentChamber tileentity = (TileEntityEnrichmentChamber)world.getBlockTileEntity(x, y, z); + return new ContainerEnrichmentChamber(player.inventory, tileentity); + case 22: + TileEntityPlatinumCompressor tileentity1 = (TileEntityPlatinumCompressor)world.getBlockTileEntity(x, y, z); + return new ContainerPlatinumCompressor(player.inventory, tileentity1); + case 23: + TileEntityCombiner tileentity2 = (TileEntityCombiner)world.getBlockTileEntity(x, y, z); + return new ContainerCombiner(player.inventory, tileentity2); + case 24: + TileEntityCrusher tileentity3 = (TileEntityCrusher)world.getBlockTileEntity(x, y, z); + return new ContainerCrusher(player.inventory, tileentity3); + } + return null; + } +} diff --git a/src/common/net/uberkat/obsidian/common/ContainerCombiner.java b/src/common/net/uberkat/obsidian/common/ContainerCombiner.java new file mode 100644 index 000000000..39e14f019 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ContainerCombiner.java @@ -0,0 +1,163 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class ContainerCombiner extends Container +{ + private TileEntityCombiner combiner; + private int lastCookTime = 0; + private int lastBurnTime = 0; + private int lastItemBurnTime = 0; + + public ContainerCombiner(InventoryPlayer par1InventoryPlayer, TileEntityCombiner par2TileEntityCombiner) + { + this.combiner = par2TileEntityCombiner; + this.addSlotToContainer(new Slot(par2TileEntityCombiner, 0, 56, 17)); + this.addSlotToContainer(new Slot(par2TileEntityCombiner, 1, 56, 53)); + this.addSlotToContainer(new SlotObsidian(par1InventoryPlayer.player, par2TileEntityCombiner, 2, 116, 35)); + int var3; + + for (var3 = 0; var3 < 3; ++var3) + { + for (int var4 = 0; var4 < 9; ++var4) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + } + } + + for (var3 = 0; var3 < 9; ++var3) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142)); + } + } + + /** + * Updates crafting matrix; called from onCraftMatrixChanged. Args: none + */ + public void updateCraftingResults() + { + super.updateCraftingResults(); + + for (int var1 = 0; var1 < this.crafters.size(); ++var1) + { + ICrafting var2 = (ICrafting)this.crafters.get(var1); + + if (this.lastCookTime != this.combiner.combinerCookTime) + { + var2.updateCraftingInventoryInfo(this, 0, this.combiner.combinerCookTime); + } + + if (this.lastBurnTime != this.combiner.combinerBurnTime) + { + var2.updateCraftingInventoryInfo(this, 1, this.combiner.combinerBurnTime); + } + + if (this.lastItemBurnTime != this.combiner.currentItemBurnTime) + { + var2.updateCraftingInventoryInfo(this, 2, this.combiner.currentItemBurnTime); + } + } + + this.lastCookTime = this.combiner.combinerCookTime; + this.lastBurnTime = this.combiner.combinerBurnTime; + this.lastItemBurnTime = this.combiner.currentItemBurnTime; + } + + public void updateProgressBar(int par1, int par2) + { + if (par1 == 0) + { + this.combiner.combinerCookTime = par2; + } + + if (par1 == 1) + { + this.combiner.combinerBurnTime = par2; + } + + if (par1 == 2) + { + this.combiner.currentItemBurnTime = par2; + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.combiner.isUseableByPlayer(par1EntityPlayer); + } + + /** + * Called to transfer a stack from one inventory to the other eg. when shift clicking. + */ + public ItemStack transferStackInSlot(int par1) + { + ItemStack var2 = null; + Slot var3 = (Slot)this.inventorySlots.get(par1); + + if (var3 != null && var3.getHasStack()) + { + ItemStack var4 = var3.getStack(); + var2 = var4.copy(); + + if (par1 == 2) + { + if (!this.mergeItemStack(var4, 3, 39, true)) + { + return null; + } + + var3.onSlotChange(var4, var2); + } + else if (par1 != 1 && par1 != 0) + { + if (CombinerRecipes.smelting().getSmeltingResult(var4) != null) + { + if (!this.mergeItemStack(var4, 0, 1, false)) + { + return null; + } + } + else if (TileEntityCombiner.isItemFuel(var4)) + { + if (!this.mergeItemStack(var4, 1, 2, false)) + { + return null; + } + } + else if (par1 >= 3 && par1 < 30) + { + if (!this.mergeItemStack(var4, 30, 39, false)) + { + return null; + } + } + else if (par1 >= 30 && par1 < 39 && !this.mergeItemStack(var4, 3, 30, false)) + { + return null; + } + } + else if (!this.mergeItemStack(var4, 3, 39, false)) + { + return null; + } + + if (var4.stackSize == 0) + { + var3.putStack((ItemStack)null); + } + else + { + var3.onSlotChanged(); + } + + if (var4.stackSize == var2.stackSize) + { + return null; + } + + var3.onPickupFromSlot(var4); + } + + return var2; + } +} diff --git a/src/common/net/uberkat/obsidian/common/ContainerCrusher.java b/src/common/net/uberkat/obsidian/common/ContainerCrusher.java new file mode 100644 index 000000000..20290eb9e --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ContainerCrusher.java @@ -0,0 +1,163 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class ContainerCrusher extends Container +{ + private TileEntityCrusher crusher; + private int lastCookTime = 0; + private int lastBurnTime = 0; + private int lastItemBurnTime = 0; + + public ContainerCrusher(InventoryPlayer par1InventoryPlayer, TileEntityCrusher par2TileEntityCrusher) + { + this.crusher = par2TileEntityCrusher; + this.addSlotToContainer(new Slot(par2TileEntityCrusher, 0, 56, 17)); + this.addSlotToContainer(new Slot(par2TileEntityCrusher, 1, 56, 53)); + this.addSlotToContainer(new SlotObsidian(par1InventoryPlayer.player, par2TileEntityCrusher, 2, 116, 35)); + int var3; + + for (var3 = 0; var3 < 3; ++var3) + { + for (int var4 = 0; var4 < 9; ++var4) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + } + } + + for (var3 = 0; var3 < 9; ++var3) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142)); + } + } + + /** + * Updates crafting matrix; called from onCraftMatrixChanged. Args: none + */ + public void updateCraftingResults() + { + super.updateCraftingResults(); + + for (int var1 = 0; var1 < this.crafters.size(); ++var1) + { + ICrafting var2 = (ICrafting)this.crafters.get(var1); + + if (this.lastCookTime != this.crusher.crusherCookTime) + { + var2.updateCraftingInventoryInfo(this, 0, this.crusher.crusherCookTime); + } + + if (this.lastBurnTime != this.crusher.crusherBurnTime) + { + var2.updateCraftingInventoryInfo(this, 1, this.crusher.crusherBurnTime); + } + + if (this.lastItemBurnTime != this.crusher.currentItemBurnTime) + { + var2.updateCraftingInventoryInfo(this, 2, this.crusher.currentItemBurnTime); + } + } + + this.lastCookTime = this.crusher.crusherCookTime; + this.lastBurnTime = this.crusher.crusherBurnTime; + this.lastItemBurnTime = this.crusher.currentItemBurnTime; + } + + public void updateProgressBar(int par1, int par2) + { + if (par1 == 0) + { + this.crusher.crusherCookTime = par2; + } + + if (par1 == 1) + { + this.crusher.crusherBurnTime = par2; + } + + if (par1 == 2) + { + this.crusher.currentItemBurnTime = par2; + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.crusher.isUseableByPlayer(par1EntityPlayer); + } + + /** + * Called to transfer a stack from one inventory to the other eg. when shift clicking. + */ + public ItemStack transferStackInSlot(int par1) + { + ItemStack var2 = null; + Slot var3 = (Slot)this.inventorySlots.get(par1); + + if (var3 != null && var3.getHasStack()) + { + ItemStack var4 = var3.getStack(); + var2 = var4.copy(); + + if (par1 == 2) + { + if (!this.mergeItemStack(var4, 3, 39, true)) + { + return null; + } + + var3.onSlotChange(var4, var2); + } + else if (par1 != 1 && par1 != 0) + { + if (CrusherRecipes.smelting().getSmeltingResult(var4) != null) + { + if (!this.mergeItemStack(var4, 0, 1, false)) + { + return null; + } + } + else if (TileEntityCrusher.isItemFuel(var4)) + { + if (!this.mergeItemStack(var4, 1, 2, false)) + { + return null; + } + } + else if (par1 >= 3 && par1 < 30) + { + if (!this.mergeItemStack(var4, 30, 39, false)) + { + return null; + } + } + else if (par1 >= 30 && par1 < 39 && !this.mergeItemStack(var4, 3, 30, false)) + { + return null; + } + } + else if (!this.mergeItemStack(var4, 3, 39, false)) + { + return null; + } + + if (var4.stackSize == 0) + { + var3.putStack((ItemStack)null); + } + else + { + var3.onSlotChanged(); + } + + if (var4.stackSize == var2.stackSize) + { + return null; + } + + var3.onPickupFromSlot(var4); + } + + return var2; + } +} diff --git a/src/common/net/uberkat/obsidian/common/ContainerEnrichmentChamber.java b/src/common/net/uberkat/obsidian/common/ContainerEnrichmentChamber.java new file mode 100644 index 000000000..f197f11e3 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ContainerEnrichmentChamber.java @@ -0,0 +1,163 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class ContainerEnrichmentChamber extends Container +{ + private TileEntityEnrichmentChamber chamber; + private int lastCookTime = 0; + private int lastBurnTime = 0; + private int lastItemBurnTime = 0; + + public ContainerEnrichmentChamber(InventoryPlayer par1InventoryPlayer, TileEntityEnrichmentChamber par2TileEntityEnrichmentChamber) + { + this.chamber = par2TileEntityEnrichmentChamber; + this.addSlotToContainer(new Slot(par2TileEntityEnrichmentChamber, 0, 56, 17)); + this.addSlotToContainer(new Slot(par2TileEntityEnrichmentChamber, 1, 56, 53)); + this.addSlotToContainer(new SlotObsidian(par1InventoryPlayer.player, par2TileEntityEnrichmentChamber, 2, 116, 35)); + int var3; + + for (var3 = 0; var3 < 3; ++var3) + { + for (int var4 = 0; var4 < 9; ++var4) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + } + } + + for (var3 = 0; var3 < 9; ++var3) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142)); + } + } + + /** + * Updates crafting matrix; called from onCraftMatrixChanged. Args: none + */ + public void updateCraftingResults() + { + super.updateCraftingResults(); + + for (int var1 = 0; var1 < this.crafters.size(); ++var1) + { + ICrafting var2 = (ICrafting)this.crafters.get(var1); + + if (this.lastCookTime != this.chamber.chamberCookTime) + { + var2.updateCraftingInventoryInfo(this, 0, this.chamber.chamberCookTime); + } + + if (this.lastBurnTime != this.chamber.chamberBurnTime) + { + var2.updateCraftingInventoryInfo(this, 1, this.chamber.chamberBurnTime); + } + + if (this.lastItemBurnTime != this.chamber.currentItemBurnTime) + { + var2.updateCraftingInventoryInfo(this, 2, this.chamber.currentItemBurnTime); + } + } + + this.lastCookTime = this.chamber.chamberCookTime; + this.lastBurnTime = this.chamber.chamberBurnTime; + this.lastItemBurnTime = this.chamber.currentItemBurnTime; + } + + public void updateProgressBar(int par1, int par2) + { + if (par1 == 0) + { + this.chamber.chamberCookTime = par2; + } + + if (par1 == 1) + { + this.chamber.chamberBurnTime = par2; + } + + if (par1 == 2) + { + this.chamber.currentItemBurnTime = par2; + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.chamber.isUseableByPlayer(par1EntityPlayer); + } + + /** + * Called to transfer a stack from one inventory to the other eg. when shift clicking. + */ + public ItemStack transferStackInSlot(int par1) + { + ItemStack var2 = null; + Slot var3 = (Slot)this.inventorySlots.get(par1); + + if (var3 != null && var3.getHasStack()) + { + ItemStack var4 = var3.getStack(); + var2 = var4.copy(); + + if (par1 == 2) + { + if (!this.mergeItemStack(var4, 3, 39, true)) + { + return null; + } + + var3.onSlotChange(var4, var2); + } + else if (par1 != 1 && par1 != 0) + { + if (EnrichmentChamberRecipes.smelting().getSmeltingResult(var4) != null) + { + if (!this.mergeItemStack(var4, 0, 1, false)) + { + return null; + } + } + else if (TileEntityEnrichmentChamber.isItemFuel(var4)) + { + if (!this.mergeItemStack(var4, 1, 2, false)) + { + return null; + } + } + else if (par1 >= 3 && par1 < 30) + { + if (!this.mergeItemStack(var4, 30, 39, false)) + { + return null; + } + } + else if (par1 >= 30 && par1 < 39 && !this.mergeItemStack(var4, 3, 30, false)) + { + return null; + } + } + else if (!this.mergeItemStack(var4, 3, 39, false)) + { + return null; + } + + if (var4.stackSize == 0) + { + var3.putStack((ItemStack)null); + } + else + { + var3.onSlotChanged(); + } + + if (var4.stackSize == var2.stackSize) + { + return null; + } + + var3.onPickupFromSlot(var4); + } + + return var2; + } +} diff --git a/src/common/net/uberkat/obsidian/common/ContainerPlatinumCompressor.java b/src/common/net/uberkat/obsidian/common/ContainerPlatinumCompressor.java new file mode 100644 index 000000000..0611cff52 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ContainerPlatinumCompressor.java @@ -0,0 +1,163 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class ContainerPlatinumCompressor extends Container +{ + private TileEntityPlatinumCompressor compressor; + private int lastCookTime = 0; + private int lastBurnTime = 0; + private int lastItemBurnTime = 0; + + public ContainerPlatinumCompressor(InventoryPlayer par1InventoryPlayer, TileEntityPlatinumCompressor par2TileEntityPlatinumCompressor) + { + this.compressor = par2TileEntityPlatinumCompressor; + this.addSlotToContainer(new Slot(par2TileEntityPlatinumCompressor, 0, 56, 17)); + this.addSlotToContainer(new Slot(par2TileEntityPlatinumCompressor, 1, 56, 53)); + this.addSlotToContainer(new SlotObsidian(par1InventoryPlayer.player, par2TileEntityPlatinumCompressor, 2, 116, 35)); + int var3; + + for (var3 = 0; var3 < 3; ++var3) + { + for (int var4 = 0; var4 < 9; ++var4) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); + } + } + + for (var3 = 0; var3 < 9; ++var3) + { + this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142)); + } + } + + /** + * Updates crafting matrix; called from onCraftMatrixChanged. Args: none + */ + public void updateCraftingResults() + { + super.updateCraftingResults(); + + for (int var1 = 0; var1 < this.crafters.size(); ++var1) + { + ICrafting var2 = (ICrafting)this.crafters.get(var1); + + if (this.lastCookTime != this.compressor.compressorCookTime) + { + var2.updateCraftingInventoryInfo(this, 0, this.compressor.compressorCookTime); + } + + if (this.lastBurnTime != this.compressor.compressorBurnTime) + { + var2.updateCraftingInventoryInfo(this, 1, this.compressor.compressorBurnTime); + } + + if (this.lastItemBurnTime != this.compressor.currentItemBurnTime) + { + var2.updateCraftingInventoryInfo(this, 2, this.compressor.currentItemBurnTime); + } + } + + this.lastCookTime = this.compressor.compressorCookTime; + this.lastBurnTime = this.compressor.compressorBurnTime; + this.lastItemBurnTime = this.compressor.currentItemBurnTime; + } + + public void updateProgressBar(int par1, int par2) + { + if (par1 == 0) + { + this.compressor.compressorCookTime = par2; + } + + if (par1 == 1) + { + this.compressor.compressorBurnTime = par2; + } + + if (par1 == 2) + { + this.compressor.currentItemBurnTime = par2; + } + } + + public boolean canInteractWith(EntityPlayer par1EntityPlayer) + { + return this.compressor.isUseableByPlayer(par1EntityPlayer); + } + + /** + * Called to transfer a stack from one inventory to the other eg. when shift clicking. + */ + public ItemStack transferStackInSlot(int par1) + { + ItemStack var2 = null; + Slot var3 = (Slot)this.inventorySlots.get(par1); + + if (var3 != null && var3.getHasStack()) + { + ItemStack var4 = var3.getStack(); + var2 = var4.copy(); + + if (par1 == 2) + { + if (!this.mergeItemStack(var4, 3, 39, true)) + { + return null; + } + + var3.onSlotChange(var4, var2); + } + else if (par1 != 1 && par1 != 0) + { + if (PlatinumCompressorRecipes.smelting().getSmeltingResult(var4) != null) + { + if (!this.mergeItemStack(var4, 0, 1, false)) + { + return null; + } + } + else if (TileEntityPlatinumCompressor.isItemFuel(var4)) + { + if (!this.mergeItemStack(var4, 1, 2, false)) + { + return null; + } + } + else if (par1 >= 3 && par1 < 30) + { + if (!this.mergeItemStack(var4, 30, 39, false)) + { + return null; + } + } + else if (par1 >= 30 && par1 < 39 && !this.mergeItemStack(var4, 3, 30, false)) + { + return null; + } + } + else if (!this.mergeItemStack(var4, 3, 39, false)) + { + return null; + } + + if (var4.stackSize == 0) + { + var3.putStack((ItemStack)null); + } + else + { + var3.onSlotChanged(); + } + + if (var4.stackSize == var2.stackSize) + { + return null; + } + + var3.onPickupFromSlot(var4); + } + + return var2; + } +} diff --git a/src/common/net/uberkat/obsidian/common/CrusherRecipes.java b/src/common/net/uberkat/obsidian/common/CrusherRecipes.java new file mode 100644 index 000000000..0fc21eb95 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/CrusherRecipes.java @@ -0,0 +1,85 @@ +package net.uberkat.obsidian.common; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import net.minecraft.src.*; + +public class CrusherRecipes +{ + private static final CrusherRecipes smeltingBase = new CrusherRecipes(); + + /** The list of smelting results. */ + private Map smeltingList = new HashMap(); + private Map metaSmeltingList = new HashMap(); + + /** + * Used to call methods addSmelting and getSmeltingResult. + */ + public static final CrusherRecipes smelting() + { + return smeltingBase; + } + + private CrusherRecipes() + { + addSmelting(ObsidianIngots.RedstoneIngot.shiftedIndex, new ItemStack(Item.redstone, 1)); + addSmelting(Item.ingotIron.shiftedIndex, new ItemStack(ObsidianIngots.IronDust, 1)); + addSmelting(Item.ingotGold.shiftedIndex, new ItemStack(ObsidianIngots.GoldDust, 1)); + addSmelting(ObsidianIngots.PlatinumIngot.shiftedIndex, new ItemStack(ObsidianIngots.PlatinumDust, 1)); + addSmelting(ObsidianIngots.GlowstoneIngot.shiftedIndex, new ItemStack(Item.lightStoneDust)); + } + + /** + * Adds a smelting recipe. + */ + public void addSmelting(int par1, ItemStack par2ItemStack) + { + this.smeltingList.put(Integer.valueOf(par1), par2ItemStack); + } + + /** + * Returns the smelting result of an item. + * Deprecated in favor of a metadata sensitive version + */ + @Deprecated + public ItemStack getSmeltingResult(int par1) + { + return (ItemStack)this.smeltingList.get(Integer.valueOf(par1)); + } + + public Map getSmeltingList() + { + return this.smeltingList; + } + + /** + * Add a metadata-sensitive furnace recipe + * @param itemID The Item ID + * @param metadata The Item Metadata + * @param itemstack The ItemStack for the result + */ + public void addSmelting(int itemID, int metadata, ItemStack itemstack) + { + metaSmeltingList.put(Arrays.asList(itemID, metadata), itemstack); + } + + /** + * Used to get the resulting ItemStack form a source ItemStack + * @param item The Source ItemStack + * @return The result ItemStack + */ + public ItemStack getSmeltingResult(ItemStack item) + { + if (item == null) + { + return null; + } + ItemStack ret = (ItemStack)metaSmeltingList.get(Arrays.asList(item.itemID, item.getItemDamage())); + if (ret != null) + { + return ret; + } + return (ItemStack)smeltingList.get(Integer.valueOf(item.itemID)); + } +} diff --git a/src/common/net/uberkat/obsidian/common/DamageSourceObsidian.java b/src/common/net/uberkat/obsidian/common/DamageSourceObsidian.java new file mode 100644 index 000000000..a7f833392 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/DamageSourceObsidian.java @@ -0,0 +1,36 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class DamageSourceObsidian extends EntityDamageSourceIndirect +{ + private Entity damageSourceProjectile; + private Entity damageSourceEntity; + + public DamageSourceObsidian(String s, Entity entity, Entity entity1) + { + super(s, entity, entity1); + damageSourceProjectile = entity; + damageSourceEntity = entity1; + } + + public Entity getProjectile() + { + return damageSourceProjectile; + } + + public Entity getEntity() + { + return damageSourceEntity; + } + + public static DamageSource causeWeaponDamage(Entity entity, Entity entity1) + { + return (new DamageSourceObsidian("weapon", entity, entity1)).setProjectile(); + } + + public static DamageSource causeObsidianArrowDamage(EntityObsidianArrow arrow, Entity entity) + { + return (new EntityDamageSourceIndirect("arrow", arrow, entity)).setProjectile(); + } +} diff --git a/src/common/net/uberkat/obsidian/common/EnrichmentChamberRecipes.java b/src/common/net/uberkat/obsidian/common/EnrichmentChamberRecipes.java new file mode 100644 index 000000000..6d9c834f6 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/EnrichmentChamberRecipes.java @@ -0,0 +1,85 @@ +package net.uberkat.obsidian.common; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import net.minecraft.src.*; + +public class EnrichmentChamberRecipes +{ + private static final EnrichmentChamberRecipes smeltingBase = new EnrichmentChamberRecipes(); + + /** The list of smelting results. */ + private Map smeltingList = new HashMap(); + private Map metaSmeltingList = new HashMap(); + + /** + * Used to call methods addSmelting and getSmeltingResult. + */ + public static final EnrichmentChamberRecipes smelting() + { + return smeltingBase; + } + + private EnrichmentChamberRecipes() + { + addSmelting(Block.obsidian.blockID, new ItemStack(ObsidianIngots.ObsidianDust, 1)); + addSmelting(Block.oreIron.blockID, new ItemStack(ObsidianIngots.IronDust, 1)); + addSmelting(Block.oreGold.blockID, new ItemStack(ObsidianIngots.GoldDust, 1)); + addSmelting(ObsidianIngots.platinumOreID, new ItemStack(ObsidianIngots.PlatinumDust, 1)); + addSmelting(Block.oreRedstone.blockID, new ItemStack(Item.redstone)); + } + + /** + * Adds a smelting recipe. + */ + public void addSmelting(int par1, ItemStack par2ItemStack) + { + this.smeltingList.put(Integer.valueOf(par1), par2ItemStack); + } + + /** + * Returns the smelting result of an item. + * Deprecated in favor of a metadata sensitive version + */ + @Deprecated + public ItemStack getSmeltingResult(int par1) + { + return (ItemStack)this.smeltingList.get(Integer.valueOf(par1)); + } + + public Map getSmeltingList() + { + return this.smeltingList; + } + + /** + * Add a metadata-sensitive furnace recipe + * @param itemID The Item ID + * @param metadata The Item Metadata + * @param itemstack The ItemStack for the result + */ + public void addSmelting(int itemID, int metadata, ItemStack itemstack) + { + metaSmeltingList.put(Arrays.asList(itemID, metadata), itemstack); + } + + /** + * Used to get the resulting ItemStack form a source ItemStack + * @param item The Source ItemStack + * @return The result ItemStack + */ + public ItemStack getSmeltingResult(ItemStack item) + { + if (item == null) + { + return null; + } + ItemStack ret = (ItemStack)metaSmeltingList.get(Arrays.asList(item.itemID, item.getItemDamage())); + if (ret != null) + { + return ret; + } + return (ItemStack)smeltingList.get(Integer.valueOf(item.itemID)); + } +} diff --git a/src/common/net/uberkat/obsidian/common/EntityKnife.java b/src/common/net/uberkat/obsidian/common/EntityKnife.java new file mode 100644 index 000000000..31b8be109 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/EntityKnife.java @@ -0,0 +1,146 @@ +package net.uberkat.obsidian.common; + +import java.util.Random; +import net.minecraft.src.*; + +public class EntityKnife extends EntityProjectile +{ + protected ItemStack thrownItem; + private int soundTimer; + + public EntityKnife(World world) + { + super(world); + } + + public EntityKnife(World world, double d, double d1, double d2) + { + this(world); + setPosition(d, d1, d2); + } + + public EntityKnife(World world, EntityLiving entityliving, ItemStack itemstack) + { + this(world); + thrownItem = itemstack; + shootingEntity = entityliving; + doesArrowBelongToPlayer = entityliving instanceof EntityPlayer; + soundTimer = 0; + setLocationAndAngles(entityliving.posX, entityliving.posY + (double)entityliving.getEyeHeight(), entityliving.posZ, entityliving.rotationYaw, entityliving.rotationPitch); + posX -= MathHelper.cos((rotationYaw / 180F) * (float)Math.PI) * 0.16F; + posY -= 0.10000000000000001D; + posZ -= MathHelper.sin((rotationYaw / 180F) * (float)Math.PI) * 0.16F; + setPosition(posX, posY, posZ); + yOffset = 0.0F; + motionX = -MathHelper.sin((rotationYaw / 180F) * (float)Math.PI) * MathHelper.cos((rotationPitch / 180F) * (float)Math.PI); + motionZ = MathHelper.cos((rotationYaw / 180F) * (float)Math.PI) * MathHelper.cos((rotationPitch / 180F) * (float)Math.PI); + motionY = -MathHelper.sin((rotationPitch / 180F) * (float)Math.PI); + setArrowHeading(motionX, motionY, motionZ, 0.8F, 3F); + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() + { + super.onUpdate(); + + if (inGround || beenInGround) + { + return; + } + + rotationPitch -= 70F; + + if (soundTimer >= 3) + { + if (!isInsideOfMaterial(Material.water)) + { + worldObj.playSoundAtEntity(this, "random.bow", 0.6F, 1.0F / (rand.nextFloat() * 0.2F + 0.6F + (float)ticksInAir / 15F)); + } + + soundTimer = 0; + } + + soundTimer++; + } + + public void onEntityHit(Entity entity) + { + if (worldObj.isRemote) + { + return; + } + + DamageSource damagesource = null; + + if (shootingEntity == null) + { + damagesource = DamageSourceObsidian.causeWeaponDamage(this, this); + } + else + { + damagesource = DamageSourceObsidian.causeWeaponDamage(this, shootingEntity); + } + + if (entity.attackEntityFrom(damagesource, thrownItem.getDamageVsEntity(entity))) + { + if (thrownItem.getItemDamage() + 2 > thrownItem.getMaxDamage()) + { + thrownItem.stackSize--; + setDead(); + } + else + { + thrownItem.damageItem(2, null); + setVelocity(0.20000000000000001D * rand.nextDouble() - 0.10000000000000001D, 0.20000000000000001D * rand.nextDouble() - 0.10000000000000001D, 0.20000000000000001D * rand.nextDouble() - 0.10000000000000001D); + } + } + else + { + bounceBack(); + } + } + + public boolean aimRotation() + { + return beenInGround; + } + + public int getMaxArrowShake() + { + return 4; + } + + public float getGravity() + { + return 0.03F; + } + + public ItemStack getPickupItem() + { + return thrownItem; + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + public void writeEntityToNBT(NBTTagCompound nbttagcompound) + { + super.writeEntityToNBT(nbttagcompound); + + if (thrownItem != null) + { + nbttagcompound.setCompoundTag("thrownItem", thrownItem.writeToNBT(new NBTTagCompound())); + } + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + public void readEntityFromNBT(NBTTagCompound nbttagcompound) + { + super.readEntityFromNBT(nbttagcompound); + thrownItem = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("thrownItem")); + } +} diff --git a/src/common/net/uberkat/obsidian/common/EntityObsidianArrow.java b/src/common/net/uberkat/obsidian/common/EntityObsidianArrow.java new file mode 100644 index 000000000..06fa21dcd --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/EntityObsidianArrow.java @@ -0,0 +1,526 @@ +package net.uberkat.obsidian.common; + +import cpw.mods.fml.common.Side; +import cpw.mods.fml.common.asm.SideOnly; +import java.util.Iterator; +import java.util.List; +import net.minecraft.src.*; + +public class EntityObsidianArrow extends Entity +{ + private int xTile = -1; + private int yTile = -1; + private int zTile = -1; + private int inTile = 0; + private int inData = 0; + private boolean inGround = false; + + /** 1 if the player can pick up the arrow */ + public int canBePickedUp = 0; + + /** Seems to be some sort of timer for animating an arrow. */ + public int arrowShake = 0; + + /** The owner of this arrow. */ + public Entity shootingEntity; + private int ticksInGround; + private int ticksInAir = 0; + private double damage = 2.0D; + + /** The amount of knockback an arrow applies when it hits a mob. */ + private int knockbackStrength; + + public EntityObsidianArrow(World par1World) + { + super(par1World); + this.setSize(0.5F, 0.5F); + } + + public EntityObsidianArrow(World par1World, double par2, double par4, double par6) + { + super(par1World); + this.setSize(0.5F, 0.5F); + this.setPosition(par2, par4, par6); + this.yOffset = 0.0F; + } + + public EntityObsidianArrow(World par1World, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving, float par4, float par5) + { + super(par1World); + this.shootingEntity = par2EntityLiving; + + if (par2EntityLiving instanceof EntityPlayer) + { + this.canBePickedUp = 1; + } + + this.posY = par2EntityLiving.posY + (double)par2EntityLiving.getEyeHeight() - 0.10000000149011612D; + double var6 = par3EntityLiving.posX - par2EntityLiving.posX; + double var8 = par3EntityLiving.posY + (double)par3EntityLiving.getEyeHeight() - 0.699999988079071D - this.posY; + double var10 = par3EntityLiving.posZ - par2EntityLiving.posZ; + double var12 = (double)MathHelper.sqrt_double(var6 * var6 + var10 * var10); + + if (var12 >= 1.0E-7D) + { + float var14 = (float)(Math.atan2(var10, var6) * 180.0D / Math.PI) - 90.0F; + float var15 = (float)(-(Math.atan2(var8, var12) * 180.0D / Math.PI)); + double var16 = var6 / var12; + double var18 = var10 / var12; + this.setLocationAndAngles(par2EntityLiving.posX + var16, this.posY, par2EntityLiving.posZ + var18, var14, var15); + this.yOffset = 0.0F; + float var20 = (float)var12 * 0.2F; + this.setArrowHeading(var6, var8 + (double)var20, var10, par4, par5); + } + } + + public EntityObsidianArrow(World par1World, EntityLiving par2EntityLiving, float par3) + { + super(par1World); + this.shootingEntity = par2EntityLiving; + + if (par2EntityLiving instanceof EntityPlayer) + { + this.canBePickedUp = 1; + } + + this.setSize(0.5F, 0.5F); + this.setLocationAndAngles(par2EntityLiving.posX, par2EntityLiving.posY + (double)par2EntityLiving.getEyeHeight(), par2EntityLiving.posZ, par2EntityLiving.rotationYaw, par2EntityLiving.rotationPitch); + this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); + this.posY -= 0.10000000149011612D; + this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); + this.setPosition(this.posX, this.posY, this.posZ); + this.yOffset = 0.0F; + this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); + this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); + this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI)); + this.setArrowHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F); + } + + protected void entityInit() + { + this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); + } + + /** + * Uses the provided coordinates as a heading and determines the velocity from it with the set force and random + * variance. Args: x, y, z, force, forceVariation + */ + public void setArrowHeading(double par1, double par3, double par5, float par7, float par8) + { + float var9 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5); + par1 /= (double)var9; + par3 /= (double)var9; + par5 /= (double)var9; + par1 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8; + par3 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8; + par5 += this.rand.nextGaussian() * 0.007499999832361937D * (double)par8; + par1 *= (double)par7; + par3 *= (double)par7; + par5 *= (double)par7; + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + float var10 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)var10) * 180.0D / Math.PI); + this.ticksInGround = 0; + } + + @SideOnly(Side.CLIENT) + + /** + * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX, + * posY, posZ, yaw, pitch + */ + public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) + { + this.setPosition(par1, par3, par5); + this.setRotation(par7, par8); + } + + @SideOnly(Side.CLIENT) + + /** + * Sets the velocity to the args. Args: x, y, z + */ + public void setVelocity(double par1, double par3, double par5) + { + this.motionX = par1; + this.motionY = par3; + this.motionZ = par5; + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) + { + float var7 = MathHelper.sqrt_double(par1 * par1 + par5 * par5); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(par1, par5) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(par3, (double)var7) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch; + this.prevRotationYaw = this.rotationYaw; + this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); + this.ticksInGround = 0; + } + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() + { + super.onUpdate(); + + if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) + { + float var1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)var1) * 180.0D / Math.PI); + } + + int var16 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); + + if (var16 > 0) + { + Block.blocksList[var16].setBlockBoundsBasedOnState(this.worldObj, this.xTile, this.yTile, this.zTile); + AxisAlignedBB var2 = Block.blocksList[var16].getCollisionBoundingBoxFromPool(this.worldObj, this.xTile, this.yTile, this.zTile); + + if (var2 != null && var2.isVecInside(Vec3.getVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ))) + { + this.inGround = true; + } + } + + if (this.arrowShake > 0) + { + --this.arrowShake; + } + + if (this.inGround) + { + int var18 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); + int var19 = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); + + if (var18 == this.inTile && var19 == this.inData) + { + ++this.ticksInGround; + + if (this.ticksInGround == 1200) + { + this.setDead(); + } + } + else + { + this.inGround = false; + this.motionX *= (double)(this.rand.nextFloat() * 0.2F); + this.motionY *= (double)(this.rand.nextFloat() * 0.2F); + this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); + this.ticksInGround = 0; + this.ticksInAir = 0; + } + } + else + { + ++this.ticksInAir; + Vec3 var17 = Vec3.getVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + Vec3 var3 = Vec3.getVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + MovingObjectPosition var4 = this.worldObj.rayTraceBlocks_do_do(var17, var3, false, true); + var17 = Vec3.getVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); + var3 = Vec3.getVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + + if (var4 != null) + { + var3 = Vec3.getVec3Pool().getVecFromPool(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord); + } + + Entity var5 = null; + List var6 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); + double var7 = 0.0D; + Iterator var9 = var6.iterator(); + float var11; + + while (var9.hasNext()) + { + Entity var10 = (Entity)var9.next(); + + if (var10.canBeCollidedWith() && (var10 != this.shootingEntity || this.ticksInAir >= 5)) + { + var11 = 0.3F; + AxisAlignedBB var12 = var10.boundingBox.expand((double)var11, (double)var11, (double)var11); + MovingObjectPosition var13 = var12.calculateIntercept(var17, var3); + + if (var13 != null) + { + double var14 = var17.distanceTo(var13.hitVec); + + if (var14 < var7 || var7 == 0.0D) + { + var5 = var10; + var7 = var14; + } + } + } + } + + if (var5 != null) + { + var4 = new MovingObjectPosition(var5); + } + + float var20; + + if (var4 != null) + { + if (var4.entityHit != null) + { + var20 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + int var24 = MathHelper.ceiling_double_int((double)var20 * this.damage); + + if (this.func_70241_g()) + { + var24 += this.rand.nextInt(var24 / 2 + 2); + } + + DamageSource var22 = null; + + if (this.shootingEntity == null) + { + var22 = DamageSourceObsidian.causeObsidianArrowDamage(this, this); + } + else + { + var22 = DamageSourceObsidian.causeObsidianArrowDamage(this, this.shootingEntity); + } + + if (this.isBurning()) + { + var4.entityHit.setFire(5); + } + + if (var4.entityHit.attackEntityFrom(var22, var24)) + { + if (var4.entityHit instanceof EntityLiving) + { + ++((EntityLiving)var4.entityHit).arrowHitTempCounter; + + if (this.knockbackStrength > 0) + { + float var25 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + + if (var25 > 0.0F) + { + var4.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)var25, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)var25); + } + } + } + + this.worldObj.playSoundAtEntity(this, "random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + this.setDead(); + } + else + { + this.motionX *= -0.10000000149011612D; + this.motionY *= -0.10000000149011612D; + this.motionZ *= -0.10000000149011612D; + this.rotationYaw += 180.0F; + this.prevRotationYaw += 180.0F; + this.ticksInAir = 0; + } + } + else + { + this.xTile = var4.blockX; + this.yTile = var4.blockY; + this.zTile = var4.blockZ; + this.inTile = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); + this.inData = this.worldObj.getBlockMetadata(this.xTile, this.yTile, this.zTile); + this.motionX = (double)((float)(var4.hitVec.xCoord - this.posX)); + this.motionY = (double)((float)(var4.hitVec.yCoord - this.posY)); + this.motionZ = (double)((float)(var4.hitVec.zCoord - this.posZ)); + var20 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); + this.posX -= this.motionX / (double)var20 * 0.05000000074505806D; + this.posY -= this.motionY / (double)var20 * 0.05000000074505806D; + this.posZ -= this.motionZ / (double)var20 * 0.05000000074505806D; + this.worldObj.playSoundAtEntity(this, "random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); + this.inGround = true; + this.arrowShake = 7; + this.func_70243_d(false); + } + } + + if (this.func_70241_g()) + { + for (int var21 = 0; var21 < 4; ++var21) + { + this.worldObj.spawnParticle("portal", this.posX + this.motionX * (double)var21 / 4.0D, this.posY + this.motionY * (double)var21 / 4.0D, this.posZ + this.motionZ * (double)var21 / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ); + } + } + + this.posX += this.motionX; + this.posY += this.motionY; + this.posZ += this.motionZ; + var20 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); + this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); + + for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)var20) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) + { + ; + } + + while (this.rotationPitch - this.prevRotationPitch >= 180.0F) + { + this.prevRotationPitch += 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw < -180.0F) + { + this.prevRotationYaw -= 360.0F; + } + + while (this.rotationYaw - this.prevRotationYaw >= 180.0F) + { + this.prevRotationYaw += 360.0F; + } + + this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; + this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; + float var23 = 0.99F; + var11 = 0.05F; + + if (this.isInWater()) + { + for (int var26 = 0; var26 < 4; ++var26) + { + float var27 = 0.25F; + this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)var27, this.posY - this.motionY * (double)var27, this.posZ - this.motionZ * (double)var27, this.motionX, this.motionY, this.motionZ); + } + + var23 = 0.8F; + } + + this.motionX *= (double)var23; + this.motionY *= (double)var23; + this.motionZ *= (double)var23; + this.motionY -= (double)var11; + this.setPosition(this.posX, this.posY, this.posZ); + this.doBlockCollisions(); + } + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setShort("xTile", (short)this.xTile); + par1NBTTagCompound.setShort("yTile", (short)this.yTile); + par1NBTTagCompound.setShort("zTile", (short)this.zTile); + par1NBTTagCompound.setByte("inTile", (byte)this.inTile); + par1NBTTagCompound.setByte("inData", (byte)this.inData); + par1NBTTagCompound.setByte("shake", (byte)this.arrowShake); + par1NBTTagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0)); + par1NBTTagCompound.setByte("pickup", (byte)this.canBePickedUp); + par1NBTTagCompound.setDouble("damage", this.damage); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + this.xTile = par1NBTTagCompound.getShort("xTile"); + this.yTile = par1NBTTagCompound.getShort("yTile"); + this.zTile = par1NBTTagCompound.getShort("zTile"); + this.inTile = par1NBTTagCompound.getByte("inTile") & 255; + this.inData = par1NBTTagCompound.getByte("inData") & 255; + this.arrowShake = par1NBTTagCompound.getByte("shake") & 255; + this.inGround = par1NBTTagCompound.getByte("inGround") == 1; + + if (par1NBTTagCompound.hasKey("damage")) + { + this.damage = par1NBTTagCompound.getDouble("damage"); + } + + if (par1NBTTagCompound.hasKey("pickup")) + { + this.canBePickedUp = par1NBTTagCompound.getByte("pickup"); + } + else if (par1NBTTagCompound.hasKey("player")) + { + this.canBePickedUp = par1NBTTagCompound.getBoolean("player") ? 1 : 0; + } + } + + /** + * Called by a player entity when they collide with an entity + */ + public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) + { + if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) + { + boolean var2 = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode; + + if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ObsidianIngots.ObsidianArrow, 1))) + { + var2 = false; + } + + if (var2) + { + this.worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + par1EntityPlayer.onItemPickup(this, 1); + this.setDead(); + } + } + } + + @SideOnly(Side.CLIENT) + public float getShadowSize() + { + return 0.0F; + } + + public void setDamage(double par1) + { + this.damage = par1; + } + + public double getDamage() + { + return this.damage; + } + + /** + * Sets the amount of knockback the arrow applies when it hits a mob. + */ + public void setKnockbackStrength(int par1) + { + this.knockbackStrength = par1; + } + + /** + * If returns false, the item will not inflict any damage against entities. + */ + public boolean canAttackWithItem() + { + return false; + } + + public void func_70243_d(boolean par1) + { + byte var2 = this.dataWatcher.getWatchableObjectByte(16); + + if (par1) + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(var2 | 1))); + } + else + { + this.dataWatcher.updateObject(16, Byte.valueOf((byte)(var2 & -2))); + } + } + + public boolean func_70241_g() + { + byte var1 = this.dataWatcher.getWatchableObjectByte(16); + return (var1 & 1) != 0; + } +} diff --git a/src/common/net/uberkat/obsidian/common/EntityObsidianTNT.java b/src/common/net/uberkat/obsidian/common/EntityObsidianTNT.java new file mode 100644 index 000000000..e8cc183ac --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/EntityObsidianTNT.java @@ -0,0 +1,124 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class EntityObsidianTNT extends Entity +{ + /** How long the fuse is */ + public int fuse; + private boolean hasExploded = false; + + public EntityObsidianTNT(World par1World) + { + super(par1World); + fuse = 0; + preventEntitySpawning = true; + setSize(0.98F, 0.98F); + yOffset = height / 2.0F; + } + + public EntityObsidianTNT(World par1World, double par2, double par4, double par6) + { + this(par1World); + setPosition(par2, par4, par6); + float var8 = (float)(Math.random() * Math.PI * 2.0D); + motionX = (double)(-((float)Math.sin((double)var8)) * 0.02F); + motionY = 0.20000000298023224D; + motionZ = (double)(-((float)Math.cos((double)var8)) * 0.02F); + fuse = ObsidianIngots.ObsidianTNTDelay; + prevPosX = par2; + prevPosY = par4; + prevPosZ = par6; + } + + protected void entityInit() {} + + /** + * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to + * prevent them from trampling crops + */ + protected boolean canTriggerWalking() + { + return false; + } + + /** + * Returns true if other Entities should be prevented from moving through this Entity. + */ + public boolean canBeCollidedWith() + { + return !isDead; + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() + { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + motionY -= 0.03999999910593033D; + moveEntity(motionX, motionY, motionZ); + motionX *= 0.9800000190734863D; + motionY *= 0.9800000190734863D; + motionZ *= 0.9800000190734863D; + + if (onGround) + { + motionX *= 0.699999988079071D; + motionZ *= 0.699999988079071D; + motionY *= -0.5D; + } + + if (fuse-- <= 0) + { + if (!worldObj.isRemote) + { + setDead(); + explode(); + } + else + { + if(hasExploded) + { + setDead(); + } + else { + worldObj.spawnParticle("lava", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D); + } + } + } + else + { + worldObj.spawnParticle("lava", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D); + } + } + + private void explode() + { + worldObj.createExplosion((Entity)null, posX, posY, posZ, ObsidianIngots.ObsidianTNTBlastRadius); + hasExploded = true; + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) + { + par1NBTTagCompound.setByte("Fuse", (byte)fuse); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) + { + fuse = par1NBTTagCompound.getByte("Fuse"); + } + + public float getShadowSize() + { + return 0.0F; + } +} diff --git a/src/common/net/uberkat/obsidian/common/EntityProjectile.java b/src/common/net/uberkat/obsidian/common/EntityProjectile.java new file mode 100644 index 000000000..d39263d81 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/EntityProjectile.java @@ -0,0 +1,394 @@ +package net.uberkat.obsidian.common; + +import java.util.List; +import net.minecraft.src.*; +import java.util.Random; + +public abstract class EntityProjectile extends Entity +{ + protected int xTile; + protected int yTile; + protected int zTile; + protected int inTile; + protected int inData; + protected boolean inGround; + public boolean doesArrowBelongToPlayer; + public int arrowShake; + public Entity shootingEntity; + protected int ticksInGround; + protected int ticksInAir; + public boolean beenInGround; + public boolean isCritical; + + public EntityProjectile(World world) + { + super(world); + xTile = -1; + yTile = -1; + zTile = -1; + inTile = 0; + inData = 0; + inGround = false; + doesArrowBelongToPlayer = false; + isCritical = false; + arrowShake = 0; + ticksInAir = 0; + yOffset = 0.0F; + setSize(0.5F, 0.5F); + } + + protected void entityInit() + { + } + + public void setArrowHeading(double d, double d1, double d2, float f, float f1) + { + float f2 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2); + d /= f2; + d1 /= f2; + d2 /= f2; + d += rand.nextGaussian() * 0.0074999999999999997D * (double)f1; + d1 += rand.nextGaussian() * 0.0074999999999999997D * (double)f1; + d2 += rand.nextGaussian() * 0.0074999999999999997D * (double)f1; + d *= f; + d1 *= f; + d2 *= f; + motionX = d; + motionY = d1; + motionZ = d2; + float f3 = MathHelper.sqrt_double(d * d + d2 * d2); + prevRotationYaw = rotationYaw = (float)((Math.atan2(d, d2) * 180D) / Math.PI); + prevRotationPitch = rotationPitch = (float)((Math.atan2(d1, f3) * 180D) / Math.PI); + ticksInGround = 0; + } + + /** + * Sets the velocity to the args. Args: x, y, z + */ + public void setVelocity(double d, double d1, double d2) + { + motionX = d; + motionY = d1; + motionZ = d2; + + if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) + { + if (aimRotation()) + { + float f = MathHelper.sqrt_double(d * d + d2 * d2); + prevRotationYaw = rotationYaw = (float)((Math.atan2(d, d2) * 180D) / Math.PI); + prevRotationPitch = rotationPitch = (float)((Math.atan2(d1, f) * 180D) / Math.PI); + prevRotationPitch = rotationPitch; + prevRotationYaw = rotationYaw; + } + + setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch); + ticksInGround = 0; + } + } + + /** + * Called to update the entity's position/logic. + */ + public void onUpdate() + { + super.onUpdate(); + + if (aimRotation() && prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) + { + float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + prevRotationYaw = rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / Math.PI); + prevRotationPitch = rotationPitch = (float)((Math.atan2(motionY, f) * 180D) / Math.PI); + } + + int i = worldObj.getBlockId(xTile, yTile, zTile); + + if (i > 0) + { + Block.blocksList[i].setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile); + AxisAlignedBB axisalignedbb = Block.blocksList[i].getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile); + + if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(posX, posY, posZ))) + { + inGround = true; + } + } + + if (arrowShake > 0) + { + arrowShake--; + } + + if (inGround) + { + int j = worldObj.getBlockId(xTile, yTile, zTile); + int k = worldObj.getBlockMetadata(xTile, yTile, zTile); + + if (j != inTile || k != inData) + { + inGround = false; + motionX *= rand.nextFloat() * 0.2F; + motionY *= rand.nextFloat() * 0.2F; + motionZ *= rand.nextFloat() * 0.2F; + ticksInGround = 0; + ticksInAir = 0; + } + else + { + ticksInGround++; + + if (ticksInGround >= (doesArrowBelongToPlayer ? 200 : 800)) + { + setDead(); + } + } + + return; + } + + ticksInAir++; + Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ); + Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); + MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks_do_do(vec3d, vec3d1, false, true); + vec3d = Vec3.createVectorHelper(posX, posY, posZ); + vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); + + if (movingobjectposition != null) + { + vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); + } + + Entity entity = null; + List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); + double d = 0.0D; + + for (int l = 0; l < list.size(); l++) + { + Entity entity1 = (Entity)list.get(l); + + if (!entity1.canBeCollidedWith() || entity1 == shootingEntity && ticksInAir < 5) + { + continue; + } + + float f4 = 0.3F; + AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f4, f4, f4); + MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3d, vec3d1); + + if (movingobjectposition1 == null) + { + continue; + } + + double d1 = vec3d.distanceTo(movingobjectposition1.hitVec); + + if (d1 < d || d == 0.0D) + { + entity = entity1; + d = d1; + } + } + + if (entity != null) + { + movingobjectposition = new MovingObjectPosition(entity); + } + + if (movingobjectposition != null) + { + if (movingobjectposition.entityHit != null) + { + onEntityHit(movingobjectposition.entityHit); + } + else + { + onGroundHit(movingobjectposition); + } + } + + if (isCritical) + { + for (int i1 = 0; i1 < 2; i1++) + { + worldObj.spawnParticle("crit", posX + (motionX * (double)i1) / 4D, posY + (motionY * (double)i1) / 4D, posZ + (motionZ * (double)i1) / 4D, -motionX, -motionY + 0.20000000000000001D, -motionZ); + } + } + + posX += motionX; + posY += motionY; + posZ += motionZ; + + if (aimRotation()) + { + float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ); + rotationYaw = (float)((Math.atan2(motionX, motionZ) * 180D) / Math.PI); + + for (rotationPitch = (float)((Math.atan2(motionY, f1) * 180D) / Math.PI); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) { } + + for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) { } + + for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) { } + + for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) { } + + rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F; + rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F; + } + + float f2 = getAirResistance(); + float f3 = getGravity(); + + if (isInWater()) + { + beenInGround = true; + + for (int j1 = 0; j1 < 4; j1++) + { + float f5 = 0.25F; + worldObj.spawnParticle("bubble", posX - motionX * (double)f5, posY - motionY * (double)f5, posZ - motionZ * (double)f5, motionX, motionY, motionZ); + } + + f2 = 0.8F; + } + + motionX *= f2; + motionY *= f2; + motionZ *= f2; + motionY -= f3; + setPosition(posX, posY, posZ); + } + + public final double getTotalVelocity() + { + return Math.sqrt(motionX * motionX + motionY * motionY + motionZ * motionZ); + } + + public boolean aimRotation() + { + return true; + } + + public void onEntityHit(Entity entity) + { + bounceBack(); + } + + public void onGroundHit(MovingObjectPosition movingobjectposition) + { + xTile = movingobjectposition.blockX; + yTile = movingobjectposition.blockY; + zTile = movingobjectposition.blockZ; + inTile = worldObj.getBlockId(xTile, yTile, zTile); + inData = worldObj.getBlockMetadata(xTile, yTile, zTile); + motionX = (float)(movingobjectposition.hitVec.xCoord - posX); + motionY = (float)(movingobjectposition.hitVec.yCoord - posY); + motionZ = (float)(movingobjectposition.hitVec.zCoord - posZ); + float f = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ); + posX -= (motionX / (double)f) * 0.050000000000000003D; + posY -= (motionY / (double)f) * 0.050000000000000003D; + posZ -= (motionZ / (double)f) * 0.050000000000000003D; + inGround = true; + beenInGround = true; + isCritical = false; + arrowShake = getMaxArrowShake(); + playHitSound(); + } + + protected void bounceBack() + { + motionX *= -0.10000000000000001D; + motionY *= -0.10000000000000001D; + motionZ *= -0.10000000000000001D; + rotationYaw += 180F; + prevRotationYaw += 180F; + ticksInAir = 0; + } + + public ItemStack getPickupItem() + { + return null; + } + + public float getAirResistance() + { + return 0.99F; + } + + public float getGravity() + { + return 0.05F; + } + + public int getMaxArrowShake() + { + return 7; + } + + public void playHitSound() + { + } + + /** + * Called by a player entity when they collide with an entity + */ + public void onCollideWithPlayer(EntityPlayer entityplayer) + { + if (worldObj.isRemote) + { + return; + } + + ItemStack itemstack = getPickupItem(); + + if (itemstack == null) + { + return; + } + + if (inGround && doesArrowBelongToPlayer && arrowShake <= 0 && entityplayer.inventory.addItemStackToInventory(itemstack)) + { + worldObj.playSoundAtEntity(this, "random.pop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + entityplayer.onItemPickup(this, 1); + setDead(); + } + } + + public float getShadowSize() + { + return 0.0F; + } + + /** + * (abstract) Protected helper method to write subclass entity data to NBT. + */ + public void writeEntityToNBT(NBTTagCompound nbttagcompound) + { + nbttagcompound.setShort("xTile", (short)xTile); + nbttagcompound.setShort("yTile", (short)yTile); + nbttagcompound.setShort("zTile", (short)zTile); + nbttagcompound.setByte("inTile", (byte)inTile); + nbttagcompound.setByte("inData", (byte)inData); + nbttagcompound.setByte("shake", (byte)arrowShake); + nbttagcompound.setBoolean("inGround", inGround); + nbttagcompound.setBoolean("player", doesArrowBelongToPlayer); + nbttagcompound.setBoolean("crit", isCritical); + nbttagcompound.setBoolean("beenInGround", beenInGround); + } + + /** + * (abstract) Protected helper method to read subclass entity data from NBT. + */ + public void readEntityFromNBT(NBTTagCompound nbttagcompound) + { + xTile = nbttagcompound.getShort("xTile"); + yTile = nbttagcompound.getShort("yTile"); + zTile = nbttagcompound.getShort("zTile"); + inTile = nbttagcompound.getByte("inTile") & 0xff; + inData = nbttagcompound.getByte("inData") & 0xff; + arrowShake = nbttagcompound.getByte("shake") & 0xff; + inGround = nbttagcompound.getBoolean("inGround"); + doesArrowBelongToPlayer = nbttagcompound.getBoolean("player"); + isCritical = nbttagcompound.getBoolean("crit"); + beenInGround = nbttagcompound.getBoolean("beenInGrond"); + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemBlockBase.java b/src/common/net/uberkat/obsidian/common/ItemBlockBase.java new file mode 100644 index 000000000..cc91b10a1 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemBlockBase.java @@ -0,0 +1,46 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class ItemBlockBase extends ItemBlock +{ + public ItemBlockBase(int i, Block block) + { + super(i); + setMaxDamage(0); + setHasSubtypes(true); + } + + @Override + public String getItemNameIS(ItemStack itemstack) + { + String name = ""; + switch(itemstack.getItemDamage()) + { + case 0: + name = "baseObsidian"; + break; + case 1: + name = "baseRedstone"; + break; + case 2: + name = "basePlatinum"; + break; + case 3: + name = "basePlatinumOre"; + break; + case 4: + name = "baseCoal"; + break; + case 5: + name = "baseGlowstone"; + break; + } + return name; + } + + public int getMetadata(int i) + { + return i; + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemLightningRod.java b/src/common/net/uberkat/obsidian/common/ItemLightningRod.java new file mode 100644 index 000000000..4156bd8f7 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemLightningRod.java @@ -0,0 +1,55 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class ItemLightningRod extends ItemObsidian +{ + public ItemLightningRod(int i) + { + super(i); + setMaxStackSize(1); + setMaxDamage(100); + setTabToDisplayOn(CreativeTabs.tabTools); + } + + public boolean hasEffect(ItemStack par1ItemStack) + { + return true; + } + + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) + { + if(itemstack.getItemDamage() == 0) + { + MovingObjectPosition movingobjectposition = entityplayer.rayTrace(75.0D, 1.0F); + if(movingobjectposition == null) + { + return itemstack; + } + Vec3 vec3d = movingobjectposition.hitVec; + double x = vec3d.xCoord; + double y = vec3d.yCoord; + double z = vec3d.zCoord; + int i = MathHelper.floor_double(x); + int j = MathHelper.floor_double(y); + int k = MathHelper.floor_double(z); + if(world.canBlockSeeTheSky(i, j, k) == false) + { + return itemstack; + } + EntityLightningBolt entitybolt = new EntityLightningBolt(world, 0D, 0D, 0D); + entitybolt.setLocationAndAngles(x, y, z, 0, 0.0F); + world.spawnEntityInWorld(entitybolt); + itemstack.setItemDamage(99); + } + return itemstack; + } + + public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) + { + if(itemstack.getItemDamage() > 0) + { + itemstack.damageItem(-1, (EntityLiving)entity); + } + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemObsidian.java b/src/common/net/uberkat/obsidian/common/ItemObsidian.java new file mode 100644 index 000000000..f1f759f09 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemObsidian.java @@ -0,0 +1,17 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class ItemObsidian extends Item +{ + public ItemObsidian(int i) + { + super(i); + itemsList[256 + i] = this; + setTabToDisplayOn(CreativeTabs.tabAllSearch); + } + + public String getTextureFile() { + return "/obsidian/items.png"; + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemObsidianArmor.java b/src/common/net/uberkat/obsidian/common/ItemObsidianArmor.java new file mode 100644 index 000000000..2032d279c --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemObsidianArmor.java @@ -0,0 +1,16 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class ItemObsidianArmor extends ItemArmor +{ + public ItemObsidianArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4) + { + super(par1, par2EnumArmorMaterial, par3, par4); + setTabToDisplayOn(CreativeTabs.tabCombat); + } + + public String getTextureFile() { + return "/obsidian/items.png"; + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemObsidianAxe.java b/src/common/net/uberkat/obsidian/common/ItemObsidianAxe.java new file mode 100644 index 000000000..bcc544cd8 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemObsidianAxe.java @@ -0,0 +1,40 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.Block; +import net.minecraft.src.EnumToolMaterial; +import net.minecraft.src.ItemStack; +import net.minecraft.src.Material; + +public class ItemObsidianAxe extends ItemObsidianTool +{ + private static Block blocksEffectiveAgainst[]; + + public ItemObsidianAxe(int par1, EnumToolMaterial par2EnumToolMaterial) + { + super(par1, 3, par2EnumToolMaterial, blocksEffectiveAgainst); + } + + /** + * Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if + * sword + */ + public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block) + { + if (par2Block != null && par2Block.blockMaterial == Material.wood) + { + return efficiencyOnProperMaterial; + } + else + { + return super.getStrVsBlock(par1ItemStack, par2Block); + } + } + + static + { + blocksEffectiveAgainst = (new Block[] + { + Block.planks, Block.bookShelf, Block.wood, Block.chest, Block.woodSingleSlab, Block.woodDoubleSlab, Block.pumpkin, Block.pumpkinLantern + }); + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemObsidianBow.java b/src/common/net/uberkat/obsidian/common/ItemObsidianBow.java new file mode 100644 index 000000000..2b7342150 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemObsidianBow.java @@ -0,0 +1,125 @@ +package net.uberkat.obsidian.common; + +import java.util.Random; +import net.minecraft.src.*; + +public class ItemObsidianBow extends ItemObsidian +{ + public ItemObsidianBow(int par1) + { + super(par1); + maxStackSize = 1; + setMaxDamage(750); + setTabToDisplayOn(CreativeTabs.tabCombat); + } + + /** + * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount + */ + public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) + { + boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0; + + if (flag || par3EntityPlayer.inventory.hasItem(ObsidianIngots.ObsidianArrow.shiftedIndex)) + { + int i = getMaxItemUseDuration(par1ItemStack) - par4; + float f = (float)i / 20F; + f = (f * f + f * 2.0F) / 3F; + + if ((double)f < 0.10000000000000001D) + { + return; + } + + if (f > 1.0F) + { + f = 1.0F; + } + + EntityObsidianArrow entityobsidianarrow = new EntityObsidianArrow(par2World, par3EntityPlayer, f * 2.0F); + + if (f == 1.0F) + { + entityobsidianarrow.func_70243_d(true); + } + + int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack); + + if (j > 0) + { + entityobsidianarrow.setDamage(entityobsidianarrow.getDamage() + (double)j * 0.5D + 0.5D); + } + + int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack); + + if (k > 0) + { + entityobsidianarrow.setKnockbackStrength(k); + } + + if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0) + { + entityobsidianarrow.setFire(100); + } + + par1ItemStack.damageItem(1, par3EntityPlayer); + par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + + if (flag) + { + entityobsidianarrow.canBePickedUp = 2; + } + else + { + par3EntityPlayer.inventory.consumeInventoryItem(ObsidianIngots.ObsidianArrow.shiftedIndex); + } + + if (!par2World.isRemote) + { + par2World.spawnEntityInWorld(entityobsidianarrow); + } + } + } + + public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + return par1ItemStack; + } + + /** + * How long it takes to use or consume an item + */ + public int getMaxItemUseDuration(ItemStack par1ItemStack) + { + return 0x11940; + } + + /** + * returns the action that specifies what animation to play when the items is being used + */ + public EnumAction getItemUseAction(ItemStack par1ItemStack) + { + return EnumAction.bow; + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer + */ + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ObsidianIngots.ObsidianArrow.shiftedIndex)) + { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + } + + return par1ItemStack; + } + + /** + * Return the enchantability factor of the item, most of the time is based on material. + */ + public int getItemEnchantability() + { + return 1; + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemObsidianHoe.java b/src/common/net/uberkat/obsidian/common/ItemObsidianHoe.java new file mode 100644 index 000000000..b56aa3178 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemObsidianHoe.java @@ -0,0 +1,62 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.Block; +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.EnumToolMaterial; +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; +import net.minecraft.src.World; + +public class ItemObsidianHoe extends ItemObsidian +{ + public ItemObsidianHoe(int par1, EnumToolMaterial par2EnumToolMaterial) + { + super(par1); + maxStackSize = 1; + setMaxDamage(par2EnumToolMaterial.getMaxUses()); + } + + /** + * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return + * True if something happen and false if it don't. This is for ITEMS, not BLOCKS ! + */ + public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7) + { + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6)) + { + return false; + } + + int i = par3World.getBlockId(par4, par5, par6); + int j = par3World.getBlockId(par4, par5 + 1, par6); + + if (par7 != 0 && j == 0 && i == Block.grass.blockID || i == Block.dirt.blockID) + { + Block block = Block.tilledField; + par3World.playSoundEffect((float)par4 + 0.5F, (float)par5 + 0.5F, (float)par6 + 0.5F, block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + + if (par3World.isRemote) + { + return true; + } + else + { + par3World.setBlockWithNotify(par4, par5, par6, block.blockID); + par1ItemStack.damageItem(1, par2EntityPlayer); + return true; + } + } + else + { + return false; + } + } + + /** + * Returns True is the item is renderer in full 3D when hold. + */ + public boolean isFull3D() + { + return true; + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemObsidianKnife.java b/src/common/net/uberkat/obsidian/common/ItemObsidianKnife.java new file mode 100644 index 000000000..d95d0099f --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemObsidianKnife.java @@ -0,0 +1,114 @@ +package net.uberkat.obsidian.common; + +import java.util.Random; +import net.minecraft.src.*; + +public class ItemObsidianKnife extends ItemObsidian +{ + private EnumToolMaterial enumToolMaterial; + protected int weaponDamage; + protected float knockBack; + protected float strVsBlock; + protected int entityDamage; + protected int blockDamage; + protected int enchantability; + + public ItemObsidianKnife(int i, EnumToolMaterial enumtoolmaterial) + { + super(i); + enumToolMaterial = enumtoolmaterial; + maxStackSize = 1; + setMaxDamage((int)((float)enumtoolmaterial.getMaxUses() * 0.5F)); + weaponDamage = (int)((float)3 + (float)enumtoolmaterial.getDamageVsEntity() * 1.5F); + knockBack = 0.2F + (enumtoolmaterial != EnumToolMaterial.GOLD ? 0.0F : 0.2F); + strVsBlock = 1; + entityDamage = 2; + blockDamage = 2; + enchantability = enumtoolmaterial.getEnchantability(); + setTabToDisplayOn(CreativeTabs.tabCombat); + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer + */ + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) + { + entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack)); + world.playSoundAtEntity(entityplayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 0.8F)); + + if (!world.isRemote) + { + EntityKnife entityknife = new EntityKnife(world, entityplayer, itemstack); + + if (entityplayer.capabilities.isCreativeMode) + { + entityknife.doesArrowBelongToPlayer = false; + } + + world.spawnEntityInWorld(entityknife); + } + + if (entityplayer.capabilities.isCreativeMode) + { + return itemstack; + } + else + { + return new ItemStack(shiftedIndex, 0, 0); + } + } + + /** + * Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if + * sword + */ + public float getStrVsBlock(ItemStack itemstack, Block block) + { + return strVsBlock * (block.blockID != Block.web.blockID ? 1.0F : 10F); + } + + /** + * Returns if the item (tool) can harvest results from the block type. + */ + public boolean canHarvestBlock(Block block) + { + return block.blockID == Block.web.blockID; + } + + public int getItemEnchantability() + { + return enchantability; + } + + public int getMaxItemUseDuration(ItemStack itemstack) + { + return 0x11940; + } + + public boolean isFull3D() + { + return true; + } + + public int getDamageVsEntity(Entity entity) + { + return weaponDamage; + } + + public boolean onBlockDestroyed(ItemStack itemstack, int i, int j, int k, int l, EntityLiving entityliving) + { + itemstack.damageItem(blockDamage, entityliving); + return true; + } + + public boolean hitEntity(ItemStack itemstack, EntityLiving entityliving, EntityLiving entityliving1) + { + if (knockBack != 0.0F) + { + PhysicsHelper.knockBack(entityliving, entityliving1, knockBack); + } + + itemstack.damageItem(entityDamage, entityliving1); + return true; + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemObsidianPaxel.java b/src/common/net/uberkat/obsidian/common/ItemObsidianPaxel.java new file mode 100644 index 000000000..11c8d448b --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemObsidianPaxel.java @@ -0,0 +1,79 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.Block; +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.EnumToolMaterial; +import net.minecraft.src.ItemStack; +import net.minecraft.src.Material; + +public class ItemObsidianPaxel extends ItemObsidianTool +{ + private static Block blocksEffectiveAgainst[]; + + public ItemObsidianPaxel(int i, EnumToolMaterial enumtoolmaterial) + { + super(i, 3, enumtoolmaterial, blocksEffectiveAgainst); + setTabToDisplayOn(CreativeTabs.tabTools); + } + + public boolean canHarvestBlock(Block block) + { + if (block == Block.obsidian) + { + return toolMaterial.getHarvestLevel() == 3; + } + if (block == Block.blockDiamond || block == Block.oreDiamond) + { + return toolMaterial.getHarvestLevel() >= 2; + } + if (block == Block.blockGold || block == Block.oreGold) + { + return toolMaterial.getHarvestLevel() >= 2; + } + if (block == Block.blockSteel || block == Block.oreIron) + { + return toolMaterial.getHarvestLevel() >= 1; + } + if (block == Block.blockLapis || block == Block.oreLapis) + { + return toolMaterial.getHarvestLevel() >= 1; + } + if (block == Block.oreRedstone || block == Block.oreRedstoneGlowing) + { + return toolMaterial.getHarvestLevel() >= 2; + } + if (block.blockMaterial == Material.rock) + { + return true; + } + else + { + return block.blockMaterial == Material.iron; + } + } + + public float getStrVsBlock(ItemStack itemstack, Block block) + { + if (block != null && (block.blockMaterial == Material.iron || block.blockMaterial == Material.rock)) + { + return efficiencyOnProperMaterial; + } + else + { + return super.getStrVsBlock(itemstack, block); + } + } + + static + { + blocksEffectiveAgainst = (new Block[] + { + Block.cobblestone, Block.woodSingleSlab, Block.woodDoubleSlab, Block.stone, Block.sandStone, Block.cobblestoneMossy, Block.oreIron, Block.blockSteel, Block.oreCoal, Block.blockGold, + Block.oreGold, Block.oreDiamond, Block.blockDiamond, Block.ice, Block.netherrack, Block.oreLapis, Block.blockLapis, Block.oreRedstone, Block.oreRedstoneGlowing, Block.rail, + Block.railDetector, Block.railPowered, Block.leaves, Block.grass, Block.dirt, Block.sand, + Block.gravel, Block.snow, Block.blockSnow, Block.blockClay, Block.tilledField, Block.slowSand, Block.mycelium, Block.planks, Block.bookShelf, Block.wood, + Block.chest, Block.stoneDoubleSlab, Block.stoneSingleSlab, Block.pumpkin, Block.pumpkinLantern, Block.snow, Block.pistonBase, Block.pistonStickyBase, Block.workbench, + Block.stoneOvenActive, Block.stoneOvenIdle, Block.music, Block.trapdoor, Block.silverfish, Block.stoneBrick, Block.glowStone + }); + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemObsidianPickaxe.java b/src/common/net/uberkat/obsidian/common/ItemObsidianPickaxe.java new file mode 100644 index 000000000..c66fb8ee4 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemObsidianPickaxe.java @@ -0,0 +1,87 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.Block; +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.EnumToolMaterial; +import net.minecraft.src.ItemStack; +import net.minecraft.src.Material; + +public class ItemObsidianPickaxe extends ItemObsidianTool +{ + private static Block blocksEffectiveAgainst[]; + + public ItemObsidianPickaxe(int par1, EnumToolMaterial par2EnumToolMaterial) + { + super(par1, 2, par2EnumToolMaterial, blocksEffectiveAgainst); + setTabToDisplayOn(CreativeTabs.tabTools); + } + + /** + * Returns if the item (tool) can harvest results from the block type. + */ + public boolean canHarvestBlock(Block par1Block) + { + if (par1Block == Block.obsidian) + { + return toolMaterial.getHarvestLevel() == 3; + } + + if (par1Block == Block.blockDiamond || par1Block == Block.oreDiamond) + { + return toolMaterial.getHarvestLevel() >= 2; + } + + if (par1Block == Block.blockGold || par1Block == Block.oreGold) + { + return toolMaterial.getHarvestLevel() >= 2; + } + + if (par1Block == Block.blockSteel || par1Block == Block.oreIron) + { + return toolMaterial.getHarvestLevel() >= 1; + } + + if (par1Block == Block.blockLapis || par1Block == Block.oreLapis) + { + return toolMaterial.getHarvestLevel() >= 1; + } + + if (par1Block == Block.oreRedstone || par1Block == Block.oreRedstoneGlowing) + { + return toolMaterial.getHarvestLevel() >= 2; + } + + if (par1Block.blockMaterial == Material.rock) + { + return true; + } + + return par1Block.blockMaterial == Material.iron; + } + + /** + * Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if + * sword + */ + public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block) + { + if (par2Block != null && (par2Block.blockMaterial == Material.iron || par2Block.blockMaterial == Material.rock)) + { + return efficiencyOnProperMaterial; + } + else + { + return super.getStrVsBlock(par1ItemStack, par2Block); + } + } + + static + { + blocksEffectiveAgainst = (new Block[] + { + Block.cobblestone, Block.stoneSingleSlab, Block.stoneDoubleSlab, Block.stone, Block.sandStone, Block.cobblestoneMossy, Block.oreIron, Block.blockSteel, Block.oreCoal, Block.blockGold, + Block.oreGold, Block.oreDiamond, Block.blockDiamond, Block.ice, Block.netherrack, Block.oreLapis, Block.blockLapis, Block.oreRedstone, Block.oreRedstoneGlowing, Block.rail, + Block.railDetector, Block.railPowered + }); + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemObsidianSpade.java b/src/common/net/uberkat/obsidian/common/ItemObsidianSpade.java new file mode 100644 index 000000000..497641e5d --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemObsidianSpade.java @@ -0,0 +1,37 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.Block; +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.EnumToolMaterial; + +public class ItemObsidianSpade extends ItemObsidianTool +{ + private static Block blocksEffectiveAgainst[]; + + public ItemObsidianSpade(int par1, EnumToolMaterial par2EnumToolMaterial) + { + super(par1, 1, par2EnumToolMaterial, blocksEffectiveAgainst); + setTabToDisplayOn(CreativeTabs.tabTools); + } + + /** + * Returns if the item (tool) can harvest results from the block type. + */ + public boolean canHarvestBlock(Block par1Block) + { + if (par1Block == Block.snow) + { + return true; + } + + return par1Block == Block.blockSnow; + } + + static + { + blocksEffectiveAgainst = (new Block[] + { + Block.grass, Block.dirt, Block.sand, Block.gravel, Block.snow, Block.blockSnow, Block.blockClay, Block.tilledField, Block.slowSand, Block.mycelium + }); + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemObsidianSword.java b/src/common/net/uberkat/obsidian/common/ItemObsidianSword.java new file mode 100644 index 000000000..fc4044d5a --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemObsidianSword.java @@ -0,0 +1,104 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.Block; +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.Entity; +import net.minecraft.src.EntityLiving; +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.EnumAction; +import net.minecraft.src.EnumToolMaterial; +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; +import net.minecraft.src.World; + +public class ItemObsidianSword extends ItemObsidian +{ + private int weaponDamage; + private final EnumToolMaterial toolMaterial; + + public ItemObsidianSword(int par1, EnumToolMaterial par2EnumToolMaterial) + { + super(par1); + toolMaterial = par2EnumToolMaterial; + maxStackSize = 1; + setMaxDamage(par2EnumToolMaterial.getMaxUses()); + weaponDamage = 4 + par2EnumToolMaterial.getDamageVsEntity(); + setTabToDisplayOn(CreativeTabs.tabCombat); + } + + /** + * Returns the strength of the stack against a given block. 1.0F base, (Quality+1)*2 if correct blocktype, 1.5F if + * sword + */ + public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block) + { + return par2Block.blockID != Block.web.blockID ? 1.5F : 15F; + } + + /** + * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise + * the damage on the stack. + */ + public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving) + { + par1ItemStack.damageItem(1, par3EntityLiving); + return true; + } + + public boolean onBlockDestroyed(ItemStack par1ItemStack, int par2, int par3, int par4, int par5, EntityLiving par6EntityLiving) + { + par1ItemStack.damageItem(2, par6EntityLiving); + return true; + } + + /** + * Returns the damage against a given entity. + */ + public int getDamageVsEntity(Entity par1Entity) + { + return weaponDamage; + } + + /** + * Returns True is the item is renderer in full 3D when hold. + */ + public boolean isFull3D() + { + return true; + } + + public EnumAction getItemUseAction(ItemStack par1ItemStack) + { + return EnumAction.block; + } + + public int getMaxItemUseDuration(ItemStack par1ItemStack) + { + return 0x11940; + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer + */ + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + par3EntityPlayer.setItemInUse(par1ItemStack, getMaxItemUseDuration(par1ItemStack)); + return par1ItemStack; + } + + /** + * Returns if the item (tool) can harvest results from the block type. + */ + public boolean canHarvestBlock(Block par1Block) + { + return par1Block.blockID == Block.web.blockID; + } + + /** + * Return the enchantability factor of the item, most of the time is based on material. + */ + public int getItemEnchantability() + { + return toolMaterial.getEnchantability(); + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemObsidianTool.java b/src/common/net/uberkat/obsidian/common/ItemObsidianTool.java new file mode 100644 index 000000000..53e98fe9a --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemObsidianTool.java @@ -0,0 +1,22 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.Block; +import net.minecraft.src.Entity; +import net.minecraft.src.EntityLiving; +import net.minecraft.src.EnumToolMaterial; +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; +import net.minecraft.src.ItemTool; + +public class ItemObsidianTool extends ItemTool +{ + public ItemObsidianTool(int par1, int par2, EnumToolMaterial par3EnumToolMaterial, Block par4ArrayOfBlock[]) + { + super(par1, par2, par3EnumToolMaterial, par4ArrayOfBlock); + } + + public String getTextureFile() + { + return "/obsidian/items.png"; + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemStopwatch.java b/src/common/net/uberkat/obsidian/common/ItemStopwatch.java new file mode 100644 index 000000000..0a260701a --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemStopwatch.java @@ -0,0 +1,36 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class ItemStopwatch extends ItemObsidian { + + public ItemStopwatch(int i) + { + super(i); + setMaxStackSize(1); + setMaxDamage(5000); + setTabToDisplayOn(CreativeTabs.tabTools); + } + + public boolean hasEffect(ItemStack itemstack) + { + return true; + } + + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) + { + if(itemstack.getItemDamage() == 0) + { + entityplayer.openGui(ObsidianIngots.instance, 18, world, (int)entityplayer.posX, (int)entityplayer.posY, (int)entityplayer.posZ); + } + return itemstack; + } + + public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) + { + if(itemstack.getItemDamage() > 0) + { + itemstack.damageItem(-1, (EntityLiving)entity); + } + } +} diff --git a/src/common/net/uberkat/obsidian/common/ItemWeatherOrb.java b/src/common/net/uberkat/obsidian/common/ItemWeatherOrb.java new file mode 100644 index 000000000..4ce72e7cd --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ItemWeatherOrb.java @@ -0,0 +1,36 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class ItemWeatherOrb extends ItemObsidian +{ + public ItemWeatherOrb(int i) + { + super(i); + setMaxStackSize(1); + setMaxDamage(5000); + setTabToDisplayOn(CreativeTabs.tabTools); + } + + public boolean hasEffect(ItemStack itemstack) + { + return true; + } + + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) + { + if(itemstack.getItemDamage() == 0) + { + entityplayer.openGui(ObsidianIngots.instance, 20, world, (int)entityplayer.posX, (int)entityplayer.posY, (int)entityplayer.posZ); + } + return itemstack; + } + + public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) + { + if(itemstack.getItemDamage() > 0) + { + itemstack.damageItem(-1, (EntityLiving)entity); + } + } +} diff --git a/src/common/net/uberkat/obsidian/common/ObsidianHooks.java b/src/common/net/uberkat/obsidian/common/ObsidianHooks.java new file mode 100644 index 000000000..21c4076e1 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ObsidianHooks.java @@ -0,0 +1,11 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class ObsidianHooks +{ + public void hook() + { + //To be completed in the future. + } +} diff --git a/src/common/net/uberkat/obsidian/common/ObsidianIngots.java b/src/common/net/uberkat/obsidian/common/ObsidianIngots.java new file mode 100644 index 000000000..227d824b6 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ObsidianIngots.java @@ -0,0 +1,901 @@ +package net.uberkat.obsidian.common; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.InetAddress; +import java.net.Socket; +import java.net.URL; +import java.util.Map; +import java.util.Properties; +import java.util.Random; +import java.util.logging.Logger; + +import net.minecraftforge.common.*; +import net.minecraft.src.*; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.*; +import cpw.mods.fml.common.Mod.Init; +import cpw.mods.fml.common.Mod.PreInit; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkMod; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.EntityRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.common.registry.TickRegistry; + +/** + * Obsidian Ingots mod -- adds in Tools, Armor, Weapons, Machines, and Magic. Universal files. + * @author AidanBrady + * + */ +@Mod(modid = "ObsidianIngots", name = "Obsidian Ingots", version = "4.0") +@NetworkMod(channels = { "ObsidianIngots" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class) +public class ObsidianIngots +{ + /** + * Obsidian Ingots logger instance + */ + public static Logger logger = Logger.getLogger("Minecraft"); + + /** + * Obsidian Ingots proxy instance + */ + @SidedProxy(clientSide = "net.uberkat.obsidian.client.ClientProxy", serverSide = "net.uberkat.obsidian.server.ServerProxy") + public static CommonProxy proxy; + + /** + * Obsidian Ingots mod instance + */ + public static ObsidianIngots instance; + + /** + * Obsidian Ingots hooks instance + */ + public static ObsidianHooks hooks; + + //Initial Declarations + + public static Version versionNumber = new Version(4, 0, 0); + public static String latestVersionNumber; + public static String recentNews; + public static String hostIP = "71.56.58.57"; + public static int hostPort = 3073; + //Enums + //Tools + public static EnumToolMaterial toolOBSIDIAN = EnumHelper.addToolMaterial("OBSIDIAN", 3, 2500, 20F, 10, 50); + public static EnumToolMaterial toolOBSIDIAN2 = EnumHelper.addToolMaterial("OBSIDIAN2", 3, 3000, 25F, 10, 100); + public static EnumToolMaterial toolLAZULI = EnumHelper.addToolMaterial("LAZULI", 2, 200, 5.0F, 0, 22); + public static EnumToolMaterial toolLAZULI2 = EnumHelper.addToolMaterial("LAZULI2", 2, 250, 6.0F, 4, 50); + public static EnumToolMaterial toolPLATINUM = EnumHelper.addToolMaterial("PLATINUM", 3, 800, 15F, 5, 30); + public static EnumToolMaterial toolPLATINUM2 = EnumHelper.addToolMaterial("PLATINUM2", 3, 1000, 20F, 5, 60); + public static EnumToolMaterial toolREDSTONE = EnumHelper.addToolMaterial("REDSTONE", 2, 250, 10F, 6, 50); + public static EnumToolMaterial toolREDSTONE2 = EnumHelper.addToolMaterial("REDSTONE2", 2, 400, 12F, 6, 60); + public static EnumToolMaterial toolGLOWSTONE = EnumHelper.addToolMaterial("GLOWSTONE", 2, 300, 14, 5, 80); + public static EnumToolMaterial toolGLOWSTONE2 = EnumHelper.addToolMaterial("GLOWSTONE2", 2, 450, 18, 5, 100); + //Armor + public static EnumArmorMaterial armorOBSIDIAN = EnumHelper.addArmorMaterial("OBSIDIAN", 50, new int[]{5, 12, 8, 5}, 50); + public static EnumArmorMaterial armorLAZULI = EnumHelper.addArmorMaterial("LAZULI", 13, new int[]{2, 5, 4, 2}, 50); + public static EnumArmorMaterial armorPLATINUM = EnumHelper.addArmorMaterial("PLATINUM", 30, new int[]{4, 10, 7, 4}, 50); + public static EnumArmorMaterial armorREDSTONE = EnumHelper.addArmorMaterial("REDSTONE", 16, new int[]{2, 7, 5, 3}, 50); + public static EnumArmorMaterial armorGLOWSTONE = EnumHelper.addArmorMaterial("GLOWSTONE", 18, new int[]{3, 7, 6, 3}, 50); + //Block IDs + public static int platinumOreID = 200; + public static int platinumBlockID = 201; + public static int redstoneBlockID = 202; + public static int obsidianTNTID = 203; + public static int refinedObsidianID = 204; + public static int lifeBlockID = 205; + public static int enrichmentChamberID = 206; + public static int platinumCompressorID = 207; + public static int combinerID = 208; + public static int crusherID = 209; + public static int coalBlockID = 210; + public static int refinedGlowstoneID = 211; + + //Base Items + public static Item WoodPaxel; + public static Item StonePaxel; + public static Item IronPaxel; + public static Item DiamondPaxel; + public static Item GoldPaxel; + public static Item WoodKnife; + public static Item StoneKnife; + public static Item IronKnife; + public static Item DiamondKnife; + public static Item GoldKnife; + public static Item IronDust; + public static Item GoldDust; + + //Glowstone Items + public static Block RefinedGlowstone; + public static Item GlowstoneIngot; + public static Item GlowstonePaxel; + public static Item GlowstonePickaxe; + public static Item GlowstoneAxe; + public static Item GlowstoneSpade; + public static Item GlowstoneHoe; + public static Item GlowstoneSword; + public static Item GlowstoneHelmet; + public static Item GlowstoneBody; + public static Item GlowstoneLegs; + public static Item GlowstoneBoots; + public static Item GlowstoneKnife; + + //Redstone Items + public static Block RedstoneBlock; + public static Item RedstoneIngot; + public static Item RedstonePaxel; + public static Item RedstonePickaxe; + public static Item RedstoneAxe; + public static Item RedstoneSpade; + public static Item RedstoneHoe; + public static Item RedstoneSword; + public static Item RedstoneHelmet; + public static Item RedstoneBody; + public static Item RedstoneLegs; + public static Item RedstoneBoots; + public static Item RedstoneKnife; + + //Platinum Items + public static Block PlatinumOre; + public static Block PlatinumBlock; + public static Item PlatinumDust; + public static Item PlatinumIngot; + public static Item PlatinumPaxel; + public static Item PlatinumPickaxe; + public static Item PlatinumAxe; + public static Item PlatinumSpade; + public static Item PlatinumHoe; + public static Item PlatinumSword; + public static Item PlatinumHelmet; + public static Item PlatinumBody; + public static Item PlatinumLegs; + public static Item PlatinumBoots; + public static Item PlatinumKnife; + + //Obsidian Items + public static Block RefinedObsidian; + public static Item ObsidianDust; + public static Item ObsidianHelmet; + public static Item ObsidianBody; + public static Item ObsidianLegs; + public static Item ObsidianBoots; + public static Item ObsidianIngot; + public static Item ObsidianPaxel; + public static Item ObsidianPickaxe; + public static Item ObsidianAxe; + public static Item ObsidianSpade; + public static Item ObsidianHoe; + public static Item ObsidianSword; + public static Item ObsidianKnife; + + //Lazuli Items + public static Item LazuliPaxel; + public static Item LazuliPickaxe; + public static Item LazuliAxe; + public static Item LazuliSpade; + public static Item LazuliHoe; + public static Item LazuliSword; + public static Item LazuliHelmet; + public static Item LazuliBody; + public static Item LazuliLegs; + public static Item LazuliBoots; + public static Item LazuliKnife; + + //Extra Items + public static Item ObsidianArrow; + public static Item ObsidianBow; + public static Item LightningRod; + public static Item Stopwatch; + public static Item WeatherOrb; + + //Extra Blocks + public static Block ObsidianTNT; + public static Block LifeBlock; + public static Block EnrichmentChamber; + public static Block PlatinumCompressor; + public static Block Combiner; + public static Block Crusher; + public static Block CoalBlock; + + //Boolean Values + public static boolean extrasEnabled; + public static boolean oreGenerationEnabled; + + //Extra data + public static float ObsidianTNTBlastRadius = 12.0F; + public static int ObsidianTNTDelay = 100; + + /** + * Total ticks passed since thePlayer joined theWorld + */ + public static int ticksPassed = 0; + + /** + * Adds all in-game crafting and smelting recipes. + */ + public void addRecipes() + { + //Crafting Recipes + //Base + GameRegistry.addRecipe(new ItemStack(WoodPaxel, 1), new Object[] { + "XYZ", " T ", " T ", Character.valueOf('X'), Item.axeWood, Character.valueOf('Y'), Item.pickaxeWood, Character.valueOf('Z'), Item.shovelWood, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(StonePaxel, 1), new Object[] { + "XYZ", " T ", " T ", Character.valueOf('X'), Item.axeStone, Character.valueOf('Y'), Item.pickaxeStone, Character.valueOf('Z'), Item.shovelStone, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(IronPaxel, 1), new Object[] { + "XYZ", " T ", " T ", Character.valueOf('X'), Item.axeSteel, Character.valueOf('Y'), Item.pickaxeSteel, Character.valueOf('Z'), Item.shovelSteel, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(DiamondPaxel, 1), new Object[] { + "XYZ", " T ", " T ", Character.valueOf('X'), Item.axeDiamond, Character.valueOf('Y'), Item.pickaxeDiamond, Character.valueOf('Z'), Item.shovelDiamond, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(GoldPaxel, 1), new Object[] { + "XYZ", " T ", " T ", Character.valueOf('X'), Item.axeGold, Character.valueOf('Y'), Item.pickaxeGold, Character.valueOf('Z'), Item.shovelGold, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(WoodKnife), new Object[] { + " ^", "I ", Character.valueOf('^'), Block.planks, Character.valueOf('I'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(StoneKnife), new Object[] { + " ^", "I ", Character.valueOf('^'), Block.cobblestone, Character.valueOf('I'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(IronKnife), new Object[] { + " ^", "I ", Character.valueOf('^'), Item.ingotIron, Character.valueOf('I'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(DiamondKnife), new Object[] { + " ^", "I ", Character.valueOf('^'), Item.diamond, Character.valueOf('I'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(GoldKnife), new Object[] { + " ^", "I ", Character.valueOf('^'), Item.ingotGold, Character.valueOf('I'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(Item.coal, 9), new Object[] { + "*", Character.valueOf('*'), Item.coal + }); + GameRegistry.addRecipe(new ItemStack(CoalBlock, 1), new Object[] { + "***", "***", "***", Character.valueOf('*'), Item.coal + }); + + //Obsidian + GameRegistry.addRecipe(new ItemStack(RefinedObsidian, 0), new Object[] { + "***", "***", "***", Character.valueOf('*'), ObsidianIngot + }); + GameRegistry.addRecipe(new ItemStack(ObsidianIngot, 9), new Object[] { + "*", Character.valueOf('*'), new ItemStack(RefinedObsidian, 0) + }); + GameRegistry.addRecipe(new ItemStack(ObsidianHelmet, 1), new Object[] { + "***", "* *", Character.valueOf('*'), ObsidianIngot + }); + GameRegistry.addRecipe(new ItemStack(ObsidianBody, 1), new Object[] { + "* *", "***", "***", Character.valueOf('*'), ObsidianIngot + }); + GameRegistry.addRecipe(new ItemStack(ObsidianLegs, 1), new Object[] { + "***", "* *", "* *", Character.valueOf('*'), ObsidianIngot + }); + GameRegistry.addRecipe(new ItemStack(ObsidianBoots, 1), new Object[] { + "* *", "* *", Character.valueOf('*'), ObsidianIngot + }); + GameRegistry.addRecipe(new ItemStack(ObsidianPaxel, 1), new Object[]{ + "XYZ", " T ", " T ", Character.valueOf('X'), ObsidianAxe, Character.valueOf('Y'), ObsidianPickaxe, Character.valueOf('Z'), ObsidianSpade, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(ObsidianPickaxe, 1), new Object[]{ + "XXX", " T ", " T ", Character.valueOf('X'), ObsidianIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(ObsidianAxe, 1), new Object[]{ + "XX", "XT", " T", Character.valueOf('X'), ObsidianIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(ObsidianSpade, 1), new Object[]{ + "X", "T", "T", Character.valueOf('X'), ObsidianIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(ObsidianHoe, 1), new Object[]{ + "XX", " T", " T", Character.valueOf('X'), ObsidianIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(ObsidianSword, 1), new Object[]{ + "X", "X", "T", Character.valueOf('X'), ObsidianIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(ObsidianKnife, 1), new Object[] { + " ^", "I ", Character.valueOf('^'), ObsidianIngot, Character.valueOf('I'), Item.stick + }); + + //Glowstone + GameRegistry.addRecipe(new ItemStack(RefinedGlowstone, 1), new Object[] { + "***", "***", "***", Character.valueOf('*'), GlowstoneIngot + }); + GameRegistry.addRecipe(new ItemStack(GlowstoneIngot, 9), new Object[] { + "*", Character.valueOf('*'), RefinedGlowstone + }); + GameRegistry.addRecipe(new ItemStack(GlowstonePaxel, 1), new Object[]{ + "XYZ", " T ", " T ", Character.valueOf('X'), GlowstoneAxe, Character.valueOf('Y'), GlowstonePickaxe, Character.valueOf('Z'), GlowstoneSpade, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(GlowstonePickaxe, 1), new Object[]{ + "XXX", " T ", " T ", Character.valueOf('X'), GlowstoneIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(GlowstoneAxe, 1), new Object[]{ + "XX", "XT", " T", Character.valueOf('X'), GlowstoneIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(GlowstoneSpade, 1), new Object[]{ + "X", "T", "T", Character.valueOf('X'), GlowstoneIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(GlowstoneHoe, 1), new Object[]{ + "XX", " T", " T", Character.valueOf('X'), GlowstoneIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(GlowstoneSword, 1), new Object[]{ + "X", "X", "T", Character.valueOf('X'), GlowstoneIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(GlowstoneHelmet, 1), new Object[] { + "***", "* *", Character.valueOf('*'), GlowstoneIngot + }); + GameRegistry.addRecipe(new ItemStack(GlowstoneBody, 1), new Object[] { + "* *", "***", "***", Character.valueOf('*'), GlowstoneIngot + }); + GameRegistry.addRecipe(new ItemStack(GlowstoneLegs, 1), new Object[] { + "***", "* *", "* *", Character.valueOf('*'), GlowstoneIngot + }); + GameRegistry.addRecipe(new ItemStack(GlowstoneBoots, 1), new Object[] { + "* *", "* *", Character.valueOf('*'), GlowstoneIngot + }); + GameRegistry.addRecipe(new ItemStack(GlowstoneKnife, 1), new Object[] { + " ^", "I ", Character.valueOf('^'), GlowstoneIngot, Character.valueOf('I'), Item.stick + }); + + //Lazuli + GameRegistry.addRecipe(new ItemStack(LazuliHelmet, 1), new Object[] { + "***", "* *", Character.valueOf('*'), new ItemStack(Item.dyePowder, 1, 4) + }); + GameRegistry.addRecipe(new ItemStack(LazuliBody, 1), new Object[] { + "* *", "***", "***", Character.valueOf('*'), new ItemStack(Item.dyePowder, 1, 4) + }); + GameRegistry.addRecipe(new ItemStack(LazuliLegs, 1), new Object[] { + "***", "* *", "* *", Character.valueOf('*'), new ItemStack(Item.dyePowder, 1, 4) + }); + GameRegistry.addRecipe(new ItemStack(LazuliBoots, 1), new Object[] { + "* *", "* *", Character.valueOf('*'), new ItemStack(Item.dyePowder, 1, 4) + }); + GameRegistry.addRecipe(new ItemStack(LazuliPaxel, 1), new Object[]{ + "XYZ", " T ", " T ", Character.valueOf('X'), LazuliAxe, Character.valueOf('Y'), LazuliPickaxe, Character.valueOf('Z'), LazuliSpade, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(LazuliPickaxe, 1), new Object[]{ + "XXX", " T ", " T ", Character.valueOf('X'), new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(LazuliAxe, 1), new Object[]{ + "XX", "XT", " T", Character.valueOf('X'), new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(LazuliSpade, 1), new Object[]{ + "X", "T", "T", Character.valueOf('X'), new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(LazuliHoe, 1), new Object[]{ + "XX", " T", " T", Character.valueOf('X'), new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(LazuliSword, 1), new Object[]{ + "X", "X", "T", Character.valueOf('X'), new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(LazuliKnife, 1), new Object[] { + " ^", "I ", Character.valueOf('^'), new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('I'), Item.stick + }); + + //Platinum + GameRegistry.addRecipe(new ItemStack(PlatinumBlock, 1), new Object[]{ + "XXX", "XXX", "XXX", Character.valueOf('X'), PlatinumIngot + }); + GameRegistry.addRecipe(new ItemStack(PlatinumPaxel, 1), new Object[]{ + "XYZ", " T ", " T ", Character.valueOf('X'), PlatinumAxe, Character.valueOf('Y'), PlatinumPickaxe, Character.valueOf('Z'), PlatinumSpade, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(PlatinumPickaxe, 1), new Object[]{ + "XXX", " T ", " T ", Character.valueOf('X'), PlatinumIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(PlatinumAxe, 1), new Object[]{ + "XX", "XT", " T", Character.valueOf('X'), PlatinumIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(PlatinumSpade, 1), new Object[]{ + "X", "T", "T", Character.valueOf('X'), PlatinumIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(PlatinumHoe, 1), new Object[]{ + "XX", " T", " T", Character.valueOf('X'), PlatinumIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(PlatinumSword, 1), new Object[]{ + "X", "X", "T", Character.valueOf('X'), PlatinumIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(PlatinumHelmet, 1), new Object[] { + "***", "* *", Character.valueOf('*'), PlatinumIngot + }); + GameRegistry.addRecipe(new ItemStack(PlatinumBody, 1), new Object[] { + "* *", "***", "***", Character.valueOf('*'), PlatinumIngot + }); + GameRegistry.addRecipe(new ItemStack(PlatinumLegs, 1), new Object[] { + "***", "* *", "* *", Character.valueOf('*'), PlatinumIngot + }); + GameRegistry.addRecipe(new ItemStack(PlatinumBoots, 1), new Object[] { + "* *", "* *", Character.valueOf('*'), PlatinumIngot + }); + GameRegistry.addRecipe(new ItemStack(PlatinumIngot, 9), new Object[] { + "*", Character.valueOf('*'), PlatinumBlock + }); + GameRegistry.addRecipe(new ItemStack(PlatinumKnife, 1), new Object[] { + " ^", "I ", Character.valueOf('^'), PlatinumIngot, Character.valueOf('I'), Item.stick + }); + + //Redstone + GameRegistry.addRecipe(new ItemStack(RedstoneBlock, 1), new Object[] { + "***", "***", "***", Character.valueOf('*'), RedstoneIngot + }); + GameRegistry.addRecipe(new ItemStack(RedstoneIngot, 9), new Object[] { + "*", Character.valueOf('*'), RedstoneBlock + }); + GameRegistry.addRecipe(new ItemStack(RedstonePaxel, 1), new Object[]{ + "XYZ", " T ", " T ", Character.valueOf('X'), RedstoneAxe, Character.valueOf('Y'), RedstonePickaxe, Character.valueOf('Z'), RedstoneSpade, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(RedstonePickaxe, 1), new Object[]{ + "XXX", " T ", " T ", Character.valueOf('X'), RedstoneIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(RedstoneAxe, 1), new Object[]{ + "XX", "XT", " T", Character.valueOf('X'), RedstoneIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(RedstoneSpade, 1), new Object[]{ + "X", "T", "T", Character.valueOf('X'), RedstoneIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(RedstoneHoe, 1), new Object[]{ + "XX", " T", " T", Character.valueOf('X'), RedstoneIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(RedstoneSword, 1), new Object[]{ + "X", "X", "T", Character.valueOf('X'), RedstoneIngot, Character.valueOf('T'), Item.stick + }); + GameRegistry.addRecipe(new ItemStack(RedstoneHelmet, 1), new Object[] { + "***", "* *", Character.valueOf('*'), RedstoneIngot + }); + GameRegistry.addRecipe(new ItemStack(RedstoneBody, 1), new Object[] { + "* *", "***", "***", Character.valueOf('*'), RedstoneIngot + }); + GameRegistry.addRecipe(new ItemStack(RedstoneLegs, 1), new Object[] { + "***", "* *", "* *", Character.valueOf('*'), RedstoneIngot + }); + GameRegistry.addRecipe(new ItemStack(RedstoneBoots, 1), new Object[] { + "* *", "* *", Character.valueOf('*'), RedstoneIngot + }); + GameRegistry.addRecipe(new ItemStack(RedstoneKnife, 1), new Object[] { + " ^", "I ", Character.valueOf('^'), RedstoneIngot, Character.valueOf('I'), Item.stick + }); + + //Extra + GameRegistry.addRecipe(new ItemStack(ObsidianTNT, 1), new Object[] { + "***", "XXX", "***", Character.valueOf('*'), Block.obsidian, Character.valueOf('X'), Block.tnt + }); + GameRegistry.addRecipe(new ItemStack(ObsidianArrow, 8), new Object[] { + "A", "B", "C", Character.valueOf('A'), ObsidianIngot, Character.valueOf('B'), Item.stick, Character.valueOf('C'), Item.feather + }); + GameRegistry.addRecipe(new ItemStack(ObsidianBow, 1), new Object[] { + " AB", "A B", " AB", Character.valueOf('A'), ObsidianIngot, Character.valueOf('B'), Item.silk + }); + if(extrasEnabled) + { + GameRegistry.addRecipe(new ItemStack(LifeBlock, 1), new Object[] { + "DDD", "DOD", "DDD", Character.valueOf('D'), Block.blockDiamond, Character.valueOf('O'), RefinedObsidian + }); + } + GameRegistry.addRecipe(new ItemStack(PlatinumCompressor, 1), new Object[] { + "***", "*P*", "***", Character.valueOf('*'), Item.redstone, Character.valueOf('P'), PlatinumBlock + }); + GameRegistry.addRecipe(new ItemStack(EnrichmentChamber, 1), new Object[] { + "***", "*R*", "***", Character.valueOf('*'), PlatinumIngot, Character.valueOf('R'), Item.redstone + }); + GameRegistry.addRecipe(new ItemStack(Combiner, 1), new Object[] { + "***", "*P*", "***", Character.valueOf('*'), Block.cobblestone, Character.valueOf('P'), PlatinumBlock + }); + GameRegistry.addRecipe(new ItemStack(Crusher, 1), new Object[] { + "***", "*L*", "***", Character.valueOf('*'), PlatinumIngot, Character.valueOf('L'), Item.bucketLava + }); + + //Smelting + GameRegistry.addSmelting(platinumOreID, new ItemStack(PlatinumIngot), 1.0F); + } + /** + * Adds all item and block names. + */ + public void addNames() + { + //Base + ObsidianUtils.addName(WoodPaxel, "Wood Paxel"); + ObsidianUtils.addName(StonePaxel, "Stone Paxel"); + ObsidianUtils.addName(IronPaxel, "Iron Paxel"); + ObsidianUtils.addName(DiamondPaxel, "Diamond Paxel"); + ObsidianUtils.addName(GoldPaxel, "Gold Paxel"); + ObsidianUtils.addName(WoodKnife, "Wood Knife"); + ObsidianUtils.addName(StoneKnife, "Stone Knife"); + ObsidianUtils.addName(IronKnife, "Iron Knife"); + ObsidianUtils.addName(DiamondKnife, "Diamond Knife"); + ObsidianUtils.addName(GoldKnife, "Gold Knife"); + ObsidianUtils.addName(IronDust, "Iron Dust"); + ObsidianUtils.addName(GoldDust, "Gold Dust"); + + //Obsidian + ObsidianUtils.addName(RefinedObsidian, "Refined Obsidian"); + ObsidianUtils.addName(ObsidianDust, "Obsidian Dust"); + ObsidianUtils.addName(ObsidianHelmet, "Obsidian Helmet"); + ObsidianUtils.addName(ObsidianBody, "Obsidian Chestplate"); + ObsidianUtils.addName(ObsidianLegs, "Obsidian Leggings"); + ObsidianUtils.addName(ObsidianBoots, "Obsidian Boots"); + ObsidianUtils.addName(ObsidianIngot, "Obsidian Ingot"); + ObsidianUtils.addName(ObsidianPaxel, "Obsidian Paxel"); + ObsidianUtils.addName(ObsidianPickaxe, "Obsidian Pickaxe"); + ObsidianUtils.addName(ObsidianAxe, "Obsidian Axe"); + ObsidianUtils.addName(ObsidianSpade, "Obsidian Shovel"); + ObsidianUtils.addName(ObsidianHoe, "Obsidian Hoe"); + ObsidianUtils.addName(ObsidianSword, "Obsidian Sword"); + ObsidianUtils.addName(ObsidianKnife, "Obsidian Knife"); + + //Lazuli + ObsidianUtils.addName(LazuliHelmet, "Lapis Lazuli Helmet"); + ObsidianUtils.addName(LazuliBody, "Lapis Lazuli Chestplate"); + ObsidianUtils.addName(LazuliLegs, "Lapis Lazuli Leggings"); + ObsidianUtils.addName(LazuliBoots, "Lapis Lazuli Boots"); + ObsidianUtils.addName(LazuliPaxel, "Lapis Lazuli Paxel"); + ObsidianUtils.addName(LazuliPickaxe, "Lapis Lazuli Pickaxe"); + ObsidianUtils.addName(LazuliAxe, "Lapis Lazuli Axe"); + ObsidianUtils.addName(LazuliSpade, "Lapis Lazuli Shovel"); + ObsidianUtils.addName(LazuliHoe, "Lapis Lazuli Hoe"); + ObsidianUtils.addName(LazuliSword, "Lapis Lazuli Sword"); + ObsidianUtils.addName(LazuliKnife, "Lazuli Knife"); + + //Platinum + ObsidianUtils.addName(PlatinumOre, "Platinum Ore"); + ObsidianUtils.addName(PlatinumBlock, "Platinum Block"); + ObsidianUtils.addName(PlatinumDust, "Platinum Dust"); + ObsidianUtils.addName(PlatinumHelmet, "Platinum Helmet"); + ObsidianUtils.addName(PlatinumBody, "Platinum Chestplate"); + ObsidianUtils.addName(PlatinumLegs, "Platinum Leggings"); + ObsidianUtils.addName(PlatinumBoots, "Platinum Boots"); + ObsidianUtils.addName(PlatinumIngot, "Platinum Ingot"); + ObsidianUtils.addName(PlatinumPaxel, "Platinum Paxel"); + ObsidianUtils.addName(PlatinumPickaxe, "Platinum Pickaxe"); + ObsidianUtils.addName(PlatinumAxe, "Platinum Axe"); + ObsidianUtils.addName(PlatinumSpade, "Platinum Shovel"); + ObsidianUtils.addName(PlatinumHoe, "Platinum Hoe"); + ObsidianUtils.addName(PlatinumSword, "Platinum Sword"); + ObsidianUtils.addName(PlatinumKnife, "Platinum Knife"); + + //Redstone + ObsidianUtils.addName(RedstoneBlock, "Redstone Block"); + ObsidianUtils.addName(RedstoneBlock, "Redstone Block"); + ObsidianUtils.addName(RedstoneHelmet, "Redstone Helmet"); + ObsidianUtils.addName(RedstoneBody, "Redstone Chestplate"); + ObsidianUtils.addName(RedstoneLegs, "Redstone Leggings"); + ObsidianUtils.addName(RedstoneBoots, "Redstone Boots"); + ObsidianUtils.addName(RedstoneIngot, "Redstone Ingot"); + ObsidianUtils.addName(RedstonePaxel, "Redstone Paxel"); + ObsidianUtils.addName(RedstonePickaxe, "Redstone Pickaxe"); + ObsidianUtils.addName(RedstoneAxe, "Redstone Axe"); + ObsidianUtils.addName(RedstoneSpade, "Redstone Shovel"); + ObsidianUtils.addName(RedstoneHoe, "Redstone Hoe"); + ObsidianUtils.addName(RedstoneSword, "Redstone Sword"); + ObsidianUtils.addName(RedstoneBlock, "Redstone Block"); + ObsidianUtils.addName(RedstoneKnife, "Redstone Knife"); + + //Glowstone + ObsidianUtils.addName(RefinedGlowstone, "Refined Glowstone Block"); + ObsidianUtils.addName(GlowstoneIngot, "Glowstone Ingot"); + ObsidianUtils.addName(GlowstonePaxel, "Glowstone Paxel"); + ObsidianUtils.addName(GlowstonePickaxe, "Glowstone Pickaxe"); + ObsidianUtils.addName(GlowstoneAxe, "Glowstone Axe"); + ObsidianUtils.addName(GlowstoneSpade, "Glowstone Shovel"); + ObsidianUtils.addName(GlowstoneHoe, "Glowstone Hoe"); + ObsidianUtils.addName(GlowstoneSword, "Glowstone Sword"); + ObsidianUtils.addName(GlowstoneHelmet, "Glowstone Helmet"); + ObsidianUtils.addName(GlowstoneBody, "Glowstone Chestplate"); + ObsidianUtils.addName(GlowstoneLegs, "Glowstone Leggings"); + ObsidianUtils.addName(GlowstoneBoots, "Glowstone Boots"); + ObsidianUtils.addName(GlowstoneKnife, "Glowstone Knife"); + + //Extras + ObsidianUtils.addName(ObsidianArrow, "Obsidian Arrow"); + ObsidianUtils.addName(ObsidianBow, "Obsidian Bow"); + ObsidianUtils.addName(ObsidianTNT, "Obsidian TNT"); + if(extrasEnabled) + { + ObsidianUtils.addName(LightningRod, "Lightning Rod"); + ObsidianUtils.addName(Stopwatch, "Steve's Stopwatch"); + ObsidianUtils.addName(LifeBlock, "Block of Life"); + ObsidianUtils.addName(WeatherOrb, "Weather Orb"); + } + ObsidianUtils.addName(EnrichmentChamber, "Enrichment Chamber"); + ObsidianUtils.addName(PlatinumCompressor, "Platinum Compressor"); + ObsidianUtils.addName(Combiner, "Combiner"); + ObsidianUtils.addName(Crusher, "Crusher"); + ObsidianUtils.addName(CoalBlock, "Coal Block"); + } + /** + * Adds all item textures from the sprite sheet. + */ + public void addTextures() + { + //Base + WoodPaxel.setIconIndex(150); + StonePaxel.setIconIndex(151); + IronPaxel.setIconIndex(152); + DiamondPaxel.setIconIndex(153); + GoldPaxel.setIconIndex(154); + WoodKnife.setIconIndex(214); + StoneKnife.setIconIndex(215); + IronKnife.setIconIndex(216); + DiamondKnife.setIconIndex(217); + GoldKnife.setIconIndex(218); + IronDust.setIconIndex(248); + GoldDust.setIconIndex(250); + + //Glowstone + GlowstoneHelmet.setIconIndex(4); + GlowstoneBody.setIconIndex(20); + GlowstoneLegs.setIconIndex(36); + GlowstoneBoots.setIconIndex(52); + GlowstoneIngot.setIconIndex(164); + GlowstoneIngot.setIconIndex(164); + GlowstonePaxel.setIconIndex(148); + GlowstonePickaxe.setIconIndex(68); + GlowstoneAxe.setIconIndex(84); + GlowstoneSpade.setIconIndex(100); + GlowstoneHoe.setIconIndex(116); + GlowstoneSword.setIconIndex(132); + GlowstoneKnife.setIconIndex(212); + + //Redstone + RedstoneHelmet.setIconIndex(3); + RedstoneBody.setIconIndex(19); + RedstoneLegs.setIconIndex(35); + RedstoneBoots.setIconIndex(51); + RedstoneIngot.setIconIndex(163); + RedstonePaxel.setIconIndex(147); + RedstonePickaxe.setIconIndex(67); + RedstoneAxe.setIconIndex(83); + RedstoneSpade.setIconIndex(99); + RedstoneHoe.setIconIndex(115); + RedstoneSword.setIconIndex(131); + RedstoneKnife.setIconIndex(211); + + //Platinum + PlatinumDust.setIconIndex(242); + PlatinumHelmet.setIconIndex(2); + PlatinumBody.setIconIndex(18); + PlatinumLegs.setIconIndex(34); + PlatinumBoots.setIconIndex(50); + PlatinumIngot.setIconIndex(162); + PlatinumPaxel.setIconIndex(146); + PlatinumPickaxe.setIconIndex(66); + PlatinumAxe.setIconIndex(82); + PlatinumSpade.setIconIndex(98); + PlatinumHoe.setIconIndex(114); + PlatinumSword.setIconIndex(130); + PlatinumKnife.setIconIndex(210); + + //Obsidian + ObsidianDust.setIconIndex(241); + ObsidianHelmet.setIconIndex(1); + ObsidianBody.setIconIndex(17); + ObsidianLegs.setIconIndex(33); + ObsidianBoots.setIconIndex(49); + ObsidianIngot.setIconIndex(161); + ObsidianPaxel.setIconIndex(145); + ObsidianPickaxe.setIconIndex(65); + ObsidianAxe.setIconIndex(81); + ObsidianSpade.setIconIndex(97); + ObsidianHoe.setIconIndex(113); + ObsidianSword.setIconIndex(129); + ObsidianKnife.setIconIndex(209); + + //Lazuli + LazuliPaxel.setIconIndex(144); + LazuliPickaxe.setIconIndex(64); + LazuliAxe.setIconIndex(80); + LazuliSpade.setIconIndex(96); + LazuliHoe.setIconIndex(112); + LazuliSword.setIconIndex(128); + LazuliHelmet.setIconIndex(0); + LazuliBody.setIconIndex(16); + LazuliLegs.setIconIndex(32); + LazuliBoots.setIconIndex(48); + LazuliKnife.setIconIndex(208); + + //Extras + ObsidianArrow.setIconIndex(193); + ObsidianBow.setIconIndex(177); + if(extrasEnabled) + { + LightningRod.setIconIndex(225); + Stopwatch.setIconIndex(224); + WeatherOrb.setIconIndex(226); + } + } + /** + * Adds and registers all items. + */ + public void addItems() + { + RedstoneHelmet = (new ItemObsidianArmor(11235, armorREDSTONE, RenderingRegistry.addNewArmourRendererPrefix("redstone"), 0)).setItemName("RedstoneHelmet"); + RedstoneBody = (new ItemObsidianArmor(11236, armorREDSTONE, RenderingRegistry.addNewArmourRendererPrefix("redstone"), 1)).setItemName("RedstoneBody"); + RedstoneLegs = (new ItemObsidianArmor(11237, armorREDSTONE, RenderingRegistry.addNewArmourRendererPrefix("redstone"), 2)).setItemName("RedstoneLegs"); + RedstoneBoots = (new ItemObsidianArmor(11238, armorREDSTONE, RenderingRegistry.addNewArmourRendererPrefix("redstone"), 3)).setItemName("RedstoneBoots"); + RedstoneIngot = new ItemObsidian(11239).setItemName("RedstoneIngot"); + RedstonePaxel = new ItemObsidianPaxel(11240, toolREDSTONE2).setItemName("RedstonePaxel"); + RedstonePickaxe = new ItemObsidianPickaxe(11241, toolREDSTONE).setItemName("RedstonePickaxe"); + RedstoneAxe = new ItemObsidianAxe(11242, toolREDSTONE).setItemName("RedstoneAxe"); + RedstoneSpade = new ItemObsidianSpade(11243, toolREDSTONE).setItemName("RedstoneSpade"); + RedstoneHoe = new ItemObsidianHoe(11244, toolREDSTONE).setItemName("RedstoneHoe"); + RedstoneSword = new ItemObsidianSword(11245, toolREDSTONE).setItemName("RedstoneSword"); + PlatinumHelmet = (new ItemObsidianArmor(11246, EnumArmorMaterial.DIAMOND, RenderingRegistry.addNewArmourRendererPrefix("platinum"), 0)).setItemName("PlatinumHelmet"); + PlatinumBody = (new ItemObsidianArmor(11247, EnumArmorMaterial.DIAMOND, RenderingRegistry.addNewArmourRendererPrefix("platinum"), 1)).setItemName("PlatinumBody"); + PlatinumLegs = (new ItemObsidianArmor(11248, EnumArmorMaterial.DIAMOND, RenderingRegistry.addNewArmourRendererPrefix("platinum"), 2)).setItemName("PlatinumLegs"); + PlatinumBoots = (new ItemObsidianArmor(11249, EnumArmorMaterial.DIAMOND, RenderingRegistry.addNewArmourRendererPrefix("platinum"), 3)).setItemName("PlatinumBoots"); + PlatinumIngot = new ItemObsidian(11250).setItemName("PlatinumIngot"); + PlatinumPaxel = new ItemObsidianPaxel(11251, toolPLATINUM2).setItemName("PlatinumPaxel"); + PlatinumPickaxe = new ItemObsidianPickaxe(11252, toolPLATINUM).setItemName("PlatinumPickaxe"); + PlatinumAxe = new ItemObsidianAxe(11253, toolPLATINUM).setItemName("PlatinumAxe"); + PlatinumSpade = new ItemObsidianSpade(11254, toolPLATINUM).setItemName("PlatinumSpade"); + PlatinumHoe = new ItemObsidianHoe(11255, toolPLATINUM).setItemName("PlatinumHoe"); + PlatinumSword = new ItemObsidianSword(11256, toolPLATINUM).setItemName("PlatinumSword"); + ObsidianHelmet = (new ItemObsidianArmor(11257, armorOBSIDIAN, RenderingRegistry.addNewArmourRendererPrefix("obsidian"), 0)).setItemName("ObsidianHelmet"); + ObsidianBody = (new ItemObsidianArmor(11258, armorOBSIDIAN, RenderingRegistry.addNewArmourRendererPrefix("obsidian"), 1)).setItemName("ObsidianBody"); + ObsidianLegs = (new ItemObsidianArmor(11259, armorOBSIDIAN, RenderingRegistry.addNewArmourRendererPrefix("obsidian"), 2)).setItemName("ObsidianLegs"); + ObsidianBoots = (new ItemObsidianArmor(11260, armorOBSIDIAN, RenderingRegistry.addNewArmourRendererPrefix("obsidian"), 3)).setItemName("ObsidianBoots"); + ObsidianIngot = new ItemObsidian(11261).setItemName("ObsidianIngot"); + ObsidianPaxel = new ItemObsidianPaxel(11262, toolOBSIDIAN2).setItemName("ObsidianPaxel"); + ObsidianPickaxe = new ItemObsidianPickaxe(11263, toolOBSIDIAN).setItemName("ObsidianPickaxe"); + ObsidianAxe = new ItemObsidianAxe(11264, toolOBSIDIAN).setItemName("ObsidianAxe"); + ObsidianSpade = new ItemObsidianSpade(11265, toolOBSIDIAN).setItemName("ObsidianSpade"); + ObsidianHoe = new ItemObsidianHoe(11266, toolOBSIDIAN).setItemName("ObsidianHoe"); + ObsidianSword = new ItemObsidianSword(11267, toolOBSIDIAN).setItemName("ObsidianSword"); + LazuliPaxel = new ItemObsidianPaxel(11268, toolLAZULI2).setItemName("LazuliPaxel"); + LazuliPickaxe = new ItemObsidianPickaxe(11269, toolLAZULI).setItemName("LazuliPickaxe"); + LazuliAxe = new ItemObsidianAxe(11270, toolLAZULI).setItemName("LazuliAxe"); + LazuliSpade = new ItemObsidianSpade(11271, toolLAZULI).setItemName("LazuliSpade"); + LazuliHoe = new ItemObsidianHoe(11272, toolLAZULI).setItemName("LazuliHoe"); + LazuliSword = new ItemObsidianSword(11273, toolLAZULI).setItemName("LazuliSword"); + LazuliHelmet = (new ItemObsidianArmor(11274, armorLAZULI, RenderingRegistry.addNewArmourRendererPrefix("lazuli"), 0)).setItemName("LazuliHelmet"); + LazuliBody = (new ItemObsidianArmor(11275, armorLAZULI, RenderingRegistry.addNewArmourRendererPrefix("lazuli"), 1)).setItemName("LazuliBody"); + LazuliLegs = (new ItemObsidianArmor(11276, armorLAZULI, RenderingRegistry.addNewArmourRendererPrefix("lazuli"), 2)).setItemName("LazuliLegs"); + LazuliBoots = (new ItemObsidianArmor(11277, armorLAZULI, RenderingRegistry.addNewArmourRendererPrefix("lazuli"), 3)).setItemName("LazuliBoots"); + ObsidianArrow = new ItemObsidian(11278).setItemName("ObsidianArrow").setTabToDisplayOn(CreativeTabs.tabCombat); + ObsidianBow = new ItemObsidianBow(11279).setItemName("ObsidianBow"); + if(extrasEnabled) + { + LightningRod = new ItemLightningRod(11280).setItemName("LightningRod"); + Stopwatch = new ItemStopwatch(11281).setItemName("Stopwatch"); + WeatherOrb = new ItemWeatherOrb(11282).setItemName("WeatherOrb"); + } + WoodPaxel = new ItemObsidianPaxel(11283, EnumToolMaterial.WOOD).setItemName("WoodPaxel"); + StonePaxel = new ItemObsidianPaxel(11284, EnumToolMaterial.STONE).setItemName("StonePaxel"); + IronPaxel = new ItemObsidianPaxel(11285, EnumToolMaterial.IRON).setItemName("IronPaxel"); + DiamondPaxel = new ItemObsidianPaxel(11286, EnumToolMaterial.EMERALD).setItemName("DiamondPaxel"); + GoldPaxel = new ItemObsidianPaxel(11287, EnumToolMaterial.GOLD).setItemName("GoldPaxel"); + WoodKnife = new ItemObsidianKnife(11288, EnumToolMaterial.WOOD).setItemName("WoodKnife"); + StoneKnife = new ItemObsidianKnife(11289, EnumToolMaterial.STONE).setItemName("StoneKnife"); + IronKnife = new ItemObsidianKnife(11290, EnumToolMaterial.IRON).setItemName("IronKnife"); + DiamondKnife = new ItemObsidianKnife(11291, EnumToolMaterial.EMERALD).setItemName("DiamondKnife"); + GoldKnife = new ItemObsidianKnife(11292, EnumToolMaterial.GOLD).setItemName("GoldKnife"); + ObsidianKnife = new ItemObsidianKnife(11293, toolOBSIDIAN).setItemName("ObsidianKnife"); + LazuliKnife = new ItemObsidianKnife(11294, toolLAZULI).setItemName("LazuliKnife"); + PlatinumKnife = new ItemObsidianKnife(11295, toolPLATINUM).setItemName("PlatinumKnife"); + RedstoneKnife = new ItemObsidianKnife(11296, toolREDSTONE).setItemName("RedstoneKnife"); + ObsidianDust = new ItemObsidian(11297).setItemName("ObsidianDust"); + IronDust = new ItemObsidian(11298).setItemName("IronDust"); + GoldDust = new ItemObsidian(11299).setItemName("GoldDust"); + PlatinumDust = new ItemObsidian(11300).setItemName("PlatinumDust"); + GlowstoneIngot = new ItemObsidian(11301).setItemName("GlowstoneIngot"); + GlowstonePaxel = new ItemObsidianPaxel(11302, toolGLOWSTONE2).setItemName("GlowstonePaxel"); + GlowstonePickaxe = new ItemObsidianPickaxe(11303, toolGLOWSTONE).setItemName("GlowstonePickaxe"); + GlowstoneAxe = new ItemObsidianAxe(11304, toolGLOWSTONE).setItemName("GlowstoneAxe"); + GlowstoneSpade = new ItemObsidianSpade(11305, toolGLOWSTONE).setItemName("GlowstoneSpade"); + GlowstoneHoe = new ItemObsidianHoe(11306, toolGLOWSTONE).setItemName("GlowstoneHoe"); + GlowstoneSword = new ItemObsidianSword(11307, toolGLOWSTONE).setItemName("GlowstoneSword"); + GlowstoneHelmet = new ItemObsidianArmor(11308, armorGLOWSTONE, RenderingRegistry.addNewArmourRendererPrefix("glowstone"), 0).setItemName("GlowstoneHelmet"); + GlowstoneBody = new ItemObsidianArmor(11309, armorGLOWSTONE, RenderingRegistry.addNewArmourRendererPrefix("glowstone"), 1).setItemName("GlowstoneBody"); + GlowstoneLegs = new ItemObsidianArmor(11310, armorGLOWSTONE, RenderingRegistry.addNewArmourRendererPrefix("glowstone"), 2).setItemName("GlowstoneLegs"); + GlowstoneBoots = new ItemObsidianArmor(11311, armorGLOWSTONE, RenderingRegistry.addNewArmourRendererPrefix("glowstone"), 3).setItemName("GlowstoneBoots"); + GlowstoneKnife = new ItemObsidianKnife(11312, toolGLOWSTONE).setItemName("GlowstoneKnife"); + } + /** + * Adds and registers all blocks. + */ + public void addBlocks() + { + //Declarations + RedstoneBlock = new BlockBase(redstoneBlockID, 1).setBlockName("RedstoneBlock").setCreativeTab(CreativeTabs.tabBlock); + PlatinumOre = new BlockBase(platinumOreID, 3).setBlockName("PlatinumOre").setCreativeTab(CreativeTabs.tabBlock); + PlatinumBlock = new BlockBase(platinumBlockID, 2).setBlockName("PlatinumBlock").setCreativeTab(CreativeTabs.tabBlock); + RefinedObsidian = new BlockBase(refinedObsidianID, 0).setBlockName("RefinedObsidian").setCreativeTab(CreativeTabs.tabBlock); + ObsidianTNT = new BlockObsidianTNT(obsidianTNTID).setBlockName("ObsidianTNT").setCreativeTab(CreativeTabs.tabBlock); + if(extrasEnabled) + { + LifeBlock = new BlockLife(lifeBlockID, 4).setBlockName("LifeBlock").setCreativeTab(CreativeTabs.tabBlock); + } + EnrichmentChamber = new BlockEnrichmentChamber(enrichmentChamberID).setBlockName("EnrichmentChamberIdle").setCreativeTab(CreativeTabs.tabBlock); + PlatinumCompressor = new BlockPlatinumCompressor(platinumCompressorID).setBlockName("PlatinumCompressorIdle").setCreativeTab(CreativeTabs.tabBlock); + Combiner = new BlockCombiner(combinerID).setBlockName("CombinerIdle").setCreativeTab(CreativeTabs.tabBlock); + Crusher = new BlockCrusher(crusherID).setBlockName("CrusherIdle").setCreativeTab(CreativeTabs.tabBlock); + CoalBlock = new BlockBase(coalBlockID, 10).setBlockName("CoalBlock").setCreativeTab(CreativeTabs.tabBlock); + RefinedGlowstone = new BlockBase(refinedGlowstoneID, 11).setBlockName("RefinedGlowstone").setCreativeTab(CreativeTabs.tabBlock); + + //Registrations + GameRegistry.registerBlock(RedstoneBlock); + GameRegistry.registerBlock(PlatinumOre); + GameRegistry.registerBlock(PlatinumBlock); + GameRegistry.registerBlock(RefinedObsidian); + GameRegistry.registerBlock(ObsidianTNT); + if(extrasEnabled) + { + GameRegistry.registerBlock(LifeBlock); + } + GameRegistry.registerBlock(EnrichmentChamber); + GameRegistry.registerBlock(PlatinumCompressor); + GameRegistry.registerBlock(Combiner); + GameRegistry.registerBlock(Crusher); + GameRegistry.registerBlock(CoalBlock); + GameRegistry.registerBlock(RefinedGlowstone); + } + /** + * Adds and registers all entities and tile entities. + */ + public void addEntities() + { + //Entity IDs + EntityRegistry.registerGlobalEntityID(EntityObsidianArrow.class, "ObsidianArrow", EntityRegistry.findGlobalUniqueEntityId()); + EntityRegistry.registerGlobalEntityID(EntityObsidianTNT.class, "ObsidianTNT", EntityRegistry.findGlobalUniqueEntityId()); + EntityRegistry.registerGlobalEntityID(EntityKnife.class, "Knife", EntityRegistry.findGlobalUniqueEntityId()); + + //Registrations + EntityRegistry.registerModEntity(EntityObsidianArrow.class, "ObsidianArrow", 50, this, 40, 5, true); + EntityRegistry.registerModEntity(EntityObsidianTNT.class, "ObsidianTNT", 51, this, 40, 5, true); + EntityRegistry.registerModEntity(EntityKnife.class, "Knife", 52, this, 40, 5, true); + + //Tile entities + GameRegistry.registerTileEntity(TileEntityEnrichmentChamber.class, "EnrichmentChamber"); + GameRegistry.registerTileEntity(TileEntityPlatinumCompressor.class, "PlatinumCompressor"); + GameRegistry.registerTileEntity(TileEntityCombiner.class, "Combiner"); + GameRegistry.registerTileEntity(TileEntityCrusher.class, "Crusher"); + } + + @PreInit + public void load(FMLPreInitializationEvent event) + { + //Register the mod's ore handler + GameRegistry.registerWorldGenerator(new OreHandler()); + //Register the mod's GUI handler + NetworkRegistry.instance().registerGuiHandler(this, new CommonGuiHandler()); + //Set the mod's instance + instance = this; + System.out.println("[Obsidian Ingots] Version " + versionNumber + " initializing..."); + proxy.registerRenderInformation(); + proxy.setProperties(); + proxy.loadUtilities(); + proxy.loadTickHandler(); + + //Hook with mods Obsidian Ingots has implemented + hooks = new ObsidianHooks(); + hooks.hook(); + System.out.println("[ObsidianIngots] Hooking complete."); + + //Add all items + addItems(); + System.out.println("[ObsidianIngots] Items loaded."); + + //Add all blocks + addBlocks(); + System.out.println("[ObsidianIngots] Blocks loaded."); + + //Set item and block names + addNames(); + System.out.println("[ObsidianIngots] Names loaded."); + + //Set item and block textures + addTextures(); + System.out.println("[ObsidianIngots] Textures loaded."); + + //Set item and block recipes + addRecipes(); + System.out.println("[ObsidianIngots] Recipes loaded."); + + //Set up entities to run on SSP and SMP + addEntities(); + System.out.println("[ObsidianIngots] Entities loaded."); + + //Success message + logger.info("[ObsidianIngots] Mod loaded."); + } +} \ No newline at end of file diff --git a/src/common/net/uberkat/obsidian/common/ObsidianUtils.java b/src/common/net/uberkat/obsidian/common/ObsidianUtils.java new file mode 100644 index 000000000..37556da60 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ObsidianUtils.java @@ -0,0 +1,217 @@ +package net.uberkat.obsidian.common; + +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.HttpURLConnection; +import java.net.InetAddress; +import java.net.Socket; +import java.net.URISyntaxException; +import java.net.URL; + +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.network.PacketDispatcher; +import cpw.mods.fml.common.registry.LanguageRegistry; +import cpw.mods.fml.server.FMLServerHandler; + +import net.minecraft.src.*; + +/** + * Official Obsidian Ingots utilities. All miscellaneous methods are located here. + * @author AidanBrady + * + */ +public class ObsidianUtils +{ + /** + * Registers a name for the specified object. + * @param obj - block/item to name + * @param name - name for the block/item + */ + public static void addName(Object obj, String name) + { + LanguageRegistry.instance().addNameForObject(obj, "en_US", name); + } + + /** + * Checks for a new version of Obsidian Ingots. + */ + public static void checkForUpdates(EntityPlayer entityplayer) + { + if(!(getLatestVersion().toString().equals("Error retrieving data.")) && !(getLatestVersion().toString().equals(ObsidianIngots.versionNumber.toString()))) + { + entityplayer.addChatMessage("Your version of ¤1Obsidian Ingots ¤7(¤8" + ObsidianIngots.versionNumber.toString() + "¤7) is outdated. Please update to version ¤8" + getLatestVersion().toString()); + } + else if(getLatestVersion().toString().equals("Error retrieving data.")) + { + System.out.println("[ObsidianIngots] Minecraft is in offline mode, could not check for updates."); + } + } + + /** + * Gets the latest version using getHTML and returns it as a string. + * @return latest version + */ + public static String getLatestVersion() + { + String[] text = getHTML("http://dl.dropbox.com/u/90411166/Mod%20Versions/ObsidianIngots.txt").split(":"); + return text[0]; + } + + /** + * Gets the recent news using getHTML and returns it as a string. + * @return recent news + */ + public static String getRecentNews() + { + String[] text = getHTML("http://dl.dropbox.com/u/90411166/Mod%20Versions/ObsidianIngots.txt").split(":"); + if(text.length > 1) return text[1]; + return "There is no news to show."; + } + + /** + * Sends Obsidian Ingots server information about this mod. + */ + public static void sendServerData() + { + new ThreadServerData(); + } + + /** + * Returns one line of HTML from the url. + * @param urlToRead - URL to read from. + * @return HTML text from the url. + */ + public static String getHTML(String urlToRead) + { + StringBuilder sb = new StringBuilder(); + URL url; + HttpURLConnection conn; + BufferedReader rd; + String line; + String result = ""; + try { + url = new URL(urlToRead); + conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("GET"); + rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); + while ((line = rd.readLine()) != null) { + result += line; + sb.append(line); + } + rd.close(); + } catch (Exception e) { + result = "Error retrieving data."; + System.err.println("[ObsidianIngots] An error occured while connecting to URL '" + urlToRead + ".'"); + } + return result; + } + + /** + * Sends a Packet3Chat packet to the defined player, with the defined message. + * @param player - Player to send packet to. + * @param msg - message sent to player. + */ + public static void sendChatMessageToPlayer(String playerUsername, String msg) + { + EntityPlayer player = FMLServerHandler.instance().getServer().getConfigurationManager().getPlayerForUsername(playerUsername); + Packet3Chat chatPacket = new Packet3Chat(msg); + if(player != null) + { + ((EntityPlayerMP)player).serverForThisPlayer.sendPacketToPlayer(chatPacket); + } + } + + /** + * Sends the server the defined packet int. + * @param i - int to send + */ + public static void sendPacketDataInt(int i) + { + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + DataOutputStream data = new DataOutputStream(bytes); + try { + data.writeInt(i); + } catch (IOException e) { + System.out.println("[ObsidianIngots] An error occured while writing packet data."); + e.printStackTrace(); + } + Packet250CustomPayload packet = new Packet250CustomPayload(); + packet.channel = "ObsidianIngots"; + packet.data = bytes.toByteArray(); + packet.length = packet.data.length; + PacketDispatcher.sendPacketToServer(packet); + System.out.println("[ObsidianIngots] Sent '" + i + "' packet to server"); + } + + /** + * Checks if the game is running on multiplayer. + * @return - if world is multiplayer + */ + public static boolean isMultiplayer() + { + if(!FMLServerHandler.instance().getServer().isSinglePlayer()) + { + return true; + } + else { + return false; + } + } + + /** + * Checks if the mod is running on the latest version. + * @return - if mod is latest version + */ + public static boolean isClientLatestVersion() + { + if(ObsidianIngots.versionNumber.toString().equals(ObsidianIngots.latestVersionNumber)) + { + return true; + } + else { + return false; + } + } + + /** + * Checks if Minecraft is running in offline mode. + * @return - if mod is running in offline mode. + */ + public static boolean isOffline() + { + try { + new URL("http://www.apple.com").openConnection().connect(); + return true; + } catch (IOException e) + { + return false; + } + } + + /** + * Sets the defined world's time to the defined time. + * @param world - world to set time + * @param paramInt - hour to set time to + */ + public static void setHourForward(World world, int paramInt) + { + long l1 = world.getWorldTime() / 24000L * 24000L; + long l2 = l1 + 24000L + paramInt * 1000; + world.setWorldTime(l2); + } + + /** + * Creates a fake explosion, with only sounds and effects. No damage is caused, to blocks or the player. + * @param entityplayer - player to explode + */ + public static void doExplosion(EntityPlayer entityplayer) + { + World world = entityplayer.worldObj; + world.spawnParticle("hugeexplosion", entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D); + world.playSoundAtEntity(entityplayer, "random.explode", 1.0F, 1.0F); + } +} diff --git a/src/common/net/uberkat/obsidian/common/OreHandler.java b/src/common/net/uberkat/obsidian/common/OreHandler.java new file mode 100644 index 000000000..68e07e972 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/OreHandler.java @@ -0,0 +1,26 @@ +package net.uberkat.obsidian.common; + +import java.util.Random; + +import net.minecraft.src.IChunkProvider; +import net.minecraft.src.World; +import net.minecraft.src.WorldGenMinable; +import cpw.mods.fml.common.IWorldGenerator; + +public class OreHandler implements IWorldGenerator +{ + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) + { + if(ObsidianIngots.oreGenerationEnabled) + { + for (int i=0;i<1;i++) + { + int randPosX = chunkX + random.nextInt(16); + int randPosY = random.nextInt(60); + int randPosZ = chunkZ + random.nextInt(16); + (new WorldGenMinable(ObsidianIngots.PlatinumOre.blockID, 8)).generate(world, random, randPosX, randPosY, randPosZ); + } + } + } + +} diff --git a/src/common/net/uberkat/obsidian/common/PacketHandler.java b/src/common/net/uberkat/obsidian/common/PacketHandler.java new file mode 100644 index 000000000..8996855d3 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/PacketHandler.java @@ -0,0 +1,83 @@ +package net.uberkat.obsidian.common; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; + +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.ModLoader; +import net.minecraft.src.NetworkManager; +import net.minecraft.src.Packet250CustomPayload; +import net.minecraft.src.World; +import cpw.mods.fml.common.network.IPacketHandler; +import cpw.mods.fml.common.network.Player; + +public class PacketHandler implements IPacketHandler +{ + public void onPacketData(NetworkManager manager, Packet250CustomPayload packet, Player player) + { + DataInputStream dataStream = new DataInputStream(new ByteArrayInputStream(packet.data)); + EntityPlayer entityplayer = (EntityPlayer)player; + + if(packet.channel.equals("ObsidianIngots")) + { + try { + int packetData = dataStream.readInt(); + + if(packetData == 0) + { + System.out.println("[ObsidianIngots] Received '0' packet from " + entityplayer.username + "."); + ObsidianUtils.setHourForward(ModLoader.getMinecraftServerInstance().worldServerForDimension(0), 0); + entityplayer.inventory.getCurrentItem().damageItem(4999, entityplayer); + } + + if(packetData == 1) + { + System.out.println("[ObsidianIngots] Received '1' packet from " + entityplayer.username + "."); + ObsidianUtils.setHourForward(ModLoader.getMinecraftServerInstance().worldServerForDimension(0), 1); + entityplayer.inventory.getCurrentItem().damageItem(4999, entityplayer); + } + + if(packetData == 2) + { + System.out.println("[ObsidianIngots] Received '2' packet from " + entityplayer.username + "."); + ObsidianUtils.setHourForward(ModLoader.getMinecraftServerInstance().worldServerForDimension(0), 2); + entityplayer.inventory.getCurrentItem().damageItem(4999, entityplayer); + } + + if(packetData == 3) + { + System.out.println("[ObsidianIngots] Received '3' packet from " + entityplayer.username + "."); + ObsidianUtils.setHourForward(ModLoader.getMinecraftServerInstance().worldServerForDimension(0), 3); + entityplayer.inventory.getCurrentItem().damageItem(4999, entityplayer); + } + if(packetData == 5) + { + System.out.println("[ObsidianIngots] Recieved '5' packet from " + entityplayer.username + "."); + entityplayer.worldObj.getWorldInfo().setRaining(false); + entityplayer.worldObj.getWorldInfo().setThundering(false); + } + if(packetData == 6) + { + System.out.println("[ObsidianIngots] Recieved '6' packet from " + entityplayer.username + "."); + entityplayer.worldObj.getWorldInfo().setRaining(true); + entityplayer.worldObj.getWorldInfo().setThundering(true); + } + if(packetData == 7) + { + System.out.println("[ObsidianIngots] Recieved '7' packet from " + entityplayer.username + "."); + entityplayer.worldObj.getWorldInfo().setThundering(true); + } + if(packetData == 8) + { + System.out.println("[ObsidianIngots] Recieved '8' packet from " + entityplayer.username + "."); + entityplayer.worldObj.getWorldInfo().setRaining(true); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } +} diff --git a/src/common/net/uberkat/obsidian/common/PhysicsHelper.java b/src/common/net/uberkat/obsidian/common/PhysicsHelper.java new file mode 100644 index 000000000..6708f1f61 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/PhysicsHelper.java @@ -0,0 +1,43 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public abstract class PhysicsHelper +{ + public PhysicsHelper() + { + } + + public static void knockBack(EntityLiving entityliving, EntityLiving entityliving1, float f) + { + entityliving.motionX = 0.0D; + entityliving.motionY = 0.0D; + entityliving.motionZ = 0.0D; + float f1 = 2.5F; + + if ((entityliving1 instanceof EntityPlayer) && entityliving1.isSprinting()) + { + entityliving.addVelocity(-Math.sin(Math.toRadians(entityliving1.rotationYaw)) * (double)f * (double)f1, 0.1F * f * f1, Math.cos(Math.toRadians(entityliving1.rotationYaw)) * (double)f * (double)f1); + } + + double d = entityliving1.posX - entityliving.posX; + double d1; + + for (d1 = entityliving1.posZ - entityliving.posZ; d * d + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) + { + d = (Math.random() - Math.random()) * 0.01D; + } + + entityliving.attackedAtYaw = (float)((Math.atan2(d1, d) * 180D) / Math.PI) - entityliving.rotationYaw; + float f2 = MathHelper.sqrt_double(d * d + d1 * d1); + float f3 = f; + entityliving.motionX -= (d / (double)f2) * (double)f3; + entityliving.motionY += 0.40000000000000002D; + entityliving.motionZ -= (d1 / (double)f2) * (double)f3; + + if (entityliving.motionY > 0.40000000000000002D) + { + entityliving.motionY = 0.40000000000000002D; + } + } +} diff --git a/src/common/net/uberkat/obsidian/common/PlatinumCompressorRecipes.java b/src/common/net/uberkat/obsidian/common/PlatinumCompressorRecipes.java new file mode 100644 index 000000000..48efd2ba0 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/PlatinumCompressorRecipes.java @@ -0,0 +1,86 @@ +package net.uberkat.obsidian.common; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import net.minecraft.src.*; + +public class PlatinumCompressorRecipes +{ + private static final PlatinumCompressorRecipes smeltingBase = new PlatinumCompressorRecipes(); + + /** The list of smelting results. */ + private Map smeltingList = new HashMap(); + private Map metaSmeltingList = new HashMap(); + + /** + * Used to call methods addSmelting and getSmeltingResult. + */ + public static final PlatinumCompressorRecipes smelting() + { + return smeltingBase; + } + + private PlatinumCompressorRecipes() + { + addSmelting(Item.redstone.shiftedIndex, new ItemStack(ObsidianIngots.RedstoneIngot, 1)); + addSmelting(ObsidianIngots.ObsidianDust.shiftedIndex, new ItemStack(ObsidianIngots.ObsidianIngot, 1)); + addSmelting(ObsidianIngots.PlatinumDust.shiftedIndex, new ItemStack(ObsidianIngots.PlatinumIngot, 1)); + addSmelting(ObsidianIngots.IronDust.shiftedIndex, new ItemStack(Item.ingotIron, 1)); + addSmelting(ObsidianIngots.GoldDust.shiftedIndex, new ItemStack(Item.ingotGold, 1)); + addSmelting(Item.lightStoneDust.shiftedIndex, new ItemStack(ObsidianIngots.GlowstoneIngot, 1)); + } + + /** + * Adds a smelting recipe. + */ + public void addSmelting(int par1, ItemStack par2ItemStack) + { + this.smeltingList.put(Integer.valueOf(par1), par2ItemStack); + } + + /** + * Returns the smelting result of an item. + * Deprecated in favor of a metadata sensitive version + */ + @Deprecated + public ItemStack getSmeltingResult(int par1) + { + return (ItemStack)this.smeltingList.get(Integer.valueOf(par1)); + } + + public Map getSmeltingList() + { + return this.smeltingList; + } + + /** + * Add a metadata-sensitive furnace recipe + * @param itemID The Item ID + * @param metadata The Item Metadata + * @param itemstack The ItemStack for the result + */ + public void addSmelting(int itemID, int metadata, ItemStack itemstack) + { + metaSmeltingList.put(Arrays.asList(itemID, metadata), itemstack); + } + + /** + * Used to get the resulting ItemStack form a source ItemStack + * @param item The Source ItemStack + * @return The result ItemStack + */ + public ItemStack getSmeltingResult(ItemStack item) + { + if (item == null) + { + return null; + } + ItemStack ret = (ItemStack)metaSmeltingList.get(Arrays.asList(item.itemID, item.getItemDamage())); + if (ret != null) + { + return ret; + } + return (ItemStack)smeltingList.get(Integer.valueOf(item.itemID)); + } +} diff --git a/src/common/net/uberkat/obsidian/common/SlotObsidian.java b/src/common/net/uberkat/obsidian/common/SlotObsidian.java new file mode 100644 index 000000000..a9b4509a0 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/SlotObsidian.java @@ -0,0 +1,57 @@ +package net.uberkat.obsidian.common; + +import net.minecraft.src.*; + +public class SlotObsidian extends Slot +{ + /** The player that is using the GUI where this slot resides. */ + private EntityPlayer thePlayer; + private int field_75228_b; + + public SlotObsidian(EntityPlayer par1EntityPlayer, IInventory par2IInventory, int par3, int par4, int par5) + { + super(par2IInventory, par3, par4, par5); + this.thePlayer = par1EntityPlayer; + } + + /** + * Check if the stack is a valid item for this slot. Always true beside for the armor slots. + */ + public boolean isItemValid(ItemStack par1ItemStack) + { + return false; + } + + /** + * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new + * stack. + */ + public ItemStack decrStackSize(int par1) + { + if (this.getHasStack()) + { + this.field_75228_b += Math.min(par1, this.getStack().stackSize); + } + + return super.decrStackSize(par1); + } + + /** + * Called when the player picks up an item from an inventory slot + */ + public void onPickupFromSlot(ItemStack par1ItemStack) + { + this.onCrafting(par1ItemStack); + super.onPickupFromSlot(par1ItemStack); + } + + /** + * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an + * internal count then calls onCrafting(item). + */ + protected void onCrafting(ItemStack par1ItemStack, int par2) + { + field_75228_b += par2; + onCrafting(par1ItemStack); + } +} diff --git a/src/common/net/uberkat/obsidian/common/ThreadServerData.java b/src/common/net/uberkat/obsidian/common/ThreadServerData.java new file mode 100644 index 000000000..f8ca88f6b --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/ThreadServerData.java @@ -0,0 +1,48 @@ +package net.uberkat.obsidian.common; + +import java.io.IOException; +import java.io.PrintWriter; +import java.net.InetAddress; +import java.net.Socket; + +import cpw.mods.fml.client.FMLClientHandler; + +import net.minecraft.src.ModLoader; + +public class ThreadServerData extends Thread +{ + /** + * Sends information about this mod to the Obsidian Ingots server. + */ + public ThreadServerData() + { + setDaemon(true); + start(); + } + + public void run() + { + System.out.println("[ObsidianIngots] Initiating server protocol..."); + try { + InetAddress address = InetAddress.getByName(ObsidianIngots.hostIP); + Socket socket = new Socket(address, ObsidianIngots.hostPort); + PrintWriter writer = new PrintWriter(socket.getOutputStream()); + if(ObsidianUtils.isMultiplayer()) + { + writer.println("USER:server"); + } + else { + if(FMLClientHandler.instance().getClient().thePlayer != null) + { + writer.println("USER:" + FMLClientHandler.instance().getClient().thePlayer.username); + } + } + writer.println("DONE"); + writer.close(); + socket.close(); + } catch (IOException e) + { + System.err.println("[ObsidianIngots] Could not connect to server, error was '" + e.getMessage() + ".'"); + } + } +} diff --git a/src/common/net/uberkat/obsidian/common/TileEntityCombiner.java b/src/common/net/uberkat/obsidian/common/TileEntityCombiner.java new file mode 100644 index 000000000..8da1cca43 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/TileEntityCombiner.java @@ -0,0 +1,378 @@ +package net.uberkat.obsidian.common; + +import cpw.mods.fml.common.FMLCommonHandler; + +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.ISidedInventory; +import net.minecraft.src.*; + +public class TileEntityCombiner extends TileEntity implements IInventory, ISidedInventory +{ + /** + * The ItemStacks that hold the items currently being used in the furnace + */ + private ItemStack[] combinerItemStacks = new ItemStack[3]; + + /** The number of ticks that the furnace will keep burning */ + public int combinerBurnTime = 0; + + /** + * The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for + */ + public int currentItemBurnTime = 0; + + /** The number of ticks that the current item has been cooking for */ + public int combinerCookTime = 0; + + /** + * Returns the number of slots in the inventory. + */ + public int getSizeInventory() + { + return this.combinerItemStacks.length; + } + + /** + * Returns the stack in slot i + */ + public ItemStack getStackInSlot(int par1) + { + return this.combinerItemStacks[par1]; + } + + /** + * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new + * stack. + */ + public ItemStack decrStackSize(int par1, int par2) + { + if (this.combinerItemStacks[par1] != null) + { + ItemStack var3; + + if (this.combinerItemStacks[par1].stackSize <= par2) + { + var3 = this.combinerItemStacks[par1]; + this.combinerItemStacks[par1] = null; + return var3; + } + else + { + var3 = this.combinerItemStacks[par1].splitStack(par2); + + if (this.combinerItemStacks[par1].stackSize == 0) + { + this.combinerItemStacks[par1] = null; + } + + return var3; + } + } + else + { + return null; + } + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - + * like when you close a workbench GUI. + */ + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.combinerItemStacks[par1] != null) + { + ItemStack var2 = this.combinerItemStacks[par1]; + this.combinerItemStacks[par1] = null; + return var2; + } + else + { + return null; + } + } + + /** + * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). + */ + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.combinerItemStacks[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + } + + /** + * Returns the name of the inventory. + */ + public String getInvName() + { + return "container.combiner"; + } + + /** + * Reads a tile entity from NBT. + */ + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readFromNBT(par1NBTTagCompound); + NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); + this.combinerItemStacks = new ItemStack[this.getSizeInventory()]; + + for (int var3 = 0; var3 < var2.tagCount(); ++var3) + { + NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); + byte var5 = var4.getByte("Slot"); + + if (var5 >= 0 && var5 < this.combinerItemStacks.length) + { + this.combinerItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4); + } + } + + this.combinerBurnTime = par1NBTTagCompound.getShort("BurnTime"); + this.combinerCookTime = par1NBTTagCompound.getShort("CookTime"); + this.currentItemBurnTime = getItemBurnTime(this.combinerItemStacks[1]); + } + + /** + * Writes a tile entity to NBT. + */ + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeToNBT(par1NBTTagCompound); + par1NBTTagCompound.setShort("BurnTime", (short)this.combinerBurnTime); + par1NBTTagCompound.setShort("CookTime", (short)this.combinerCookTime); + NBTTagList var2 = new NBTTagList(); + + for (int var3 = 0; var3 < this.combinerItemStacks.length; ++var3) + { + if (this.combinerItemStacks[var3] != null) + { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte)var3); + this.combinerItemStacks[var3].writeToNBT(var4); + var2.appendTag(var4); + } + } + + par1NBTTagCompound.setTag("Items", var2); + } + + /** + * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't + * this more of a set than a get?* + */ + public int getInventoryStackLimit() + { + return 64; + } + + /** + * Returns an integer between 0 and the passed value representing how close the current item is to being completely + * cooked + */ + public int getCookProgressScaled(int par1) + { + return this.combinerCookTime * par1 / 200; + } + + /** + * Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel + * item, where 0 means that the item is exhausted and the passed value means that the item is fresh + */ + public int getBurnTimeRemainingScaled(int par1) + { + if (this.currentItemBurnTime == 0) + { + this.currentItemBurnTime = 200; + } + + return this.combinerBurnTime * par1 / this.currentItemBurnTime; + } + + /** + * Returns true if the furnace is currently burning + */ + public boolean isBurning() + { + return this.combinerBurnTime > 0; + } + + /** + * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count + * ticks and creates a new spawn inside its implementation. + */ + public void updateEntity() + { + boolean var1 = this.combinerBurnTime > 0; + boolean var2 = false; + + if (this.combinerBurnTime > 0) + { + --this.combinerBurnTime; + } + + if (!this.worldObj.isRemote) + { + if (this.combinerBurnTime == 0 && this.canSmelt()) + { + this.currentItemBurnTime = this.combinerBurnTime = getItemBurnTime(this.combinerItemStacks[1]); + + if (this.combinerBurnTime > 0) + { + var2 = true; + + if (this.combinerItemStacks[1] != null) + { + --this.combinerItemStacks[1].stackSize; + + if (this.combinerItemStacks[1].stackSize == 0) + { + this.combinerItemStacks[1] = null; + } + } + } + } + + if (this.isBurning() && this.canSmelt()) + { + ++this.combinerCookTime; + + if (this.combinerCookTime == 200) + { + this.combinerCookTime = 0; + this.smeltItem(); + var2 = true; + } + } + else + { + this.combinerCookTime = 0; + } + + if (var1 != this.combinerBurnTime > 0) + { + var2 = true; + BlockCombiner.updateCombinerBlockState(this.combinerBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); + } + } + + if (var2) + { + this.onInventoryChanged(); + } + } + + /** + * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc. + */ + private boolean canSmelt() + { + if (this.combinerItemStacks[0] == null) + { + return false; + } + else + { + ItemStack var1 = CombinerRecipes.smelting().getSmeltingResult(this.combinerItemStacks[0]); + if (var1 == null) return false; + if (this.combinerItemStacks[2] == null) return true; + if (!this.combinerItemStacks[2].isItemEqual(var1)) return false; + int result = combinerItemStacks[2].stackSize + var1.stackSize; + return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize()); + } + } + + /** + * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack + */ + public void smeltItem() + { + if (this.canSmelt()) + { + ItemStack var1 = CombinerRecipes.smelting().getSmeltingResult(this.combinerItemStacks[0]); + + if (this.combinerItemStacks[2] == null) + { + this.combinerItemStacks[2] = var1.copy(); + } + else if (this.combinerItemStacks[2].isItemEqual(var1)) + { + //========================================================== + //Adding extra importance here, so this really small bug + //fix stops slipping through the cracks. + // + //Makes it so that items that result in multiple items are + //smelted correctly each time. + // + // + // + this.combinerItemStacks[2].stackSize += var1.stackSize; + //========================================================== + } + + --this.combinerItemStacks[0].stackSize; + + if (this.combinerItemStacks[0].stackSize <= 0) + { + this.combinerItemStacks[0] = null; + } + } + } + + /** + * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't + * fuel + */ + public static int getItemBurnTime(ItemStack par1ItemStack) + { + if (par1ItemStack == null) + { + return 0; + } + else + { + int var1 = par1ItemStack.getItem().shiftedIndex; + if (par1ItemStack.getItem() instanceof ItemBlock && var1 == Block.cobblestone.blockID) return 200; + } + return 0; + } + + /** + * Return true if item is a fuel source (getItemBurnTime() > 0). + */ + public static boolean isItemFuel(ItemStack par0ItemStack) + { + return getItemBurnTime(par0ItemStack) > 0; + } + + /** + * Do not make give this method the name canInteractWith because it clashes with Container + */ + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + public void openChest() {} + + public void closeChest() {} + + @Override + public int getStartInventorySide(ForgeDirection side) + { + if (side == ForgeDirection.DOWN) return 1; + if (side == ForgeDirection.UP) return 0; + return 2; + } + + @Override + public int getSizeInventorySide(ForgeDirection side) + { + return 1; + } +} diff --git a/src/common/net/uberkat/obsidian/common/TileEntityCrusher.java b/src/common/net/uberkat/obsidian/common/TileEntityCrusher.java new file mode 100644 index 000000000..9f89e3739 --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/TileEntityCrusher.java @@ -0,0 +1,380 @@ +package net.uberkat.obsidian.common; + +import cpw.mods.fml.common.FMLCommonHandler; + +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.ISidedInventory; +import net.minecraft.src.*; + +public class TileEntityCrusher extends TileEntity implements IInventory, ISidedInventory +{ + /** + * The ItemStacks that hold the items currently being used in the furnace + */ + private ItemStack[] crusherItemStacks = new ItemStack[3]; + + /** The number of ticks that the furnace will keep burning */ + public int crusherBurnTime = 0; + + /** + * The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for + */ + public int currentItemBurnTime = 0; + + /** The number of ticks that the current item has been cooking for */ + public int crusherCookTime = 0; + + /** + * Returns the number of slots in the inventory. + */ + public int getSizeInventory() + { + return this.crusherItemStacks.length; + } + + /** + * Returns the stack in slot i + */ + public ItemStack getStackInSlot(int par1) + { + return this.crusherItemStacks[par1]; + } + + /** + * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new + * stack. + */ + public ItemStack decrStackSize(int par1, int par2) + { + if (this.crusherItemStacks[par1] != null) + { + ItemStack var3; + + if (this.crusherItemStacks[par1].stackSize <= par2) + { + var3 = this.crusherItemStacks[par1]; + this.crusherItemStacks[par1] = null; + return var3; + } + else + { + var3 = this.crusherItemStacks[par1].splitStack(par2); + + if (this.crusherItemStacks[par1].stackSize == 0) + { + this.crusherItemStacks[par1] = null; + } + + return var3; + } + } + else + { + return null; + } + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - + * like when you close a workbench GUI. + */ + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.crusherItemStacks[par1] != null) + { + ItemStack var2 = this.crusherItemStacks[par1]; + this.crusherItemStacks[par1] = null; + return var2; + } + else + { + return null; + } + } + + /** + * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). + */ + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.crusherItemStacks[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + } + + /** + * Returns the name of the inventory. + */ + public String getInvName() + { + return "container.crusher"; + } + + /** + * Reads a tile entity from NBT. + */ + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readFromNBT(par1NBTTagCompound); + NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); + this.crusherItemStacks = new ItemStack[this.getSizeInventory()]; + + for (int var3 = 0; var3 < var2.tagCount(); ++var3) + { + NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); + byte var5 = var4.getByte("Slot"); + + if (var5 >= 0 && var5 < this.crusherItemStacks.length) + { + this.crusherItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4); + } + } + + this.crusherBurnTime = par1NBTTagCompound.getShort("BurnTime"); + this.crusherCookTime = par1NBTTagCompound.getShort("CookTime"); + this.currentItemBurnTime = getItemBurnTime(this.crusherItemStacks[1]); + } + + /** + * Writes a tile entity to NBT. + */ + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeToNBT(par1NBTTagCompound); + par1NBTTagCompound.setShort("BurnTime", (short)this.crusherBurnTime); + par1NBTTagCompound.setShort("CookTime", (short)this.crusherCookTime); + NBTTagList var2 = new NBTTagList(); + + for (int var3 = 0; var3 < this.crusherItemStacks.length; ++var3) + { + if (this.crusherItemStacks[var3] != null) + { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte)var3); + this.crusherItemStacks[var3].writeToNBT(var4); + var2.appendTag(var4); + } + } + + par1NBTTagCompound.setTag("Items", var2); + } + + /** + * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't + * this more of a set than a get?* + */ + public int getInventoryStackLimit() + { + return 64; + } + + /** + * Returns an integer between 0 and the passed value representing how close the current item is to being completely + * cooked + */ + public int getCookProgressScaled(int par1) + { + return this.crusherCookTime * par1 / 200; + } + + /** + * Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel + * item, where 0 means that the item is exhausted and the passed value means that the item is fresh + */ + public int getBurnTimeRemainingScaled(int par1) + { + if (this.currentItemBurnTime == 0) + { + this.currentItemBurnTime = 200; + } + + return this.crusherBurnTime * par1 / this.currentItemBurnTime; + } + + /** + * Returns true if the furnace is currently burning + */ + public boolean isBurning() + { + return this.crusherBurnTime > 0; + } + + /** + * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count + * ticks and creates a new spawn inside its implementation. + */ + public void updateEntity() + { + boolean var1 = this.crusherBurnTime > 0; + boolean var2 = false; + + if (this.crusherBurnTime > 0) + { + --this.crusherBurnTime; + } + + if (!this.worldObj.isRemote) + { + if (this.crusherBurnTime == 0 && this.canSmelt()) + { + this.currentItemBurnTime = this.crusherBurnTime = getItemBurnTime(this.crusherItemStacks[1]); + + if (this.crusherBurnTime > 0) + { + var2 = true; + + if (this.crusherItemStacks[1] != null) + { + --this.crusherItemStacks[1].stackSize; + + if (this.crusherItemStacks[1].stackSize == 0) + { + this.crusherItemStacks[1] = null; + } + } + } + } + + if (this.isBurning() && this.canSmelt()) + { + ++this.crusherCookTime; + + if (this.crusherCookTime == 200) + { + this.crusherCookTime = 0; + this.smeltItem(); + var2 = true; + } + } + else + { + this.crusherCookTime = 0; + } + + if (var1 != this.crusherBurnTime > 0) + { + var2 = true; + BlockCrusher.updateCrusherBlockState(this.crusherBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); + } + } + + if (var2) + { + this.onInventoryChanged(); + } + } + + /** + * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc. + */ + private boolean canSmelt() + { + if (this.crusherItemStacks[0] == null) + { + return false; + } + else + { + ItemStack var1 = CrusherRecipes.smelting().getSmeltingResult(this.crusherItemStacks[0]); + if (var1 == null) return false; + if (this.crusherItemStacks[2] == null) return true; + if (!this.crusherItemStacks[2].isItemEqual(var1)) return false; + int result = crusherItemStacks[2].stackSize + var1.stackSize; + return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize()); + } + } + + /** + * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack + */ + public void smeltItem() + { + if (this.canSmelt()) + { + ItemStack var1 = CrusherRecipes.smelting().getSmeltingResult(this.crusherItemStacks[0]); + + if (this.crusherItemStacks[2] == null) + { + this.crusherItemStacks[2] = var1.copy(); + } + else if (this.crusherItemStacks[2].isItemEqual(var1)) + { + //========================================================== + //Adding extra importance here, so this really small bug + //fix stops slipping through the cracks. + // + //Makes it so that items that result in multiple items are + //smelted correctly each time. + // + // + // + this.crusherItemStacks[2].stackSize += var1.stackSize; + //========================================================== + } + + --this.crusherItemStacks[0].stackSize; + + if (this.crusherItemStacks[0].stackSize <= 0) + { + this.crusherItemStacks[0] = null; + } + } + } + + /** + * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't + * fuel + */ + public static int getItemBurnTime(ItemStack par1ItemStack) + { + if (par1ItemStack == null) + { + return 0; + } + else + { + int var1 = par1ItemStack.getItem().shiftedIndex; + if (var1 == Item.redstone.shiftedIndex) return 600; + if (var1 == ObsidianIngots.RedstoneIngot.shiftedIndex) + if (par1ItemStack.getItem() instanceof ItemBlock && var1 == ObsidianIngots.RedstoneBlock.blockID) return 5400; + } + return 0; + } + + /** + * Return true if item is a fuel source (getItemBurnTime() > 0). + */ + public static boolean isItemFuel(ItemStack par0ItemStack) + { + return getItemBurnTime(par0ItemStack) > 0; + } + + /** + * Do not make give this method the name canInteractWith because it clashes with Container + */ + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + public void openChest() {} + + public void closeChest() {} + + @Override + public int getStartInventorySide(ForgeDirection side) + { + if (side == ForgeDirection.DOWN) return 1; + if (side == ForgeDirection.UP) return 0; + return 2; + } + + @Override + public int getSizeInventorySide(ForgeDirection side) + { + return 1; + } +} diff --git a/src/common/net/uberkat/obsidian/common/TileEntityEnrichmentChamber.java b/src/common/net/uberkat/obsidian/common/TileEntityEnrichmentChamber.java new file mode 100644 index 000000000..1e1a756ae --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/TileEntityEnrichmentChamber.java @@ -0,0 +1,378 @@ +package net.uberkat.obsidian.common; + +import cpw.mods.fml.common.FMLCommonHandler; + +import net.minecraftforge.common.ISidedInventory; +import net.minecraftforge.common.ForgeDirection; +import net.minecraft.src.*; + +public class TileEntityEnrichmentChamber extends TileEntity implements IInventory, ISidedInventory +{ + /** + * The ItemStacks that hold the items currently being used in the furnace + */ + private ItemStack[] chamberItemStacks = new ItemStack[3]; + + /** The number of ticks that the furnace will keep burning */ + public int chamberBurnTime = 0; + + /** + * The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for + */ + public int currentItemBurnTime = 0; + + /** The number of ticks that the current item has been cooking for */ + public int chamberCookTime = 0; + + /** + * Returns the number of slots in the inventory. + */ + public int getSizeInventory() + { + return this.chamberItemStacks.length; + } + + /** + * Returns the stack in slot i + */ + public ItemStack getStackInSlot(int par1) + { + return this.chamberItemStacks[par1]; + } + + /** + * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new + * stack. + */ + public ItemStack decrStackSize(int par1, int par2) + { + if (this.chamberItemStacks[par1] != null) + { + ItemStack var3; + + if (this.chamberItemStacks[par1].stackSize <= par2) + { + var3 = this.chamberItemStacks[par1]; + this.chamberItemStacks[par1] = null; + return var3; + } + else + { + var3 = this.chamberItemStacks[par1].splitStack(par2); + + if (this.chamberItemStacks[par1].stackSize == 0) + { + this.chamberItemStacks[par1] = null; + } + + return var3; + } + } + else + { + return null; + } + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - + * like when you close a workbench GUI. + */ + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.chamberItemStacks[par1] != null) + { + ItemStack var2 = this.chamberItemStacks[par1]; + this.chamberItemStacks[par1] = null; + return var2; + } + else + { + return null; + } + } + + /** + * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). + */ + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.chamberItemStacks[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + } + + /** + * Returns the name of the inventory. + */ + public String getInvName() + { + return "container.chamber"; + } + + /** + * Reads a tile entity from NBT. + */ + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readFromNBT(par1NBTTagCompound); + NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); + this.chamberItemStacks = new ItemStack[this.getSizeInventory()]; + + for (int var3 = 0; var3 < var2.tagCount(); ++var3) + { + NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); + byte var5 = var4.getByte("Slot"); + + if (var5 >= 0 && var5 < this.chamberItemStacks.length) + { + this.chamberItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4); + } + } + + this.chamberBurnTime = par1NBTTagCompound.getShort("BurnTime"); + this.chamberCookTime = par1NBTTagCompound.getShort("CookTime"); + this.currentItemBurnTime = getItemBurnTime(this.chamberItemStacks[1]); + } + + /** + * Writes a tile entity to NBT. + */ + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeToNBT(par1NBTTagCompound); + par1NBTTagCompound.setShort("BurnTime", (short)this.chamberBurnTime); + par1NBTTagCompound.setShort("CookTime", (short)this.chamberCookTime); + NBTTagList var2 = new NBTTagList(); + + for (int var3 = 0; var3 < this.chamberItemStacks.length; ++var3) + { + if (this.chamberItemStacks[var3] != null) + { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte)var3); + this.chamberItemStacks[var3].writeToNBT(var4); + var2.appendTag(var4); + } + } + + par1NBTTagCompound.setTag("Items", var2); + } + + /** + * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't + * this more of a set than a get?* + */ + public int getInventoryStackLimit() + { + return 64; + } + + /** + * Returns an integer between 0 and the passed value representing how close the current item is to being completely + * cooked + */ + public int getCookProgressScaled(int par1) + { + return this.chamberCookTime * par1 / 200; + } + + /** + * Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel + * item, where 0 means that the item is exhausted and the passed value means that the item is fresh + */ + public int getBurnTimeRemainingScaled(int par1) + { + if (this.currentItemBurnTime == 0) + { + this.currentItemBurnTime = 200; + } + + return this.chamberBurnTime * par1 / this.currentItemBurnTime; + } + + /** + * Returns true if the furnace is currently burning + */ + public boolean isBurning() + { + return this.chamberBurnTime > 0; + } + + /** + * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count + * ticks and creates a new spawn inside its implementation. + */ + public void updateEntity() + { + boolean var1 = this.chamberBurnTime > 0; + boolean var2 = false; + + if (this.chamberBurnTime > 0) + { + --this.chamberBurnTime; + } + + if (!this.worldObj.isRemote) + { + if (this.chamberBurnTime == 0 && this.canSmelt()) + { + this.currentItemBurnTime = this.chamberBurnTime = getItemBurnTime(this.chamberItemStacks[1]); + + if (this.chamberBurnTime > 0) + { + var2 = true; + + if (this.chamberItemStacks[1] != null) + { + --this.chamberItemStacks[1].stackSize; + + if (this.chamberItemStacks[1].stackSize == 0) + { + this.chamberItemStacks[1] = null; + } + } + } + } + + if (this.isBurning() && this.canSmelt()) + { + ++this.chamberCookTime; + + if (this.chamberCookTime == 200) + { + this.chamberCookTime = 0; + this.smeltItem(); + var2 = true; + } + } + else + { + this.chamberCookTime = 0; + } + + if (var1 != this.chamberBurnTime > 0) + { + var2 = true; + BlockEnrichmentChamber.updateChamberBlockState(this.chamberBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); + } + } + + if (var2) + { + this.onInventoryChanged(); + } + } + + /** + * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc. + */ + private boolean canSmelt() + { + if (this.chamberItemStacks[0] == null) + { + return false; + } + else + { + ItemStack var1 = EnrichmentChamberRecipes.smelting().getSmeltingResult(this.chamberItemStacks[0]); + if (var1 == null) return false; + if (this.chamberItemStacks[2] == null) return true; + if (!this.chamberItemStacks[2].isItemEqual(var1)) return false; + int result = chamberItemStacks[2].stackSize + var1.stackSize; + return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize()); + } + } + + /** + * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack + */ + public void smeltItem() + { + if (this.canSmelt()) + { + ItemStack var1 = EnrichmentChamberRecipes.smelting().getSmeltingResult(this.chamberItemStacks[0]); + + if (this.chamberItemStacks[2] == null) + { + this.chamberItemStacks[2] = var1.copy(); + } + else if (this.chamberItemStacks[2].isItemEqual(var1)) + { + //========================================================== + //Adding extra importance here, so this really small bug + //fix stops slipping through the cracks. + // + //Makes it so that items that result in multiple items are + //smelted correctly each time. + // + // + // + this.chamberItemStacks[2].stackSize += var1.stackSize; + //========================================================== + } + + --this.chamberItemStacks[0].stackSize; + + if (this.chamberItemStacks[0].stackSize <= 0) + { + this.chamberItemStacks[0] = null; + } + } + } + + /** + * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't + * fuel + */ + public static int getItemBurnTime(ItemStack par1ItemStack) + { + if (par1ItemStack == null) + { + return 0; + } + else + { + int var1 = par1ItemStack.getItem().shiftedIndex; + if (var1 == Item.redstone.shiftedIndex) return 600; + } + return 0; + } + + /** + * Return true if item is a fuel source (getItemBurnTime() > 0). + */ + public static boolean isItemFuel(ItemStack par0ItemStack) + { + return getItemBurnTime(par0ItemStack) > 0; + } + + /** + * Do not make give this method the name canInteractWith because it clashes with Container + */ + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + public void openChest() {} + + public void closeChest() {} + + @Override + public int getStartInventorySide(ForgeDirection side) + { + if (side == ForgeDirection.DOWN) return 1; + if (side == ForgeDirection.UP) return 0; + return 2; + } + + @Override + public int getSizeInventorySide(ForgeDirection side) + { + return 1; + } +} diff --git a/src/common/net/uberkat/obsidian/common/TileEntityPlatinumCompressor.java b/src/common/net/uberkat/obsidian/common/TileEntityPlatinumCompressor.java new file mode 100644 index 000000000..a49cf461a --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/TileEntityPlatinumCompressor.java @@ -0,0 +1,379 @@ +package net.uberkat.obsidian.common; + +import cpw.mods.fml.common.FMLCommonHandler; + +import net.minecraft.src.*; +import net.minecraftforge.common.ISidedInventory; +import net.minecraftforge.common.ForgeDirection; + +public class TileEntityPlatinumCompressor extends TileEntity implements IInventory, ISidedInventory +{ + /** + * The ItemStacks that hold the items currently being used in the furnace + */ + private ItemStack[] compressorItemStacks = new ItemStack[3]; + + /** The number of ticks that the furnace will keep burning */ + public int compressorBurnTime = 0; + + /** + * The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for + */ + public int currentItemBurnTime = 0; + + /** The number of ticks that the current item has been cooking for */ + public int compressorCookTime = 0; + + /** + * Returns the number of slots in the inventory. + */ + public int getSizeInventory() + { + return this.compressorItemStacks.length; + } + + /** + * Returns the stack in slot i + */ + public ItemStack getStackInSlot(int par1) + { + return this.compressorItemStacks[par1]; + } + + /** + * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new + * stack. + */ + public ItemStack decrStackSize(int par1, int par2) + { + if (this.compressorItemStacks[par1] != null) + { + ItemStack var3; + + if (this.compressorItemStacks[par1].stackSize <= par2) + { + var3 = this.compressorItemStacks[par1]; + this.compressorItemStacks[par1] = null; + return var3; + } + else + { + var3 = this.compressorItemStacks[par1].splitStack(par2); + + if (this.compressorItemStacks[par1].stackSize == 0) + { + this.compressorItemStacks[par1] = null; + } + + return var3; + } + } + else + { + return null; + } + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - + * like when you close a workbench GUI. + */ + public ItemStack getStackInSlotOnClosing(int par1) + { + if (this.compressorItemStacks[par1] != null) + { + ItemStack var2 = this.compressorItemStacks[par1]; + this.compressorItemStacks[par1] = null; + return var2; + } + else + { + return null; + } + } + + /** + * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). + */ + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) + { + this.compressorItemStacks[par1] = par2ItemStack; + + if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) + { + par2ItemStack.stackSize = this.getInventoryStackLimit(); + } + } + + /** + * Returns the name of the inventory. + */ + public String getInvName() + { + return "container.compressor"; + } + + /** + * Reads a tile entity from NBT. + */ + public void readFromNBT(NBTTagCompound par1NBTTagCompound) + { + super.readFromNBT(par1NBTTagCompound); + NBTTagList var2 = par1NBTTagCompound.getTagList("Items"); + this.compressorItemStacks = new ItemStack[this.getSizeInventory()]; + + for (int var3 = 0; var3 < var2.tagCount(); ++var3) + { + NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3); + byte var5 = var4.getByte("Slot"); + + if (var5 >= 0 && var5 < this.compressorItemStacks.length) + { + this.compressorItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4); + } + } + + this.compressorBurnTime = par1NBTTagCompound.getShort("BurnTime"); + this.compressorCookTime = par1NBTTagCompound.getShort("CookTime"); + this.currentItemBurnTime = getItemBurnTime(this.compressorItemStacks[1]); + } + + /** + * Writes a tile entity to NBT. + */ + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeToNBT(par1NBTTagCompound); + par1NBTTagCompound.setShort("BurnTime", (short)this.compressorBurnTime); + par1NBTTagCompound.setShort("CookTime", (short)this.compressorCookTime); + NBTTagList var2 = new NBTTagList(); + + for (int var3 = 0; var3 < this.compressorItemStacks.length; ++var3) + { + if (this.compressorItemStacks[var3] != null) + { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte)var3); + this.compressorItemStacks[var3].writeToNBT(var4); + var2.appendTag(var4); + } + } + + par1NBTTagCompound.setTag("Items", var2); + } + + /** + * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't + * this more of a set than a get?* + */ + public int getInventoryStackLimit() + { + return 64; + } + + /** + * Returns an integer between 0 and the passed value representing how close the current item is to being completely + * cooked + */ + public int getCookProgressScaled(int par1) + { + return this.compressorCookTime * par1 / 200; + } + + /** + * Returns an integer between 0 and the passed value representing how much burn time is left on the current fuel + * item, where 0 means that the item is exhausted and the passed value means that the item is fresh + */ + public int getBurnTimeRemainingScaled(int par1) + { + if (this.currentItemBurnTime == 0) + { + this.currentItemBurnTime = 200; + } + + return this.compressorBurnTime * par1 / this.currentItemBurnTime; + } + + /** + * Returns true if the furnace is currently burning + */ + public boolean isBurning() + { + return this.compressorBurnTime > 0; + } + + /** + * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count + * ticks and creates a new spawn inside its implementation. + */ + public void updateEntity() + { + boolean var1 = this.compressorBurnTime > 0; + boolean var2 = false; + + if (this.compressorBurnTime > 0) + { + --this.compressorBurnTime; + } + + if (!this.worldObj.isRemote) + { + if (this.compressorBurnTime == 0 && this.canSmelt()) + { + this.currentItemBurnTime = this.compressorBurnTime = getItemBurnTime(this.compressorItemStacks[1]); + + if (this.compressorBurnTime > 0) + { + var2 = true; + + if (this.compressorItemStacks[1] != null) + { + --this.compressorItemStacks[1].stackSize; + + if (this.compressorItemStacks[1].stackSize == 0) + { + this.compressorItemStacks[1] = null; + } + } + } + } + + if (this.isBurning() && this.canSmelt()) + { + ++this.compressorCookTime; + + if (this.compressorCookTime == 200) + { + this.compressorCookTime = 0; + this.smeltItem(); + var2 = true; + } + } + else + { + this.compressorCookTime = 0; + } + + if (var1 != this.compressorBurnTime > 0) + { + var2 = true; + BlockPlatinumCompressor.updateCompressorBlockState(this.compressorBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); + } + } + + if (var2) + { + this.onInventoryChanged(); + } + } + + /** + * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc. + */ + private boolean canSmelt() + { + if (this.compressorItemStacks[0] == null) + { + return false; + } + else + { + ItemStack var1 = PlatinumCompressorRecipes.smelting().getSmeltingResult(this.compressorItemStacks[0]); + if (var1 == null) return false; + if (this.compressorItemStacks[2] == null) return true; + if (!this.compressorItemStacks[2].isItemEqual(var1)) return false; + int result = compressorItemStacks[2].stackSize + var1.stackSize; + return (result <= getInventoryStackLimit() && result <= var1.getMaxStackSize()); + } + } + + /** + * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack + */ + public void smeltItem() + { + if (this.canSmelt()) + { + ItemStack var1 = PlatinumCompressorRecipes.smelting().getSmeltingResult(this.compressorItemStacks[0]); + + if (this.compressorItemStacks[2] == null) + { + this.compressorItemStacks[2] = var1.copy(); + } + else if (this.compressorItemStacks[2].isItemEqual(var1)) + { + //========================================================== + //Adding extra importance here, so this really small bug + //fix stops slipping through the cracks. + // + //Makes it so that items that result in multiple items are + //smelted correctly each time. + // + // + // + this.compressorItemStacks[2].stackSize += var1.stackSize; + //========================================================== + } + + --this.compressorItemStacks[0].stackSize; + + if (this.compressorItemStacks[0].stackSize <= 0) + { + this.compressorItemStacks[0] = null; + } + } + } + + /** + * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't + * fuel + */ + public static int getItemBurnTime(ItemStack par1ItemStack) + { + if (par1ItemStack == null) + { + return 0; + } + else + { + int var1 = par1ItemStack.getItem().shiftedIndex; + if (var1 == ObsidianIngots.PlatinumIngot.shiftedIndex) return 200; + if (par1ItemStack.getItem() instanceof ItemBlock && var1 == ObsidianIngots.PlatinumBlock.blockID) return 1800; + } + return 0; + } + + /** + * Return true if item is a fuel source (getItemBurnTime() > 0). + */ + public static boolean isItemFuel(ItemStack par0ItemStack) + { + return getItemBurnTime(par0ItemStack) > 0; + } + + /** + * Do not make give this method the name canInteractWith because it clashes with Container + */ + public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) + { + return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; + } + + public void openChest() {} + + public void closeChest() {} + + @Override + public int getStartInventorySide(ForgeDirection side) + { + if (side == ForgeDirection.DOWN) return 1; + if (side == ForgeDirection.UP) return 0; + return 2; + } + + @Override + public int getSizeInventorySide(ForgeDirection side) + { + return 1; + } +} diff --git a/src/common/net/uberkat/obsidian/common/Version.java b/src/common/net/uberkat/obsidian/common/Version.java new file mode 100644 index 000000000..f905f6d9e --- /dev/null +++ b/src/common/net/uberkat/obsidian/common/Version.java @@ -0,0 +1,41 @@ +package net.uberkat.obsidian.common; + +public class Version { + + public int major; + public int minor; + public int build; + + public Version(int majorNum, int minorNum, int buildNum) + { + major = majorNum; + minor = minorNum; + build = buildNum; + } + + public void reset() + { + major = 0; + minor = 0; + build = 0; + } + + public String toString() + { + if(major == 0 && minor == 0 && build == 0) + { + return ""; + } + else if(major != 0 && minor != 0 && build == 0) + { + return major + "." + minor; + } + else if(major != 0 && minor == 0 && build == 0) + { + return major + "." + minor; + } + else { + return major + "." + minor + "." + build; + } + } +} diff --git a/src/minecraft/net/uberkat/obsidian/client/ClientProxy.java b/src/minecraft/net/uberkat/obsidian/client/ClientProxy.java new file mode 100644 index 000000000..477b0e667 --- /dev/null +++ b/src/minecraft/net/uberkat/obsidian/client/ClientProxy.java @@ -0,0 +1,152 @@ +package net.uberkat.obsidian.client; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.Side; +import cpw.mods.fml.common.network.IGuiHandler; +import cpw.mods.fml.common.registry.TickRegistry; +import net.minecraft.client.Minecraft; +import net.minecraft.src.Block; +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.GuiScreen; +import net.minecraft.src.IBlockAccess; +import net.minecraft.src.ModLoader; +import net.minecraft.src.RenderBlocks; +import net.minecraft.src.World; +import net.minecraftforge.client.MinecraftForgeClient; +import net.uberkat.obsidian.common.CommonProxy; +import net.uberkat.obsidian.common.EntityKnife; +import net.uberkat.obsidian.common.EntityObsidianArrow; +import net.uberkat.obsidian.common.EntityObsidianTNT; +import net.uberkat.obsidian.common.ObsidianIngots; +import net.uberkat.obsidian.common.ObsidianUtils; +import net.uberkat.obsidian.common.TileEntityCombiner; +import net.uberkat.obsidian.common.TileEntityCrusher; +import net.uberkat.obsidian.common.TileEntityEnrichmentChamber; +import net.uberkat.obsidian.common.TileEntityPlatinumCompressor; + +/** + * Client proxy for Obsidian Ingots mod. + * @author AidanBrady + * + */ +public class ClientProxy extends CommonProxy +{ + @Override + public void registerRenderInformation() + { + System.out.println("[ObsidianIngots] Beginning render initiative..."); + //Preload block/item textures + MinecraftForgeClient.preloadTexture("/obsidian/items.png"); + MinecraftForgeClient.preloadTexture("/obsidian/terrain.png"); + MinecraftForgeClient.preloadTexture("/obsidian/Compressor.png"); + MinecraftForgeClient.preloadTexture("/obsidian/Combiner.png"); + + //Register entity rendering handlers + RenderingRegistry.registerEntityRenderingHandler(EntityObsidianTNT.class, new RenderObsidianTNT()); + RenderingRegistry.registerEntityRenderingHandler(EntityObsidianArrow.class, new RenderObsidianArrow()); + RenderingRegistry.registerEntityRenderingHandler(EntityKnife.class, new RenderKnife()); + System.out.println("[ObsidianIngots] Render initiative complete."); + } + + public void setProperties() + { + Properties properties = new Properties(); + try + { + File config = new File(new StringBuilder().append(Minecraft.getMinecraftDir()).append("/config/ObsidianIngots.txt").toString()); + if(config.exists()) + { + properties.load(new FileInputStream(config)); + ObsidianIngots.platinumOreID = Integer.parseInt(properties.getProperty("platinumOreID")); + ObsidianIngots.platinumBlockID = Integer.parseInt(properties.getProperty("platinumBlockID")); + ObsidianIngots.redstoneBlockID = Integer.parseInt(properties.getProperty("redstoneBlockID")); + ObsidianIngots.obsidianTNTID = Integer.parseInt(properties.getProperty("obsidianTNTID")); + ObsidianIngots.refinedObsidianID = Integer.parseInt(properties.getProperty("refinedObsidianID")); + ObsidianIngots.lifeBlockID = Integer.parseInt(properties.getProperty("lifeBlockID")); + ObsidianIngots.enrichmentChamberID = Integer.parseInt(properties.getProperty("enrichmentChamberID")); + ObsidianIngots.platinumCompressorID = Integer.parseInt(properties.getProperty("platinumCompressorID")); + ObsidianIngots.combinerID = Integer.parseInt(properties.getProperty("combinerID")); + ObsidianIngots.crusherID = Integer.parseInt(properties.getProperty("crusherID")); + ObsidianIngots.coalBlockID = Integer.parseInt(properties.getProperty("coalBlockID")); + ObsidianIngots.refinedGlowstoneID = Integer.parseInt(properties.getProperty("refinedGlowstoneID")); + ObsidianIngots.extrasEnabled = Boolean.parseBoolean(properties.getProperty("extrasEnabled")); + ObsidianIngots.oreGenerationEnabled = Boolean.parseBoolean(properties.getProperty("oreGenerationEnabled")); + ObsidianIngots.logger.info("[ObsidianIngots] Data loaded."); + } + else { + config.createNewFile(); + ObsidianIngots.logger.info("[ObsidianIngots] Created 'ObsidianIngots.txt' configuration file."); + FileOutputStream fileoutputstream = new FileOutputStream(config); + properties.setProperty("platinumOreID", Integer.toString(200)); + properties.setProperty("platinumBlockID", Integer.toString(201)); + properties.setProperty("redstoneBlockID", Integer.toString(202)); + properties.setProperty("obsidianTNTID", Integer.toString(203)); + properties.setProperty("refinedObsidianID", Integer.toString(204)); + properties.setProperty("lifeBlockID", Integer.toString(205)); + properties.setProperty("enrichmentChamberID", Integer.toString(206)); + properties.setProperty("platinumCompressorID", Integer.toString(207)); + properties.setProperty("combinerID", Integer.toString(208)); + properties.setProperty("crusherID", Integer.toString(209)); + properties.setProperty("coalBlockID", Integer.toString(210)); + properties.setProperty("refinedGlowstoneID", Integer.toString(211)); + properties.setProperty("extrasEnabled", Boolean.toString(true)); + properties.setProperty("oreGenerationEnabled", Boolean.toString(true)); + properties.store(fileoutputstream, "Official Obsidian Ingots Configuration."); + fileoutputstream.close(); + } + + } catch (IOException ioexception) + { + System.err.println("[ObsidianIngots] An error occured while reading from configuration file."); + ioexception.printStackTrace(); + } + } + + public void loadUtilities() + { + System.out.println("[ObsidianIngots] Beginning utility initiative..."); + ObsidianIngots.latestVersionNumber = ObsidianUtils.getLatestVersion(); + ObsidianIngots.recentNews = ObsidianUtils.getRecentNews(); + ObsidianUtils.sendServerData(); + System.out.println("[ObsidianIngots] Utility initiative complete."); + } + + @Override + public GuiScreen getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) + { + switch(ID) + { + case 18: + return new GuiStopwatch(player); + case 19: + return new GuiCredits(); + case 20: + return new GuiWeatherOrb(player); + case 21: + TileEntityEnrichmentChamber tileentity = (TileEntityEnrichmentChamber)world.getBlockTileEntity(x, y, z); + return new GuiEnrichmentChamber(player.inventory, tileentity); + case 22: + TileEntityPlatinumCompressor tileentity1 = (TileEntityPlatinumCompressor)world.getBlockTileEntity(x, y, z); + return new GuiPlatinumCompressor(player.inventory, tileentity1); + case 23: + TileEntityCombiner tileentity2 = (TileEntityCombiner)world.getBlockTileEntity(x, y, z); + return new GuiCombiner(player.inventory, tileentity2); + case 24: + TileEntityCrusher tileentity3 = (TileEntityCrusher)world.getBlockTileEntity(x, y, z); + return new GuiCrusher(player.inventory, tileentity3); + } + return null; + } + + public void loadTickHandler() + { + TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT); + } +} diff --git a/src/minecraft/net/uberkat/obsidian/client/ClientTickHandler.java b/src/minecraft/net/uberkat/obsidian/client/ClientTickHandler.java new file mode 100644 index 000000000..1ac924ea2 --- /dev/null +++ b/src/minecraft/net/uberkat/obsidian/client/ClientTickHandler.java @@ -0,0 +1,38 @@ +package net.uberkat.obsidian.client; + +import java.util.EnumSet; + +import net.minecraft.src.ModLoader; +import net.minecraftforge.common.MinecraftForge; +import net.uberkat.obsidian.common.ObsidianIngots; +import net.uberkat.obsidian.common.ObsidianUtils; + +import cpw.mods.fml.common.ITickHandler; +import cpw.mods.fml.common.TickType; + +public class ClientTickHandler implements ITickHandler +{ + public void tickStart(EnumSet type, Object... tickData) + { + if(ObsidianIngots.ticksPassed == 0 && ModLoader.getMinecraftInstance().theWorld != null && ModLoader.getMinecraftInstance().thePlayer != null) + { + ObsidianUtils.checkForUpdates(ModLoader.getMinecraftInstance().thePlayer); + ObsidianIngots.ticksPassed++; + } + } + + public void tickEnd(EnumSet type, Object... tickData) + { + + } + + public EnumSet ticks() + { + return EnumSet.of(TickType.CLIENT, TickType.WORLDLOAD); + } + + public String getLabel() + { + return "ObsidianIngots"; + } +} diff --git a/src/minecraft/net/uberkat/obsidian/client/GuiCombiner.java b/src/minecraft/net/uberkat/obsidian/client/GuiCombiner.java new file mode 100644 index 000000000..970d5c717 --- /dev/null +++ b/src/minecraft/net/uberkat/obsidian/client/GuiCombiner.java @@ -0,0 +1,49 @@ +package net.uberkat.obsidian.client; + +import org.lwjgl.opengl.GL11; +import net.minecraft.src.*; +import net.uberkat.obsidian.common.ContainerCombiner; +import net.uberkat.obsidian.common.TileEntityCombiner; + +public class GuiCombiner extends GuiContainer +{ + private TileEntityCombiner combinerInventory; + + public GuiCombiner(InventoryPlayer par1InventoryPlayer, TileEntityCombiner par2TileEntityCombiner) + { + super(new ContainerCombiner(par1InventoryPlayer, par2TileEntityCombiner)); + combinerInventory = par2TileEntityCombiner; + } + + /** + * Draw the foreground layer for the GuiContainer (everythin in front of the items) + */ + protected void drawGuiContainerForegroundLayer() + { + fontRenderer.drawString("Combiner", 49, 6, 0x404040); + fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + } + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + int var4 = this.mc.renderEngine.getTexture("/gui/GuiCombiner.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(var4); + int var5 = (this.width - this.xSize) / 2; + int var6 = (this.height - this.ySize) / 2; + drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); + int var7; + + if (this.combinerInventory.isBurning()) + { + var7 = this.combinerInventory.getBurnTimeRemainingScaled(12); + this.drawTexturedModalRect(var5 + 56, var6 + 36 + 12 - var7, 176, 12 - var7, 14, var7 + 2); + } + + var7 = this.combinerInventory.getCookProgressScaled(24); + this.drawTexturedModalRect(var5 + 79, var6 + 34, 176, 14, var7 + 1, 16); + } +} diff --git a/src/minecraft/net/uberkat/obsidian/client/GuiCredits.java b/src/minecraft/net/uberkat/obsidian/client/GuiCredits.java new file mode 100644 index 000000000..8914ee476 --- /dev/null +++ b/src/minecraft/net/uberkat/obsidian/client/GuiCredits.java @@ -0,0 +1,76 @@ +package net.uberkat.obsidian.client; + +import java.io.IOException; +import java.net.URL; + +import org.lwjgl.Sys; + +import net.minecraft.src.*; +import net.uberkat.obsidian.common.ObsidianIngots; +import net.uberkat.obsidian.common.ObsidianUtils; + +public class GuiCredits extends GuiScreen { + + private static String updateProgress = ""; + + public void initGui() + { + controlList.clear(); + controlList.add(new GuiButton(2, width / 2 - 100, height / 4 + 72 + 12, "Update")); + controlList.add(new GuiButton(1, width / 2 - 100, height / 4 + 96 + 12, "Cancel")); + } + + public void onGuiClosed() + { + updateProgress = ""; + } + + public static void onFinishedDownloading() + { + updateProgress = "Successfully updated. Restart Minecraft to load."; + } + + public static void onErrorDownloading() + { + updateProgress = "Error updating."; + } + + protected void actionPerformed(GuiButton guibutton) + { + if(!guibutton.enabled) + { + return; + } + if(guibutton.id == 2) + { + if(!ObsidianUtils.isClientLatestVersion()) + { + updateProgress = "Downloading latest version..."; + guibutton.enabled = false; + new ThreadUpdate("http://dl.dropbox.com/u/90411166/Obsidian%20Ingots.zip"); + } + } + if(guibutton.id == 1) + { + mc.displayGuiScreen(null); + } + } + + public void writeText(String text, int yAxis) + { + drawString(fontRenderer, text, width / 2 - 140, (height / 4 - 60) + 20 + yAxis, 0xa0a0a0); + } + + public void drawScreen(int i, int j, float f) + { + drawDefaultBackground(); + drawCenteredString(fontRenderer, "Obsidian Ingots by aidancbrady", width / 2, (height / 4 - 60) + 20, 0xffffff); + drawString(fontRenderer, (new StringBuilder()).append("Your version: ").append(ObsidianUtils.isClientLatestVersion() ? ObsidianIngots.versionNumber.toString() : (ObsidianIngots.versionNumber.toString() + " -- OUTDATED")).toString(), width / 2 - 140, (height / 4 - 60) + 20 + 36, 0xa0a0a0); + drawString(fontRenderer, (new StringBuilder()).append("Newest version: ").append(ObsidianIngots.latestVersionNumber).toString(), width / 2 - 140, (height / 4 - 60) + 20 + 45, 0xa0a0a0); + writeText("*Developed on Mac OS X 10.8 Mountain Lion", 63); + writeText("*Code, textures, and ideas by aidancbrady", 72); + writeText("Recent news: " + ObsidianIngots.recentNews, 81); + writeText(updateProgress, 99); + super.drawScreen(i, j, f); + } +} diff --git a/src/minecraft/net/uberkat/obsidian/client/GuiCrusher.java b/src/minecraft/net/uberkat/obsidian/client/GuiCrusher.java new file mode 100644 index 000000000..4994dda24 --- /dev/null +++ b/src/minecraft/net/uberkat/obsidian/client/GuiCrusher.java @@ -0,0 +1,49 @@ +package net.uberkat.obsidian.client; + +import org.lwjgl.opengl.GL11; +import net.minecraft.src.*; +import net.uberkat.obsidian.common.ContainerCrusher; +import net.uberkat.obsidian.common.TileEntityCrusher; + +public class GuiCrusher extends GuiContainer +{ + private TileEntityCrusher crusherInventory; + + public GuiCrusher(InventoryPlayer par1InventoryPlayer, TileEntityCrusher par2TileEntityCrusher) + { + super(new ContainerCrusher(par1InventoryPlayer, par2TileEntityCrusher)); + crusherInventory = par2TileEntityCrusher; + } + + /** + * Draw the foreground layer for the GuiContainer (everythin in front of the items) + */ + protected void drawGuiContainerForegroundLayer() + { + fontRenderer.drawString("Crusher", 50, 6, 0x404040); + fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + } + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + int var4 = this.mc.renderEngine.getTexture("/gui/GuiCrusher.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(var4); + int var5 = (this.width - this.xSize) / 2; + int var6 = (this.height - this.ySize) / 2; + drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); + int var7; + + if (this.crusherInventory.isBurning()) + { + var7 = this.crusherInventory.getBurnTimeRemainingScaled(12); + this.drawTexturedModalRect(var5 + 56, var6 + 36 + 12 - var7, 176, 12 - var7, 14, var7 + 2); + } + + var7 = this.crusherInventory.getCookProgressScaled(24); + this.drawTexturedModalRect(var5 + 79, var6 + 34, 176, 14, var7 + 1, 16); + } +} diff --git a/src/minecraft/net/uberkat/obsidian/client/GuiEnrichmentChamber.java b/src/minecraft/net/uberkat/obsidian/client/GuiEnrichmentChamber.java new file mode 100644 index 000000000..58c44e94f --- /dev/null +++ b/src/minecraft/net/uberkat/obsidian/client/GuiEnrichmentChamber.java @@ -0,0 +1,49 @@ +package net.uberkat.obsidian.client; + +import org.lwjgl.opengl.GL11; +import net.minecraft.src.*; +import net.uberkat.obsidian.common.ContainerEnrichmentChamber; +import net.uberkat.obsidian.common.TileEntityEnrichmentChamber; + +public class GuiEnrichmentChamber extends GuiContainer +{ + private TileEntityEnrichmentChamber chamberInventory; + + public GuiEnrichmentChamber(InventoryPlayer par1InventoryPlayer, TileEntityEnrichmentChamber par2TileEntityEnrichmentChamber) + { + super(new ContainerEnrichmentChamber(par1InventoryPlayer, par2TileEntityEnrichmentChamber)); + chamberInventory = par2TileEntityEnrichmentChamber; + } + + /** + * Draw the foreground layer for the GuiContainer (everythin in front of the items) + */ + protected void drawGuiContainerForegroundLayer() + { + fontRenderer.drawString("Enrichment Chamber", 45, 6, 0x404040); + fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + } + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + int var4 = this.mc.renderEngine.getTexture("/gui/GuiChamber.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(var4); + int var5 = (this.width - this.xSize) / 2; + int var6 = (this.height - this.ySize) / 2; + drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); + int var7; + + if (this.chamberInventory.isBurning()) + { + var7 = this.chamberInventory.getBurnTimeRemainingScaled(12); + this.drawTexturedModalRect(var5 + 56, var6 + 36 + 12 - var7, 176, 12 - var7, 14, var7 + 2); + } + + var7 = this.chamberInventory.getCookProgressScaled(24); + this.drawTexturedModalRect(var5 + 79, var6 + 34, 176, 14, var7 + 1, 16); + } +} diff --git a/src/minecraft/net/uberkat/obsidian/client/GuiPlatinumCompressor.java b/src/minecraft/net/uberkat/obsidian/client/GuiPlatinumCompressor.java new file mode 100644 index 000000000..4d3dea6fb --- /dev/null +++ b/src/minecraft/net/uberkat/obsidian/client/GuiPlatinumCompressor.java @@ -0,0 +1,49 @@ +package net.uberkat.obsidian.client; + +import org.lwjgl.opengl.GL11; +import net.minecraft.src.*; +import net.uberkat.obsidian.common.ContainerPlatinumCompressor; +import net.uberkat.obsidian.common.TileEntityPlatinumCompressor; + +public class GuiPlatinumCompressor extends GuiContainer +{ + private TileEntityPlatinumCompressor compressorInventory; + + public GuiPlatinumCompressor(InventoryPlayer par1InventoryPlayer, TileEntityPlatinumCompressor par2TileEntityPlatinumCompressor) + { + super(new ContainerPlatinumCompressor(par1InventoryPlayer, par2TileEntityPlatinumCompressor)); + compressorInventory = par2TileEntityPlatinumCompressor; + } + + /** + * Draw the foreground layer for the GuiContainer (everythin in front of the items) + */ + protected void drawGuiContainerForegroundLayer() + { + fontRenderer.drawString("Platinum Compressor", 45, 6, 0x404040); + fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040); + } + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) + { + int var4 = this.mc.renderEngine.getTexture("/gui/GuiCompressor.png"); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture(var4); + int var5 = (this.width - this.xSize) / 2; + int var6 = (this.height - this.ySize) / 2; + drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); + int var7; + + if (this.compressorInventory.isBurning()) + { + var7 = this.compressorInventory.getBurnTimeRemainingScaled(12); + this.drawTexturedModalRect(var5 + 56, var6 + 36 + 12 - var7, 176, 12 - var7, 14, var7 + 2); + } + + var7 = this.compressorInventory.getCookProgressScaled(24); + this.drawTexturedModalRect(var5 + 79, var6 + 34, 176, 14, var7 + 1, 16); + } +} diff --git a/src/minecraft/net/uberkat/obsidian/client/GuiStopwatch.java b/src/minecraft/net/uberkat/obsidian/client/GuiStopwatch.java new file mode 100644 index 000000000..fbab1e762 --- /dev/null +++ b/src/minecraft/net/uberkat/obsidian/client/GuiStopwatch.java @@ -0,0 +1,140 @@ +package net.uberkat.obsidian.client; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.src.*; +import net.uberkat.obsidian.common.ObsidianUtils; + +public class GuiStopwatch extends GuiScreen { + + private static EntityPlayer player; + private int xSize = 176; + private int ySize = 166; + + public GuiStopwatch(EntityPlayer entityplayer) + { + player = entityplayer; + } + + public void initGui() + { + controlList.clear(); + controlList.add(new GuiButton(1, width / 2 - 80, height / 2 - 65, 50, 20, "Sunrise")); + controlList.add(new GuiButton(2, width / 2 - 80, height / 2 - 35, 50, 20, "Noon")); + controlList.add(new GuiButton(3, width / 2 + 5, height / 2 - 65, 50, 20, "Sunset")); + controlList.add(new GuiButton(4, width / 2 + 5, height / 2 - 35, 50, 20, "Midnight")); + controlList.add(new GuiButton(5, width / 2 - 94, height / 2 + 30, 80, 20, "Credits")); + controlList.add(new GuiButton(6, width / 2 - 10, height / 2 + 30, 80, 20, "Close")); + } + + public void drawScreen(int i, int j, float f) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int k = mc.renderEngine.getTexture("/gui/GuiStopwatch.png"); + mc.renderEngine.bindTexture(k); + drawTexturedModalRect(width / 2 - 100, height / 2 - 100, 0, 0, 176, 166); + drawString(fontRenderer, "Steve's Stopwatch", width / 2 - 60, height / 2 - 95, 0xffffff); + super.drawScreen(i, j, f); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + public void keyTyped(char c, int i) + { + if (i == 1) + { + mc.displayGuiScreen(null); + } + } + + public boolean doesGuiPauseGame() + { + return false; + } + + public void actionPerformed(GuiButton guibutton) + { + if(guibutton.id == 1) + { + if(mc.isSingleplayer()) + { + ObsidianUtils.setHourForward(player.worldObj, 0); + player.inventory.getCurrentItem().damageItem(4999, player); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + else { + ObsidianUtils.sendPacketDataInt(0); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + } + if(guibutton.id == 2) + { + if(mc.isSingleplayer()) + { + ObsidianUtils.setHourForward(player.worldObj, 6); + player.inventory.getCurrentItem().damageItem(4999, player); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + else { + ObsidianUtils.sendPacketDataInt(1); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + } + if(guibutton.id == 3) + { + if(mc.isSingleplayer()) + { + ObsidianUtils.setHourForward(player.worldObj, 12); + player.inventory.getCurrentItem().damageItem(4999, player); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + else { + ObsidianUtils.sendPacketDataInt(2); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + } + if(guibutton.id == 4) + { + if(mc.isSingleplayer()) + { + ObsidianUtils.setHourForward(player.worldObj, 18); + player.inventory.getCurrentItem().damageItem(4999, player); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + else { + ObsidianUtils.sendPacketDataInt(3); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + } + if(guibutton.id == 5) + { + mc.displayGuiScreen(new GuiCredits()); + } + if(guibutton.id == 6) + { + mc.displayGuiScreen(null); + } + } + + protected void mouseClicked(int i, int j, int k) + { + super.mouseClicked(i, j, k); + int x = i - (width - xSize) / 2; + int y = j - (height - ySize) / 2; + + if(x > 4 && x < 14 && y > 4 && y < 14) + { + mc.displayGuiScreen(null); + } + } +} diff --git a/src/minecraft/net/uberkat/obsidian/client/GuiWeatherOrb.java b/src/minecraft/net/uberkat/obsidian/client/GuiWeatherOrb.java new file mode 100644 index 000000000..5f21a4c64 --- /dev/null +++ b/src/minecraft/net/uberkat/obsidian/client/GuiWeatherOrb.java @@ -0,0 +1,145 @@ +package net.uberkat.obsidian.client; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.src.*; +import net.uberkat.obsidian.common.ObsidianUtils; + +public class GuiWeatherOrb extends GuiScreen { + + private static EntityPlayer player; + private int xSize = 176; + private int ySize = 166; + + public GuiWeatherOrb(EntityPlayer entityplayer) + { + player = entityplayer; + } + + public void initGui() + { + controlList.clear(); + controlList.add(new GuiButton(1, width / 2 - 80, height / 2 - 65, 50, 20, "Clear")); + controlList.add(new GuiButton(2, width / 2 - 80, height / 2 - 35, 50, 20, "Storm/Rain")); + controlList.add(new GuiButton(3, width / 2 + 5, height / 2 - 65, 50, 20, "Storm")); + controlList.add(new GuiButton(4, width / 2 + 5, height / 2 - 35, 50, 20, "Rain")); + controlList.add(new GuiButton(5, width / 2 - 94, height / 2 + 30, 80, 20, "Credits")); + controlList.add(new GuiButton(6, width / 2 - 10, height / 2 + 30, 80, 20, "Close")); + } + + public void drawScreen(int i, int j, float f) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int k = mc.renderEngine.getTexture("/gui/GuiWeatherOrb.png"); + mc.renderEngine.bindTexture(k); + drawTexturedModalRect(width / 2 - 100, height / 2 - 100, 0, 0, 176, 166); + drawString(fontRenderer, "Weather Orb", width / 2 - 60, height / 2 - 95, 0xffffff); + super.drawScreen(i, j, f); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + public void keyTyped(char c, int i) + { + if (i == 1) + { + mc.displayGuiScreen(null); + } + } + + public boolean doesGuiPauseGame() + { + return false; + } + + public void actionPerformed(GuiButton guibutton) + { + if(guibutton.id == 1) + { + if(mc.isSingleplayer()) + { + player.worldObj.getWorldInfo().setRaining(false); + player.worldObj.getWorldInfo().setThundering(false); + player.worldObj.setRainStrength(0.0F); + player.inventory.getCurrentItem().damageItem(4999, player); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + else { + ObsidianUtils.sendPacketDataInt(5); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + } + if(guibutton.id == 2) + { + if(mc.isSingleplayer()) + { + player.worldObj.getWorldInfo().setRaining(true); + player.worldObj.getWorldInfo().setThundering(true); + player.worldObj.setRainStrength(1.0F); + player.inventory.getCurrentItem().damageItem(4999, player); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + else { + ObsidianUtils.sendPacketDataInt(6); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + } + if(guibutton.id == 3) + { + if(mc.isSingleplayer()) + { + player.worldObj.getWorldInfo().setThundering(true); + player.inventory.getCurrentItem().damageItem(4999, player); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + else { + ObsidianUtils.sendPacketDataInt(7); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + } + if(guibutton.id == 4) + { + if(mc.isSingleplayer()) + { + player.worldObj.getWorldInfo().setRaining(true); + player.worldObj.setRainStrength(1.0F); + player.inventory.getCurrentItem().damageItem(4999, player); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + else { + ObsidianUtils.sendPacketDataInt(8); + ObsidianUtils.doExplosion(player); + mc.displayGuiScreen(null); + } + } + if(guibutton.id == 5) + { + mc.displayGuiScreen(new GuiCredits()); + } + if(guibutton.id == 6) + { + mc.displayGuiScreen(null); + } + } + + protected void mouseClicked(int i, int j, int k) + { + super.mouseClicked(i, j, k); + int x = i - (width - xSize) / 2; + int y = j - (height - ySize) / 2; + + if(x > 4 && x < 14 && y > 4 && y < 14) + { + mc.displayGuiScreen(null); + } + } +} diff --git a/src/minecraft/net/uberkat/obsidian/client/RenderKnife.java b/src/minecraft/net/uberkat/obsidian/client/RenderKnife.java new file mode 100644 index 000000000..d2c73350a --- /dev/null +++ b/src/minecraft/net/uberkat/obsidian/client/RenderKnife.java @@ -0,0 +1,99 @@ +package net.uberkat.obsidian.client; + +import org.lwjgl.opengl.GL11; +import net.minecraft.src.*; +import net.uberkat.obsidian.common.EntityKnife; + +import org.lwjgl.opengl.GL12; + +public class RenderKnife extends Render +{ + private float pitch; + + public RenderKnife() + { + pitch = 40F; + } + + public void renderKnife(EntityKnife entityknife, double d, double d1, double d2, float f, float f1) + { + this.setRenderManager(RenderManager.instance); + loadTexture("/obsidian/Knife.png"); + if (entityknife.prevRotationYaw == 0.0F && entityknife.prevRotationPitch == 0.0F) + { + return; + } + GL11.glPushMatrix(); + GL11.glTranslatef((float)d, (float)d1, (float)d2); + GL11.glRotatef((entityknife.prevRotationYaw + (entityknife.rotationYaw - entityknife.prevRotationYaw) * f1) - 90F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(entityknife.prevRotationPitch + (entityknife.rotationPitch - entityknife.prevRotationPitch) * f1, 0.0F, 0.0F, 1.0F); + Tessellator tessellator = Tessellator.instance; + int i = 0; + float f2 = 0.0F; + float f3 = 0.5F; + float f4 = (float)(0 + i * 10) / 32F; + float f5 = (float)(5 + i * 10) / 32F; + float f6 = 0.0F; + float f7 = 0.15625F; + float f8 = (float)(5 + i * 10) / 32F; + float f9 = (float)(10 + i * 10) / 32F; + float f10 = 0.05625F; + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + float f11 = (float)entityknife.arrowShake - f1; + + if (f11 > 0.0F) + { + float f12 = -MathHelper.sin(f11 * 3F) * f11; + GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); + } + + GL11.glRotatef(45F, 1.0F, 0.0F, 0.0F); + GL11.glScalef(f10, f10, f10); + GL11.glTranslatef(-4F, 0.0F, 0.0F); + GL11.glNormal3f(f10, 0.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(-7D, -2D, -2D, f6, f8); + tessellator.addVertexWithUV(-7D, -2D, 2D, f7, f8); + tessellator.addVertexWithUV(-7D, 2D, 2D, f7, f9); + tessellator.addVertexWithUV(-7D, 2D, -2D, f6, f9); + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + tessellator.addVertexWithUV(-7D, -2D, -2D, f6, f8); + tessellator.addVertexWithUV(-7D, -2D, 2D, f7, f8); + tessellator.addVertexWithUV(-7D, 2D, 2D, f7, f9); + tessellator.addVertexWithUV(-7D, 2D, -2D, f6, f9); + tessellator.draw(); + GL11.glNormal3f(-f10, 0.0F, 0.0F); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(-7D, 2D, -2D, f6, f8); + tessellator.addVertexWithUV(-7D, 2D, 2D, f7, f8); + tessellator.addVertexWithUV(-7D, -2D, 2D, f7, f9); + tessellator.addVertexWithUV(-7D, -2D, -2D, f6, f9); + tessellator.draw(); + + for (int j = 0; j < 4; j++) + { + GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); + GL11.glNormal3f(0.0F, 0.0F, f10); + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(-8D, -2D, 0.0D, f2, f4); + tessellator.addVertexWithUV(8D, -2D, 0.0D, f3, f4); + tessellator.addVertexWithUV(8D, 2D, 0.0D, f3, f5); + tessellator.addVertexWithUV(-8D, 2D, 0.0D, f2, f5); + tessellator.draw(); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render 0.0F) + { + float var22 = -MathHelper.sin(var21 * 3.0F) * var21; + GL11.glRotatef(var22, 0.0F, 0.0F, 1.0F); + } + + GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F); + GL11.glScalef(var20, var20, var20); + GL11.glTranslatef(-4.0F, 0.0F, 0.0F); + GL11.glNormal3f(var20, 0.0F, 0.0F); + var10.startDrawingQuads(); + var10.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)var16, (double)var18); + var10.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)var17, (double)var18); + var10.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)var17, (double)var19); + var10.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)var16, (double)var19); + var10.draw(); + GL11.glNormal3f(-var20, 0.0F, 0.0F); + var10.startDrawingQuads(); + var10.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)var16, (double)var18); + var10.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)var17, (double)var18); + var10.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)var17, (double)var19); + var10.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)var16, (double)var19); + var10.draw(); + + for (int var23 = 0; var23 < 4; ++var23) + { + GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); + GL11.glNormal3f(0.0F, 0.0F, var20); + var10.startDrawingQuads(); + var10.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)var12, (double)var14); + var10.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)var13, (double)var14); + var10.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)var13, (double)var15); + var10.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)var12, (double)var15); + var10.draw(); + } + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glPopMatrix(); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render 1.0F) + { + f2 = 1.0F; + } + + f2 *= f2; + f2 *= f2; + float f4 = 1.0F + f2 * 0.3F; + GL11.glScalef(f4, f4, f4); + } + + float f3 = (1.0F - (((float)entityobsidiantnt.fuse - f1) + 1.0F) / 100F) * 0.8F; + loadTexture("/obsidian/terrain.png"); + blockRenderer.renderBlockAsItem(ObsidianIngots.ObsidianTNT, 0, entityobsidiantnt.getBrightness(f1)); + + if ((entityobsidiantnt.fuse / 5) % 2 == 0) + { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f3); + blockRenderer.renderBlockAsItem(ObsidianIngots.ObsidianTNT, 0, 1.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + GL11.glPopMatrix(); + } + + /** + * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then + * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic + * (Render 0) + { + outputStream.write(buffer, 0, lastBytesDownloaded); + buffer = new byte[10240]; + bytesDownloaded += lastBytesDownloaded; + } + + outputStream.close(); + stream.close(); + GuiCredits.onFinishedDownloading(); + System.out.println("[ObsidianIngots] Successfully updated to latest version (" + ObsidianIngots.latestVersionNumber + ")."); + finalize(); + + } catch(Throwable e) + { + GuiCredits.onErrorDownloading(); + System.err.println("[ObsidianIngots] Error while finishing update thread: " + e.getMessage()); + try { + finalize(); + } catch (Throwable e1) { + System.err.println("[ObsidianIngots] Error while finalizing update thread: " + e1.getMessage()); + } + } + } + + public void prepareForDownload() + { + File download = new File(new StringBuilder().append(ModLoader.getMinecraftInstance().getMinecraftDir()).append("/mods/ObsidianIngots.jar").toString()); + File config = new File(new StringBuilder().append(ModLoader.getMinecraftInstance().getMinecraftDir()).append("/config/mod_ObsidianIngots.txt").toString()); + if(download.exists()) + { + download.delete(); + } + if(config.exists()) + { + config.delete(); + } + System.out.println("[ObsidianIngots] Preparing to update..."); + } +}