2015-08-29 14:33:25 +02:00
|
|
|
/*
|
|
|
|
* This file ("TileEntityCompost.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2015-11-02 20:55:19 +01:00
|
|
|
* © 2015 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2015-03-07 12:51:28 +01:00
|
|
|
package ellpeck.actuallyadditions.tile;
|
2015-02-09 17:25:05 +01:00
|
|
|
|
2015-03-07 12:51:28 +01:00
|
|
|
import ellpeck.actuallyadditions.items.InitItems;
|
|
|
|
import ellpeck.actuallyadditions.items.ItemFertilizer;
|
|
|
|
import ellpeck.actuallyadditions.items.ItemMisc;
|
|
|
|
import ellpeck.actuallyadditions.items.metalists.TheMiscItems;
|
2015-02-09 17:25:05 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
2015-02-17 16:15:16 +01:00
|
|
|
public class TileEntityCompost extends TileEntityInventoryBase{
|
2015-02-09 17:25:05 +01:00
|
|
|
|
2015-11-28 19:02:01 +01:00
|
|
|
public static final int AMOUNT = 10;
|
2015-12-01 19:48:09 +01:00
|
|
|
public int conversionTime;
|
2015-11-28 19:02:01 +01:00
|
|
|
|
2015-02-09 17:25:05 +01:00
|
|
|
public TileEntityCompost(){
|
2015-04-19 01:50:02 +02:00
|
|
|
super(1, "compost");
|
2015-02-09 17:25:05 +01:00
|
|
|
}
|
|
|
|
|
2015-02-20 22:45:33 +01:00
|
|
|
@Override
|
2015-02-17 16:15:16 +01:00
|
|
|
public void updateEntity(){
|
2015-11-18 23:11:24 +01:00
|
|
|
super.updateEntity();
|
2015-02-09 17:25:05 +01:00
|
|
|
if(!worldObj.isRemote){
|
2015-03-19 21:27:56 +01:00
|
|
|
boolean theFlag = this.conversionTime > 0;
|
2015-11-28 19:02:01 +01:00
|
|
|
if(this.slots[0] != null && !(this.slots[0].getItem() instanceof ItemFertilizer) && this.slots[0].stackSize >= AMOUNT){
|
2015-02-09 17:25:05 +01:00
|
|
|
this.conversionTime++;
|
2015-12-16 22:33:13 +01:00
|
|
|
if(this.conversionTime >= 2000){
|
2015-11-28 19:02:01 +01:00
|
|
|
this.slots[0] = new ItemStack(InitItems.itemFertilizer, AMOUNT);
|
2015-02-09 17:25:05 +01:00
|
|
|
this.conversionTime = 0;
|
|
|
|
}
|
|
|
|
}
|
2015-03-19 21:27:56 +01:00
|
|
|
if(theFlag != this.conversionTime > 0){
|
|
|
|
this.markDirty();
|
|
|
|
}
|
2015-02-09 17:25:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-22 00:04:48 +01:00
|
|
|
@Override
|
|
|
|
public boolean shouldSyncSlots(){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
@Override
|
2015-12-19 10:30:39 +01:00
|
|
|
public void writeSyncableNBT(NBTTagCompound compound, boolean sync){
|
2015-12-22 00:04:48 +01:00
|
|
|
super.writeSyncableNBT(compound, sync);
|
2015-12-19 10:30:39 +01:00
|
|
|
compound.setInteger("ConversionTime", this.conversionTime);
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
|
|
|
|
2015-03-07 02:23:31 +01:00
|
|
|
@Override
|
2015-12-19 10:30:39 +01:00
|
|
|
public void readSyncableNBT(NBTTagCompound compound, boolean sync){
|
|
|
|
super.readSyncableNBT(compound, sync);
|
|
|
|
this.conversionTime = compound.getInteger("ConversionTime");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getInventoryStackLimit(){
|
|
|
|
return AMOUNT;
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
|
|
|
return this.isItemValidForSlot(slot, stack);
|
|
|
|
}
|
|
|
|
|
2015-12-19 10:30:39 +01:00
|
|
|
@Override
|
|
|
|
public boolean isItemValidForSlot(int i, ItemStack stack){
|
|
|
|
return stack.getItem() instanceof ItemMisc && stack.getItemDamage() == TheMiscItems.MASHED_FOOD.ordinal();
|
|
|
|
}
|
|
|
|
|
2015-03-07 02:23:31 +01:00
|
|
|
@Override
|
|
|
|
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
|
|
|
return stack.getItem() instanceof ItemFertilizer;
|
|
|
|
}
|
2015-02-09 17:25:05 +01:00
|
|
|
}
|