OSDN Git Service

熱分解台できたのでpush
authormozipi <mozipi@users.sourceforge.jp>
Mon, 21 Jan 2013 14:00:16 +0000 (23:00 +0900)
committermozipi <mozipi@users.sourceforge.jp>
Mon, 21 Jan 2013 14:00:16 +0000 (23:00 +0900)
ついでにデバッグ用のwindow開くようにした

18 files changed:
common/chemicraft/ChemiCraft.java
common/chemicraft/ChemiCraftAPI.java
common/chemicraft/block/BlockPyrolysisTable.java
common/chemicraft/container/ContainerPyrolysisTable.java
common/chemicraft/debug/CommandDeleteItem.java
common/chemicraft/debug/DebugData.java [new file with mode: 0644]
common/chemicraft/debug/DebugTick.java [new file with mode: 0644]
common/chemicraft/gui/GuiPyrolysisTable.java
common/chemicraft/inventory/InventoryPyrolysisTableMaterial.java
common/chemicraft/item/ItemGasCollectingBottle.java
common/chemicraft/system/CommonProxy.java
common/chemicraft/tileentity/TileEntityPyrolysisTable.java
common/chemicraft/util/ChunkProviderChemical.java [new file with mode: 0644]
common/chemicraft/util/MathHelperPlus.java
common/chemicraft/util/WorldProviderChemical.java [new file with mode: 0644]
common/chemicraft/util/WorldTypeChemical.java [new file with mode: 0644]
src/chemicraft/client/ClientProxy.java
仕様書/分解装置.odt

index 06bbe9a..6e0c759 100644 (file)
@@ -1,13 +1,13 @@
 package chemicraft;\r
 \r
-import ic2.api.energy.event.EnergyTileEvent;\r
-import ic2.api.energy.event.EnergyTileLoadEvent;\r
 import net.minecraft.block.Block;\r
 import net.minecraft.block.material.Material;\r
 import net.minecraft.creativetab.CreativeTabs;\r
 import net.minecraft.item.Item;\r
 import net.minecraft.item.ItemStack;\r
+import net.minecraftforge.common.BiomeManager;\r
 import net.minecraftforge.common.Configuration;\r
+import net.minecraftforge.common.DimensionManager;\r
 import net.minecraftforge.common.Property;\r
 import chemicraft.block.BlockChemicalCombinationTable;\r
 import chemicraft.block.BlockChemicalCraftingTable;\r
@@ -32,6 +32,7 @@ import chemicraft.util.Auxiliary.ArrayAuxiliary;
 import chemicraft.util.Auxiliary.NameAuxiliary;\r
 import chemicraft.util.CreativeTabAtoms;\r
 import chemicraft.util.NBTRecipeGrenade;\r
+import chemicraft.util.WorldProviderChemical;\r
 import cpw.mods.fml.common.Mod;\r
 import cpw.mods.fml.common.SidedProxy;\r
 import cpw.mods.fml.common.event.FMLPostInitializationEvent;\r
@@ -327,6 +328,8 @@ public class ChemiCraft {
                                new ItemStack(this.itemAtomGrenade, 16, 0),\r
                                new NBTRecipeGrenade()\r
                                );\r
+               //Tickingの追加\r
+               this.proxy.registerTickHandler();\r
        }\r
 \r
        private void apiProcessing(final FMLPostInitializationEvent event) {\r
index c04730b..b7b64e6 100644 (file)
@@ -5,6 +5,7 @@ import java.util.HashMap;
 
 import net.minecraft.item.ItemStack;
 import chemicraft.system.ChemiCraftCraftingManager;
+import chemicraft.tileentity.TileEntityPyrolysisTable;
 import chemicraft.util.ChemicalNBTRecipe;
 import chemicraft.util.ICompoundHandler;
 import chemicraft.util.MaterialRecipe;
@@ -178,10 +179,28 @@ public class ChemiCraftAPI {
 
 
 
+       public void addDecompositionRecipe(ItemStack material, int[] results, int[] stacks) {
+               ItemStack[] itemstacks = new ItemStack[results.length];
+               for (int i = 0; i < itemstacks.length; i++) {
+                       itemstacks[i] = new ItemStack(ChemiCraft.instance.atomsID,stacks[i], results[i]);
+               }
+               TileEntityPyrolysisTable.addRecipe(material, itemstacks);
+       }
+
+
+
+       public void addDecompositionRecipe(ItemStack itemstack, int burnTime) {
+               TileEntityPyrolysisTable.addFuel(itemstack, burnTime);
+       }
+
+
+
        public void addSharplessMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
                materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, true));
        }
 
+
+
        public void addMaterialRecipe(ItemStack[] materials, ItemStack result, ChemicalNBTRecipe nbtRecipe){
                materialRecipe.add(new MaterialRecipe(result, materials, nbtRecipe, false));
        }
index 686d29f..728545f 100644 (file)
@@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.tileentity.TileEntity;
 import net.minecraft.world.World;
 import chemicraft.ChemiCraft;
