Good changes coming!
This commit is contained in:
parent
c9bce2dc82
commit
265d71056e
10 changed files with 332 additions and 501 deletions
|
|
@ -32,7 +32,7 @@ public class CrissCross
|
|||
@Instance(Reference.modid)
|
||||
public static CrissCross instance;
|
||||
|
||||
@SidedProxy(clientSide = "com.oitsjustjose.criss_cross.Util.ClientProxy", serverSide = "com.oitsjustjose.criss_cross.Util.CommonProxy")
|
||||
@SidedProxy(clientSide = "com.oitsjustjose.criss_cross.util.ClientProxy", serverSide = "com.oitsjustjose.criss_cross.util.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@EventHandler
|
||||
|
|
|
|||
|
|
@ -5,11 +5,12 @@ import java.util.List;
|
|||
|
||||
import com.oitsjustjose.criss_cross.items.CCItems;
|
||||
import com.oitsjustjose.criss_cross.items.ItemDust;
|
||||
import com.oitsjustjose.criss_cross.tileentity.TileCobblegen;
|
||||
import com.oitsjustjose.criss_cross.tileentity.TileCropomator;
|
||||
import com.oitsjustjose.criss_cross.tileentity.TileElectroextractor;
|
||||
import com.oitsjustjose.criss_cross.tileentity.TileStonegen;
|
||||
import com.oitsjustjose.criss_cross.tileentity.TileWoodchipper;
|
||||
import com.oitsjustjose.criss_cross.util.CCLog;
|
||||
import com.oitsjustjose.criss_cross.util.ClientProxy;
|
||||
import com.oitsjustjose.criss_cross.util.ConfigHandler;
|
||||
import com.oitsjustjose.criss_cross.util.ItemHelper;
|
||||
|
||||
|
|
@ -18,7 +19,6 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
|
@ -37,7 +37,11 @@ public class CCMachineRecipes
|
|||
initElectroextractorOreDictionary();
|
||||
initWoodchipperFuels();
|
||||
initWoodchipperOreDictionary();
|
||||
|
||||
|
||||
TileStonegen.addFuel(new ItemStack(Items.water_bucket));
|
||||
TileStonegen.addFuel(new ItemStack(CCItems.buckets));
|
||||
TileCobblegen.addFuel(new ItemStack(Items.water_bucket));
|
||||
TileCobblegen.addFuel(new ItemStack(CCItems.buckets));
|
||||
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.diamond_ore), new ItemStack(Items.diamond, electroQTY));
|
||||
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.emerald_ore), new ItemStack(Items.emerald, electroQTY));
|
||||
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.coal_ore), new ItemStack(Items.coal, electroQTY));
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
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.TileCobblegen;
|
||||
import com.oitsjustjose.criss_cross.tileentity.TileStonegen;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
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));
|
||||
TileCobblegen.addFuel(new ItemStack(Items.water_bucket));
|
||||
TileCobblegen.addFuel(new ItemStack(CCItems.buckets));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
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.TileStonegen;
|
||||
|
||||
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));
|
||||
TileStonegen.addFuel(new ItemStack(Items.water_bucket));
|
||||
TileStonegen.addFuel(new ItemStack(CCItems.buckets));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,17 +2,27 @@ package com.oitsjustjose.criss_cross.tileentity;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.oitsjustjose.criss_cross.blocks.BlockCobblegen;
|
||||
import com.oitsjustjose.criss_cross.blocks.BlockStonegen;
|
||||
import com.oitsjustjose.criss_cross.container.ContainerCobblegen;
|
||||
import com.oitsjustjose.criss_cross.recipes.CobblegenRecipes;
|
||||
import com.oitsjustjose.criss_cross.util.ConfigHandler;
|
||||
import com.oitsjustjose.criss_cross.util.Reference;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntityLockable;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileCobblegen extends TileGeneric
|
||||
public class TileCobblegen extends TileEntityLockable implements ITickable, ISidedInventory
|
||||
{
|
||||
private static int proTicks = ConfigHandler.blockGeneratorProcessTimes;
|
||||
private static final int[] slotsTop = new int[] { 0 };
|
||||
|
|
@ -21,15 +31,10 @@ public class TileCobblegen extends TileGeneric
|
|||
private static ArrayList<ItemStack> fuelItems = new ArrayList<ItemStack>();
|
||||
private static String customName;
|
||||
private ItemStack[] ItemStacks = new ItemStack[3];
|
||||
|
||||
|
||||
public int fuelTime;
|
||||
public int processTime;
|
||||
public int fuelUsetime;
|
||||
|
||||
public TileCobblegen()
|
||||
{
|
||||
super("Cobblegen", proTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
|
|
@ -84,7 +89,7 @@ public class TileCobblegen extends TileGeneric
|
|||
if (flag != this.fuelTime > 0)
|
||||
{
|
||||
flag1 = true;
|
||||
BlockCobblegen.updateBlockState(this.fuelTime > 0, this.worldObj, this.pos);
|
||||
BlockStonegen.updateBlockState(this.fuelTime > 0, this.worldObj, this.pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,14 +99,179 @@ public class TileCobblegen extends TileGeneric
|
|||
}
|
||||
}
|
||||
|
||||
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 getGuiID()
|
||||
{
|
||||
return Reference.modid + ":container.cobblestonegen";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return this.customName != null && this.customName.length() > 0;
|
||||
}
|
||||
|
||||
public void setCustomInventoryName(String newName)
|
||||
{
|
||||
this.customName = newName;
|
||||
}
|
||||
|
||||
@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");
|
||||
if (this.ItemStacks[1] != null)
|
||||
this.fuelUsetime = getItemBurnTime(this.ItemStacks[1]);
|
||||
else
|
||||
this.fuelUsetime = 0;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
private boolean canProcess()
|
||||
{
|
||||
ItemStack input = this.ItemStacks[0];
|
||||
if (input != null)
|
||||
{
|
||||
ItemStack output = CobblegenRecipes.getInstance().getResult(input);
|
||||
if (output == null)
|
||||
return false;
|
||||
ItemStack output = new ItemStack(Blocks.cobblestone);
|
||||
ItemStack outputSlot = this.ItemStacks[2];
|
||||
if (outputSlot == null)
|
||||
return true;
|
||||
|
|
@ -113,9 +283,27 @@ public class TileCobblegen extends TileGeneric
|
|||
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)
|
||||
if (itemstack.getItem() == Items.lava_bucket)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -126,17 +314,16 @@ public class TileCobblegen extends TileGeneric
|
|||
{
|
||||
|
||||
ItemStack input = ItemStacks[0];
|
||||
ItemStack output = CobblegenRecipes.getInstance().getResult(input);
|
||||
ItemStack output = new ItemStack(Blocks.cobblestone);
|
||||
ItemStack outputSlot = ItemStacks[2];
|
||||
if (outputSlot == null)
|
||||
{
|
||||
ItemStacks[2] = output.copy();
|
||||
}
|
||||
else
|
||||
if (outputSlot.isItemEqual(output))
|
||||
{
|
||||
outputSlot.stackSize += output.stackSize;
|
||||
}
|
||||
else if (outputSlot.isItemEqual(output))
|
||||
{
|
||||
outputSlot.stackSize += output.stackSize;
|
||||
}
|
||||
|
||||
if (input.stackSize <= 0)
|
||||
{
|
||||
|
|
@ -145,10 +332,121 @@ public class TileCobblegen extends TileGeneric
|
|||
}
|
||||
}
|
||||
|
||||
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.pos) != this ? false : player.getDistanceSq((double) this.pos.getX() + 0.5D, (double) this.pos.getY() + 0.5D, (double) this.pos.getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
return this.fuelTime;
|
||||
case 1:
|
||||
return this.fuelUsetime;
|
||||
case 2:
|
||||
return this.processTime;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
this.fuelTime = value;
|
||||
break;
|
||||
case 1:
|
||||
this.fuelUsetime = value;
|
||||
break;
|
||||
case 2:
|
||||
this.processTime = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
for (int i = 0; i < this.ItemStacks.length; ++i)
|
||||
this.ItemStacks[i] = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandSenderName()
|
||||
{
|
||||
return this.hasCustomName() ? this.customName : "container.cobblegen";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn)
|
||||
{
|
||||
return new ContainerCobblegen(playerInventory.player, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
|
||||
{
|
||||
return slot == 2 ? false : (slot == 1 ? isItemFuel(itemstack) : true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
return side == EnumFacing.DOWN ? slotsBottom : (side == EnumFacing.UP ? slotsTop : slotsSides);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack itemstack, EnumFacing direction)
|
||||
{
|
||||
return this.isItemValidForSlot(slot, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack itemstack, EnumFacing direction)
|
||||
{
|
||||
return direction != EnumFacing.DOWN || slot != 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,343 +0,0 @@
|
|||
package com.oitsjustjose.criss_cross.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.oitsjustjose.criss_cross.util.Reference;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntityLockable;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class TileGeneric extends TileEntityLockable implements ITickable, ISidedInventory
|
||||
{
|
||||
private static int proTicks = 0;
|
||||
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 String defaultName;
|
||||
private static String customName;
|
||||
private ItemStack[] ItemStacks = new ItemStack[3];
|
||||
private static ArrayList<ItemStack> fuelItems = new ArrayList<ItemStack>();
|
||||
|
||||
public int fuelTime;
|
||||
public int processTime;
|
||||
public int fuelUsetime;
|
||||
|
||||
public TileGeneric(String tileName, int processTicks)
|
||||
{
|
||||
this.defaultName = tileName;
|
||||
this.proTicks = processTicks;
|
||||
|
||||
/*
|
||||
* Any Tile Entity extending this TE must implement its own update(),
|
||||
* canProcess(), isValid(), processItem(), and createContainer()
|
||||
*/
|
||||
}
|
||||
|
||||
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 getGuiID()
|
||||
{
|
||||
return Reference.modid + ":container." + this.defaultName.toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return this.customName != null && this.customName.length() > 0;
|
||||
}
|
||||
|
||||
public void setCustomInventoryName(String newName)
|
||||
{
|
||||
this.customName = newName;
|
||||
}
|
||||
|
||||
@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");
|
||||
if (this.ItemStacks[1] != null)
|
||||
this.fuelUsetime = getItemBurnTime(this.ItemStacks[1]);
|
||||
else
|
||||
this.fuelUsetime = 0;
|
||||
}
|
||||
|
||||
@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 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 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.pos) != this ? false
|
||||
: player.getDistanceSq((double) this.pos.getX() + 0.5D, (double) this.pos.getY() + 0.5D, (double) this.pos.getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
|
||||
{
|
||||
return slot == 2 ? false : (slot == 1 ? isItemFuel(itemstack) : true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side)
|
||||
{
|
||||
return side == EnumFacing.DOWN ? slotsBottom : (side == EnumFacing.UP ? slotsTop : slotsSides);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack itemstack, EnumFacing direction)
|
||||
{
|
||||
return this.isItemValidForSlot(slot, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack itemstack, EnumFacing direction)
|
||||
{
|
||||
return direction != EnumFacing.DOWN || slot != 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
return this.fuelTime;
|
||||
case 1:
|
||||
return this.fuelUsetime;
|
||||
case 2:
|
||||
return this.processTime;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 0:
|
||||
this.fuelTime = value;
|
||||
break;
|
||||
case 1:
|
||||
this.fuelUsetime = value;
|
||||
break;
|
||||
case 2:
|
||||
this.processTime = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
for (int i = 0; i < this.ItemStacks.length; ++i)
|
||||
this.ItemStacks[i] = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandSenderName()
|
||||
{
|
||||
return this.hasCustomName() ? this.customName : "container." + this.defaultName.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
|
@ -4,12 +4,13 @@ import java.util.ArrayList;
|
|||
|
||||
import com.oitsjustjose.criss_cross.blocks.BlockStonegen;
|
||||
import com.oitsjustjose.criss_cross.container.ContainerStonegen;
|
||||
import com.oitsjustjose.criss_cross.recipes.StonegenRecipes;
|
||||
import com.oitsjustjose.criss_cross.util.ConfigHandler;
|
||||
import com.oitsjustjose.criss_cross.util.Reference;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
|
@ -272,9 +273,7 @@ public class TileStonegen extends TileEntityLockable implements ITickable, ISide
|
|||
ItemStack input = this.ItemStacks[0];
|
||||
if (input != null)
|
||||
{
|
||||
ItemStack output = StonegenRecipes.getInstance().getResult(input);
|
||||
if (output == null)
|
||||
return false;
|
||||
ItemStack output = new ItemStack(Blocks.stone);
|
||||
ItemStack outputSlot = this.ItemStacks[2];
|
||||
if (outputSlot == null)
|
||||
return true;
|
||||
|
|
@ -306,7 +305,7 @@ public class TileStonegen extends TileEntityLockable implements ITickable, ISide
|
|||
|
||||
public static boolean isValid(ItemStack itemstack)
|
||||
{
|
||||
if (StonegenRecipes.getInstance().getResult(itemstack) != null)
|
||||
if (itemstack.getItem() == Items.lava_bucket)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -317,7 +316,7 @@ public class TileStonegen extends TileEntityLockable implements ITickable, ISide
|
|||
{
|
||||
|
||||
ItemStack input = ItemStacks[0];
|
||||
ItemStack output = StonegenRecipes.getInstance().getResult(input);
|
||||
ItemStack output = new ItemStack(Blocks.stone);
|
||||
ItemStack outputSlot = ItemStacks[2];
|
||||
if (outputSlot == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public class Reference
|
|||
{
|
||||
public static final String modid = "CrissCross";
|
||||
public static final String version = "1.3";
|
||||
public static final String guifactory = "com.oitsjustjose.criss_cross.GUI.GUIFactory";
|
||||
public static final String guifactory = "com.oitsjustjose.criss_cross.gui.GUIFactory";
|
||||
|
||||
private static final ArrayList<Item> allItems = new ArrayList<Item>();
|
||||
private static final ArrayList<Block> allBlocks = new ArrayList<Block>();
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 4.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 4.7 KiB |
Loading…
Reference in a new issue