Stone and Cobblestone Gens!
|
|
@ -0,0 +1,119 @@
|
||||||
|
package com.oitsjustjose.criss_cross.Blocks;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.oitsjustjose.criss_cross.CrissCross;
|
||||||
|
import com.oitsjustjose.criss_cross.GUI.GUIHandler;
|
||||||
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityCobblegen;
|
||||||
|
import com.oitsjustjose.criss_cross.Util.Reference;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockCobblegen extends BlockMachineBase
|
||||||
|
{
|
||||||
|
private static String unlocName = "CobblestoneGenerator";
|
||||||
|
|
||||||
|
public BlockCobblegen()
|
||||||
|
{
|
||||||
|
super(unlocName);
|
||||||
|
GameRegistry.registerTileEntity(TileEntityCobblegen.class, unlocName);
|
||||||
|
GameRegistry.registerBlock(this, unlocName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void registerBlockIcons(IIconRegister register)
|
||||||
|
{
|
||||||
|
blockTextures[0] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Bottom");
|
||||||
|
blockTextures[1] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Top");
|
||||||
|
blockTextures[2] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Front");
|
||||||
|
blockTextures[3] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Sides");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World world, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityCobblegen();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void breakBlock(World world, int x, int y, int z, Block block, int meta)
|
||||||
|
{
|
||||||
|
Random random = new Random();
|
||||||
|
TileEntityCobblegen tile = (TileEntityCobblegen) world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if(tile != null)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < tile.getSizeInventory(); ++i)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = tile.getStackInSlot(i);
|
||||||
|
|
||||||
|
if(itemstack != null)
|
||||||
|
{
|
||||||
|
float f = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
float f1 = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
float f2 = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
|
||||||
|
while(itemstack.stackSize > 0)
|
||||||
|
{
|
||||||
|
int j = random.nextInt(21) + 10;
|
||||||
|
|
||||||
|
if(j > itemstack.stackSize)
|
||||||
|
{
|
||||||
|
j = itemstack.stackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
itemstack.stackSize -= j;
|
||||||
|
EntityItem entityitem = new EntityItem(world, (double) ((float) x + f),
|
||||||
|
(double) ((float) y + f1), (double) ((float) z + f2),
|
||||||
|
new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
|
||||||
|
|
||||||
|
if(itemstack.hasTagCompound())
|
||||||
|
{
|
||||||
|
entityitem.getEntityItem()
|
||||||
|
.setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||||
|
}
|
||||||
|
|
||||||
|
float f3 = 0.05F;
|
||||||
|
entityitem.motionX = (double) ((float) random.nextGaussian() * f3);
|
||||||
|
entityitem.motionY = (double) ((float) random.nextGaussian() * f3 + 0.2F);
|
||||||
|
entityitem.motionZ = (double) ((float) random.nextGaussian() * f3);
|
||||||
|
world.spawnEntityInWorld(entityitem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
world.func_147453_f(x, y, z, block);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
super.breakBlock(world, x, y, z, block, meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
|
||||||
|
float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if(world.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TileEntityCobblegen tileext = (TileEntityCobblegen) world.getTileEntity(x, y, z);
|
||||||
|
if(tileext != null)
|
||||||
|
player.openGui(CrissCross.instance, GUIHandler.Cobblegen, world, x, y, z);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
package com.oitsjustjose.criss_cross.Blocks;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import com.oitsjustjose.criss_cross.CrissCross;
|
||||||
|
import com.oitsjustjose.criss_cross.GUI.GUIHandler;
|
||||||
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityStonegen;
|
||||||
|
import com.oitsjustjose.criss_cross.Util.Reference;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class BlockStonegen extends BlockMachineBase
|
||||||
|
{
|
||||||
|
private static String unlocName = "StoneGenerator";
|
||||||
|
|
||||||
|
public BlockStonegen()
|
||||||
|
{
|
||||||
|
super(unlocName);
|
||||||
|
GameRegistry.registerTileEntity(TileEntityStonegen.class, unlocName);
|
||||||
|
GameRegistry.registerBlock(this, unlocName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void registerBlockIcons(IIconRegister register)
|
||||||
|
{
|
||||||
|
blockTextures[0] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Bottom");
|
||||||
|
blockTextures[1] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Top");
|
||||||
|
blockTextures[2] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Front");
|
||||||
|
blockTextures[3] = register.registerIcon(Reference.modid + ":" + this.unlocName + "/" + unlocName + "_Sides");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World world, int meta)
|
||||||
|
{
|
||||||
|
return new TileEntityStonegen();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void breakBlock(World world, int x, int y, int z, Block block, int meta)
|
||||||
|
{
|
||||||
|
Random random = new Random();
|
||||||
|
TileEntityStonegen tile = (TileEntityStonegen) world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if(tile != null)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < tile.getSizeInventory(); ++i)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = tile.getStackInSlot(i);
|
||||||
|
|
||||||
|
if(itemstack != null)
|
||||||
|
{
|
||||||
|
float f = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
float f1 = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
float f2 = random.nextFloat() * 0.8F + 0.1F;
|
||||||
|
|
||||||
|
while(itemstack.stackSize > 0)
|
||||||
|
{
|
||||||
|
int j = random.nextInt(21) + 10;
|
||||||
|
|
||||||
|
if(j > itemstack.stackSize)
|
||||||
|
{
|
||||||
|
j = itemstack.stackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
itemstack.stackSize -= j;
|
||||||
|
EntityItem entityitem = new EntityItem(world, (double) ((float) x + f),
|
||||||
|
(double) ((float) y + f1), (double) ((float) z + f2),
|
||||||
|
new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
|
||||||
|
|
||||||
|
if(itemstack.hasTagCompound())
|
||||||
|
{
|
||||||
|
entityitem.getEntityItem()
|
||||||
|
.setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||||
|
}
|
||||||
|
|
||||||
|
float f3 = 0.05F;
|
||||||
|
entityitem.motionX = (double) ((float) random.nextGaussian() * f3);
|
||||||
|
entityitem.motionY = (double) ((float) random.nextGaussian() * f3 + 0.2F);
|
||||||
|
entityitem.motionZ = (double) ((float) random.nextGaussian() * f3);
|
||||||
|
world.spawnEntityInWorld(entityitem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
world.func_147453_f(x, y, z, block);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
super.breakBlock(world, x, y, z, block, meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX,
|
||||||
|
float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
if(world.isRemote)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TileEntityStonegen tileext = (TileEntityStonegen) world.getTileEntity(x, y, z);
|
||||||
|
if(tileext != null)
|
||||||
|
player.openGui(CrissCross.instance, GUIHandler.Stonegen, world, x, y, z);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,12 +11,16 @@ public class CCBlocks
|
||||||
public static Block cropomator;
|
public static Block cropomator;
|
||||||
public static Block electroextractor;
|
public static Block electroextractor;
|
||||||
public static Block woodchipper;
|
public static Block woodchipper;
|
||||||
|
public static Block cobblegen;
|
||||||
|
public static Block stonegen;
|
||||||
|
|
||||||
public static void init()
|
public static void init()
|
||||||
{
|
{
|
||||||
cropomator = new BlockCropomator();
|
cropomator = new BlockCropomator();
|
||||||
electroextractor = new BlockElectroextractor();
|
electroextractor = new BlockElectroextractor();
|
||||||
woodchipper = new BlockWoodchipper();
|
woodchipper = new BlockWoodchipper();
|
||||||
|
cobblegen = new BlockCobblegen();
|
||||||
|
stonegen = new BlockStonegen();
|
||||||
|
|
||||||
NetworkRegistry.INSTANCE.registerGuiHandler(CrissCross.instance, new GUIHandler());
|
NetworkRegistry.INSTANCE.registerGuiHandler(CrissCross.instance, new GUIHandler());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,178 @@
|
||||||
|
package com.oitsjustjose.criss_cross.Container;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityCobblegen;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.ICrafting;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class ContainerCobblegen extends Container
|
||||||
|
{
|
||||||
|
TileEntityCobblegen cobblegen;
|
||||||
|
EntityPlayer player;
|
||||||
|
|
||||||
|
private int lastUseTime;
|
||||||
|
private int lastChopTime;
|
||||||
|
private int lastFuelTime;
|
||||||
|
|
||||||
|
public ContainerCobblegen(EntityPlayer player, TileEntityCobblegen cobblegen)
|
||||||
|
{
|
||||||
|
this.player = player;
|
||||||
|
this.cobblegen = cobblegen;
|
||||||
|
|
||||||
|
lastUseTime = 0;
|
||||||
|
lastChopTime = 0;
|
||||||
|
lastFuelTime = 0;
|
||||||
|
|
||||||
|
this.addSlotToContainer(new Slot(cobblegen, 0, 56, 17)); // input
|
||||||
|
this.addSlotToContainer(new Slot(cobblegen, 1, 56, 53)); // catalyst
|
||||||
|
this.addSlotToContainer(new MachineOutputSlot(player, cobblegen, 2, 116, 35));
|
||||||
|
this.addInventorySlots();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void updateProgressBar(int timeType1, int timeType2)
|
||||||
|
{
|
||||||
|
switch(timeType1)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
this.cobblegen.processTime = timeType2;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
this.cobblegen.fuelTime = timeType2;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
this.cobblegen.fuelUsetime = timeType2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCraftingToCrafters(ICrafting crafting)
|
||||||
|
{
|
||||||
|
super.addCraftingToCrafters(crafting);
|
||||||
|
crafting.sendProgressBarUpdate(this, 0, this.cobblegen.processTime);
|
||||||
|
crafting.sendProgressBarUpdate(this, 1, this.cobblegen.fuelTime);
|
||||||
|
crafting.sendProgressBarUpdate(this, 2, this.cobblegen.fuelUsetime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detectAndSendChanges()
|
||||||
|
{
|
||||||
|
super.detectAndSendChanges();
|
||||||
|
for(int i = 0; i < this.crafters.size(); ++i)
|
||||||
|
{
|
||||||
|
ICrafting crafting = (ICrafting) this.crafters.get(i);
|
||||||
|
|
||||||
|
if(this.lastUseTime != this.cobblegen.processTime)
|
||||||
|
crafting.sendProgressBarUpdate(this, 0, this.cobblegen.processTime);
|
||||||
|
if(this.lastChopTime != this.cobblegen.fuelTime)
|
||||||
|
crafting.sendProgressBarUpdate(this, 1, this.cobblegen.fuelTime);
|
||||||
|
if(this.lastFuelTime != this.cobblegen.fuelUsetime)
|
||||||
|
crafting.sendProgressBarUpdate(this, 2, this.cobblegen.fuelUsetime);
|
||||||
|
}
|
||||||
|
this.lastUseTime = this.cobblegen.processTime;
|
||||||
|
this.lastChopTime = this.cobblegen.fuelTime;
|
||||||
|
this.lastFuelTime = this.cobblegen.fuelUsetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = null;
|
||||||
|
Slot slot = (Slot) this.inventorySlots.get(slotID);
|
||||||
|
|
||||||
|
if(slot != null && slot.getHasStack())
|
||||||
|
{
|
||||||
|
ItemStack itemstack1 = slot.getStack();
|
||||||
|
itemstack = itemstack1.copy();
|
||||||
|
|
||||||
|
if(slotID == 2)
|
||||||
|
{
|
||||||
|
if(!this.mergeItemStack(itemstack1, 3, 39, true))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot.onSlotChange(itemstack1, itemstack);
|
||||||
|
}
|
||||||
|
else if(slotID != 1 && slotID != 0)
|
||||||
|
{
|
||||||
|
if(TileEntityCobblegen.isValid(itemstack1))
|
||||||
|
{
|
||||||
|
if(!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(TileEntityCobblegen.isItemFuel(itemstack1))
|
||||||
|
{
|
||||||
|
if(!this.mergeItemStack(itemstack1, 1, 2, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(slotID >= 3 && slotID < 30)
|
||||||
|
{
|
||||||
|
if(!this.mergeItemStack(itemstack1, 30, 39, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(!this.mergeItemStack(itemstack1, 3, 39, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(itemstack1.stackSize == 0)
|
||||||
|
{
|
||||||
|
slot.putStack((ItemStack) null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slot.onSlotChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(itemstack1.stackSize == itemstack.stackSize)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot.onPickupFromSlot(player, itemstack1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInteractWith(EntityPlayer player)
|
||||||
|
{
|
||||||
|
return this.cobblegen.isUseableByPlayer(this.player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void addInventorySlots()
|
||||||
|
{
|
||||||
|
this.addInventorySlots(8, 84, 142);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void addInventorySlots(int xOffset, int yOffset, int yHotbar)
|
||||||
|
{
|
||||||
|
InventoryPlayer inventory = this.player.inventory;
|
||||||
|
|
||||||
|
for(int i = 0; i < 3; ++i)
|
||||||
|
for(int j = 0; j < 9; ++j)
|
||||||
|
this.addSlotToContainer(new Slot(inventory, 9 + j + i * 9, xOffset + j * 18, yOffset + i * 18));
|
||||||
|
|
||||||
|
for(int i = 0; i < 9; ++i)
|
||||||
|
this.addSlotToContainer(new Slot(inventory, i, xOffset + i * 18, yHotbar));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,178 @@
|
||||||
|
package com.oitsjustjose.criss_cross.Container;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityStonegen;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.ICrafting;
|
||||||
|
import net.minecraft.inventory.Slot;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class ContainerStonegen extends Container
|
||||||
|
{
|
||||||
|
TileEntityStonegen Stonegen;
|
||||||
|
EntityPlayer player;
|
||||||
|
|
||||||
|
private int lastUseTime;
|
||||||
|
private int lastChopTime;
|
||||||
|
private int lastFuelTime;
|
||||||
|
|
||||||
|
public ContainerStonegen(EntityPlayer player, TileEntityStonegen Stonegen)
|
||||||
|
{
|
||||||
|
this.player = player;
|
||||||
|
this.Stonegen = Stonegen;
|
||||||
|
|
||||||
|
lastUseTime = 0;
|
||||||
|
lastChopTime = 0;
|
||||||
|
lastFuelTime = 0;
|
||||||
|
|
||||||
|
this.addSlotToContainer(new Slot(Stonegen, 0, 56, 17)); // input
|
||||||
|
this.addSlotToContainer(new Slot(Stonegen, 1, 56, 53)); // catalyst
|
||||||
|
this.addSlotToContainer(new MachineOutputSlot(player, Stonegen, 2, 116, 35));
|
||||||
|
this.addInventorySlots();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void updateProgressBar(int timeType1, int timeType2)
|
||||||
|
{
|
||||||
|
switch(timeType1)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
this.Stonegen.processTime = timeType2;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
this.Stonegen.fuelTime = timeType2;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
this.Stonegen.fuelUsetime = timeType2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCraftingToCrafters(ICrafting crafting)
|
||||||
|
{
|
||||||
|
super.addCraftingToCrafters(crafting);
|
||||||
|
crafting.sendProgressBarUpdate(this, 0, this.Stonegen.processTime);
|
||||||
|
crafting.sendProgressBarUpdate(this, 1, this.Stonegen.fuelTime);
|
||||||
|
crafting.sendProgressBarUpdate(this, 2, this.Stonegen.fuelUsetime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detectAndSendChanges()
|
||||||
|
{
|
||||||
|
super.detectAndSendChanges();
|
||||||
|
for(int i = 0; i < this.crafters.size(); ++i)
|
||||||
|
{
|
||||||
|
ICrafting crafting = (ICrafting) this.crafters.get(i);
|
||||||
|
|
||||||
|
if(this.lastUseTime != this.Stonegen.processTime)
|
||||||
|
crafting.sendProgressBarUpdate(this, 0, this.Stonegen.processTime);
|
||||||
|
if(this.lastChopTime != this.Stonegen.fuelTime)
|
||||||
|
crafting.sendProgressBarUpdate(this, 1, this.Stonegen.fuelTime);
|
||||||
|
if(this.lastFuelTime != this.Stonegen.fuelUsetime)
|
||||||
|
crafting.sendProgressBarUpdate(this, 2, this.Stonegen.fuelUsetime);
|
||||||
|
}
|
||||||
|
this.lastUseTime = this.Stonegen.processTime;
|
||||||
|
this.lastChopTime = this.Stonegen.fuelTime;
|
||||||
|
this.lastFuelTime = this.Stonegen.fuelUsetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = null;
|
||||||
|
Slot slot = (Slot) this.inventorySlots.get(slotID);
|
||||||
|
|
||||||
|
if(slot != null && slot.getHasStack())
|
||||||
|
{
|
||||||
|
ItemStack itemstack1 = slot.getStack();
|
||||||
|
itemstack = itemstack1.copy();
|
||||||
|
|
||||||
|
if(slotID == 2)
|
||||||
|
{
|
||||||
|
if(!this.mergeItemStack(itemstack1, 3, 39, true))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot.onSlotChange(itemstack1, itemstack);
|
||||||
|
}
|
||||||
|
else if(slotID != 1 && slotID != 0)
|
||||||
|
{
|
||||||
|
if(TileEntityStonegen.isValid(itemstack1))
|
||||||
|
{
|
||||||
|
if(!this.mergeItemStack(itemstack1, 0, 1, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(TileEntityStonegen.isItemFuel(itemstack1))
|
||||||
|
{
|
||||||
|
if(!this.mergeItemStack(itemstack1, 1, 2, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(slotID >= 3 && slotID < 30)
|
||||||
|
{
|
||||||
|
if(!this.mergeItemStack(itemstack1, 30, 39, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(slotID >= 30 && slotID < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(!this.mergeItemStack(itemstack1, 3, 39, false))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(itemstack1.stackSize == 0)
|
||||||
|
{
|
||||||
|
slot.putStack((ItemStack) null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slot.onSlotChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(itemstack1.stackSize == itemstack.stackSize)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
slot.onPickupFromSlot(player, itemstack1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInteractWith(EntityPlayer player)
|
||||||
|
{
|
||||||
|
return this.Stonegen.isUseableByPlayer(this.player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void addInventorySlots()
|
||||||
|
{
|
||||||
|
this.addInventorySlots(8, 84, 142);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void addInventorySlots(int xOffset, int yOffset, int yHotbar)
|
||||||
|
{
|
||||||
|
InventoryPlayer inventory = this.player.inventory;
|
||||||
|
|
||||||
|
for(int i = 0; i < 3; ++i)
|
||||||
|
for(int j = 0; j < 9; ++j)
|
||||||
|
this.addSlotToContainer(new Slot(inventory, 9 + j + i * 9, xOffset + j * 18, yOffset + i * 18));
|
||||||
|
|
||||||
|
for(int i = 0; i < 9; ++i)
|
||||||
|
this.addSlotToContainer(new Slot(inventory, i, xOffset + i * 18, yHotbar));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.oitsjustjose.criss_cross.GUI;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityCobblegen;
|
||||||
|
|
||||||
|
import com.oitsjustjose.criss_cross.Container.ContainerCobblegen;
|
||||||
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
|
||||||
|
public class GUICobblegen extends GuiContainer
|
||||||
|
{
|
||||||
|
public static final ResourceLocation texture = new ResourceLocation("crisscross", "textures/gui/cobblegen.png");
|
||||||
|
|
||||||
|
private TileEntityCobblegen cobblegen;
|
||||||
|
|
||||||
|
public GUICobblegen(EntityPlayer player, TileEntityCobblegen cobblegen)
|
||||||
|
{
|
||||||
|
super(new ContainerCobblegen(player, cobblegen));
|
||||||
|
this.cobblegen = cobblegen;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.cobblegen"), 30, 7, 4210752);
|
||||||
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 7, this.ySize - 92,
|
||||||
|
4210752);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
this.mc.renderEngine.bindTexture(texture);
|
||||||
|
int k = (this.width - this.xSize) / 2;
|
||||||
|
int l = (this.height - this.ySize) / 2;
|
||||||
|
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||||
|
|
||||||
|
if(this.cobblegen.isUsingFuel())
|
||||||
|
{
|
||||||
|
int i1 = this.cobblegen.getBurnTimeRemainingScaled(13);
|
||||||
|
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1);
|
||||||
|
i1 = this.cobblegen.getProgressScaled(24);
|
||||||
|
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,12 +2,16 @@ package com.oitsjustjose.criss_cross.GUI;
|
||||||
|
|
||||||
import com.oitsjustjose.criss_cross.Container.ContainerCropomator;
|
import com.oitsjustjose.criss_cross.Container.ContainerCropomator;
|
||||||
import com.oitsjustjose.criss_cross.Container.ContainerElectroextractor;
|
import com.oitsjustjose.criss_cross.Container.ContainerElectroextractor;
|
||||||
|
import com.oitsjustjose.criss_cross.Container.ContainerStonegen;
|
||||||
import com.oitsjustjose.criss_cross.Container.ContainerWoodchipper;
|
import com.oitsjustjose.criss_cross.Container.ContainerWoodchipper;
|
||||||
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityCobblegen;
|
||||||
import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator;
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityCropomator;
|
||||||
import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor;
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityElectroextractor;
|
||||||
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityStonegen;
|
||||||
import com.oitsjustjose.criss_cross.TileEntity.TileEntityWoodchipper;
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityWoodchipper;
|
||||||
|
|
||||||
import cpw.mods.fml.common.network.IGuiHandler;
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
|
import com.oitsjustjose.criss_cross.Container.ContainerCobblegen;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
@ -17,6 +21,8 @@ public class GUIHandler implements IGuiHandler
|
||||||
public static final int Cropomator = 1;
|
public static final int Cropomator = 1;
|
||||||
public static final int Electroextractor = 2;
|
public static final int Electroextractor = 2;
|
||||||
public static final int Woodchipper = 3;
|
public static final int Woodchipper = 3;
|
||||||
|
public static final int Cobblegen = 4;
|
||||||
|
public static final int Stonegen = 5;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||||
|
|
@ -41,6 +47,18 @@ public class GUIHandler implements IGuiHandler
|
||||||
|
|
||||||
return new ContainerWoodchipper(player, TE);
|
return new ContainerWoodchipper(player, TE);
|
||||||
}
|
}
|
||||||
|
if(tile instanceof TileEntityCobblegen)
|
||||||
|
{
|
||||||
|
TileEntityCobblegen TE = (TileEntityCobblegen) tile;
|
||||||
|
|
||||||
|
return new ContainerCobblegen(player, TE);
|
||||||
|
}
|
||||||
|
if(tile instanceof TileEntityStonegen)
|
||||||
|
{
|
||||||
|
TileEntityStonegen TE = (TileEntityStonegen) tile;
|
||||||
|
|
||||||
|
return new ContainerStonegen(player, TE);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -69,6 +87,18 @@ public class GUIHandler implements IGuiHandler
|
||||||
|
|
||||||
return new GUIWoodchipper(player, TE);
|
return new GUIWoodchipper(player, TE);
|
||||||
}
|
}
|
||||||
|
if(tile instanceof TileEntityCobblegen)
|
||||||
|
{
|
||||||
|
TileEntityCobblegen TE = (TileEntityCobblegen) tile;
|
||||||
|
|
||||||
|
return new GUICobblegen(player, TE);
|
||||||
|
}
|
||||||
|
if(tile instanceof TileEntityStonegen)
|
||||||
|
{
|
||||||
|
TileEntityStonegen TE = (TileEntityStonegen) tile;
|
||||||
|
|
||||||
|
return new GUIStonegen(player, TE);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.oitsjustjose.criss_cross.GUI;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityStonegen;
|
||||||
|
|
||||||
|
import com.oitsjustjose.criss_cross.Container.ContainerStonegen;
|
||||||
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
|
||||||
|
public class GUIStonegen extends GuiContainer
|
||||||
|
{
|
||||||
|
public static final ResourceLocation texture = new ResourceLocation("crisscross", "textures/gui/stonegen.png");
|
||||||
|
|
||||||
|
private TileEntityStonegen stonegen;
|
||||||
|
|
||||||
|
public GUIStonegen(EntityPlayer player, TileEntityStonegen stonegen)
|
||||||
|
{
|
||||||
|
super(new ContainerStonegen(player, stonegen));
|
||||||
|
this.stonegen = stonegen;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.stonegen"), 30, 7, 4210752);
|
||||||
|
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 7, this.ySize - 92,
|
||||||
|
4210752);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void drawGuiContainerBackgroundLayer(float partialTickTime, int mouseX, int mouseY)
|
||||||
|
{
|
||||||
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
this.mc.renderEngine.bindTexture(texture);
|
||||||
|
int k = (this.width - this.xSize) / 2;
|
||||||
|
int l = (this.height - this.ySize) / 2;
|
||||||
|
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||||
|
|
||||||
|
if(this.stonegen.isUsingFuel())
|
||||||
|
{
|
||||||
|
int i1 = this.stonegen.getBurnTimeRemainingScaled(13);
|
||||||
|
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 1);
|
||||||
|
i1 = this.stonegen.getProgressScaled(24);
|
||||||
|
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.oitsjustjose.criss_cross.Items;
|
package com.oitsjustjose.criss_cross.Items;
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
|
|
||||||
public class CCItems
|
public class CCItems
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,24 @@ public class CCCraftingRecipes
|
||||||
electroextractorRecipe();
|
electroextractorRecipe();
|
||||||
woodChipperRecipe();
|
woodChipperRecipe();
|
||||||
initBucketRecipes();
|
initBucketRecipes();
|
||||||
|
initBlockGeneratorRecipes();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void initBlockGeneratorRecipes()
|
||||||
|
{
|
||||||
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(CCBlocks.cobblegen),
|
||||||
|
"CPC",
|
||||||
|
"#$#",
|
||||||
|
"CPC",
|
||||||
|
'$', "blockIron", 'C', "cobblestone", 'P', Blocks.piston, '#', Items.stone_pickaxe
|
||||||
|
));
|
||||||
|
|
||||||
|
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(CCBlocks.stonegen),
|
||||||
|
"CPC",
|
||||||
|
"#$#",
|
||||||
|
"CPC",
|
||||||
|
'$', "blockIron", 'C', "stone", 'P', Blocks.piston, '#', Items.stone_pickaxe
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initBucketRecipes()
|
static void initBucketRecipes()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.oitsjustjose.criss_cross.Recipes;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.oitsjustjose.criss_cross.Items.CCItems;
|
||||||
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityCobblegen;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
|
||||||
|
public class CobblegenRecipes
|
||||||
|
{
|
||||||
|
private static final CobblegenRecipes recipeBase = new CobblegenRecipes();
|
||||||
|
private Map recipes = Maps.newHashMap();
|
||||||
|
|
||||||
|
public CobblegenRecipes()
|
||||||
|
{
|
||||||
|
this.addRecipe(new ItemStack(Items.lava_bucket), new ItemStack(Blocks.cobblestone));
|
||||||
|
TileEntityCobblegen.addFuel(new ItemStack(Items.water_bucket));
|
||||||
|
TileEntityCobblegen.addFuel(new ItemStack(CCItems.magicBucket));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CobblegenRecipes getInstance()
|
||||||
|
{
|
||||||
|
return recipeBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addRecipe(ItemStack input, ItemStack stack)
|
||||||
|
{
|
||||||
|
this.recipes.put(input, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getResult(ItemStack stack)
|
||||||
|
{
|
||||||
|
Iterator iterator = this.recipes.entrySet().iterator();
|
||||||
|
Entry entry;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if(!iterator.hasNext())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
entry = (Entry) iterator.next();
|
||||||
|
}
|
||||||
|
while(!this.compareItemStacks(stack, (ItemStack) entry.getKey()));
|
||||||
|
|
||||||
|
return (ItemStack) entry.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean compareItemStacks(ItemStack stack1, ItemStack stack2)
|
||||||
|
{
|
||||||
|
return stack2.getItem() == stack1.getItem()
|
||||||
|
&& (stack2.getItemDamage() == 32767 || stack2.getItemDamage() == stack1.getItemDamage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map getRecipeList()
|
||||||
|
{
|
||||||
|
return this.recipes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
package com.oitsjustjose.criss_cross.Recipes;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.oitsjustjose.criss_cross.Items.CCItems;
|
||||||
|
import com.oitsjustjose.criss_cross.TileEntity.TileEntityStonegen;
|
||||||
|
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class StonegenRecipes
|
||||||
|
{
|
||||||
|
private static final StonegenRecipes recipeBase = new StonegenRecipes();
|
||||||
|
private Map recipes = Maps.newHashMap();
|
||||||
|
|
||||||
|
public StonegenRecipes()
|
||||||
|
{
|
||||||
|
this.addRecipe(new ItemStack(Items.lava_bucket), new ItemStack(Blocks.stone));
|
||||||
|
TileEntityStonegen.addFuel(new ItemStack(Items.water_bucket));
|
||||||
|
TileEntityStonegen.addFuel(new ItemStack(CCItems.magicBucket));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StonegenRecipes getInstance()
|
||||||
|
{
|
||||||
|
return recipeBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addRecipe(ItemStack input, ItemStack stack)
|
||||||
|
{
|
||||||
|
this.recipes.put(input, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getResult(ItemStack stack)
|
||||||
|
{
|
||||||
|
Iterator iterator = this.recipes.entrySet().iterator();
|
||||||
|
Entry entry;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if(!iterator.hasNext())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
entry = (Entry) iterator.next();
|
||||||
|
}
|
||||||
|
while(!this.compareItemStacks(stack, (ItemStack) entry.getKey()));
|
||||||
|
|
||||||
|
return (ItemStack) entry.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean compareItemStacks(ItemStack stack1, ItemStack stack2)
|
||||||
|
{
|
||||||
|
return stack2.getItem() == stack1.getItem()
|
||||||
|
&& (stack2.getItemDamage() == 32767 || stack2.getItemDamage() == stack1.getItemDamage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map getRecipeList()
|
||||||
|
{
|
||||||
|
return this.recipes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,392 @@
|
||||||
|
package com.oitsjustjose.criss_cross.TileEntity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.oitsjustjose.criss_cross.Util.ConfigHandler;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import com.oitsjustjose.criss_cross.Blocks.BlockCobblegen;
|
||||||
|
import com.oitsjustjose.criss_cross.Recipes.CobblegenRecipes;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
|
public class TileEntityCobblegen extends TileEntity implements ISidedInventory
|
||||||
|
{
|
||||||
|
private static int proTicks = ConfigHandler.blockGeneratorProcessTimes;
|
||||||
|
private static final int[] slotsTop = new int[]
|
||||||
|
{
|
||||||
|
0
|
||||||
|
};
|
||||||
|
private static final int[] slotsBottom = new int[]
|
||||||
|
{
|
||||||
|
2, 1
|
||||||
|
};
|
||||||
|
private static final int[] slotsSides = new int[]
|
||||||
|
{
|
||||||
|
1
|
||||||
|
};
|
||||||
|
private static ArrayList<ItemStack> fuelItems = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
|
private ItemStack[] ItemStacks = new ItemStack[3];
|
||||||
|
|
||||||
|
public int fuelTime;
|
||||||
|
public int processTime;
|
||||||
|
public int fuelUsetime;
|
||||||
|
|
||||||
|
public static ArrayList<ItemStack> getFuels()
|
||||||
|
{
|
||||||
|
return fuelItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSizeInventory()
|
||||||
|
{
|
||||||
|
return this.ItemStacks.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlot(int slot)
|
||||||
|
{
|
||||||
|
return this.ItemStacks[slot];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack decrStackSize(int slot, int qtyToDecr)
|
||||||
|
{
|
||||||
|
if(this.ItemStacks[slot] != null)
|
||||||
|
{
|
||||||
|
ItemStack itemstack;
|
||||||
|
|
||||||
|
if(this.ItemStacks[slot].stackSize <= qtyToDecr)
|
||||||
|
{
|
||||||
|
itemstack = this.ItemStacks[slot];
|
||||||
|
this.ItemStacks[slot] = null;
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemstack = this.ItemStacks[slot].splitStack(qtyToDecr);
|
||||||
|
|
||||||
|
if(this.ItemStacks[slot].stackSize == 0)
|
||||||
|
{
|
||||||
|
this.ItemStacks[slot] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlotOnClosing(int slot)
|
||||||
|
{
|
||||||
|
if(this.ItemStacks[slot] != null)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = this.ItemStacks[slot];
|
||||||
|
this.ItemStacks[slot] = null;
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInventorySlotContents(int slot, ItemStack itemstack)
|
||||||
|
{
|
||||||
|
this.ItemStacks[slot] = itemstack;
|
||||||
|
|
||||||
|
if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit())
|
||||||
|
{
|
||||||
|
itemstack.stackSize = this.getInventoryStackLimit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInventoryName()
|
||||||
|
{
|
||||||
|
return "container.cobblegen";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCustomInventoryName()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound tag)
|
||||||
|
{
|
||||||
|
super.readFromNBT(tag);
|
||||||
|
NBTTagList nbttaglist = tag.getTagList("Items", 10);
|
||||||
|
this.ItemStacks = new ItemStack[this.getSizeInventory()];
|
||||||
|
|
||||||
|
for(int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||||
|
{
|
||||||
|
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||||
|
byte b0 = nbttagcompound1.getByte("Slot");
|
||||||
|
|
||||||
|
if(b0 >= 0 && b0 < this.ItemStacks.length)
|
||||||
|
{
|
||||||
|
this.ItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fuelTime = tag.getShort("FuelTime");
|
||||||
|
this.processTime = tag.getShort("WorkTime");
|
||||||
|
this.fuelUsetime = getItemBurnTime(this.ItemStacks[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound tag)
|
||||||
|
{
|
||||||
|
super.writeToNBT(tag);
|
||||||
|
tag.setShort("FuelTime", (short) this.fuelTime);
|
||||||
|
tag.setShort("WorkTime", (short) this.processTime);
|
||||||
|
NBTTagList nbttaglist = new NBTTagList();
|
||||||
|
|
||||||
|
for(int i = 0; i < this.ItemStacks.length; ++i)
|
||||||
|
{
|
||||||
|
if(this.ItemStacks[i] != null)
|
||||||
|
{
|
||||||
|
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||||
|
nbttagcompound1.setByte("Slot", (byte) i);
|
||||||
|
this.ItemStacks[i].writeToNBT(nbttagcompound1);
|
||||||
|
nbttaglist.appendTag(nbttagcompound1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tag.setTag("Items", nbttaglist);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInventoryStackLimit()
|
||||||
|
{
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int getProgressScaled(int par1)
|
||||||
|
{
|
||||||
|
return this.processTime * par1 / proTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int getBurnTimeRemainingScaled(int par1)
|
||||||
|
{
|
||||||
|
if(this.fuelUsetime == 0)
|
||||||
|
{
|
||||||
|
this.fuelUsetime = proTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.fuelTime * par1 / this.fuelUsetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUsingFuel()
|
||||||
|
{
|
||||||
|
return this.fuelTime > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateEntity()
|
||||||
|
{
|
||||||
|
boolean flag = this.fuelTime > 0;
|
||||||
|
boolean flag1 = false;
|
||||||
|
|
||||||
|
if(this.fuelTime > 0)
|
||||||
|
{
|
||||||
|
--this.fuelTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.worldObj.isRemote)
|
||||||
|
{
|
||||||
|
if(this.fuelTime != 0 || this.ItemStacks[1] != null && this.ItemStacks[0] != null)
|
||||||
|
{
|
||||||
|
if(this.fuelTime == 0 && this.canProcess())
|
||||||
|
{
|
||||||
|
this.fuelUsetime = this.fuelTime = getItemBurnTime(this.ItemStacks[1]);
|
||||||
|
|
||||||
|
if(this.fuelTime > 0)
|
||||||
|
{
|
||||||
|
flag1 = true;
|
||||||
|
|
||||||
|
if(this.ItemStacks[1] != null)
|
||||||
|
{
|
||||||
|
if(this.ItemStacks[1].stackSize == 0)
|
||||||
|
{
|
||||||
|
this.ItemStacks[1] = ItemStacks[1].getItem().getContainerItem(ItemStacks[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.isUsingFuel() && this.canProcess())
|
||||||
|
{
|
||||||
|
++this.processTime;
|
||||||
|
|
||||||
|
if(this.processTime == proTicks)
|
||||||
|
{
|
||||||
|
this.processTime = 0;
|
||||||
|
this.processItem();
|
||||||
|
flag1 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.processTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flag != this.fuelTime > 0)
|
||||||
|
{
|
||||||
|
flag1 = true;
|
||||||
|
BlockCobblegen.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord,
|
||||||
|
this.zCoord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flag1)
|
||||||
|
{
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canProcess()
|
||||||
|
{
|
||||||
|
ItemStack input = this.ItemStacks[0];
|
||||||
|
if(input != null)
|
||||||
|
{
|
||||||
|
ItemStack output = CobblegenRecipes.getInstance().getResult(input);
|
||||||
|
if(output == null)
|
||||||
|
return false;
|
||||||
|
ItemStack outputSlot = this.ItemStacks[2];
|
||||||
|
if(outputSlot == null)
|
||||||
|
return true;
|
||||||
|
if(!outputSlot.isItemEqual(output))
|
||||||
|
return false;
|
||||||
|
int result = outputSlot.stackSize + output.stackSize;
|
||||||
|
return result <= output.getMaxStackSize();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addFuel(ItemStack itemstack)
|
||||||
|
{
|
||||||
|
fuelItems.add(itemstack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean removeFuel(ItemStack itemstack)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < fuelItems.size(); i++)
|
||||||
|
{
|
||||||
|
if(fuelItems.get(i) == itemstack)
|
||||||
|
{
|
||||||
|
fuelItems.remove(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isValid(ItemStack itemstack)
|
||||||
|
{
|
||||||
|
if(CobblegenRecipes.getInstance().getResult(itemstack) != null)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processItem()
|
||||||
|
{
|
||||||
|
if(this.canProcess())
|
||||||
|
{
|
||||||
|
|
||||||
|
ItemStack input = ItemStacks[0];
|
||||||
|
ItemStack output = CobblegenRecipes.getInstance().getResult(input);
|
||||||
|
ItemStack outputSlot = ItemStacks[2];
|
||||||
|
if(outputSlot == null)
|
||||||
|
{
|
||||||
|
ItemStacks[2] = output.copy();
|
||||||
|
}
|
||||||
|
else if(outputSlot.isItemEqual(output))
|
||||||
|
{
|
||||||
|
outputSlot.stackSize += output.stackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(input.stackSize <= 0)
|
||||||
|
{
|
||||||
|
ItemStacks[0] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getItemBurnTime(ItemStack itemstack)
|
||||||
|
{
|
||||||
|
return isItemFuel(itemstack) ? proTicks : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isItemFuel(ItemStack itemstack)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < fuelItems.size(); i++)
|
||||||
|
{
|
||||||
|
ItemStack temp = fuelItems.get(i);
|
||||||
|
if(temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUseableByPlayer(EntityPlayer player)
|
||||||
|
{
|
||||||
|
|
||||||
|
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false
|
||||||
|
: player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D,
|
||||||
|
(double) this.zCoord + 0.5D) <= 64.0D;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openInventory()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeInventory()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
|
||||||
|
{
|
||||||
|
return slot == 2 ? false : (slot == 1 ? isItemFuel(itemstack) : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getAccessibleSlotsFromSide(int slot)
|
||||||
|
{
|
||||||
|
return slot == 0 ? slotsBottom : (slot == 1 ? slotsTop : slotsSides);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
|
||||||
|
{
|
||||||
|
return this.isItemValidForSlot(slot, itemstack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
|
||||||
|
{
|
||||||
|
return side != 0 || slot != 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void markDirty()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,393 @@
|
||||||
|
package com.oitsjustjose.criss_cross.TileEntity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.oitsjustjose.criss_cross.Blocks.BlockStonegen;
|
||||||
|
import com.oitsjustjose.criss_cross.Recipes.StonegenRecipes;
|
||||||
|
import com.oitsjustjose.criss_cross.Util.ConfigHandler;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
|
public class TileEntityStonegen extends TileEntity implements ISidedInventory
|
||||||
|
{
|
||||||
|
private static int proTicks = ConfigHandler.blockGeneratorProcessTimes;
|
||||||
|
private static final int[] slotsTop = new int[]
|
||||||
|
{
|
||||||
|
0
|
||||||
|
};
|
||||||
|
private static final int[] slotsBottom = new int[]
|
||||||
|
{
|
||||||
|
2, 1
|
||||||
|
};
|
||||||
|
private static final int[] slotsSides = new int[]
|
||||||
|
{
|
||||||
|
1
|
||||||
|
};
|
||||||
|
private static ArrayList<ItemStack> fuelItems = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
|
private ItemStack[] ItemStacks = new ItemStack[3];
|
||||||
|
|
||||||
|
public int fuelTime;
|
||||||
|
public int processTime;
|
||||||
|
public int fuelUsetime;
|
||||||
|
|
||||||
|
public static ArrayList<ItemStack> getFuels()
|
||||||
|
{
|
||||||
|
return fuelItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSizeInventory()
|
||||||
|
{
|
||||||
|
return this.ItemStacks.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlot(int slot)
|
||||||
|
{
|
||||||
|
return this.ItemStacks[slot];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack decrStackSize(int slot, int qtyToDecr)
|
||||||
|
{
|
||||||
|
if(this.ItemStacks[slot] != null)
|
||||||
|
{
|
||||||
|
ItemStack itemstack;
|
||||||
|
|
||||||
|
if(this.ItemStacks[slot].stackSize <= qtyToDecr)
|
||||||
|
{
|
||||||
|
itemstack = this.ItemStacks[slot];
|
||||||
|
this.ItemStacks[slot] = null;
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemstack = this.ItemStacks[slot].splitStack(qtyToDecr);
|
||||||
|
|
||||||
|
if(this.ItemStacks[slot].stackSize == 0)
|
||||||
|
{
|
||||||
|
this.ItemStacks[slot] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlotOnClosing(int slot)
|
||||||
|
{
|
||||||
|
if(this.ItemStacks[slot] != null)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = this.ItemStacks[slot];
|
||||||
|
this.ItemStacks[slot] = null;
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInventorySlotContents(int slot, ItemStack itemstack)
|
||||||
|
{
|
||||||
|
this.ItemStacks[slot] = itemstack;
|
||||||
|
|
||||||
|
if(itemstack != null && itemstack.stackSize > this.getInventoryStackLimit())
|
||||||
|
{
|
||||||
|
itemstack.stackSize = this.getInventoryStackLimit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInventoryName()
|
||||||
|
{
|
||||||
|
return "container.stonegen";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCustomInventoryName()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound tag)
|
||||||
|
{
|
||||||
|
super.readFromNBT(tag);
|
||||||
|
NBTTagList nbttaglist = tag.getTagList("Items", 10);
|
||||||
|
this.ItemStacks = new ItemStack[this.getSizeInventory()];
|
||||||
|
|
||||||
|
for(int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||||
|
{
|
||||||
|
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||||
|
byte b0 = nbttagcompound1.getByte("Slot");
|
||||||
|
|
||||||
|
if(b0 >= 0 && b0 < this.ItemStacks.length)
|
||||||
|
{
|
||||||
|
this.ItemStacks[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fuelTime = tag.getShort("FuelTime");
|
||||||
|
this.processTime = tag.getShort("WorkTime");
|
||||||
|
this.fuelUsetime = getItemBurnTime(this.ItemStacks[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound tag)
|
||||||
|
{
|
||||||
|
super.writeToNBT(tag);
|
||||||
|
tag.setShort("FuelTime", (short) this.fuelTime);
|
||||||
|
tag.setShort("WorkTime", (short) this.processTime);
|
||||||
|
NBTTagList nbttaglist = new NBTTagList();
|
||||||
|
|
||||||
|
for(int i = 0; i < this.ItemStacks.length; ++i)
|
||||||
|
{
|
||||||
|
if(this.ItemStacks[i] != null)
|
||||||
|
{
|
||||||
|
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||||
|
nbttagcompound1.setByte("Slot", (byte) i);
|
||||||
|
this.ItemStacks[i].writeToNBT(nbttagcompound1);
|
||||||
|
nbttaglist.appendTag(nbttagcompound1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tag.setTag("Items", nbttaglist);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getInventoryStackLimit()
|
||||||
|
{
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int getProgressScaled(int par1)
|
||||||
|
{
|
||||||
|
return this.processTime * par1 / proTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int getBurnTimeRemainingScaled(int par1)
|
||||||
|
{
|
||||||
|
if(this.fuelUsetime == 0)
|
||||||
|
{
|
||||||
|
this.fuelUsetime = proTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.fuelTime * par1 / this.fuelUsetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUsingFuel()
|
||||||
|
{
|
||||||
|
return this.fuelTime > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateEntity()
|
||||||
|
{
|
||||||
|
boolean flag = this.fuelTime > 0;
|
||||||
|
boolean flag1 = false;
|
||||||
|
|
||||||
|
if(this.fuelTime > 0)
|
||||||
|
{
|
||||||
|
--this.fuelTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.worldObj.isRemote)
|
||||||
|
{
|
||||||
|
if(this.fuelTime != 0 || this.ItemStacks[1] != null && this.ItemStacks[0] != null)
|
||||||
|
{
|
||||||
|
if(this.fuelTime == 0 && this.canProcess())
|
||||||
|
{
|
||||||
|
this.fuelUsetime = this.fuelTime = getItemBurnTime(this.ItemStacks[1]);
|
||||||
|
|
||||||
|
if(this.fuelTime > 0)
|
||||||
|
{
|
||||||
|
flag1 = true;
|
||||||
|
|
||||||
|
if(this.ItemStacks[1] != null)
|
||||||
|
{
|
||||||
|
--this.ItemStacks[1].stackSize;
|
||||||
|
|
||||||
|
if(this.ItemStacks[1].stackSize == 0)
|
||||||
|
{
|
||||||
|
this.ItemStacks[1] = ItemStacks[1].getItem().getContainerItem(ItemStacks[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.isUsingFuel() && this.canProcess())
|
||||||
|
{
|
||||||
|
++this.processTime;
|
||||||
|
|
||||||
|
if(this.processTime == proTicks)
|
||||||
|
{
|
||||||
|
this.processTime = 0;
|
||||||
|
this.processItem();
|
||||||
|
flag1 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.processTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flag != this.fuelTime > 0)
|
||||||
|
{
|
||||||
|
flag1 = true;
|
||||||
|
BlockStonegen.updateBlockState(this.fuelTime > 0, this.worldObj, this.xCoord, this.yCoord,
|
||||||
|
this.zCoord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flag1)
|
||||||
|
{
|
||||||
|
this.markDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canProcess()
|
||||||
|
{
|
||||||
|
ItemStack input = this.ItemStacks[0];
|
||||||
|
if(input != null)
|
||||||
|
{
|
||||||
|
ItemStack output = StonegenRecipes.getInstance().getResult(input);
|
||||||
|
if(output == null)
|
||||||
|
return false;
|
||||||
|
ItemStack outputSlot = this.ItemStacks[2];
|
||||||
|
if(outputSlot == null)
|
||||||
|
return true;
|
||||||
|
if(!outputSlot.isItemEqual(output))
|
||||||
|
return false;
|
||||||
|
int result = outputSlot.stackSize + output.stackSize;
|
||||||
|
return result <= output.getMaxStackSize();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addFuel(ItemStack itemstack)
|
||||||
|
{
|
||||||
|
fuelItems.add(itemstack);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean removeFuel(ItemStack itemstack)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < fuelItems.size(); i++)
|
||||||
|
{
|
||||||
|
if(fuelItems.get(i) == itemstack)
|
||||||
|
{
|
||||||
|
fuelItems.remove(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isValid(ItemStack itemstack)
|
||||||
|
{
|
||||||
|
if(StonegenRecipes.getInstance().getResult(itemstack) != null)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processItem()
|
||||||
|
{
|
||||||
|
if(this.canProcess())
|
||||||
|
{
|
||||||
|
|
||||||
|
ItemStack input = ItemStacks[0];
|
||||||
|
ItemStack output = StonegenRecipes.getInstance().getResult(input);
|
||||||
|
ItemStack outputSlot = ItemStacks[2];
|
||||||
|
if(outputSlot == null)
|
||||||
|
{
|
||||||
|
ItemStacks[2] = output.copy();
|
||||||
|
}
|
||||||
|
else if(outputSlot.isItemEqual(output))
|
||||||
|
{
|
||||||
|
outputSlot.stackSize += output.stackSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(input.stackSize <= 0)
|
||||||
|
{
|
||||||
|
ItemStacks[0] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getItemBurnTime(ItemStack itemstack)
|
||||||
|
{
|
||||||
|
return isItemFuel(itemstack) ? proTicks : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isItemFuel(ItemStack itemstack)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < fuelItems.size(); i++)
|
||||||
|
{
|
||||||
|
ItemStack temp = fuelItems.get(i);
|
||||||
|
if(temp.getItem() == itemstack.getItem() && temp.getItemDamage() == itemstack.getItemDamage())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUseableByPlayer(EntityPlayer player)
|
||||||
|
{
|
||||||
|
|
||||||
|
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false
|
||||||
|
: player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D,
|
||||||
|
(double) this.zCoord + 0.5D) <= 64.0D;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openInventory()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeInventory()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
|
||||||
|
{
|
||||||
|
return slot == 2 ? false : (slot == 1 ? isItemFuel(itemstack) : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getAccessibleSlotsFromSide(int slot)
|
||||||
|
{
|
||||||
|
return slot == 0 ? slotsBottom : (slot == 1 ? slotsTop : slotsSides);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canInsertItem(int slot, ItemStack itemstack, int side)
|
||||||
|
{
|
||||||
|
return this.isItemValidForSlot(slot, itemstack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canExtractItem(int slot, ItemStack itemstack, int side)
|
||||||
|
{
|
||||||
|
return side != 0 || slot != 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void markDirty()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -52,8 +52,7 @@ public class ConfigHandler
|
||||||
"minecraft:water_bucket", "minecraft:potion:0", "CrissCross:magicBucket:0"
|
"minecraft:water_bucket", "minecraft:potion:0", "CrissCross:magicBucket:0"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static int autosmithProcessTime;
|
public static int blockGeneratorProcessTimes;
|
||||||
public static String autosmithRecipeItem;
|
|
||||||
|
|
||||||
public static void init(File configFile)
|
public static void init(File configFile)
|
||||||
{
|
{
|
||||||
|
|
@ -134,12 +133,8 @@ public class ConfigHandler
|
||||||
|
|
||||||
|
|
||||||
//Autosmith's Configs
|
//Autosmith's Configs
|
||||||
autosmithProcessTime = config.getInt("Autosmith Process Time", config.CATEGORY_GENERAL, 200, 0, Short.MAX_VALUE,
|
blockGeneratorProcessTimes = config.getInt("Stone Generators' Process Times", config.CATEGORY_GENERAL, 20, 0, Short.MAX_VALUE,
|
||||||
"Control how many ticks it takes the Autosmith to process an item. Default is 200; furnaces are also 200.");
|
"Control how many ticks it takes a stone generator to process an item. Default is 20; furnaces are 200.");
|
||||||
|
|
||||||
autosmithRecipeItem = config.getString("Autosmith Crafting Item", config.CATEGORY_GENERAL,
|
|
||||||
"minecraft:diamond_block",
|
|
||||||
"This is the item located in the center of the crafting recipe for the Autosmith. Formatted as: <modid>:<item>:<meta> or <modid>:<item>.");
|
|
||||||
|
|
||||||
if(config.hasChanged())
|
if(config.hasChanged())
|
||||||
config.save();
|
config.save();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
tile.CrissCross.Cropomator.name=Cropomator
|
tile.CrissCross.Cropomator.name=Cropomator
|
||||||
tile.CrissCross.ElectroExtractor.name=ElectroExtractor
|
tile.CrissCross.ElectroExtractor.name=ElectroExtractor
|
||||||
tile.CrissCross.WoodChipper.name=Wood Chipper
|
tile.CrissCross.WoodChipper.name=Wood Chipper
|
||||||
|
tile.CrissCross.CobblestoneGenerator.name=Cobblestone Generator
|
||||||
|
tile.CrissCross.StoneGenerator.name=Smooth Stone Generator
|
||||||
|
|
||||||
|
|
||||||
#Items
|
#Items
|
||||||
#Dust Name Components
|
#Dust Name Components
|
||||||
|
|
@ -16,6 +19,8 @@ item.CrissCross.voidBucket.name=Insatiable Bucket
|
||||||
container.cropomator=Cropomator
|
container.cropomator=Cropomator
|
||||||
container.electroextractor=ElectroExtractor
|
container.electroextractor=ElectroExtractor
|
||||||
container.woodchipper=Wood Chipper
|
container.woodchipper=Wood Chipper
|
||||||
|
container.stonegen=Smooth Stone Generator
|
||||||
|
container.cobblegen=Cobblestone Generator
|
||||||
|
|
||||||
#NEI Integration
|
#NEI Integration
|
||||||
recipe.cropomatorfuel=Cropomator Fuels
|
recipe.cropomatorfuel=Cropomator Fuels
|
||||||
|
|
@ -24,6 +29,8 @@ recipe.electroextractor=ElectroExtractor
|
||||||
recipe.electroextractorfuel=ElectorExtractor Fuels
|
recipe.electroextractorfuel=ElectorExtractor Fuels
|
||||||
recipe.woodchipper=Wood Chipper
|
recipe.woodchipper=Wood Chipper
|
||||||
recipe.woodchipperfuel=Wood Chipper Fuels
|
recipe.woodchipperfuel=Wood Chipper Fuels
|
||||||
|
recipe.stonegen=Smooth Stone Generator
|
||||||
|
recipe.cobblegen=Cobblestone Generator
|
||||||
|
|
||||||
#Tab
|
#Tab
|
||||||
itemGroup.tabCrissCross=Criss Cross
|
itemGroup.tabCrissCross=Criss Cross
|
||||||
|
After Width: | Height: | Size: 403 B |
|
After Width: | Height: | Size: 6.2 KiB |
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"animation": {
|
||||||
|
"frametime": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 531 B |
|
After Width: | Height: | Size: 944 B |
|
After Width: | Height: | Size: 403 B |
|
After Width: | Height: | Size: 6.2 KiB |
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"animation": {
|
||||||
|
"frametime": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 531 B |
|
After Width: | Height: | Size: 944 B |
BIN
src/main/resources/assets/crisscross/textures/gui/cobblegen.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
src/main/resources/assets/crisscross/textures/gui/stonegen.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |