mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 07:35:47 +00:00
Fix #965 issues displaying multiblock owner ledgers
This commit is contained in:
1 parent
84b1fa8c07
commit
d82db2f003
12 files changed
+103
-165
No files matched your search
@@ -16,7 +16,6 @@ import forestry.apiculture.multiblock.IAlvearyControllerInternal;
|
||||
import forestry.apiculture.multiblock.TileAlvearyPlain;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.ledgers.OwnerLedger;
|
||||
import forestry.core.render.EnumTankLevel;
|
||||
|
||||
public class GuiAlveary extends GuiForestryTitled<ContainerAlveary, TileAlvearyPlain> {
|
||||
@@ -41,13 +40,4 @@ public class GuiAlveary extends GuiForestryTitled<ContainerAlveary, TileAlvearyP
|
||||
|
||||
this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height);
|
||||
}
|
||||
|
||||
/* LEDGERS */
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
IAlvearyControllerInternal alvearyController = inventory.getMultiblockLogic().getController();
|
||||
ledgerManager.add(new OwnerLedger(ledgerManager, alvearyController));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.multiblock;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -24,19 +23,10 @@ import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.apiculture.FakeBeekeepingLogic;
|
||||
import forestry.core.access.EnumAccess;
|
||||
import forestry.core.access.FakeAccessHandler;
|
||||
import forestry.core.access.IAccessHandler;
|
||||
import forestry.core.errors.FakeErrorLogic;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.multiblock.FakeMultiblockController;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
|
||||
public class FakeAlvearyController extends FakeMultiblockController implements IAlvearyControllerInternal {
|
||||
public static final FakeAlvearyController instance = new FakeAlvearyController();
|
||||
@@ -65,16 +55,6 @@ public class FakeAlvearyController extends FakeMultiblockController implements I
|
||||
return FakeBeekeepingLogic.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockLightValue() {
|
||||
return 0;
|
||||
@@ -85,26 +65,11 @@ public class FakeAlvearyController extends FakeMultiblockController implements I
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOwner() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
return FakeErrorLogic.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkCoordinates getCoordinates() {
|
||||
return null;
|
||||
@@ -115,31 +80,11 @@ public class FakeAlvearyController extends FakeMultiblockController implements I
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiome() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAccessHandler getAccessHandler() {
|
||||
return FakeAccessHandler.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventoryAdapter getInternalInventory() {
|
||||
return FakeInventoryAdapter.instance();
|
||||
|
||||
@@ -12,13 +12,17 @@ package forestry.core.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
@@ -84,6 +88,23 @@ public abstract class BlockStructure extends BlockForestry {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityLiving, ItemStack itemstack) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entityLiving instanceof EntityPlayer) {
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
|
||||
if (tile instanceof MultiblockTileEntityForestry) {
|
||||
EntityPlayer player = (EntityPlayer) entityLiving;
|
||||
GameProfile gameProfile = player.getGameProfile();
|
||||
((MultiblockTileEntityForestry) tile).setOwner(gameProfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
|
||||
|
||||
@@ -93,6 +93,10 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
int maxLedgerWidth = (this.width - this.xSize) / 2;
|
||||
this.ledgerManager = new LedgerManager(this, maxLedgerWidth);
|
||||
|
||||
addLedgers();
|
||||
}
|
||||
|
||||
protected void addLedgers() {
|
||||
if (inventory instanceof IErrorSource) {
|
||||
ledgerManager.add((IErrorSource) inventory);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.core.multiblock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
@@ -19,7 +20,16 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.core.access.EnumAccess;
|
||||
import forestry.core.access.FakeAccessHandler;
|
||||
import forestry.core.access.IAccessHandler;
|
||||
import forestry.core.errors.FakeErrorLogic;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
|
||||
public abstract class FakeMultiblockController implements IMultiblockControllerInternal {
|
||||
@Override
|
||||
@@ -144,4 +154,49 @@ public abstract class FakeMultiblockController implements IMultiblockControllerI
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAccessHandler getAccessHandler() {
|
||||
return FakeAccessHandler.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
return FakeErrorLogic.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,16 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.api.core.INBTTagable;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.core.access.IRestrictedAccess;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.tiles.IClimatised;
|
||||
|
||||
// internal implementation of IMultiblockController
|
||||
public interface IMultiblockControllerInternal extends IMultiblockController, INBTTagable {
|
||||
public interface IMultiblockControllerInternal extends IMultiblockController, INBTTagable, IRestrictedAccess, IErrorLogicSource, IClimatised, IStreamableGui {
|
||||
/**
|
||||
* Attach a new part to this machine.
|
||||
* @param part The part to add.
|
||||
|
||||
@@ -807,6 +807,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
|
||||
/**
|
||||
* @return True if this multiblock machine is considered assembled and ready to go.
|
||||
*/
|
||||
@Override
|
||||
public boolean isAssembled() {
|
||||
return this.assemblyState == AssemblyState.Assembled;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.core.access.AccessHandler;
|
||||
import forestry.core.access.IAccessHandler;
|
||||
import forestry.core.access.IOwnable;
|
||||
import forestry.core.access.IRestrictedAccess;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
@@ -66,18 +65,9 @@ public abstract class MultiblockControllerForestry extends MultiblockControllerB
|
||||
|
||||
Multiset<GameProfile> owners = HashMultiset.create();
|
||||
for (IMultiblockComponent part : connectedParts) {
|
||||
if (part instanceof IRestrictedAccess) {
|
||||
IAccessHandler accessHandler = ((IRestrictedAccess) part).getAccessHandler();
|
||||
GameProfile owner = accessHandler.getOwner();
|
||||
if (owner != null) {
|
||||
owners.add(owner);
|
||||
}
|
||||
} else if (part instanceof IOwnable) {
|
||||
IOwnable ownable = (IOwnable) part;
|
||||
GameProfile owner = ownable.getOwner();
|
||||
if (owner != null) {
|
||||
owners.add(owner);
|
||||
}
|
||||
GameProfile owner = part.getOwner();
|
||||
if (owner != null) {
|
||||
owners.add(owner);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,15 +21,13 @@ import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.multiblock.IMultiblockLogic;
|
||||
import forestry.api.multiblock.MultiblockTileEntityBase;
|
||||
import forestry.core.access.IOwnable;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.tiles.IFilterSlotDelegate;
|
||||
import forestry.core.tiles.ILocatable;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
|
||||
public abstract class MultiblockTileEntityForestry<T extends IMultiblockLogic> extends MultiblockTileEntityBase<T> implements ISidedInventory, IFilterSlotDelegate, IOwnable, ILocatable {
|
||||
public abstract class MultiblockTileEntityForestry<T extends IMultiblockLogic> extends MultiblockTileEntityBase<T> implements ISidedInventory, IFilterSlotDelegate, ILocatable {
|
||||
private GameProfile owner;
|
||||
|
||||
public MultiblockTileEntityForestry(T multiblockLogic) {
|
||||
@@ -67,27 +65,6 @@ public abstract class MultiblockTileEntityForestry<T extends IMultiblockLogic> e
|
||||
getInternalInventory().writeToNBT(data);
|
||||
}
|
||||
|
||||
/* IOwnable */
|
||||
@Override
|
||||
public boolean isOwned() {
|
||||
return owner != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner(GameProfile owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOwner(EntityPlayer player) {
|
||||
return PlayerUtil.isSameGameProfile(owner, player.getGameProfile());
|
||||
}
|
||||
|
||||
/* INVENTORY */
|
||||
public IInventoryAdapter getInternalInventory() {
|
||||
return FakeInventoryAdapter.instance();
|
||||
@@ -199,4 +176,14 @@ public abstract class MultiblockTileEntityForestry<T extends IMultiblockLogic> e
|
||||
public final World getWorld() {
|
||||
return worldObj;
|
||||
}
|
||||
|
||||
/* IMultiblockComponent */
|
||||
@Override
|
||||
public final GameProfile getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public final void setOwner(GameProfile owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import forestry.api.farming.FarmDirection;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.ledgers.ClimateLedger;
|
||||
import forestry.core.gui.ledgers.OwnerLedger;
|
||||
import forestry.core.gui.widgets.SocketWidget;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.farming.gui.widgets.FarmLogicSlot;
|
||||
@@ -44,12 +43,11 @@ public class GuiFarm extends GuiForestryTitled<ContainerFarm, TileFarm> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
protected void addLedgers() {
|
||||
IFarmControllerInternal farmController = inventory.getMultiblockLogic().getController();
|
||||
ledgerManager.add(new ClimateLedger(ledgerManager, farmController));
|
||||
ledgerManager.add(new FarmLedger(ledgerManager, farmController.getFarmLedgerDelegate()));
|
||||
ledgerManager.add(new OwnerLedger(ledgerManager, farmController));
|
||||
super.addLedgers();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,5 +60,4 @@ public class GuiFarm extends GuiForestryTitled<ContainerFarm, TileFarm> {
|
||||
drawTexturedModalRect(guiLeft + 81, guiTop + 94 + 17 - fertilizerRemain, xSize, 17 - fertilizerRemain, 4, fertilizerRemain);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,8 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.multiblock;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
@@ -20,24 +18,15 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.circuits.CircuitSocketType;
|
||||
import forestry.api.circuits.ICircuitSocketType;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.IFarmInventory;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.access.EnumAccess;
|
||||
import forestry.core.access.FakeAccessHandler;
|
||||
import forestry.core.access.IAccessHandler;
|
||||
import forestry.core.errors.FakeErrorLogic;
|
||||
import forestry.core.fluids.FakeTankManager;
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.multiblock.FakeMultiblockController;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.farming.gui.IFarmLedgerDelegate;
|
||||
|
||||
import io.netty.util.internal.EmptyArrays;
|
||||
@@ -49,26 +38,6 @@ public class FakeFarmController extends FakeMultiblockController implements IFar
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getCoords() {
|
||||
return EmptyArrays.EMPTY_INTS;
|
||||
@@ -129,11 +98,6 @@ public class FakeFarmController extends FakeMultiblockController implements IFar
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAccessHandler getAccessHandler() {
|
||||
return FakeAccessHandler.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSocketCount() {
|
||||
return 0;
|
||||
@@ -154,11 +118,6 @@ public class FakeFarmController extends FakeMultiblockController implements IFar
|
||||
return CircuitSocketType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
return FakeErrorLogic.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFarmLedgerDelegate getFarmLedgerDelegate() {
|
||||
return FakeFarmLedgerDelegate.instance;
|
||||
@@ -174,21 +133,6 @@ public class FakeFarmController extends FakeMultiblockController implements IFar
|
||||
return FakeTankManager.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
private static class FakeFarmInventory implements IFarmInventory {
|
||||
public static final FakeFarmInventory instance = new FakeFarmInventory();
|
||||
|
||||
|
||||
Reference in new issue
Block a user