+import chemicraft.debug.DebugTick;
 import chemicraft.tileentity.TileEntityPyrolysisTable;
 
 public class BlockPyrolysisTable extends BlockContainer {
@@ -31,6 +32,20 @@ public class BlockPyrolysisTable extends BlockContainer {
 
 
        @Override
+       public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
+               TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4);
+               if (tileentity != null) {
+                       DebugTick.removeDebugData("PyrolysisTable" +
+                                       "(x:" + tileentity.xCoord +
+                                       " y:" + tileentity.yCoord +
+                                       " z:" + tileentity.zCoord + ")");
+               }
+               super.breakBlock(par1World, par2, par3, par4, par5, par6);
+       }
+
+
+
+       @Override
        public int getBlockTextureFromSide(int par1)
        {
                if(par1 == 0){
index 15b55d2..83477d0 100644 (file)
@@ -2,8 +2,12 @@ package chemicraft.container;
 
 import net.minecraft.entity.player.EntityPlayer;
 import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
 import net.minecraft.world.World;
 import chemicraft.ChemiCraft;
+import chemicraft.slot.SlotPyrolysisTableFuel;
+import chemicraft.slot.SlotPyrolysisTableMaterial;
+import chemicraft.slot.SlotPyrolysisTableResult;
 import chemicraft.tileentity.TileEntityPyrolysisTable;
 
 public class ContainerPyrolysisTable extends Container {
@@ -14,12 +18,37 @@ public class ContainerPyrolysisTable extends Container {
        private int posY;
        private int posZ;
 
+       private TileEntityPyrolysisTable tileentity;
+
        public ContainerPyrolysisTable(EntityPlayer par1EntityPlayer, TileEntityPyrolysisTable par2){
                super();
+               this.tileentity = par2;
                this.worldObj = par2.worldObj;
                this.posX = par2.xCoord;
                this.posY = par2.yCoord;
                this.posZ = par2.zCoord;
+
+               for (int i = 0; i < 4; i++) {
+                       for (int j = 0; j < 4; j++) {
+                               this.addSlotToContainer(new SlotPyrolysisTableResult(this.tileentity.getInvResult(), i*4 + j, 88+i*18, 17+j*18));
+                       }
+               }
+               this.addSlotToContainer(new SlotPyrolysisTableMaterial(this.tileentity.getInvMaterial(), 0, 27, 20));
+               this.addSlotToContainer(new SlotPyrolysisTableFuel(this.tileentity.getInvFuel(), 0, 27, 63));
+
+               int var3;
+               for (var3 = 0; var3 < 3; ++var3)
+               {
+                       for (int var4 = 0; var4 < 9; ++var4)
+                       {
+                               this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var4 + var3 * 9 + 9, 8 + var4 * 18, 121 + var3 * 18));
+                       }
+               }
+
+               for (var3 = 0; var3 < 9; ++var3)
+               {
+                       this.addSlotToContainer(new Slot(par1EntityPlayer.inventory, var3, 8 + var3 * 18, 179));
+               }
        }
 
        @Override
index be3b649..50fa3d6 100644 (file)
@@ -48,6 +48,7 @@ public class CommandDeleteItem extends CommandBase {
                        world = player.worldObj;
                        list = world.loadedEntityList;
                        itr = list.iterator();
+                       player.dimension = 128;
                        while(itr.hasNext()){
                                Entity entity = itr.next();
                                if(entity instanceof EntityItem){
diff --git a/common/chemicraft/debug/DebugData.java b/common/chemicraft/debug/DebugData.java
new file mode 100644 (file)
index 0000000..7af7876
--- /dev/null
@@ -0,0 +1,21 @@
+package chemicraft.debug;
+
+public class DebugData {
+
+       private String key;
+       private Object value;
+
+       public DebugData(String par1, Object par2) {
+               this.key = par1;
+               this.value = par2;
+       }
+
+       public String getKey() {
+               return this.key;
+       }
+
+       public Object getValue() {
+               return this.value;
+       }
+
+}
diff --git a/common/chemicraft/debug/DebugTick.java b/common/chemicraft/debug/DebugTick.java
new file mode 100644 (file)
index 0000000..e168e75
--- /dev/null
@@ -0,0 +1,89 @@
+package chemicraft.debug;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+import cpw.mods.fml.common.ITickHandler;
+import cpw.mods.fml.common.TickType;
+
+public class DebugTick extends JPanel implements ITickHandler {
+
+       private static HashMap<String, DebugData[]> displayDataList = new HashMap<String, DebugData[]>();
+
+       public DebugTick() {
+               JFrame frame = new JFrame();
+               frame.setSize(640, 480);
+               frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+               frame.add(this);
+               frame.setVisible(true);
+
+       }
+
+       @Override
+       public void tickStart(EnumSet<TickType> type, Object... tickData) {
+
+       }
+
+       @Override
+       public void tickEnd(EnumSet<TickType> type, Object... tickData) {
+               this.repaint();
+       }
+
+       @Override
+       public EnumSet<TickType> ticks() {
+               return EnumSet.of(TickType.GUI, TickType.CLIENT);
+       }
+
+       @Override
+       public String getLabel() {
+               return null;
+       }
+
+       @Override
+       public void paintComponent(Graphics g) {
+               Graphics2D g2 = (Graphics2D) g;
+
+               g2.clearRect(0, 0, this.getWidth(), this.getHeight());
+
+               int fontPos = 20;
+               Iterator<String> itKey = displayDataList.keySet().iterator();
+               while (itKey.hasNext()) {
+                       String key = itKey.next();
+                       DebugData[] datas = displayDataList.get(key);
+                       g2.setFont(new Font("MS ゴシック", Font.BOLD, 16));
+                       g2.setColor(Color.RED);
+                       g2.drawString(key + ":", 10, fontPos);
+                       g2.setFont(new Font("MS ゴシック", Font.PLAIN, 12));
+                       g2.setColor(Color.BLACK);
+
+                       fontPos += 16;
+
+                       for (int i = 0; i < datas.length; i++) {
+                               g2.drawString(String.valueOf(datas[i].getKey()) + ":" + String.valueOf(datas[i].getValue()), 10, fontPos);
+                               fontPos += 12;
+                       }
+
+                       fontPos += 4;
+
+               }
+       }
+
+       public static void setDebugData(String key, DebugData... value) {
+               displayDataList.put(key, value);
+       }
+
+       public static void removeDebugData(String key) {
+               displayDataList.remove(key);
+       }
+
+}
index 04a342a..903740c 100644 (file)
@@ -8,8 +8,11 @@ import chemicraft.tileentity.TileEntityPyrolysisTable;
 
 public class GuiPyrolysisTable extends GuiContainer{
 
+       private TileEntityPyrolysisTable tileentity;
+
        public GuiPyrolysisTable(EntityPlayer par1EntityPlayer, TileEntityPyrolysisTable par2) {
                super(new ContainerPyrolysisTable(par1EntityPlayer, par2));
+               this.tileentity = par2;
                this.ySize = 204;
        }
 
@@ -19,5 +22,9 @@ public class GuiPyrolysisTable extends GuiContainer{
                this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
        }
 
+       @Override
+       protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+               this.fontRenderer.drawString(String.valueOf("Temp:" + (int)this.tileentity.getHeat()), 110, 100, 0x000000);
+       }
 
 }
index 7e7b232..ada8aa4 100644 (file)
@@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack;
 
 public class InventoryPyrolysisTableMaterial implements IInventory {
 
-       private ItemStack[] inventory = new ItemStack[16];
+       private ItemStack[] inventory = new ItemStack[1];
        private Container eventHandler;
 
        public void setEventHandler(Container par1){
index f412384..2547632 100644 (file)
@@ -61,7 +61,7 @@ public class ItemGasCollectingBottle extends ItemAtomInfoContainer
                return par1ItemStack;
        }
 
-       public void isStackOrDrop(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer)
+       protected void isStackOrDrop(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer)
        {
                if (!par2EntityPlayer.inventory.addItemStackToInventory(par1ItemStack)) {
                        par2EntityPlayer.dropPlayerItem(par1ItemStack);
index 98753f2..58f4c0a 100644 (file)
@@ -7,11 +7,14 @@ import chemicraft.container.ContainerChemicalCombinationTable;
 import chemicraft.container.ContainerChemicalCraftingTable;
 import chemicraft.container.ContainerPyrolysisTable;
 import chemicraft.container.ContainerToolAndWeaponCraftingTable;
+import chemicraft.debug.DebugTick;
 import chemicraft.tileentity.TileEntityChemicalCombinationTable;
 import chemicraft.tileentity.TileEntityChemicalCraftingTable;
 import chemicraft.tileentity.TileEntityPyrolysisTable;
 import chemicraft.tileentity.TileEntityToolAndWeaponCraftingTable;
 import cpw.mods.fml.common.network.IGuiHandler;
+import cpw.mods.fml.common.registry.TickRegistry;
+import cpw.mods.fml.relauncher.Side;
 
 public class CommonProxy implements IGuiHandler {
 
@@ -51,4 +54,8 @@ public class CommonProxy implements IGuiHandler {
                return null;
        }
 
+       public void registerTickHandler() {
+               TickRegistry.registerTickHandler(new DebugTick(), Side.SERVER);
+       }
+
 }
\ No newline at end of file
index 696990e..40fd89e 100644 (file)
 package chemicraft.tileentity;
 
-import ic2.api.Direction;
-import ic2.api.energy.tile.IEnergySink;
-
 import java.io.DataOutputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Random;
 
+import net.minecraft.block.Block;
+import net.minecraft.item.ItemStack;
 import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.network.packet.Packet;
 import net.minecraft.tileentity.TileEntity;
+import chemicraft.debug.DebugData;
+import chemicraft.debug.DebugTick;
+import chemicraft.inventory.InventoryPyrolysisTableFuel;
 import chemicraft.inventory.InventoryPyrolysisTableMaterial;
 import chemicraft.inventory.InventoryPyrolysisTableResult;
+import chemicraft.system.PacketHandler;
 
 import com.google.common.io.ByteArrayDataInput;
 
+import cpw.mods.fml.common.network.PacketDispatcher;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
 public class TileEntityPyrolysisTable extends TileEntity {
 
        private InventoryPyrolysisTableMaterial invm = new InventoryPyrolysisTableMaterial();
        private InventoryPyrolysisTableResult invr = new InventoryPyrolysisTableResult();
+       private InventoryPyrolysisTableFuel invf = new InventoryPyrolysisTableFuel();
+
+       /**
+        * 熱量
+        */
+       private float heat = 0;
+
+       /**
+        * 素材の加熱時間
+        */
+       private float burnTime = 0;
+
+       /**
+        * 燃料の残り燃焼時間
+        */
+       private float fuelRestTime = 0;
+
+       /**
+        * 最大熱量
+        */
+       private static final int MAX_HEAT = 1700;
+
+       /**
+        * 燃料が燃え始める最低熱量
+        */
+       private static final int MIN_HEAT = 400;
+
+       /**
+        * 燃料の燃焼速度比率・素材の燃焼速度比率の中心となる熱量
+        */
+       private static final int CENTER_HEAT = 1050;
+
+       /**
+        * 分解までの時間
+        */
+       private static final int MAX_BURN_TIME = 2000;
+
+       /**
+        * Random of instance.
+        */
+       public static final Random rand = new Random();
+
+       /**
+        * 燃料のリスト。
+        */
+       private static HashMap<ItemStack, Integer> fuelList = new HashMap<ItemStack, Integer>();
+
+       /**
+        * レシピのリスト
+        */
+       private static HashMap<ItemStack, ItemStack[]> recipeList = new HashMap<ItemStack, ItemStack[]>();
+
+       @Override
+       public void updateEntity() {
+
+               //boolean var2 = false;
+
+               boolean var1 = this.worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord);
+               if (this.worldObj.getBlockId(xCoord, yCoord-1, zCoord) == Block.fire.blockID) {
+                       if (this.heat < 1700) {
+                               if (this.worldObj.isRaining() && var1 && !this.worldObj.isThundering()) {
+                                       this.heat += 0.1F;
+                               } else if (this.worldObj.isThundering() && var1) {
+                                       this.heat += 0.25F;
+                               } else {
+                                       this.heat += 3F;
+                               }
+                       } else {
+                               this.heat = 1700;
+                       }
+               } else {
+                       if (this.heat > 0) {
+                               if(this.worldObj.isRaining() && var1 && !this.worldObj.isThundering()) {
+                                       this.heat -= 0.25F;
+                               } else if(this.worldObj.isThundering() && var1) {
+                                       this.heat -= 0.5F;
+                               } else {
+                                       this.heat -= 0.05F;
+                               }
+                       } else {
+                               this.heat = 0;
+                       }
+               }
+
+               if (this.fuelRestTime >= 0) {
+                       this.burnTime += 10 * CENTER_HEAT / this.heat;
+                       this.fuelRestTime -= 10 * CENTER_HEAT / this.heat;
+               }
+
+               if (this.burnTime >= MAX_BURN_TIME) {
+                       Iterator<ItemStack> itMaterial = recipeList.keySet().iterator();
+                       while (itMaterial.hasNext()) {
+                               ItemStack itemstackMaterial = itMaterial.next();
+                               ItemStack materialItem = this.invm.getStackInSlot(0);
+                               if (materialItem != null) {
+                                       if (this.isInItemCheck(itemstackMaterial)) {
+                                               //var2 = true;
+                                               if (itemstackMaterial.itemID == materialItem.itemID && itemstackMaterial.getItemDamage() == materialItem.getItemDamage()) {
+                                                       this.inItem(itemstackMaterial);
+                                                       if (materialItem.stackSize >= 1) {
+                                                               this.invm.setInventorySlotContents(0, new ItemStack(materialItem.itemID, --materialItem.stackSize, materialItem.getItemDamage()));
+                                                       } else {
+                                                               this.invm.setInventorySlotContents(0, null);
+                                                       }
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+                       this.burnTime = 0;
+               }
+
+               boolean var3 = false;
+               if (this.heat > MIN_HEAT) {
+                       Iterator<ItemStack> itMaterial = recipeList.keySet().iterator();
+                       while (itMaterial.hasNext()) {
+                               ItemStack itemstackMaterial = itMaterial.next();
+                               ItemStack materialItem = this.invm.getStackInSlot(0);
+                               if (materialItem != null) {
+                                       if (this.isInItemCheck(itemstackMaterial)) {
+                                               //var2 = true;
+                                               if (itemstackMaterial.itemID == materialItem.itemID && itemstackMaterial.getItemDamage() == materialItem.getItemDamage()) {
+                                                       var3 = true;
+                                                       if (this.fuelRestTime <= 0) {
+                                                               Iterator<ItemStack> itFuel = fuelList.keySet().iterator();
+                                                               while (itFuel.hasNext()) {
+                                                                       ItemStack itemstackFuel = itFuel.next();
+                                                                       ItemStack fuelItem = this.invf.getStackInSlot(0);
+                                                                       if (fuelItem != null) {
+                                                                               if (itemstackFuel.itemID == fuelItem.itemID && itemstackFuel.getItemDamage() == fuelItem.getItemDamage()) {
+                                                                                       this.fuelRestTime = fuelList.get(itemstackFuel);
+                                                                                       if (fuelItem.stackSize >= 1) {
+                                                                                               this.invf.setInventorySlotContents(0, new ItemStack(fuelItem.itemID, --fuelItem.stackSize, fuelItem.getItemDamage()));
+                                                                                               break;
+                                                                                       } else {
+                                                                                               this.invf.setInventorySlotContents(0, null);
+                                                                                               break;
+                                                                                       }
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               } else {
+                                       this.burnTime = 0;
+                                       //var2 = false;
+                               }
+                       }
+                       if (!var3) {
+                               this.burnTime = 0;
+                       }
+               }
+
+               /*
+               DebugTick.setDebugData("PyrolysisTable" +
+                               "(x:" + this.xCoord +
+                               " y:" + this.yCoord +
+                               " z:" + this.zCoord + ")",
+                               new DebugData("Heat", this.heat),
+                               new DebugData("FuelRestTime", this.fuelRestTime),
+                               new DebugData("BurnTime", this.burnTime),
+                               new DebugData("アイテムが入るか", var2)
+                               );
+                */
+       }
 
        @Override
        public void readFromNBT(NBTTagCompound par1) {
                super.readFromNBT(par1);
+               this.heat = par1.getFloat("Heat");
+               this.burnTime = par1.getFloat("BurnTime");
+               this.fuelRestTime = par1.getFloat("FuelRestTime");
+
+               NBTTagList var2 = par1.getTagList("Items");
+               for (int var3 = 0; var3 < var2.tagCount(); ++var3)
+               {
+                       NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
+                       int var5 = var4.getByte("Slot") & 255;
+
+                       if  (var5 >= 0 && var5 < this.invm.getSizeInventory())
+                       {
+                               this.invm.setInventorySlotContents(var5, ItemStack.loadItemStackFromNBT(var4));
+                       }
+               }
+
+               NBTTagList var6 = par1.getTagList("Items2");
+               for (int var3 = 0; var3 < var6.tagCount(); ++var3)
+               {
+                       NBTTagCompound var7 = (NBTTagCompound)var6.tagAt(var3);
+                       int var8 = var7.getByte("Slot2") & 255;
+
+                       if  (var8 >= 0 && var8 < this.invr.getSizeInventory())
+                       {
+                               this.invr.setInventorySlotContents(var8, ItemStack.loadItemStackFromNBT(var7));
+                       }
+               }
+
+               NBTTagList var9 = par1.getTagList("Items3");
+               for (int var3 = 0; var3 < var9.tagCount(); ++var3)
+               {
+                       NBTTagCompound var10 = (NBTTagCompound)var9.tagAt(var3);
+                       int var11 = var10.getByte("Slot3") & 255;
+
+                       if  (var11 >= 0 && var11 < this.invf.getSizeInventory())
+                       {
+                               this.invf.setInventorySlotContents(var11, ItemStack.loadItemStackFromNBT(var10));
+                       }
+               }
        }
 
        @Override
        public void writeToNBT(NBTTagCompound par1) {
                super.writeToNBT(par1);
+               par1.setFloat("Heat", this.heat);
+               par1.setFloat("BurnTime", this.burnTime);
+               par1.setFloat("FuelRestTime", this.fuelRestTime);
+
+               NBTTagList var2 = new NBTTagList();
+               for (int var3 = 0; var3 < this.invm.getSizeInventory(); ++var3)
+               {
+                       if  (this.invm.getStackInSlot(var3) != null)
+                       {
+                               NBTTagCompound var4 = new NBTTagCompound();
+                               var4.setByte("Slot", (byte)var3);
+                               this.invm.getStackInSlot(var3).writeToNBT(var4);
+                               var2.appendTag(var4);
+                       }
+               }
+               par1.setTag("Items", var2);
+
+               NBTTagList var5 = new NBTTagList();
+               for (int var6 = 0; var6 < this.invr.getSizeInventory(); ++var6)
+               {
+                       if  (this.invr.getStackInSlot(var6) != null)
+                       {
+                               NBTTagCompound var7 = new NBTTagCompound();
+                               var7.setByte("Slot2", (byte)var6);
+                               this.invr.getStackInSlot(var6).writeToNBT(var7);
+                               var5.appendTag(var7);
+                       }
+               }
+               par1.setTag("Items2", var5);
+
+               NBTTagList var8 = new NBTTagList();
+               for (int var9 = 0; var9 < this.invf.getSizeInventory(); ++var9)
+               {
+                       if  (this.invf.getStackInSlot(var9) != null)
+                       {
+                               NBTTagCompound var10 = new NBTTagCompound();
+                               var10.setByte("Slot3", (byte)var9);
+                               this.invf.getStackInSlot(var9).writeToNBT(var10);
+                               var8.appendTag(var10);
+                       }
+               }
+               par1.setTag("Items3", var8);
+       }
+
+       @Override
+       public Packet getDescriptionPacket() {
+               return PacketHandler.getPacket(this);
        }
 
        public void readPacket(ByteArrayDataInput data) {
                try {
+                       this.heat = data.readFloat();
+                       this.burnTime = data.readInt();
+                       this.fuelRestTime = data.readFloat();
+                       for(int i = 0;i < this.invm.getSizeInventory();i++){
+                               int id = data.readInt();
+                               int size = data.readByte();
+                               int damage = data.readInt();
+                               if (id != 0 && size != 0){
+                                       this.invm.setInventorySlotContents(i, new ItemStack(id, size, damage));
+                               }else{
+                                       this.invm.setInventorySlotContents(i, null);
+                               }
+                       }
+
+                       for(int i = 0;i < this.invr.getSizeInventory();i++){
+                               int id = data.readInt();
+                               int size = data.readByte();
+                               int damage = data.readInt();
+                               if (id != 0 && size != 0){
+                                       this.invr.setInventorySlotContents(i, new ItemStack(id, size, damage));
+                               }else{
+                                       this.invr.setInventorySlotContents(i, null);
+                               }
+                       }
+
+                       for(int i = 0;i < this.invf.getSizeInventory();i++){
+                               int id = data.readInt();
+                               int size = data.readByte();
+                               int damage = data.readInt();
+                               if (id != 0 && size != 0){
+                                       this.invf.setInventorySlotContents(i, new ItemStack(id, size, damage));
+                               }else{
+                                       this.invf.setInventorySlotContents(i, null);
+                               }
+                       }
                } catch (Exception e) {
                        e.printStackTrace();
                }
@@ -37,11 +336,78 @@ public class TileEntityPyrolysisTable extends TileEntity {
 
        public void writePacket(DataOutputStream dos){
                try {
+                       dos.writeFloat(this.heat);
+                       dos.writeFloat(this.burnTime);
+                       dos.writeFloat(this.fuelRestTime);
+                       for(int i = 0;i < this.invm.getSizeInventory();i++){
+                               int id = 0;
+                               int size = 0;
+                               int damage  = 0;
+                               ItemStack itemstack = this.invm.getStackInSlot(i);
+                               if (itemstack != null){
+                                       id = itemstack.itemID;
+                                       size = itemstack.stackSize;
+                                       damage = itemstack.getItemDamage();
+                                       dos.writeInt(id);
+                                       dos.writeByte(size);
+                                       dos.writeInt(damage);
+                               }else{
+                                       dos.writeInt(0);
+                                       dos.writeByte(0);
+                                       dos.writeInt(0);
+                               }
+                       }
+
+                       for(int i = 0;i < this.invr.getSizeInventory();i++){
+                               int id = 0;
+                               int size = 0;
+                               int damage  = 0;
+                               ItemStack itemstack = this.invr.getStackInSlot(i);
+                               if (itemstack != null){
+                                       id = itemstack.itemID;
+                                       size = itemstack.stackSize;
+                                       damage = itemstack.getItemDamage();
+                                       dos.writeInt(id);
+                                       dos.writeByte(size);
+                                       dos.writeInt(damage);
+                               }else{
+                                       dos.writeInt(0);
+                                       dos.writeByte(0);
+                                       dos.writeInt(0);
+                               }
+                       }
+
+                       for(int i = 0;i < this.invf.getSizeInventory();i++){
+                               int id = 0;
+                               int size = 0;
+                               int damage  = 0;
+                               ItemStack itemstack = this.invf.getStackInSlot(i);
+                               if (itemstack != null){
+                                       id = itemstack.itemID;
+                                       size = itemstack.stackSize;
+                                       damage = itemstack.getItemDamage();
+                                       dos.writeInt(id);
+                                       dos.writeByte(size);
+                                       dos.writeInt(damage);
+                               }else{
+                                       dos.writeInt(0);
+                                       dos.writeByte(0);
+                                       dos.writeInt(0);
+                               }
+                       }
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
 
+       public float getBurnTime() {
+               return this.burnTime;
+       }
+
+       public float getHeat() {
+               return this.heat;
+       }
+
        public InventoryPyrolysisTableMaterial getInvMaterial() {
                return this.invm;
        }
@@ -50,4 +416,94 @@ public class TileEntityPyrolysisTable extends TileEntity {
                return this.invr;
        }
 
+       public InventoryPyrolysisTableFuel getInvFuel() {
+               return this.invf;
+       }
+
+       public boolean isInItemCheck(ItemStack key) {
+               ItemStack[] results = recipeList.get(key).clone();
+               ItemStack[] containerResults = new ItemStack[this.invr.getSizeInventory()];
+               for (int i = 0; i < this.invr.getSizeInventory(); i++) {
+                       containerResults[i] = this.invr.getStackInSlot(i);
+               }
+
+               for (int i = 0; i < results.length; i++) {
+                       int var1 = results[i].itemID;
+                       int var3 = results[i].getItemDamage();
+                       int var5 = results[i].stackSize;
+                       for (int j = 0; j < containerResults.length; j++) {
+                               if (containerResults[j] == null) {
+                                       results[i] = null;
+                                       break;
+                               } else {
+                                       int var2 = containerResults[j].itemID;
+                                       int var4 = containerResults[j].getItemDamage();
+                                       int var6 = containerResults[j].stackSize;
+                                       int var7 = containerResults[j].getMaxStackSize();
+                                       if (var1 == var2 && var3 == var4) {
+                                               if (var5 + var6 <= var7) {
+                                                       results[i] = null;
+                                                       break;
+                                               } else {
+                                                       var5 -= var7 - var6;
+                                               }
+                                       }
+                               }
+                       }
+               }
+               for (int i = 0; i < results.length; i++) {
+                       if (results[i] != null) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       public void inItem(ItemStack key) {
+               ItemStack[] results = recipeList.get(key);
+               ItemStack[] containerResults = new ItemStack[this.invr.getSizeInventory()];
+               for (int i = 0; i < this.invr.getSizeInventory(); i++) {
+                       containerResults[i] = this.invr.getStackInSlot(i);
+               }
+
+               for (int i = 0; i < results.length; i++) {
+                       int var1 = results[i].itemID;
+                       int var3 = results[i].getItemDamage();
+                       int var5 = results[i].stackSize;
+                       for (int j = 0; j < containerResults.length; j++) {
+                               if (containerResults[j] == null) {
+                                       this.invr.setInventorySlotContents(j, results[i]);
+                                       break;
+                               } else {
+                                       int var2 = containerResults[j].itemID;
+                                       int var4 = containerResults[j].getItemDamage();
+                                       int var6 = containerResults[j].stackSize;
+                                       int var7 = containerResults[j].getMaxStackSize();
+                                       if (var1 == var2 && var3 == var4) {
+                                               if (var5 + var6 <= var7) {
+                                                       System.out.println(var5);
+                                                       System.out.println(var6);
+                                                       System.out.println(var5 + var6);
+                                                       System.out.println(i);
+                                                       System.out.println(j);
+                                                       this.invr.setInventorySlotContents(j, new ItemStack(results[i].itemID, var5 + var6, results[i].getItemDamage()));
+                                                       break;
+                                               } else {
+                                                       this.invr.setInventorySlotContents(j, new ItemStack(results[i].itemID, var7, results[i].getItemDamage()));
+                                                       var5 -= var7 - var6;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       public static void addFuel(ItemStack itemstack, int burnTime) {
+               fuelList.put(itemstack, burnTime);
+       }
+
+       public static void addRecipe(ItemStack material, ItemStack[] result) {
+               recipeList.put(material, result);
+       }
+
 }
diff --git a/common/chemicraft/util/ChunkProviderChemical.java b/common/chemicraft/util/ChunkProviderChemical.java
new file mode 100644 (file)
index 0000000..31cb6a9
--- /dev/null
@@ -0,0 +1,687 @@
+package chemicraft.util;
+
+import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.CAVE;
+import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.MINESHAFT;
+import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.RAVINE;
+import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.SCATTERED_FEATURE;
+import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.STRONGHOLD;
+import static net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.VILLAGE;
+import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.DUNGEON;
+import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE;
+import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE;
+import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAVA;
+
+import java.util.List;
+import java.util.Random;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockSand;
+import net.minecraft.entity.EnumCreatureType;
+import net.minecraft.util.IProgressUpdate;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.ChunkPosition;
+import net.minecraft.world.SpawnerAnimals;
+import net.minecraft.world.World;
+import net.minecraft.world.biome.BiomeGenBase;
+import net.minecraft.world.chunk.Chunk;
+import net.minecraft.world.chunk.IChunkProvider;
+import net.minecraft.world.gen.MapGenBase;
+import net.minecraft.world.gen.MapGenCaves;
+import net.minecraft.world.gen.MapGenRavine;
+import net.minecraft.world.gen.NoiseGeneratorOctaves;
+import net.minecraft.world.gen.feature.MapGenScatteredFeature;
+import net.minecraft.world.gen.feature.WorldGenDungeons;
+import net.minecraft.world.gen.feature.WorldGenLakes;
+import net.minecraft.world.gen.structure.MapGenMineshaft;
+import net.minecraft.world.gen.structure.MapGenStronghold;
+import net.minecraft.world.gen.structure.MapGenVillage;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.Event.Result;
+import net.minecraftforge.event.terraingen.ChunkProviderEvent;
+import net.minecraftforge.event.terraingen.PopulateChunkEvent;
+import net.minecraftforge.event.terraingen.TerrainGen;
+
+public class ChunkProviderChemical implements IChunkProvider
+{
+       /** RNG. */
+       private Random rand;
+
+       /** A NoiseGeneratorOctaves used in generating terrain */
+       private NoiseGeneratorOctaves noiseGen1;
+
+       /** A NoiseGeneratorOctaves used in generating terrain */
+       private NoiseGeneratorOctaves noiseGen2;
+
+       /** A NoiseGeneratorOctaves used in generating terrain */
+       private NoiseGeneratorOctaves noiseGen3;
+
+       /** A NoiseGeneratorOctaves used in generating terrain */
+       private NoiseGeneratorOctaves noiseGen4;
+
+       /** A NoiseGeneratorOctaves used in generating terrain */
+       public NoiseGeneratorOctaves noiseGen5;
+
+       /** A NoiseGeneratorOctaves used in generating terrain */
+       public NoiseGeneratorOctaves noiseGen6;
+       public NoiseGeneratorOctaves mobSpawnerNoise;
+
+       /** Reference to the World object. */
+       private World worldObj;
+
+       /** are map structures going to be generated (e.g. strongholds) */
+       private final boolean mapFeaturesEnabled;
+
+       /** Holds the overall noise array used in chunk generation */
+       private double[] noiseArray;
+       private double[] stoneNoise = new double[256];
+       private MapGenBase caveGenerator = new MapGenCaves();
+
+       /** Holds Stronghold Generator */
+       private MapGenStronghold strongholdGenerator = new MapGenStronghold();
+
+       /** Holds Village Generator */
+       private MapGenVillage villageGenerator = new MapGenVillage();
+
+       /** Holds Mineshaft Generator */
+       private MapGenMineshaft mineshaftGenerator = new MapGenMineshaft();
+       private MapGenScatteredFeature scatteredFeatureGenerator = new MapGenScatteredFeature();
+
+       /** Holds ravine generator */
+       private MapGenBase ravineGenerator = new MapGenRavine();
+
+       /** The biomes that are used to generate the chunk */
+       private BiomeGenBase[] biomesForGeneration;
+
+       /** A double array that hold terrain noise from noiseGen3 */
+       double[] noise3;
+
+       /** A double array that hold terrain noise */
+       double[] noise1;
+
+       /** A double array that hold terrain noise from noiseGen2 */
+       double[] noise2;
+
+       /** A double array that hold terrain noise from noiseGen5 */
+       double[] noise5;
+
+       /** A double array that holds terrain noise from noiseGen6 */
+       double[] noise6;
+
+       /**
+        * Used to store the 5x5 parabolic field that is used during terrain generation.
+        */
+       float[] parabolicField;
+       int[][] field_73219_j = new int[32][32];
+
+       {
+               caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE);
+               strongholdGenerator = (MapGenStronghold) TerrainGen.getModdedMapGen(strongholdGenerator, STRONGHOLD);
+               villageGenerator = (MapGenVillage) TerrainGen.getModdedMapGen(villageGenerator, VILLAGE);
+               mineshaftGenerator = (MapGenMineshaft) TerrainGen.getModdedMapGen(mineshaftGenerator, MINESHAFT);
+               scatteredFeatureGenerator = (MapGenScatteredFeature) TerrainGen.getModdedMapGen(scatteredFeatureGenerator, SCATTERED_FEATURE);
+               ravineGenerator = TerrainGen.getModdedMapGen(ravineGenerator, RAVINE);
+       }
+
+       public ChunkProviderChemical(World par1World, long par2, boolean par4)
+       {
+               this.worldObj = par1World;
+               this.mapFeaturesEnabled = par4;
+               this.rand = new Random(par2);
+               this.noiseGen1 = new NoiseGeneratorOctaves(this.rand, 16);
+               this.noiseGen2 = new NoiseGeneratorOctaves(this.rand, 16);
+               this.noiseGen3 = new NoiseGeneratorOctaves(this.rand, 8);
+               this.noiseGen4 = new NoiseGeneratorOctaves(this.rand, 4);
+               this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10);
+               this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16);
+               this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8);
+
+               NoiseGeneratorOctaves[] noiseGens = {noiseGen1, noiseGen2, noiseGen3, noiseGen4, noiseGen5, noiseGen6, mobSpawnerNoise};
+               noiseGens = TerrainGen.getModdedNoiseGenerators(par1World, this.rand, noiseGens);
+               this.noiseGen1 = noiseGens[0];
+               this.noiseGen2 = noiseGens[1];
+               this.noiseGen3 = noiseGens[2];
+               this.noiseGen4 = noiseGens[3];
+               this.noiseGen5 = noiseGens[4];
+               this.noiseGen6 = noiseGens[5];
+               this.mobSpawnerNoise = noiseGens[6];
+       }
+
+       /**
+        * Generates the shape of the terrain for the chunk though its all stone though the water is frozen if the
+        * temperature is low enough
+        */
+       public void generateTerrain(int par1, int par2, byte[] par3ArrayOfByte)
+       {
+               byte var4 = 4;
+               byte var5 = 16;
+               byte var6 = 63;
+               int var7 = var4 + 1;
+               byte var8 = 17;
+               int var9 = var4 + 1;
+               this.biomesForGeneration = this.worldObj.getWorldChunkManager().getBiomesForGeneration(this.biomesForGeneration, par1 * 4 - 2, par2 * 4 - 2, var7 + 5, var9 + 5);
+               this.noiseArray = this.initializeNoiseField(this.noiseArray, par1 * var4, 0, par2 * var4, var7, var8, var9);
+
+               for (int var10 = 0; var10 < var4; ++var10)
+               {
+                       for (int var11 = 0; var11 < var4; ++var11)
+                       {
+                               for (int var12 = 0; var12 < var5; ++var12)
+                               {
+                                       double var13 = 0.125D;
+                                       double var15 = this.noiseArray[((var10 + 0) * var9 + var11 + 0) * var8 + var12 + 0];
+                                       double var17 = this.noiseArray[((var10 + 0) * var9 + var11 + 1) * var8 + var12 + 0];
+                                       double var19 = this.noiseArray[((var10 + 1) * var9 + var11 + 0) * var8 + var12 + 0];
+                                       double var21 = this.noiseArray[((var10 + 1) * var9 + var11 + 1) * var8 + var12 + 0];
+                                       double var23 = (this.noiseArray[((var10 + 0) * var9 + var11 + 0) * var8 + var12 + 1] - var15) * var13;
+                                       double var25 = (this.noiseArray[((var10 + 0) * var9 + var11 + 1) * var8 + var12 + 1] - var17) * var13;
+                                       double var27 = (this.noiseArray[((var10 + 1) * var9 + var11 + 0) * var8 + var12 + 1] - var19) * var13;
+                                       double var29 = (this.noiseArray[((var10 + 1) * var9 + var11 + 1) * var8 + var12 + 1] - var21) * var13;
+
+                                       for (int var31 = 0; var31 < 8; ++var31)
+                                       {
+                                               double var32 = 0.25D;
+                                               double var34 = var15;
+                                               double var36 = var17;
+                                               double var38 = (var19 - var15) * var32;
+                                               double var40 = (var21 - var17) * var32;
+
+                                               for (int var42 = 0; var42 < 4; ++var42)
+                                               {
+                                                       int var43 = var42 + var10 * 4 << 11 | 0 + var11 * 4 << 7 | var12 * 8 + var31;
+                                                       short var44 = 128;
+                                                       var43 -= var44;
+                                                       double var45 = 0.25D;
+                                                       double var49 = (var36 - var34) * var45;
+                                                       double var47 = var34 - var49;
+
+                                                       for (int var51 = 0; var51 < 4; ++var51)
+                                                       {
+                                                               if ((var47 += var49) > 0.0D)
+                                                               {
+                                                                       par3ArrayOfByte[var43 += var44] = (byte)Block.stone.blockID;
+                                                               }
+                                                               else if (var12 * 8 + var31 < var6)
+                                                               {
+                                                                       //par3ArrayOfByte[var43 += var44] = (byte)Block.waterStill.blockID;
+                                                               }
+                                                               else
+                                                               {
+                                                                       par3ArrayOfByte[var43 += var44] = 0;
+                                                               }
+                                                       }
+
+                                                       var34 += var38;
+                                                       var36 += var40;
+                                               }
+
+                                               var15 += var23;
+                                               var17 += var25;
+                                               var19 += var27;
+                                               var21 += var29;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Replaces the stone that was placed in with blocks that match the biome
+        */
+       public void replaceBlocksForBiome(int par1, int par2, byte[] par3ArrayOfByte, BiomeGenBase[] par4ArrayOfBiomeGenBase)
+       {
+               ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, par1, par2, par3ArrayOfByte, par4ArrayOfBiomeGenBase);
+               MinecraftForge.EVENT_BUS.post(event);
+               if (event.getResult() == Result.DENY) return;
+
+               byte var5 = 63;
+               double var6 = 0.03125D;
+               this.stoneNoise = this.noiseGen4.generateNoiseOctaves(this.stoneNoise, par1 * 16, par2 * 16, 0, 16, 16, 1, var6 * 2.0D, var6 * 2.0D, var6 * 2.0D);
+
+               for (int var8 = 0; var8 < 16; ++var8)
+               {
+                       for (int var9 = 0; var9 < 16; ++var9)
+                       {
+                               BiomeGenBase var10 = par4ArrayOfBiomeGenBase[var9 + var8 * 16];
+                               float var11 = var10.getFloatTemperature();
+                               int var12 = (int)(this.stoneNoise[var8 + var9 * 16] / 3.0D + 3.0D + this.rand.nextDouble() * 0.25D);
+                               int var13 = -1;
+                               byte var14 = var10.topBlock;
+                               byte var15 = var10.fillerBlock;
+
+                               for (int var16 = 127; var16 >= 0; --var16)
+                               {
+                                       int var17 = (var9 * 16 + var8) * 128 + var16;
+
+                                       if (var16 <= 0 + this.rand.nextInt(5))
+                                       {
+                                               par3ArrayOfByte[var17] = (byte)Block.bedrock.blockID;
+                                       }
+                                       else
+                                       {
+                                               byte var18 = par3ArrayOfByte[var17];
+
+                                               if (var18 == 0)
+                                               {
+                                                       var13 = -1;
+                                               }
+                                               else if (var18 == Block.stone.blockID)
+                                               {
+                                                       if (var13 == -1)
+                                                       {
+                                                               if (var12 <= 0)
+                                                               {
+                                                                       var14 = 0;
+                                                                       var15 = (byte)Block.stone.blockID;
+                                                               }
+                                                               else if (var16 >= var5 - 4 && var16 <= var5 + 1)
+                                                               {
+                                                                       var14 = var10.topBlock;
+                                                                       var15 = var10.fillerBlock;
+                                                               }
+
+                                                               if (var16 < var5 && var14 == 0)
+                                                               {
+                                                                       if (var11 < 0.15F)
+                                                                       {
+                                                                               //var14 = (byte)Block.ice.blockID;
+                                                                       }
+                                                                       else
+                                                                       {
+                                                                               //var14 = (byte)Block.waterStill.blockID;
+                                                                       }
+                                                               }
+
+                                                               var13 = var12;
+
+                                                               if (var16 >= var5 - 1)
+                                                               {
+                                                                       par3ArrayOfByte[var17] = var14;
+                                                               }
+                                                               else
+                                                               {
+                                                                       par3ArrayOfByte[var17] = var15;
+                                                               }
+                                                       }
+                                                       else if (var13 > 0)
+                                                       {
+                                                               --var13;
+                                                               par3ArrayOfByte[var17] = var15;
+
+                                                               if (var13 == 0 && var15 == Block.sand.blockID)
+                                                               {
+                                                                       var13 = this.rand.nextInt(4);
+                                                                       var15 = (byte)Block.sandStone.blockID;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /**
+        * loads or generates the chunk at the chunk location specified
+        */
+       public Chunk loadChunk(int par1, int par2)
+       {
+               return this.provideChunk(par1, par2);
+       }
+
+       /**
+        * Will return back a chunk, if it doesn't exist and its not a MP client it will generates all the blocks for the
+        * specified chunk from the map seed and chunk seed
+        */
+       public Chunk provideChunk(int par1, int par2)
+       {
+               this.rand.setSeed((long)par1 * 341873128712L + (long)par2 * 132897987541L);
+               byte[] var3 = new byte[32768];
+               this.generateTerrain(par1, par2, var3);
+               this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, par1 * 16, par2 * 16, 16, 16);
+               this.replaceBlocksForBiome(par1, par2, var3, this.biomesForGeneration);
+               this.caveGenerator.generate(this, this.worldObj, par1, par2, var3);
+               this.ravineGenerator.generate(this, this.worldObj, par1, par2, var3);
+
+               if (this.mapFeaturesEnabled)
+               {
+                       this.mineshaftGenerator.generate(this, this.worldObj, par1, par2, var3);
+                       this.villageGenerator.generate(this, this.worldObj, par1, par2, var3);
+                       this.strongholdGenerator.generate(this, this.worldObj, par1, par2, var3);
+                       this.scatteredFeatureGenerator.generate(this, this.worldObj, par1, par2, var3);
+               }
+
+               Chunk var4 = new Chunk(this.worldObj, var3, par1, par2);
+               byte[] var5 = var4.getBiomeArray();
+
+               for (int var6 = 0; var6 < var5.length; ++var6)
+               {
+                       var5[var6] = (byte)this.biomesForGeneration[var6].biomeID;
+               }
+
+               var4.generateSkylightMap();
+               return var4;
+       }
+
+       /**
+        * generates a subset of the level's terrain data. Takes 7 arguments: the [empty] noise array, the position, and the
+        * size.
+        */
+       private double[] initializeNoiseField(double[] par1ArrayOfDouble, int par2, int par3, int par4, int par5, int par6, int par7)
+       {
+               ChunkProviderEvent.InitNoiseField event = new ChunkProviderEvent.InitNoiseField(this, par1ArrayOfDouble, par2, par3, par4, par5, par6, par7);
+               MinecraftForge.EVENT_BUS.post(event);
+               if (event.getResult() == Result.DENY) return event.noisefield;
+
+               if (par1ArrayOfDouble == null)
+               {
+                       par1ArrayOfDouble = new double[par5 * par6 * par7];
+               }
+
+               if (this.parabolicField == null)
+               {
+                       this.parabolicField = new float[25];
+
+                       for (int var8 = -2; var8 <= 2; ++var8)
+                       {
+                               for (int var9 = -2; var9 <= 2; ++var9)
+                               {
+                                       float var10 = 10.0F / MathHelper.sqrt_float((float)(var8 * var8 + var9 * var9) + 0.2F);
+                                       this.parabolicField[var8 + 2 + (var9 + 2) * 5] = var10;
+                               }
+                       }
+               }
+
+               double var44 = 684.412D;
+               double var45 = 684.412D;
+               this.noise5 = this.noiseGen5.generateNoiseOctaves(this.noise5, par2, par4, par5, par7, 1.121D, 1.121D, 0.5D);
+               this.noise6 = this.noiseGen6.generateNoiseOctaves(this.noise6, par2, par4, par5, par7, 200.0D, 200.0D, 0.5D);
+               this.noise3 = this.noiseGen3.generateNoiseOctaves(this.noise3, par2, par3, par4, par5, par6, par7, var44 / 80.0D, var45 / 160.0D, var44 / 80.0D);
+               this.noise1 = this.noiseGen1.generateNoiseOctaves(this.noise1, par2, par3, par4, par5, par6, par7, var44, var45, var44);
+               this.noise2 = this.noiseGen2.generateNoiseOctaves(this.noise2, par2, par3, par4, par5, par6, par7, var44, var45, var44);
+               boolean var43 = false;
+               boolean var42 = false;
+               int var12 = 0;
+               int var13 = 0;
+
+               for (int var14 = 0; var14 < par5; ++var14)
+               {
+                       for (int var15 = 0; var15 < par7; ++var15)
+                       {
+                               float var16 = 0.0F;
+                               float var17 = 0.0F;
+                               float var18 = 0.0F;
+                               byte var19 = 2;
+                               BiomeGenBase var20 = this.biomesForGeneration[var14 + 2 + (var15 + 2) * (par5 + 5)];
+
+                               for (int var21 = -var19; var21 <= var19; ++var21)
+                               {
+                                       for (int var22 = -var19; var22 <= var19; ++var22)
+                                       {
+                                               BiomeGenBase var23 = this.biomesForGeneration[var14 + var21 + 2 + (var15 + var22 + 2) * (par5 + 5)];
+                                               float var24 = this.parabolicField[var21 + 2 + (var22 + 2) * 5] / (var23.minHeight + 2.0F);
+
+                                               if (var23.minHeight > var20.minHeight)
+                                               {
+                                                       var24 /= 2.0F;
+                                               }
+
+                                               var16 += var23.maxHeight * var24;
+                                               var17 += var23.minHeight * var24;
+                                               var18 += var24;
+                                       }
+                               }
+
+                               var16 /= var18;
+                               var17 /= var18;
+                               var16 = var16 * 0.9F + 0.1F;
+                               var17 = (var17 * 4.0F - 1.0F) / 8.0F;
+                               double var47 = this.noise6[var13] / 8000.0D;
+
+                               if (var47 < 0.0D)
+                               {
+                                       var47 = -var47 * 0.3D;
+                               }
+
+                               var47 = var47 * 3.0D - 2.0D;
+
+                               if (var47 < 0.0D)
+                               {
+                                       var47 /= 2.0D;
+
+                                       if (var47 < -1.0D)
+                                       {
+                                               var47 = -1.0D;
+                                       }
+
+                                       var47 /= 1.4D;
+                                       var47 /= 2.0D;
+                               }
+                               else
+                               {
+                                       if (var47 > 1.0D)
+                                       {
+                                               var47 = 1.0D;
+                                       }
+
+                                       var47 /= 8.0D;
+                               }
+
+                               ++var13;
+
+                               for (int var46 = 0; var46 < par6; ++var46)
+                               {
+                                       double var48 = (double)var17;
+                                       double var26 = (double)var16;
+                                       var48 += var47 * 0.2D;
+                                       var48 = var48 * (double)par6 / 16.0D;
+                                       double var28 = (double)par6 / 2.0D + var48 * 4.0D;
+                                       double var30 = 0.0D;
+                                       double var32 = ((double)var46 - var28) * 12.0D * 128.0D / 128.0D / var26;
+
+                                       if (var32 < 0.0D)
+                                       {
+                                               var32 *= 4.0D;
+                                       }
+
+                                       double var34 = this.noise1[var12] / 512.0D;
+                                       double var36 = this.noise2[var12] / 512.0D;
+                                       double var38 = (this.noise3[var12] / 10.0D + 1.0D) / 2.0D;
+
+                                       if (var38 < 0.0D)
+                                       {
+                                               var30 = var34;
+                                       }
+                                       else if (var38 > 1.0D)
+                                       {
+                                               var30 = var36;
+                                       }
+                                       else
+                                       {
+                                               var30 = var34 + (var36 - var34) * var38;
+                                       }
+
+                                       var30 -= var32;
+
+                                       if (var46 > par6 - 4)
+                                       {
+                                               double var40 = (double)((float)(var46 - (par6 - 4)) / 3.0F);
+                                               var30 = var30 * (1.0D - var40) + -10.0D * var40;
+                                       }
+
+                                       par1ArrayOfDouble[var12] = var30;
+                                       ++var12;
+                               }
+                       }
+               }
+
+               return par1ArrayOfDouble;
+       }
+
+       /**
+        * Checks to see if a chunk exists at x, y
+        */
+       public boolean chunkExists(int par1, int par2)
+       {
+               return true;
+       }
+
+       /**
+        * Populates chunk with ores etc etc
+        */
+       public void populate(IChunkProvider par1IChunkProvider, int par2, int par3)
+       {
+               BlockSand.fallInstantly = true;
+               int var4 = par2 * 16;
+               int var5 = par3 * 16;
+               BiomeGenBase var6 = this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16);
+               this.rand.setSeed(this.worldObj.getSeed());
+               long var7 = this.rand.nextLong() / 2L * 2L + 1L;
+               long var9 = this.rand.nextLong() / 2L * 2L + 1L;
+               this.rand.setSeed((long)par2 * var7 + (long)par3 * var9 ^ this.worldObj.getSeed());
+               boolean var11 = false;
+
+               MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, rand, par2, par3, var11));
+
+               if (this.mapFeaturesEnabled)
+               {
+                       this.mineshaftGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
+                       var11 = this.villageGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
+                       this.strongholdGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
+                       this.scatteredFeatureGenerator.generateStructuresInChunk(this.worldObj, this.rand, par2, par3);
+               }
+
+               int var12;
+               int var13;
+               int var14;
+
+               if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, var11, LAKE) &&
+                               !var11 && this.rand.nextInt(4) == 0)
+               {
+                       var12 = var4 + this.rand.nextInt(16) + 8;
+                       var13 = this.rand.nextInt(128);
+                       var14 = var5 + this.rand.nextInt(16) + 8;
+                       //(new WorldGenLakes(Block.waterStill.blockID)).generate(this.worldObj, this.rand, var12, var13, var14);
+               }
+
+               if (TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, var11, LAVA) &&
+                               !var11 && this.rand.nextInt(8) == 0)
+               {
+                       var12 = var4 + this.rand.nextInt(16) + 8;
+                       var13 = this.rand.nextInt(this.rand.nextInt(120) + 8);
+                       var14 = var5 + this.rand.nextInt(16) + 8;
+
+                       if (var13 < 63 || this.rand.nextInt(10) == 0)
+                       {
+                               (new WorldGenLakes(Block.lavaStill.blockID)).generate(this.worldObj, this.rand, var12, var13, var14);
+                       }
+               }
+
+               boolean doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, var11, DUNGEON);
+               for (var12 = 0; doGen && var12 < 8; ++var12)
+               {
+                       var13 = var4 + this.rand.nextInt(16) + 8;
+                       var14 = this.rand.nextInt(128);
+                       int var15 = var5 + this.rand.nextInt(16) + 8;
+
+                       if ((new WorldGenDungeons()).generate(this.worldObj, this.rand, var13, var14, var15))
+                       {
+                               ;
+                       }
+               }
+
+               var6.decorate(this.worldObj, this.rand, var4, var5);
+               SpawnerAnimals.performWorldGenSpawning(this.worldObj, var6, var4 + 8, var5 + 8, 16, 16, this.rand);
+               var4 += 8;
+               var5 += 8;
+
+               doGen = TerrainGen.populate(par1IChunkProvider, worldObj, rand, par2, par3, var11, ICE);
+               for (var12 = 0; doGen && var12 < 16; ++var12)
+               {
+                       for (var13 = 0; var13 < 16; ++var13)
+                       {
+                               var14 = this.worldObj.getPrecipitationHeight(var4 + var12, var5 + var13);
+
+                               if (this.worldObj.isBlockFreezable(var12 + var4, var14 - 1, var13 + var5))
+                               {
+                                       this.worldObj.setBlockWithNotify(var12 + var4, var14 - 1, var13 + var5, Block.ice.blockID);
+                               }
+
+                               if (this.worldObj.canSnowAt(var12 + var4, var14, var13 + var5))
+                               {
+                                       this.worldObj.setBlockWithNotify(var12 + var4, var14, var13 + var5, Block.snow.blockID);
+                               }
+                       }
+               }
+
+               MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, rand, par2, par3, var11));
+
+               BlockSand.fallInstantly = false;
+       }
+
+       /**
+        * Two modes of operation: if passed true, save all Chunks in one go.  If passed false, save up to two chunks.
+        * Return true if all chunks have been saved.
+        */
+       public boolean saveChunks(boolean par1, IProgressUpdate par2IProgressUpdate)
+       {
+               return true;
+       }
+
+       /**
+        * Unloads the 100 oldest chunks from memory, due to a bug with chunkSet.add() never being called it thinks the list
+        * is always empty and will not remove any chunks.
+        */
+       public boolean unload100OldestChunks()
+       {
+               return false;
+       }
+
+       /**
+        * Returns if the IChunkProvider supports saving.
+        */
+       public boolean canSave()
+       {
+               return true;
+       }
+
+       /**
+        * Converts the instance data to a readable string.
+        */
+       public String makeString()
+       {
+               return "RandomLevelSource";
+       }
+
+       /**
+        * Returns a list of creatures of the specified type that can spawn at the given location.
+        */
+       public List getPossibleCreatures(EnumCreatureType par1EnumCreatureType, int par2, int par3, int par4)
+       {
+               BiomeGenBase var5 = this.worldObj.getBiomeGenForCoords(par2, par4);
+               return var5 == null ? null : (var5 == BiomeGenBase.swampland && par1EnumCreatureType == EnumCreatureType.monster && this.scatteredFeatureGenerator.hasStructureAt(par2, par3, par4) ? this.scatteredFeatureGenerator.getScatteredFeatureSpawnList() : var5.getSpawnableList(par1EnumCreatureType));
+       }
+
+       /**
+        * Returns the location of the closest structure of the specified type. If not found returns null.
+        */
+       public ChunkPosition findClosestStructure(World par1World, String par2Str, int par3, int par4, int par5)
+       {
+               return "Stronghold".equals(par2Str) && this.strongholdGenerator != null ? this.strongholdGenerator.getNearestInstance(par1World, par3, par4, par5) : null;
+       }
+
+       public int getLoadedChunkCount()
+       {
+               return 0;
+       }
+
+       public void recreateStructures(int par1, int par2)
+       {
+               if (this.mapFeaturesEnabled)
+               {
+                       this.mineshaftGenerator.generate(this, this.worldObj, par1, par2, (byte[])null);
+                       this.villageGenerator.generate(this, this.worldObj, par1, par2, (byte[])null);
+                       this.strongholdGenerator.generate(this, this.worldObj, par1, par2, (byte[])null);
+                       this.scatteredFeatureGenerator.generate(this, this.worldObj, par1, par2, (byte[])null);
+               }
+       }
+}
index a4fbb2b..775a77e 100644 (file)
@@ -3,42 +3,29 @@ package chemicraft.util;
 import java.util.ArrayList;
 import java.util.Random;
 
-public class MathHelperPlus
-{
+public class MathHelperPlus {
+
+       public static Random rand = new Random();
 
        /**
         * Return probability(0~).
         */
-       public static int probability(double... par1)
-       {
+       public static int probability(double... par1) {
                ArrayList<Double> var1 = new ArrayList<Double>();
-               for (int var2 = 0; var2 < par1.length; var2++){
+               for (int var2 = 0; var2 < par1.length; var2++) {
                        var1.add(par1[var2]);
                }
                return probability(var1);
        }
 
-       public static int probability(ArrayList<Double> par1)
-       {
-               Random var2 = new Random();
-               int var3 = var2.nextInt(100);
-               double var4 = 0.0D;
-
-               for (int var5 = 0; var5 < par1.size(); var5++) {
-                       var4 += par1.get(var5);
-               }
-
-               ArrayList<Double> var6 = new ArrayList<Double>();
-               for (int var7 = 0; var7 < par1.size(); var7++) {
-                       var6.add(par1.get(var7) / var4 * 100);
-               }
-
-               double var8 = 0.0D;
-               for (int var9 = 0; var9 < var6.size(); var9++) {
-                       if (var3 < var6.get(var9) + var8) {
-                               return var9;
+       public static int probability(ArrayList<Double> par1) {
+               for (int i = 0; i < par1.size(); i++) {
+                       double var1 = par1.get(i) / 100;
+                       double var2 = Math.random();
+                       if (var1 <= var2) {
+                               return i;
                        } else {
-                               var8 += var6.get(var9);
+                               continue;
                        }
                }
                return -1;
diff --git a/common/chemicraft/util/WorldProviderChemical.java b/common/chemicraft/util/WorldProviderChemical.java
new file mode 100644 (file)
index 0000000..ca7b168
--- /dev/null
@@ -0,0 +1,15 @@
+package chemicraft.util;
+
+import net.minecraft.world.WorldProvider;
+
+public class WorldProviderChemical extends WorldProvider
+{
+
+       public WorldProviderChemical() {
+       }
+
+       public String getDimensionName()
+       {
+               return "Chemical";
+       }
+}
diff --git a/common/chemicraft/util/WorldTypeChemical.java b/common/chemicraft/util/WorldTypeChemical.java
new file mode 100644 (file)
index 0000000..afe6a2e
--- /dev/null
@@ -0,0 +1,34 @@
+package chemicraft.util;
+
+import net.minecraft.world.World;
+import net.minecraft.world.WorldType;
+import net.minecraft.world.biome.WorldChunkManager;
+import net.minecraft.world.chunk.IChunkProvider;
+
+public class WorldTypeChemical extends WorldType {
+
+       public WorldTypeChemical(int par1, String par2Str) {
+               super(par1, par2Str);
+       }
+
+       public WorldChunkManager getChunkManager(World par1) {
+               return new WorldChunkManager(par1);
+       }
+
+       public IChunkProvider getChunkGenerator(World par1) {
+               return new ChunkProviderChemical(par1, par1.getSeed(), par1.getWorldInfo().isMapFeaturesEnabled());
+       }
+
+       public int getSeaLevel(World par1) {
+               return 64;
+       }
+
+       public boolean hasVoidParticles(boolean var1) {
+               return false;
+       }
+
+       public double voidFadeMagnitude() {
+               return 1.0D;
+       }
+
+}
index 89c93ea..c1cd215 100644 (file)
@@ -5,6 +5,7 @@ import net.minecraft.tileentity.TileEntity;
 import net.minecraft.world.World;
 import net.minecraftforge.client.MinecraftForgeClient;
 import chemicraft.ChemiCraft;
+import chemicraft.debug.DebugTick;
 import chemicraft.entity.EntityAtomsGrenade;
 import chemicraft.gui.GuiChemicalCombinationTable;
 import chemicraft.gui.GuiChemicalCraftingTable;
@@ -18,6 +19,8 @@ import chemicraft.tileentity.TileEntityPyrolysisTable;
 import chemicraft.tileentity.TileEntityToolAndWeaponCraftingTable;
 import cpw.mods.fml.client.FMLClientHandler;
 import cpw.mods.fml.client.registry.RenderingRegistry;
+import cpw.mods.fml.common.registry.TickRegistry;
+import cpw.mods.fml.relauncher.Side;
 
 public class ClientProxy extends CommonProxy {
 
@@ -59,4 +62,9 @@ public class ClientProxy extends CommonProxy {
                return FMLClientHandler.instance().getClient().theWorld;
        }
 
+       @Override
+       public void registerTickHandler() {
+               TickRegistry.registerTickHandler(new DebugTick(), Side.CLIENT);
+       }
+
 }
index a6d2d08..1dd7129 100644 (file)
Binary files a/仕様書/分解装置.odt and b/仕様書/分解装置.odt differ