mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-10-26 14:23:57 +00:00
More work on inventory stuff, and fix all the broken merge stuff
This commit is contained in:
1 parent
034cdf2860
commit
3636af5b9c
21 files changed
+352
-507
No files matched your search
@@ -17,18 +17,17 @@ import forestry.api.apiculture.IHiveFrame;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.apiculture.trigger.ApicultureTriggers;
|
||||
import forestry.core.gadgets.TileBase;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
public class TileApiary extends TileBeehouse {
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
@@ -43,6 +42,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
/* IBEEHOUSING */
|
||||
@Override
|
||||
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
float mod = 1.0f;
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
@@ -55,6 +55,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
float mod = 0.1f;
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
@@ -67,6 +68,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
float mod = 1.0f;
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
@@ -79,6 +81,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
float mod = 1.0f;
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
@@ -91,6 +94,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
float mod = 1f;
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
@@ -103,6 +107,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
float mod = 1f;
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
@@ -115,6 +120,7 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(int amount) {
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
int wear = Math.round(amount * PluginApiculture.beeInterface.getBeekeepingMode(worldObj).getWearModifier());
|
||||
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
@@ -130,128 +136,6 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
}
|
||||
}
|
||||
|
||||
/* IINVENTORY */
|
||||
@Override
|
||||
protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (!super.canTakeStackFromSide(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
switch (slotIndex) {
|
||||
case SLOT_QUEEN:
|
||||
case SLOT_DRONE:
|
||||
case SLOT_FRAMES_1:
|
||||
case SLOT_FRAMES_2:
|
||||
case SLOT_FRAMES_3:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (!super.canPutStackFromSide(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
if (slotIndex == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemstack)
|
||||
&& !PluginApiculture.beeInterface.isDrone(itemstack))
|
||||
return true;
|
||||
|
||||
if (slotIndex == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemstack))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return super.getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
super.setSlotContents(i, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
return inventory.decrStackSize(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return inventory.getStackInSlotOnClosing(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventory.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return super.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return super.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
return super.isItemValidForSlot(slotIndex, itemstack);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
|
||||
return super.canInsertItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
return super.canExtractItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return super.getAccessibleSlotsFromSide(side);
|
||||
}
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
// @Override
|
||||
// public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
|
||||
|
||||
@@ -29,18 +29,19 @@ import forestry.core.network.PacketIds;
|
||||
import forestry.core.network.PacketInventoryStack;
|
||||
import forestry.core.network.PacketTileUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised, ISidedInventory {
|
||||
|
||||
// CONSTANTS
|
||||
public static final int SLOT_QUEEN = 0;
|
||||
@@ -53,9 +54,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public static final int SLOT_FRAMES_3 = 11;
|
||||
public static final int SLOT_INVENTORY_COUNT = 7;
|
||||
public static final int SLOT_FRAMES_COUNT = 3;
|
||||
|
||||
// Inventory
|
||||
protected final InventoryAdapter inventory = new InventoryAdapter(12, "Items");
|
||||
private final IBeekeepingLogic logic;
|
||||
private BiomeGenBase biome;
|
||||
private int displayHealthMax = 0;
|
||||
@@ -64,6 +62,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public TileBeehouse() {
|
||||
setHints(Config.hints.get("apiary"));
|
||||
logic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
|
||||
setInternalInventory(new TileInventoryAdapter(this, 12, "Items"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,8 +76,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound.setInteger("BiomeId", biome.biomeID);
|
||||
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
if (logic != null)
|
||||
logic.writeToNBT(nbttagcompound);
|
||||
}
|
||||
@@ -89,8 +86,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
int biomeId = nbttagcompound.getInteger("BiomeId");
|
||||
biome = BiomeGenBase.getBiome(biomeId);
|
||||
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
logic.readFromNBT(nbttagcompound);
|
||||
|
||||
}
|
||||
@@ -137,12 +132,11 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public void updateClientSide() {
|
||||
|
||||
// / Multiplayer FX
|
||||
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
|
||||
if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN)))
|
||||
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) {
|
||||
IBee displayQueen = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN));
|
||||
IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN));
|
||||
displayQueen.doFX(logic.getEffectData(), this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -157,7 +151,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
// Add swarm effects
|
||||
if (worldObj.getTotalWorldTime() % 200 * 10 == 0)
|
||||
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
|
||||
onQueenChange(getInternalInventory().getStackInSlot(SLOT_QUEEN));
|
||||
/* These should get already done on the client / doesn't work server-side anyway
|
||||
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0)
|
||||
queen.doFX(logic.getEffectData(), this);
|
||||
@@ -184,7 +178,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
@Override
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
return inventory.tryAddStack(product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true);
|
||||
return getInternalInventory().tryAddStack(product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true);
|
||||
}
|
||||
|
||||
/* NETWORK SYNCH */
|
||||
@@ -200,6 +194,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
/* STATE INFORMATION */
|
||||
private int getHealthDisplay() {
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
if (inventory.getStackInSlot(SLOT_QUEEN) == null)
|
||||
return 0;
|
||||
|
||||
@@ -212,6 +207,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
}
|
||||
|
||||
private int getMaxHealthDisplay() {
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
if (inventory.getStackInSlot(SLOT_QUEEN) == null)
|
||||
return 0;
|
||||
|
||||
@@ -281,16 +277,95 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
/* INVENTORY MANAGMENT */
|
||||
@Override
|
||||
public InventoryAdapter getInternalInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return inventory.getStackInSlot(i);
|
||||
return getInternalInventory().getStackInSlot(i);
|
||||
}
|
||||
|
||||
public void setSlotContents(int i, ItemStack itemstack) {
|
||||
inventory.setInventorySlotContents(i, itemstack);
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return getInternalInventory().getAccessibleSlotsFromSide(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return getInternalInventory().getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotIndex, int amount) {
|
||||
return getInternalInventory().decrStackSize(slotIndex, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slotIndex) {
|
||||
return getInternalInventory().getStackInSlotOnClosing(slotIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack stack) {
|
||||
getInternalInventory().setInventorySlotContents(slotIndex, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return getInternalInventory().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return getInternalInventory().isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack))
|
||||
return false;
|
||||
|
||||
if (slotIndex == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemstack)
|
||||
&& !PluginApiculture.beeInterface.isDrone(itemstack))
|
||||
return true;
|
||||
|
||||
return slotIndex == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (!getInternalInventory().canExtractItem(side, itemstack, side))
|
||||
return false;
|
||||
|
||||
switch (slotIndex) {
|
||||
case SLOT_QUEEN:
|
||||
case SLOT_DRONE:
|
||||
case SLOT_FRAMES_1:
|
||||
case SLOT_FRAMES_2:
|
||||
case SLOT_FRAMES_3:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack stack, int side) {
|
||||
return isItemValidForSlot(slotIndex, stack);
|
||||
}
|
||||
|
||||
// / IBEEHOUSING
|
||||
@@ -331,12 +406,12 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
@Override
|
||||
public void setQueen(ItemStack itemstack) {
|
||||
setSlotContents(SLOT_QUEEN, itemstack);
|
||||
setInventorySlotContents(SLOT_QUEEN, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrone(ItemStack itemstack) {
|
||||
setSlotContents(SLOT_DRONE, itemstack);
|
||||
setInventorySlotContents(SLOT_DRONE, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -430,10 +505,11 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public boolean onEggLaid(IBee queen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* IHousing */
|
||||
@Override
|
||||
public GameProfile getOwnerName() {
|
||||
return this.getOwnerProfile();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -276,19 +276,19 @@ public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
|
||||
if (tile instanceof TileBeehouse) {
|
||||
TileBeehouse apiary = ((TileBeehouse) tile);
|
||||
apiary.initialize();
|
||||
apiary.setSlotContents(TileBeehouse.SLOT_QUEEN,
|
||||
apiary.setInventorySlotContents(TileBeehouse.SLOT_QUEEN,
|
||||
PluginApiculture.beeInterface.getMemberStack(getVillageBee(world, xCoord, yCoord, zCoord), EnumBeeType.PRINCESS.ordinal()));
|
||||
apiary.setSlotContents(TileBeehouse.SLOT_DRONE,
|
||||
apiary.setInventorySlotContents(TileBeehouse.SLOT_DRONE,
|
||||
PluginApiculture.beeInterface.getMemberStack(getVillageBee(world, xCoord, yCoord, zCoord), EnumBeeType.DRONE.ordinal()));
|
||||
|
||||
for (int i = TileBeehouse.SLOT_FRAMES_1; i < TileBeehouse.SLOT_FRAMES_1 + TileBeehouse.SLOT_FRAMES_COUNT; i++) {
|
||||
float roll = world.rand.nextFloat();
|
||||
if (roll < 0.2f)
|
||||
apiary.setSlotContents(i, ForestryItem.frameUntreated.getItemStack());
|
||||
apiary.setInventorySlotContents(i, ForestryItem.frameUntreated.getItemStack());
|
||||
else if (roll < 0.4f)
|
||||
apiary.setSlotContents(i, ForestryItem.frameImpregnated.getItemStack());
|
||||
apiary.setInventorySlotContents(i, ForestryItem.frameImpregnated.getItemStack());
|
||||
else if (roll < 0.6)
|
||||
apiary.setSlotContents(i, ForestryItem.frameProven.getItemStack());
|
||||
apiary.setInventorySlotContents(i, ForestryItem.frameProven.getItemStack());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gadgets;
|
||||
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -65,6 +64,6 @@ public abstract class BlockForestry extends BlockContainer {
|
||||
|
||||
TileForestry tile = (TileForestry) world.getTileEntity(i, j, k);
|
||||
if (entityliving instanceof EntityPlayer)
|
||||
tile.owner = ((EntityPlayer) entityliving).getGameProfile();
|
||||
tile.setOwner(((EntityPlayer) entityliving));
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,6 @@ import forestry.core.network.PacketTileNBT;
|
||||
import forestry.core.network.PacketTileUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.utils.Utils;
|
||||
|
||||
@@ -44,14 +42,14 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
|
||||
|
||||
/* MEMBER */
|
||||
private final NaturalistGame game = new NaturalistGame();
|
||||
private final InventoryAdapter inventory;
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
public TileEscritoire() {
|
||||
inventory = new TileInventoryAdapter(this, 12, "Items");
|
||||
setInternalInventory(new TileInventoryAdapter(this, 12, "Items"));
|
||||
}
|
||||
|
||||
/* GUI */
|
||||
@@ -66,7 +64,6 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
game.writeToNBT(nbttagcompound);
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,7 +71,6 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
game.readFromNBT(nbttagcompound);
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
/* GAME */
|
||||
@@ -83,42 +79,43 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
|
||||
}
|
||||
|
||||
public void processTurnResult(GameProfile gameProfile) {
|
||||
if(!game.isWon())
|
||||
if (!game.isWon())
|
||||
return;
|
||||
|
||||
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(inventory.getStackInSlot(SLOT_ANALYZE));
|
||||
if(individual == null)
|
||||
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(getInternalInventory().getStackInSlot(SLOT_ANALYZE));
|
||||
if (individual == null)
|
||||
return;
|
||||
|
||||
for(ItemStack itemstack : individual.getGenome().getPrimary().getResearchBounty(worldObj, gameProfile, individual, game.getBountyLevel()))
|
||||
inventory.addStack(itemstack, SLOT_RESULTS_1, SLOTS_RESULTS_COUNT, false, true);
|
||||
for (ItemStack itemstack : individual.getGenome().getPrimary().getResearchBounty(worldObj, gameProfile, individual, game.getBountyLevel())) {
|
||||
getInternalInventory().addStack(itemstack, SLOT_RESULTS_1, SLOTS_RESULTS_COUNT, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean areProbeSlotsFilled() {
|
||||
int filledSlots = 0;
|
||||
int required = game.getSampleSize() < SLOTS_INPUT_COUNT ? game.getSampleSize() : SLOTS_INPUT_COUNT;
|
||||
for(int i = SLOT_INPUT_1; i < SLOT_INPUT_1 + required; i++)
|
||||
if(inventory.getStackInSlot(i) != null)
|
||||
for (int i = SLOT_INPUT_1; i < SLOT_INPUT_1 + required; i++) {
|
||||
if (getInternalInventory().getStackInSlot(i) != null)
|
||||
filledSlots++;
|
||||
}
|
||||
|
||||
return filledSlots >= required;
|
||||
}
|
||||
|
||||
public void probe() {
|
||||
if (!worldObj.isRemote && inventory.getStackInSlot(SLOT_ANALYZE) != null && areProbeSlotsFilled()) {
|
||||
game.probe(inventory.getStackInSlot(SLOT_ANALYZE), this, SLOT_INPUT_1, SLOTS_INPUT_COUNT);
|
||||
}
|
||||
if (!worldObj.isRemote && getInternalInventory().getStackInSlot(SLOT_ANALYZE) != null && areProbeSlotsFilled())
|
||||
game.probe(getInternalInventory().getStackInSlot(SLOT_ANALYZE), this, SLOT_INPUT_1, SLOTS_INPUT_COUNT);
|
||||
}
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
public void fromPacket(ForestryPacket packetRaw) {
|
||||
if(packetRaw instanceof PacketTileUpdate) {
|
||||
if (packetRaw instanceof PacketTileUpdate) {
|
||||
super.fromPacket(packetRaw);
|
||||
return;
|
||||
}
|
||||
|
||||
PacketTileNBT packet = (PacketTileNBT)packetRaw;
|
||||
PacketTileNBT packet = (PacketTileNBT) packetRaw;
|
||||
readFromNBT(packet.getTagCompound());
|
||||
}
|
||||
|
||||
@@ -127,97 +124,89 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
|
||||
}
|
||||
|
||||
/* ISIDEDINVENTORY */
|
||||
@Override
|
||||
public InventoryAdapter getInternalInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
if(slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + SLOTS_INPUT_COUNT)
|
||||
return slotIndex < SLOT_INPUT_1 + game.getSampleSize();
|
||||
if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack))
|
||||
if (slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + SLOTS_INPUT_COUNT)
|
||||
return slotIndex < SLOT_INPUT_1 + Math.min(game.getSampleSize(), SLOTS_INPUT_COUNT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
if(!super.canTakeStackFromSide(slotIndex, itemstack, side))
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
return slotIndex >= SLOT_RESULTS_1 && slotIndex < SLOT_RESULTS_1 + SLOTS_RESULTS_COUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
|
||||
if(!super.canPutStackFromSide(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
int samples = game.getSampleSize();
|
||||
return slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + (samples < SLOTS_INPUT_COUNT ? samples : SLOTS_INPUT_COUNT);
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return isItemValidForSlot(slotIndex, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
inventory.setInventorySlotContents(slotIndex, itemstack);
|
||||
if(slotIndex == SLOT_ANALYZE && Proxies.common.isSimulating(worldObj)) {
|
||||
if(!AlleleManager.alleleRegistry.isIndividual(inventory.getStackInSlot(SLOT_ANALYZE))
|
||||
if (slotIndex == SLOT_ANALYZE && Proxies.common.isSimulating(worldObj)) {
|
||||
if (!AlleleManager.alleleRegistry.isIndividual(inventory.getStackInSlot(SLOT_ANALYZE))
|
||||
&& inventory.getStackInSlot(SLOT_ANALYZE) != null) {
|
||||
ItemStack ersatz = Utils.convertSaplingToGeneticEquivalent(inventory.getStackInSlot(SLOT_ANALYZE));
|
||||
if(ersatz != null)
|
||||
if (ersatz != null)
|
||||
inventory.setInventorySlotContents(SLOT_ANALYZE, ersatz);
|
||||
}
|
||||
game.initialize(inventory.getStackInSlot(SLOT_ANALYZE));
|
||||
}
|
||||
}
|
||||
|
||||
@Override public int getSizeInventory() { return inventory.getSizeInventory(); }
|
||||
@Override public ItemStack getStackInSlot(int i) { return inventory.getStackInSlot(i); }
|
||||
@Override public ItemStack decrStackSize(int i, int j) { return inventory.decrStackSize(i, j); }
|
||||
@Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); }
|
||||
@Override public ItemStack getStackInSlotOnClosing(int slot) { return inventory.getStackInSlotOnClosing(slot); }
|
||||
@Override public void openInventory() {}
|
||||
@Override public void closeInventory() {}
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return getInternalInventory().getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return getInternalInventory().getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
return getInternalInventory().decrStackSize(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return getInternalInventory().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return getInternalInventory().getStackInSlotOnClosing(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return super.isUseableByPlayer(player);
|
||||
return getInternalInventory().isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return super.hasCustomInventoryName();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
|
||||
return super.canInsertItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
return super.canExtractItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return super.getAccessibleSlotsFromSide(side);
|
||||
return getInternalInventory().getAccessibleSlotsFromSide(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -232,7 +221,7 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
|
||||
|
||||
@Override
|
||||
public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) {
|
||||
if(slotIndex == SLOT_ANALYZE)
|
||||
if (slotIndex == SLOT_ANALYZE)
|
||||
game.reset();
|
||||
return null;
|
||||
}
|
||||
@@ -247,5 +236,4 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import forestry.core.network.PacketTileUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.EnumAccess;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import forestry.core.utils.Vect;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -87,8 +88,9 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
|
||||
if(inventory != null) inventory.readFromNBT(data);
|
||||
|
||||
if (inventory != null)
|
||||
inventory.readFromNBT(data);
|
||||
|
||||
if (data.hasKey("Access"))
|
||||
access = EnumAccess.values()[data.getInteger("Access")];
|
||||
@@ -107,7 +109,8 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
if(inventory != null) inventory.writeToNBT(data);
|
||||
if (inventory != null)
|
||||
inventory.writeToNBT(data);
|
||||
data.setInteger("Access", access.ordinal());
|
||||
if (this.owner != null) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
@@ -264,10 +267,9 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
|
||||
@Override
|
||||
public boolean isOwner(EntityPlayer player) {
|
||||
if (owner != null)
|
||||
return owner.getId().compareTo(player.getPersistentID()) == 0;
|
||||
else
|
||||
return false;
|
||||
if (owner != null && player != null)
|
||||
return PlayerUtil.isSameGameProfile(owner, player.getGameProfile());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,6 @@ import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.GuiHandler;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.gui.IPagedInventory;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public abstract class TileNaturalistChest extends TileBase implements IInventory, IPagedInventory {
|
||||
|
||||
@@ -157,19 +156,13 @@ public abstract class TileNaturalistChest extends TileBase implements IInventory
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return super.isUseableByPlayer(player);
|
||||
return getInternalInventory().isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return super.hasCustomInventoryName();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -30,9 +30,9 @@ public class ContainerForestry extends Container {
|
||||
public ContainerForestry(IInventory inventory) {
|
||||
this.inventory = inventory;
|
||||
if (inventory instanceof TileForestry)
|
||||
this.inventoryForestry = (TileForestry)inventory;
|
||||
this.inventoryForestry = (TileForestry) inventory;
|
||||
else
|
||||
this.inventoryForestry = null;
|
||||
this.inventoryForestry = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,16 +50,15 @@ public class ContainerForestry extends Container {
|
||||
return null;
|
||||
|
||||
if ((inventoryForestry != null) && (inventoryForestry.getAccess() != EnumAccess.SHARED))
|
||||
if ((inventoryForestry.owner != null) && !PlayerUtil.isSameGameProfile(inventoryForestry.owner, player.getGameProfile()))
|
||||
if (!inventoryForestry.isOwner(player))
|
||||
return null;
|
||||
|
||||
Slot slot = slotIndex < 0 ? null : (Slot) this.inventorySlots.get(slotIndex);
|
||||
if (slot instanceof SlotForestry) {
|
||||
((SlotForestry) slot).onSlotClick(slotIndex, button, modifier, player);
|
||||
|
||||
if (((SlotForestry) slot).isPhantom()) {
|
||||
if (((SlotForestry) slot).isPhantom())
|
||||
return slotClickPhantom(slot, button, modifier, player);
|
||||
}
|
||||
}
|
||||
return super.slotClick(slotIndex, button, modifier, player);
|
||||
}
|
||||
|
||||
@@ -47,12 +47,12 @@ public class TileInventoryAdapter extends InventoryAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
return tile.getAccess() == EnumAccess.SHARED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side) {
|
||||
public boolean canExtractItem(int slotIndex, ItemStack stack, int side) {
|
||||
return tile.getAccess() == EnumAccess.SHARED;
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class PacketTileUpdate extends PacketUpdate {
|
||||
|
||||
isOwnable = tile.isOwnable();
|
||||
access = tile.getAccess();
|
||||
owner = tile.owner;
|
||||
owner = tile.getOwnerProfile();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,6 @@ import forestry.core.gadgets.Engine;
|
||||
import forestry.core.gadgets.TileBase;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.factory.triggers.FactoryTriggers;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -56,14 +55,12 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
private int ashProduction;
|
||||
private final int ashForItem;
|
||||
|
||||
private final TileInventoryAdapter inventory;
|
||||
|
||||
public EngineCopper() {
|
||||
super(Defaults.ENGINE_COPPER_HEAT_MAX, 200000, 4000);
|
||||
setHints(Config.hints.get("engine.copper"));
|
||||
|
||||
ashForItem = Defaults.ENGINE_COPPER_ASH_FOR_ITEM;
|
||||
inventory = new TileInventoryAdapter(this, 5, "Items");
|
||||
setInternalInventory(new TileInventoryAdapter(this, 5, "Items"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,7 +69,7 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
}
|
||||
|
||||
private int getFuelSlot() {
|
||||
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
if (inventory.getStackInSlot(SLOT_FUEL) == null)
|
||||
return -1;
|
||||
|
||||
@@ -83,7 +80,7 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
}
|
||||
|
||||
private int getFreeWasteSlot() {
|
||||
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
for (int i = SLOT_WASTE_1; i <= SLOT_WASTE_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
return i;
|
||||
@@ -99,7 +96,6 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
|
||||
super.updateServerSide();
|
||||
|
||||
if (worldObj.getTotalWorldTime() % 20 * 10 != 0)
|
||||
@@ -114,7 +110,7 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
}
|
||||
|
||||
int fuelSlot = getFuelSlot();
|
||||
if (fuelSlot >= 0 && determineBurnDuration(inventory.getStackInSlot(fuelSlot)) > 0)
|
||||
if (fuelSlot >= 0 && determineBurnDuration(getInternalInventory().getStackInSlot(fuelSlot)) > 0)
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
else
|
||||
setErrorState(EnumErrorCode.NOFUEL);
|
||||
@@ -138,6 +134,7 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
int wasteslot = getFreeWasteSlot();
|
||||
|
||||
if (fuelslot >= 0 && wasteslot >= 0) {
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
burnTime = totalBurnTime = determineBurnDuration(inventory.getStackInSlot(fuelslot));
|
||||
if (burnTime > 0) {
|
||||
fuelItem = inventory.getStackInSlot(fuelslot).getItem();
|
||||
@@ -188,11 +185,13 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
|
||||
// If we have reached the necessary amount, we need to add ash
|
||||
int wasteslot = getFreeWasteSlot();
|
||||
if (wasteslot >= 0)
|
||||
if (wasteslot >= 0) {
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
if (inventory.getStackInSlot(wasteslot) == null)
|
||||
inventory.setInventorySlotContents(wasteslot, ForestryItem.ash.getItemStack());
|
||||
else
|
||||
inventory.getStackInSlot(wasteslot).stackSize++;
|
||||
}
|
||||
// Reset
|
||||
ashProduction = 0;
|
||||
// try to dump stash
|
||||
@@ -233,7 +232,7 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
}
|
||||
|
||||
private void dumpToPipe(ForgeDirection[] pipes) {
|
||||
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
for (int i = SLOT_WASTE_1; i < SLOT_WASTE_1 + SLOT_WASTE_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
continue;
|
||||
@@ -272,6 +271,7 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
if (fuelSlot < 0)
|
||||
return false;
|
||||
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
return ((float) inventory.getStackInSlot(fuelSlot).stackSize / (float) inventory.getStackInSlot(fuelSlot).getMaxStackSize()) > percentage;
|
||||
}
|
||||
|
||||
@@ -294,9 +294,6 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
totalBurnTime = nbttagcompound.getInteger("EngineTotalTime");
|
||||
if (nbttagcompound.hasKey("AshProduction"))
|
||||
ashProduction = nbttagcompound.getInteger("AshProduction");
|
||||
|
||||
// Fuel
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -314,8 +311,6 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
nbttagcompound.setInteger("EngineBurnTime", burnTime);
|
||||
nbttagcompound.setInteger("EngineTotalTime", totalBurnTime);
|
||||
nbttagcompound.setInteger("AshProduction", ashProduction);
|
||||
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
// / SMP GUI
|
||||
@@ -353,32 +348,32 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
// / IINVENTORY
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
return getInternalInventory().getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return inventory.getStackInSlot(i);
|
||||
return getInternalInventory().getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
inventory.setInventorySlotContents(i, itemstack);
|
||||
getInternalInventory().setInventorySlotContents(i, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
return inventory.decrStackSize(i, j);
|
||||
return getInternalInventory().decrStackSize(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return inventory.getStackInSlotOnClosing(slot);
|
||||
return getInternalInventory().getStackInSlotOnClosing(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventory.getInventoryStackLimit();
|
||||
return getInternalInventory().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -389,12 +384,9 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return super.isUseableByPlayer(player);
|
||||
return getInternalInventory().isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -402,69 +394,39 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return super.hasCustomInventoryName();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
return super.isItemValidForSlot(slotIndex, itemstack);
|
||||
if (!getInternalInventory().isItemValidForSlot(slotIndex, itemstack))
|
||||
return false;
|
||||
|
||||
return slotIndex == SLOT_FUEL && FuelManager.copperEngineFuel.containsKey(itemstack);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
|
||||
return super.canInsertItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
return super.canExtractItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return super.getAccessibleSlotsFromSide(side);
|
||||
}
|
||||
|
||||
/* ISIDEDINVENTORY */
|
||||
@Override
|
||||
public InventoryAdapter getInternalInventory() {
|
||||
return inventory;
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
|
||||
return isItemValidForSlot(xCoord, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (!super.canTakeStackFromSide(slotIndex, itemstack, side))
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (!getInternalInventory().canExtractItem(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
return slotIndex >= SLOT_WASTE_1 && slotIndex < SLOT_WASTE_1 + SLOT_WASTE_COUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (!super.canPutStackFromSide(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
return slotIndex == SLOT_FUEL && FuelManager.copperEngineFuel.containsKey(itemstack);
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return getInternalInventory().getAccessibleSlotsFromSide(side);
|
||||
}
|
||||
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
|
||||
@@ -33,11 +33,13 @@ import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.DelayTimer;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.plugins.PluginIC2;
|
||||
|
||||
public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
|
||||
protected static class EuConfig {
|
||||
|
||||
public int euForCycle;
|
||||
public int rfPerCycle;
|
||||
public int euStorage;
|
||||
@@ -51,7 +53,6 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
}
|
||||
|
||||
private final short batterySlot = 0;
|
||||
private final InventoryAdapter inventory = new InventoryAdapter(1, "electrical");
|
||||
private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets");
|
||||
private final EuConfig euConfig = new EuConfig(Defaults.ENGINE_TIN_EU_FOR_CYCLE, Defaults.ENGINE_TIN_ENERGY_PER_CYCLE, Defaults.ENGINE_TIN_MAX_EU_STORED);
|
||||
|
||||
@@ -63,7 +64,10 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
super(Defaults.ENGINE_TIN_HEAT_MAX, 100000, 4000);
|
||||
setHints(Config.hints.get("engine.tin"));
|
||||
|
||||
if (PluginIC2.instance.isAvailable()) ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3);
|
||||
setInternalInventory(new TileInventoryAdapter(this, 1, "electrical"));
|
||||
|
||||
if (PluginIC2.instance.isAvailable())
|
||||
ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,8 +80,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySink != null) ic2EnergySink.readFromNBT(nbttagcompound);
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
if (ic2EnergySink != null)
|
||||
ic2EnergySink.readFromNBT(nbttagcompound);
|
||||
sockets.readFromNBT(nbttagcompound);
|
||||
|
||||
ItemStack chip = sockets.getStackInSlot(0);
|
||||
@@ -92,21 +96,23 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySink != null) ic2EnergySink.writeToNBT(nbttagcompound);
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
if (ic2EnergySink != null)
|
||||
ic2EnergySink.writeToNBT(nbttagcompound);
|
||||
sockets.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (ic2EnergySink != null) ic2EnergySink.onChunkUnload();
|
||||
if (ic2EnergySink != null)
|
||||
ic2EnergySink.onChunkUnload();
|
||||
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (ic2EnergySink != null) ic2EnergySink.invalidate();
|
||||
if (ic2EnergySink != null)
|
||||
ic2EnergySink.invalidate();
|
||||
|
||||
super.invalidate();
|
||||
}
|
||||
@@ -162,7 +168,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
return;
|
||||
}
|
||||
|
||||
if (inventory.getStackInSlot(batterySlot) != null)
|
||||
if (getInternalInventory().getStackInSlot(batterySlot) != null)
|
||||
replenishFromBattery(batterySlot);
|
||||
|
||||
// Updating of gui delayed to prevent it from going crazy
|
||||
@@ -194,7 +200,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
if (!isActivated())
|
||||
return;
|
||||
|
||||
ic2EnergySink.discharge(inventory.getStackInSlot(slot), euConfig.euForCycle * 3);
|
||||
ic2EnergySink.discharge(getInternalInventory().getStackInSlot(slot), euConfig.euForCycle * 3);
|
||||
}
|
||||
|
||||
// / STATE INFORMATION
|
||||
@@ -204,7 +210,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
}
|
||||
|
||||
public int getStorageScaled(int i) {
|
||||
if (ic2EnergySink == null) return 0;
|
||||
if (ic2EnergySink == null)
|
||||
return 0;
|
||||
|
||||
return Math.min(i, (int) (ic2EnergySink.getEnergyStored() * i) / ic2EnergySink.getCapacity());
|
||||
}
|
||||
@@ -239,7 +246,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
heat = j;
|
||||
break;
|
||||
case 3:
|
||||
if (ic2EnergySink != null) ic2EnergySink.setEnergyStored(j);
|
||||
if (ic2EnergySink != null)
|
||||
ic2EnergySink.setEnergyStored(j);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -250,9 +258,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 0, currentOutput);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 1, energyManager.toPacketInt());
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 2, heat);
|
||||
if (ic2EnergySink != null) {
|
||||
if (ic2EnergySink != null)
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 3, (short) ic2EnergySink.getEnergyStored());
|
||||
}
|
||||
}
|
||||
|
||||
// / ENERGY CONFIG CHANGE
|
||||
@@ -261,38 +268,39 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
euConfig.rfPerCycle += rfChange;
|
||||
euConfig.euStorage += storageChange;
|
||||
|
||||
if (ic2EnergySink != null) ic2EnergySink.setCapacity(euConfig.euStorage);
|
||||
if (ic2EnergySink != null)
|
||||
ic2EnergySink.setCapacity(euConfig.euStorage);
|
||||
}
|
||||
|
||||
/* IINVENTORY */
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
return getInternalInventory().getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return inventory.getStackInSlot(i);
|
||||
return getInternalInventory().getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
return inventory.decrStackSize(i, j);
|
||||
return getInternalInventory().decrStackSize(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
inventory.setInventorySlotContents(i, itemstack);
|
||||
getInternalInventory().setInventorySlotContents(i, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventory.getInventoryStackLimit();
|
||||
return getInternalInventory().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return inventory.getStackInSlotOnClosing(slot);
|
||||
return getInternalInventory().getStackInSlotOnClosing(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -303,12 +311,9 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return super.isUseableByPlayer(player);
|
||||
return getInternalInventory().isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -316,21 +321,17 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return super.hasCustomInventoryName();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
return super.isItemValidForSlot(slotIndex, itemstack);
|
||||
return getInternalInventory().isItemValidForSlot(slotIndex, itemstack);
|
||||
}
|
||||
|
||||
//TODO: Add ISideInventory and clarify allowed items
|
||||
|
||||
/* ISOCKETABLE */
|
||||
@Override
|
||||
@@ -358,9 +359,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
}
|
||||
|
||||
sockets.setInventorySlotContents(slot, stack);
|
||||
if (stack == null) {
|
||||
if (stack == null)
|
||||
return;
|
||||
}
|
||||
|
||||
ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(stack);
|
||||
if (chipset != null)
|
||||
|
||||
@@ -24,7 +24,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import ic2.api.energy.prefab.BasicSource;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.fuels.GeneratorFuel;
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
@@ -38,14 +37,15 @@ import forestry.core.interfaces.IRenderableMachine;
|
||||
import forestry.core.network.EntityNetData;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.utils.LiquidHelper;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.plugins.PluginIC2;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
public class MachineGenerator extends TileBase implements ISpecialInventory, ILiquidTankContainer, IRenderableMachine {
|
||||
public class MachineGenerator extends TileBase implements ISidedInventory, ILiquidTankContainer, IRenderableMachine {
|
||||
|
||||
// / CONSTANTS
|
||||
public static final short SLOT_CAN = 0;
|
||||
@@ -56,18 +56,18 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
private final TankManager tankManager;
|
||||
private int tickCount = 0;
|
||||
|
||||
private final InventoryAdapter inventory = new InventoryAdapter(1, "Items");
|
||||
protected BasicSource ic2EnergySource;
|
||||
|
||||
public MachineGenerator() {
|
||||
setHints(Config.hints.get("generator"));
|
||||
|
||||
setInternalInventory(new TileInventoryAdapter(this, 1, "Items"));
|
||||
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FuelManager.generatorFuel.keySet());
|
||||
tankManager = new TankManager(resourceTank);
|
||||
|
||||
if (PluginIC2.instance.isAvailable()) {
|
||||
if (PluginIC2.instance.isAvailable())
|
||||
ic2EnergySource = new BasicSource(this, maxEnergy, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,40 +84,44 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySource != null) ic2EnergySource.writeToNBT(nbttagcompound);
|
||||
if (ic2EnergySource != null)
|
||||
ic2EnergySource.writeToNBT(nbttagcompound);
|
||||
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
if (ic2EnergySource != null) ic2EnergySource.readFromNBT(nbttagcompound);
|
||||
if (ic2EnergySource != null)
|
||||
ic2EnergySource.readFromNBT(nbttagcompound);
|
||||
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
if (ic2EnergySource != null) ic2EnergySource.onChunkUnload();
|
||||
if (ic2EnergySource != null)
|
||||
ic2EnergySource.onChunkUnload();
|
||||
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (ic2EnergySource != null) ic2EnergySource.invalidate();
|
||||
if (ic2EnergySource != null)
|
||||
ic2EnergySource.invalidate();
|
||||
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
|
||||
// Check inventory slots for fuel
|
||||
// Check if we have suitable items waiting in the item slot
|
||||
TileInventoryAdapter inventory = getInternalInventory();
|
||||
if (inventory.getStackInSlot(SLOT_CAN) != null) {
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN));
|
||||
if (container != null)
|
||||
@@ -140,8 +144,8 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
if (resourceTank.getFluidAmount() > 0) {
|
||||
GeneratorFuel fuel = FuelManager.generatorFuel.get(resourceTank.getFluid().getFluid());
|
||||
|
||||
if (resourceTank.getFluidAmount() >= fuel.fuelConsumed.amount &&
|
||||
ic2EnergySource.getFreeCapacity() >= fuel.eu) {
|
||||
if (resourceTank.getFluidAmount() >= fuel.fuelConsumed.amount
|
||||
&& ic2EnergySource.getFreeCapacity() >= fuel.eu) {
|
||||
ic2EnergySource.addEnergy(fuel.eu);
|
||||
this.tickCount++;
|
||||
|
||||
@@ -168,7 +172,8 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
}
|
||||
|
||||
public int getStoredScaled(int i) {
|
||||
if (ic2EnergySource == null) return 0;
|
||||
if (ic2EnergySource == null)
|
||||
return 0;
|
||||
|
||||
return (int) (ic2EnergySource.getEnergyStored() * i) / maxEnergy;
|
||||
}
|
||||
@@ -186,87 +191,95 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
int firstMessageId = tankManager.maxMessageId() + 1;
|
||||
if (i == firstMessageId) {
|
||||
if (ic2EnergySource != null) ic2EnergySource.setEnergyStored(j);
|
||||
}
|
||||
if (i == firstMessageId)
|
||||
if (ic2EnergySource != null)
|
||||
ic2EnergySource.setEnergyStored(j);
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
int firstMessageId = tankManager.maxMessageId() + 1;
|
||||
if (ic2EnergySource != null) {
|
||||
if (ic2EnergySource != null)
|
||||
iCrafting.sendProgressBarUpdate(container, firstMessageId, (short) ic2EnergySource.getEnergyStored());
|
||||
}
|
||||
}
|
||||
|
||||
/* IINVENTORY */
|
||||
@Override public ItemStack getStackInSlot(int i) { return inventory.getStackInSlot(i); }
|
||||
@Override public void setInventorySlotContents(int i, ItemStack itemstack) { inventory.setInventorySlotContents(i, itemstack); }
|
||||
@Override public int getSizeInventory() { return inventory.getSizeInventory(); }
|
||||
@Override public ItemStack decrStackSize(int i, int j) { return inventory.decrStackSize(i, j); }
|
||||
@Override public ItemStack getStackInSlotOnClosing(int slot) { return inventory.getStackInSlotOnClosing(slot); }
|
||||
@Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); }
|
||||
@Override public void openInventory() {}
|
||||
@Override public void closeInventory() {}
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return getInternalInventory().getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
getInternalInventory().setInventorySlotContents(i, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return getInternalInventory().getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
return getInternalInventory().decrStackSize(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return getInternalInventory().getStackInSlotOnClosing(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return getInternalInventory().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return super.isUseableByPlayer(player);
|
||||
return getInternalInventory().isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return super.hasCustomInventoryName();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
return super.isItemValidForSlot(slotIndex, itemstack);
|
||||
}
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack stack) {
|
||||
if (!getInternalInventory().isItemValidForSlot(slotIndex, stack))
|
||||
return false;
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
@Override
|
||||
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
|
||||
if (slotIndex == SLOT_CAN) {
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(stack);
|
||||
if (container == null)
|
||||
return false;
|
||||
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(stack);
|
||||
if (container == null)
|
||||
return 0;
|
||||
|
||||
if (container.fluid == null || !FuelManager.generatorFuel.containsKey(container.fluid.getFluid()))
|
||||
return 0;
|
||||
|
||||
if (inventory.getStackInSlot(SLOT_CAN) == null) {
|
||||
if (doAdd)
|
||||
inventory.setInventorySlotContents(SLOT_CAN, stack.copy());
|
||||
|
||||
return stack.stackSize;
|
||||
return container.fluid != null && FuelManager.generatorFuel.containsKey(container.fluid.getFluid());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!inventory.getStackInSlot(SLOT_CAN).isItemEqual(stack))
|
||||
return 0;
|
||||
|
||||
int space = inventory.getStackInSlot(SLOT_CAN).getMaxStackSize() - inventory.getStackInSlot(SLOT_CAN).stackSize;
|
||||
if (space <= 0)
|
||||
return 0;
|
||||
|
||||
if (doAdd)
|
||||
inventory.getStackInSlot(SLOT_CAN).stackSize += stack.stackSize;
|
||||
|
||||
return Math.min(space, stack.stackSize);
|
||||
|
||||
/* ISIDEDINVENTORY */
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack stack, int side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
|
||||
return null;
|
||||
public boolean canInsertItem(int slotIndex, ItemStack stack, int side) {
|
||||
return isItemValidForSlot(slotIndex, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return getInternalInventory().getAccessibleSlotsFromSide(side);
|
||||
}
|
||||
|
||||
/* ILiquidTankContainer */
|
||||
@@ -280,6 +293,7 @@ public class MachineGenerator extends TileBase implements ISpecialInventory, ILi
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@@ -10,26 +10,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.energy.gui;
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
import forestry.core.gui.ContainerLiquidTanks;
|
||||
import forestry.core.gui.slots.SlotLiquidContainer;
|
||||
import forestry.energy.gadgets.EngineBronze;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class ContainerEngineBronze extends ContainerLiquidTanks {
|
||||
<<<<<<< Updated upstream
|
||||
protected final EngineBronze engine;
|
||||
=======
|
||||
|
||||
protected EngineBronze engine;
|
||||
>>>>>>> Stashed changes
|
||||
protected final EngineBronze engine;
|
||||
|
||||
public ContainerEngineBronze(InventoryPlayer player, EngineBronze engine) {
|
||||
super(engine, engine);
|
||||
|
||||
@@ -17,14 +17,11 @@ import net.minecraft.inventory.Slot;
|
||||
import forestry.core.gui.ContainerForestry;
|
||||
import forestry.core.gui.slots.SlotClosed;
|
||||
import forestry.energy.gadgets.EngineCopper;
|
||||
import scala.collection.parallel.ParSeqLike.Updated;
|
||||
|
||||
public class ContainerEngineCopper extends ContainerForestry {
|
||||
<<<<<<< Updated upstream
|
||||
protected final EngineCopper engine;
|
||||
=======
|
||||
|
||||
protected EngineCopper engine;
|
||||
>>>>>>> Stashed changes
|
||||
protected final EngineCopper engine;
|
||||
|
||||
public ContainerEngineCopper(InventoryPlayer player, EngineCopper tile) {
|
||||
super(tile);
|
||||
@@ -59,14 +56,9 @@ public class ContainerEngineCopper extends ContainerForestry {
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
for (Object crafter : crafters)
|
||||
engine.sendGUINetworkData(this, (ICrafting) crafter);
|
||||
=======
|
||||
for (Object crafter : crafters) {
|
||||
engine.sendGUINetworkData(this, (ICrafting) crafter);
|
||||
}
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,16 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.energy.gui;
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
import forestry.core.gui.ContainerLiquidTanks;
|
||||
import forestry.core.gui.slots.SlotLiquidContainer;
|
||||
import forestry.energy.gadgets.MachineGenerator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
|
||||
@@ -10,17 +10,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.gui;
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
import forestry.core.gui.ContainerLiquidTanks;
|
||||
import forestry.core.gui.slots.SlotClosed;
|
||||
import forestry.core.gui.slots.SlotLiquidContainer;
|
||||
import forestry.factory.gadgets.MachineBottler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
|
||||
@@ -10,28 +10,17 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.gui;
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
=======
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
>>>>>>> Stashed changes
|
||||
import forestry.core.gui.ContainerLiquidTanks;
|
||||
import forestry.core.gui.slots.SlotCustom;
|
||||
import forestry.core.gui.slots.SlotLiquidContainer;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.factory.gadgets.MachineFermenter;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class ContainerFermenter extends ContainerLiquidTanks {
|
||||
<<<<<<< Updated upstream
|
||||
protected final MachineFermenter fermenter;
|
||||
=======
|
||||
|
||||
protected MachineFermenter fermenter;
|
||||
>>>>>>> Stashed changes
|
||||
protected final MachineFermenter fermenter;
|
||||
|
||||
public ContainerFermenter(InventoryPlayer player, MachineFermenter fermenter) {
|
||||
super(fermenter, fermenter);
|
||||
|
||||
@@ -108,19 +108,8 @@ public class MailAddress implements INBTTagable, IMailAddress {
|
||||
if (!(o instanceof MailAddress))
|
||||
return false;
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
MailAddress address = (MailAddress) o;
|
||||
return PlayerUtil.isSameGameProfile(address.gameProfile, gameProfile);
|
||||
=======
|
||||
MailAddress other = (MailAddress) o;
|
||||
return isSamePlayer(gameProfile, other.gameProfile);
|
||||
}
|
||||
|
||||
private static boolean isSamePlayer(GameProfile a, GameProfile b) {
|
||||
if (a.getId() != null && b.getId() != null)
|
||||
return a.getId().equals(b.getId());
|
||||
return a.getName() != null && a.getName().equals(b.getName());
|
||||
>>>>>>> Stashed changes
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,13 +35,8 @@ import forestry.plugins.PluginMail;
|
||||
public class PostRegistry implements IPostRegistry {
|
||||
|
||||
public static PostOffice cachedPostOffice;
|
||||
<<<<<<< Updated upstream
|
||||
public static final HashMap<IMailAddress, POBox> cachedPOBoxes = new HashMap<IMailAddress, POBox>();
|
||||
public static final HashMap<IMailAddress, ITradeStation> cachedTradeStations = new HashMap<IMailAddress, ITradeStation>();
|
||||
=======
|
||||
public static Map<IMailAddress, POBox> cachedPOBoxes = new HashMap<IMailAddress, POBox>();
|
||||
public static Map<IMailAddress, ITradeStation> cachedTradeStations = new HashMap<IMailAddress, ITradeStation>();
|
||||
>>>>>>> Stashed changes
|
||||
public static final Map<IMailAddress, POBox> cachedPOBoxes = new HashMap<IMailAddress, POBox>();
|
||||
public static final Map<IMailAddress, ITradeStation> cachedTradeStations = new HashMap<IMailAddress, ITradeStation>();
|
||||
|
||||
/**
|
||||
* @param world the Minecraft world the PO box will be in
|
||||
@@ -101,7 +96,7 @@ public class PostRegistry implements IPostRegistry {
|
||||
@Override
|
||||
public TradeStation getTradeStation(World world, IMailAddress address) {
|
||||
if (cachedTradeStations.containsKey(address))
|
||||
return (TradeStation)cachedTradeStations.get(address);
|
||||
return (TradeStation) cachedTradeStations.get(address);
|
||||
|
||||
TradeStation trade = (TradeStation) world.loadItemData(TradeStation.class, TradeStation.SAVE_NAME + address);
|
||||
|
||||
@@ -227,5 +222,4 @@ public class PostRegistry implements IPostRegistry {
|
||||
return ForestryItem.letters.isItemEqual(itemstack);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -43,29 +43,18 @@ public class ContainerTrader extends ContainerForestry {
|
||||
}
|
||||
|
||||
// Stamps
|
||||
<<<<<<< Updated upstream
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
addSlot(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, ItemStamps.class));
|
||||
|
||||
// Letters
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
addSlot(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, Items.paper));
|
||||
=======
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
addSlot(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, new Object[]{ItemStamps.class}));
|
||||
addSlot(new SlotCustom(inventory, TradeStation.SLOT_STAMPS_1 + j + i * 2, 15 + j * 18, 37 + i * 18, ItemStamps.class));
|
||||
}
|
||||
}
|
||||
|
||||
// Letters
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
addSlot(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, new Object[]{Items.paper}));
|
||||
addSlot(new SlotCustom(inventory, TradeStation.SLOT_LETTERS_1 + j + i * 2, 15 + j * 18, 73 + i * 18, Items.paper));
|
||||
}
|
||||
}
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
// Buffers
|
||||
final int bufCols = 5;
|
||||
|
||||
Reference in new issue
Block a user