mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-23 21:39:51 +00:00
Add checking to make sure client and server can't open different GUIs
This commit is contained in:
1 parent
408a66bb40
commit
3c7856f264
39 files changed
+434
-236
No files matched your search
@@ -33,13 +33,13 @@ import cpw.mods.fml.common.registry.GameRegistry.Type;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.EventHandlerCore;
|
||||
import forestry.core.GuiHandler;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.GameMode;
|
||||
import forestry.core.config.Version;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.errors.ErrorStateRegistry;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.multiblock.MultiblockEventHandler;
|
||||
import forestry.core.network.PacketHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
@@ -35,12 +35,11 @@ import forestry.core.entities.EntityMinecartContainerForestry;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.IGuiHandlerEntity;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IClimatised;
|
||||
|
||||
public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContainerForestry implements IBeeHousing, IGuiBeeHousingInventory, IClimatised, IStreamableGui, IGuiHandlerEntity {
|
||||
public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContainerForestry implements IBeeHousing, IGuiBeeHousingInventory, IClimatised, IStreamableGui {
|
||||
private static final Random random = new Random();
|
||||
private static final int beeFXInterval = 4;
|
||||
private static final int pollenFXInterval = 50;
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.IGuiHandlerEntity;
|
||||
import forestry.core.network.IGuiHandlerItem;
|
||||
import forestry.core.network.IGuiHandlerTile;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
public static int encodeGuiData(GuiId guiId, int data) {
|
||||
return data << 8 | guiId.ordinal();
|
||||
}
|
||||
|
||||
public static int decodeGuiID(int guiId) {
|
||||
return guiId & 0xFF;
|
||||
}
|
||||
|
||||
public static int decodeGuiData(int guiId) {
|
||||
return guiId >> 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
int cleanId = decodeGuiID(id);
|
||||
int data = decodeGuiData(id);
|
||||
|
||||
if (cleanId >= GuiId.values().length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (GuiId.values()[cleanId]) {
|
||||
case ItemGui: {
|
||||
ItemStack heldItem = player.getCurrentEquippedItem();
|
||||
if (heldItem != null) {
|
||||
Item item = heldItem.getItem();
|
||||
if (item instanceof IGuiHandlerItem) {
|
||||
return ((IGuiHandlerItem) item).getGui(player, heldItem, data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TileGui: {
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (tileEntity instanceof IGuiHandlerTile) {
|
||||
return ((IGuiHandlerTile) tileEntity).getGui(player, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EntityGui: {
|
||||
Entity entity = world.getEntityByID(x);
|
||||
if (entity instanceof IGuiHandlerEntity) {
|
||||
return ((IGuiHandlerEntity) entity).getGui(player, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
int cleanId = decodeGuiID(id);
|
||||
int data = decodeGuiData(id);
|
||||
|
||||
if (cleanId >= GuiId.values().length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (GuiId.values()[cleanId]) {
|
||||
case ItemGui: {
|
||||
ItemStack heldItem = player.getCurrentEquippedItem();
|
||||
if (heldItem != null) {
|
||||
Item item = heldItem.getItem();
|
||||
if (item instanceof IGuiHandlerItem) {
|
||||
return ((IGuiHandlerItem) item).getContainer(player, heldItem, data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TileGui: {
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (tileEntity instanceof IGuiHandlerTile) {
|
||||
return ((IGuiHandlerTile) tileEntity).getContainer(player, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EntityGui: {
|
||||
Entity entity = world.getEntityByID(x);
|
||||
if (entity instanceof IGuiHandlerEntity) {
|
||||
return ((IGuiHandlerEntity) entity).getContainer(player, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -24,16 +24,16 @@ import com.mojang.authlib.GameProfile;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.access.AccessHandler;
|
||||
import forestry.core.access.EnumAccess;
|
||||
import forestry.core.access.IAccessHandler;
|
||||
import forestry.core.access.IRestrictedAccess;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.gui.IGuiHandlerEntity;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.tiles.ITitled;
|
||||
|
||||
public abstract class EntityMinecartForestry extends EntityMinecart implements ITitled, IRestrictedAccess, IHintSource {
|
||||
public abstract class EntityMinecartForestry extends EntityMinecart implements ITitled, IRestrictedAccess, IHintSource, IGuiHandlerEntity {
|
||||
private final AccessHandler accessHandler = new AccessHandler(this);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -54,7 +54,7 @@ public abstract class EntityMinecartForestry extends EntityMinecart implements I
|
||||
}
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
player.openGui(ForestryAPI.instance, GuiId.EntityGui.ordinal(), worldObj, getEntityId(), -1, 0);
|
||||
GuiHandler.openGui(player, this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class ContainerNaturalistInventory extends ContainerTile<TileNaturalistCh
|
||||
|
||||
@Override
|
||||
public void handleSelectionRequest(EntityPlayerMP player, PacketGuiSelectRequest packet) {
|
||||
tile.flipPage(player, packet.getPrimaryIndex());
|
||||
tile.flipPage(player, (short) packet.getPrimaryIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
public static void openGui(EntityPlayer entityplayer, IGuiHandlerEntity guiHandler) {
|
||||
openGui(entityplayer, guiHandler, (short) 0);
|
||||
}
|
||||
|
||||
public static void openGui(EntityPlayer entityplayer, IGuiHandlerEntity guiHandler, short data) {
|
||||
int guiData = encodeGuiData(guiHandler, data);
|
||||
entityplayer.openGui(ForestryAPI.instance, guiData, entityplayer.worldObj, guiHandler.getEntityId(), 0, 0);
|
||||
}
|
||||
|
||||
public static void openGui(EntityPlayer entityplayer, IGuiHandlerItem guiHandler) {
|
||||
openGui(entityplayer, guiHandler, (short) 0);
|
||||
}
|
||||
|
||||
public static void openGui(EntityPlayer entityplayer, IGuiHandlerItem guiHandler, short data) {
|
||||
int guiData = encodeGuiData(guiHandler, data);
|
||||
entityplayer.openGui(ForestryAPI.instance, guiData, entityplayer.worldObj, 0, 0, 0);
|
||||
}
|
||||
|
||||
public static void openGui(EntityPlayer entityplayer, IGuiHandlerTile guiHandler) {
|
||||
openGui(entityplayer, guiHandler, (short) 0);
|
||||
}
|
||||
|
||||
public static void openGui(EntityPlayer entityplayer, IGuiHandlerTile guiHandler, short data) {
|
||||
int guiData = encodeGuiData(guiHandler, data);
|
||||
ChunkCoordinates coordinates = guiHandler.getCoordinates();
|
||||
entityplayer.openGui(ForestryAPI.instance, guiData, entityplayer.worldObj, coordinates.posX, coordinates.posY, coordinates.posZ);
|
||||
}
|
||||
|
||||
private static int encodeGuiData(IGuiHandlerForestry guiHandler, short data) {
|
||||
GuiId guiId = GuiIdRegistry.getGuiIdForGuiHandler(guiHandler);
|
||||
return data << 16 | guiId.getId();
|
||||
}
|
||||
|
||||
private static GuiId decodeGuiID(int guiData) {
|
||||
int guiId = guiData & 0xFF;
|
||||
return GuiIdRegistry.getGuiId(guiId);
|
||||
}
|
||||
|
||||
private static short decodeGuiData(int guiId) {
|
||||
return (short) (guiId >> 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) {
|
||||
GuiId guiId = decodeGuiID(guiData);
|
||||
if (guiId == null) {
|
||||
return null;
|
||||
}
|
||||
short data = decodeGuiData(guiData);
|
||||
|
||||
switch (guiId.getGuiType()) {
|
||||
case Item: {
|
||||
ItemStack heldItem = player.getCurrentEquippedItem();
|
||||
if (heldItem != null) {
|
||||
Item item = heldItem.getItem();
|
||||
if (guiId.getGuiHandlerClass().isInstance(item)) {
|
||||
return ((IGuiHandlerItem) item).getGui(player, heldItem, data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Tile: {
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (guiId.getGuiHandlerClass().isInstance(tileEntity)) {
|
||||
return ((IGuiHandlerTile) tileEntity).getGui(player, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Entity: {
|
||||
Entity entity = world.getEntityByID(x);
|
||||
if (guiId.getGuiHandlerClass().isInstance(entity)) {
|
||||
return ((IGuiHandlerEntity) entity).getGui(player, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int guiData, EntityPlayer player, World world, int x, int y, int z) {
|
||||
GuiId guiId = decodeGuiID(guiData);
|
||||
if (guiId == null) {
|
||||
return null;
|
||||
}
|
||||
short data = decodeGuiData(guiData);
|
||||
|
||||
switch (guiId.getGuiType()) {
|
||||
case Item: {
|
||||
ItemStack heldItem = player.getCurrentEquippedItem();
|
||||
if (heldItem != null) {
|
||||
Item item = heldItem.getItem();
|
||||
if (guiId.getGuiHandlerClass().isInstance(item)) {
|
||||
return ((IGuiHandlerItem) item).getContainer(player, heldItem, data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Tile: {
|
||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||
if (guiId.getGuiHandlerClass().isInstance(tileEntity)) {
|
||||
return ((IGuiHandlerTile) tileEntity).getContainer(player, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Entity: {
|
||||
Entity entity = world.getEntityByID(x);
|
||||
if (guiId.getGuiHandlerClass().isInstance(entity)) {
|
||||
return ((IGuiHandlerEntity) entity).getContainer(player, data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
public class GuiId {
|
||||
private final int id;
|
||||
private final GuiType guiType;
|
||||
private final Class<? extends IGuiHandlerForestry> guiHandlerClass;
|
||||
|
||||
GuiId(int id, GuiType guiType, Class<? extends IGuiHandlerForestry> guiHandlerClass) {
|
||||
this.id = id;
|
||||
this.guiType = guiType;
|
||||
this.guiHandlerClass = guiHandlerClass;
|
||||
}
|
||||
|
||||
public GuiType getGuiType() {
|
||||
return guiType;
|
||||
}
|
||||
|
||||
public Class<? extends IGuiHandlerForestry> getGuiHandlerClass() {
|
||||
return guiHandlerClass;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.apiculture.entities.EntityMinecartApiary;
|
||||
import forestry.apiculture.entities.EntityMinecartBeehouse;
|
||||
import forestry.apiculture.items.ItemBeealyzer;
|
||||
import forestry.apiculture.items.ItemHabitatLocator;
|
||||
import forestry.apiculture.items.ItemImprinter;
|
||||
import forestry.apiculture.multiblock.TileAlveary;
|
||||
import forestry.apiculture.multiblock.TileAlvearyHygroregulator;
|
||||
import forestry.apiculture.multiblock.TileAlvearySieve;
|
||||
import forestry.arboriculture.items.ItemTreealyzer;
|
||||
import forestry.core.items.ItemSolderingIron;
|
||||
import forestry.core.tiles.TileAnalyzer;
|
||||
import forestry.core.tiles.TileEscritoire;
|
||||
import forestry.core.tiles.TileNaturalistChest;
|
||||
import forestry.energy.tiles.TileEngineBiogas;
|
||||
import forestry.energy.tiles.TileEngineElectric;
|
||||
import forestry.energy.tiles.TileEnginePeat;
|
||||
import forestry.energy.tiles.TileGenerator;
|
||||
import forestry.factory.tiles.TileBottler;
|
||||
import forestry.factory.tiles.TileCarpenter;
|
||||
import forestry.factory.tiles.TileCentrifuge;
|
||||
import forestry.factory.tiles.TileFabricator;
|
||||
import forestry.factory.tiles.TileFermenter;
|
||||
import forestry.factory.tiles.TileMoistener;
|
||||
import forestry.factory.tiles.TileRaintank;
|
||||
import forestry.factory.tiles.TileSqueezer;
|
||||
import forestry.factory.tiles.TileStill;
|
||||
import forestry.factory.tiles.TileWorktable;
|
||||
import forestry.farming.tiles.TileFarm;
|
||||
import forestry.food.items.ItemInfuser;
|
||||
import forestry.lepidopterology.items.ItemFlutterlyzer;
|
||||
import forestry.mail.items.ItemCatalogue;
|
||||
import forestry.mail.items.ItemLetter;
|
||||
import forestry.mail.tiles.TileMailbox;
|
||||
import forestry.mail.tiles.TileStampCollector;
|
||||
import forestry.mail.tiles.TileTrader;
|
||||
import forestry.storage.items.ItemBackpack;
|
||||
import forestry.storage.items.ItemBackpackNaturalist;
|
||||
|
||||
public class GuiIdRegistry {
|
||||
private static final Map<Class<? extends IGuiHandlerForestry>, GuiId> classMap = new HashMap<>();
|
||||
private static final Map<Integer, GuiId> idMap = new HashMap<>();
|
||||
private static int nextId = 0;
|
||||
|
||||
static {
|
||||
registerGuiHandlers(GuiType.Tile, Arrays.<Class<? extends IGuiHandlerForestry>>asList(
|
||||
TileAlveary.class,
|
||||
TileAlvearyHygroregulator.class,
|
||||
TileAlvearySieve.class,
|
||||
|
||||
TileAnalyzer.class,
|
||||
TileEscritoire.class,
|
||||
TileNaturalistChest.class,
|
||||
TileRaintank.class,
|
||||
TileWorktable.class,
|
||||
|
||||
TileBottler.class,
|
||||
TileCarpenter.class,
|
||||
TileCentrifuge.class,
|
||||
TileFabricator.class,
|
||||
TileFermenter.class,
|
||||
TileMoistener.class,
|
||||
TileSqueezer.class,
|
||||
TileStill.class,
|
||||
|
||||
TileFarm.class,
|
||||
|
||||
TileEngineBiogas.class,
|
||||
TileEngineElectric.class,
|
||||
TileEnginePeat.class,
|
||||
TileGenerator.class,
|
||||
|
||||
TileMailbox.class,
|
||||
TileStampCollector.class,
|
||||
TileTrader.class
|
||||
));
|
||||
|
||||
registerGuiHandlers(GuiType.Item, Arrays.<Class<? extends IGuiHandlerForestry>>asList(
|
||||
ItemBackpack.class,
|
||||
ItemBackpackNaturalist.class,
|
||||
ItemBeealyzer.class,
|
||||
ItemCatalogue.class,
|
||||
ItemFlutterlyzer.class,
|
||||
ItemHabitatLocator.class,
|
||||
ItemImprinter.class,
|
||||
ItemInfuser.class,
|
||||
ItemLetter.class,
|
||||
ItemSolderingIron.class,
|
||||
ItemTreealyzer.class
|
||||
));
|
||||
|
||||
registerGuiHandlers(GuiType.Entity, Arrays.<Class<? extends IGuiHandlerForestry>>asList(
|
||||
EntityMinecartApiary.class,
|
||||
EntityMinecartBeehouse.class
|
||||
));
|
||||
}
|
||||
|
||||
private static void registerGuiHandlers(GuiType guiType, List<Class<? extends IGuiHandlerForestry>> guiHandlerClasses) {
|
||||
for (Class<? extends IGuiHandlerForestry> tileGuiHandlerClass : guiHandlerClasses) {
|
||||
GuiId guiId = new GuiId(nextId++, guiType, tileGuiHandlerClass);
|
||||
classMap.put(tileGuiHandlerClass, guiId);
|
||||
idMap.put(guiId.getId(), guiId);
|
||||
}
|
||||
}
|
||||
|
||||
public static GuiId getGuiIdForGuiHandler(IGuiHandlerForestry guiHandler) {
|
||||
Class<? extends IGuiHandlerForestry> guiHandlerClass = guiHandler.getClass();
|
||||
GuiId guiId = classMap.get(guiHandlerClass);
|
||||
if (guiId == null) {
|
||||
for (Map.Entry<Class<? extends IGuiHandlerForestry>, GuiId> classGuiIdEntry : classMap.entrySet()) {
|
||||
if (classGuiIdEntry.getKey().isAssignableFrom(guiHandlerClass)) {
|
||||
guiId = classGuiIdEntry.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (guiId == null) {
|
||||
throw new IllegalStateException("No gui ID for gui handler: " + guiHandler);
|
||||
}
|
||||
return guiId;
|
||||
}
|
||||
|
||||
public static GuiId getGuiId(int id) {
|
||||
return idMap.get(id);
|
||||
}
|
||||
}
|
||||
Executable → Regular
+5
-5
@@ -8,10 +8,10 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
package forestry.core.gui;
|
||||
|
||||
public enum GuiId {
|
||||
ItemGui,
|
||||
TileGui,
|
||||
EntityGui;
|
||||
public enum GuiType {
|
||||
Item,
|
||||
Tile,
|
||||
Entity;
|
||||
}
|
||||
+4
-2
@@ -8,12 +8,14 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public interface IGuiHandlerEntity {
|
||||
public interface IGuiHandlerEntity extends IGuiHandlerForestry {
|
||||
Object getGui(EntityPlayer player, int data);
|
||||
|
||||
Object getContainer(EntityPlayer player, int data);
|
||||
|
||||
int getEntityId();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
public interface IGuiHandlerForestry {
|
||||
}
|
||||
+2
-2
@@ -8,12 +8,12 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IGuiHandlerItem {
|
||||
public interface IGuiHandlerItem extends IGuiHandlerForestry {
|
||||
Object getGui(EntityPlayer player, ItemStack heldItem, int data);
|
||||
|
||||
Object getContainer(EntityPlayer player, ItemStack heldItem, int data);
|
||||
+4
-2
@@ -8,11 +8,13 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.network;
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public interface IGuiHandlerTile {
|
||||
import forestry.core.tiles.ILocatable;
|
||||
|
||||
public interface IGuiHandlerTile extends IGuiHandlerForestry, ILocatable {
|
||||
Object getGui(EntityPlayer player, int data);
|
||||
|
||||
Object getContainer(EntityPlayer player, int data);
|
||||
@@ -18,5 +18,5 @@ import net.minecraft.inventory.IInventory;
|
||||
*/
|
||||
public interface IPagedInventory extends IInventory {
|
||||
|
||||
void flipPage(EntityPlayer player, int page);
|
||||
void flipPage(EntityPlayer player, short page);
|
||||
}
|
||||
@@ -16,10 +16,9 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.IGuiHandlerItem;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.gui.IGuiHandlerItem;
|
||||
|
||||
public abstract class ItemWithGui extends ItemForestry implements IGuiHandlerItem {
|
||||
public ItemWithGui() {
|
||||
@@ -33,14 +32,14 @@ public abstract class ItemWithGui extends ItemForestry implements IGuiHandlerIte
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
|
||||
if (!world.isRemote) {
|
||||
openGui(world, entityplayer);
|
||||
openGui(entityplayer);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
protected void openGui(World world, EntityPlayer entityplayer) {
|
||||
entityplayer.openGui(ForestryAPI.instance, GuiId.ItemGui.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ);
|
||||
protected void openGui(EntityPlayer entityplayer) {
|
||||
GuiHandler.openGui(entityplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,14 +19,13 @@ import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.multiblock.IMultiblockLogic;
|
||||
import forestry.api.multiblock.MultiblockTileEntityBase;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.gui.IGuiHandlerTile;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.IGuiHandlerTile;
|
||||
import forestry.core.tiles.IFilterSlotDelegate;
|
||||
import forestry.core.tiles.ILocatable;
|
||||
|
||||
@@ -41,7 +40,7 @@ public abstract class MultiblockTileEntityForestry<T extends IMultiblockLogic> e
|
||||
* Called by a structure block when it is right clicked by a player.
|
||||
*/
|
||||
public void openGui(EntityPlayer player) {
|
||||
player.openGui(ForestryAPI.instance, GuiId.TileGui.ordinal(), worldObj, xCoord, yCoord, zCoord);
|
||||
GuiHandler.openGui(player, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,10 +15,9 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.network.GuiId;
|
||||
|
||||
public abstract class TileBase extends TileForestry implements IHintSource {
|
||||
protected final List<String> hints;
|
||||
@@ -28,7 +27,7 @@ public abstract class TileBase extends TileForestry implements IHintSource {
|
||||
}
|
||||
|
||||
public void openGui(EntityPlayer player) {
|
||||
player.openGui(ForestryAPI.instance, GuiId.TileGui.ordinal(), worldObj, xCoord, yCoord, zCoord);
|
||||
GuiHandler.openGui(player, this);
|
||||
}
|
||||
|
||||
public boolean canDrainWithBucket() {
|
||||
|
||||
@@ -36,11 +36,11 @@ import forestry.core.access.EnumAccess;
|
||||
import forestry.core.access.IAccessHandler;
|
||||
import forestry.core.access.IRestrictedAccess;
|
||||
import forestry.core.errors.ErrorLogic;
|
||||
import forestry.core.gui.IGuiHandlerTile;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IGuiHandlerTile;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.packets.PacketTileStream;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.io.IOException;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
|
||||
public abstract class TileMill extends TileBase {
|
||||
|
||||
@@ -23,7 +22,7 @@ public abstract class TileMill extends TileBase {
|
||||
public int charge = 0;
|
||||
public float progress;
|
||||
|
||||
protected TileMill(GuiId guiId, String hintKey) {
|
||||
protected TileMill(String hintKey) {
|
||||
super(hintKey);
|
||||
speed = 0.01F;
|
||||
}
|
||||
|
||||
@@ -14,16 +14,14 @@ import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.GuiHandler;
|
||||
import forestry.core.gui.ContainerNaturalistInventory;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.gui.GuiNaturalistInventory;
|
||||
import forestry.core.gui.IPagedInventory;
|
||||
import forestry.core.inventory.InventoryNaturalistChest;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
|
||||
public abstract class TileNaturalistChest extends TileBase implements IPagedInventory {
|
||||
private static final float lidAngleVariationPerTick = 0.1F;
|
||||
@@ -91,8 +89,8 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flipPage(EntityPlayer player, int page) {
|
||||
player.openGui(ForestryAPI.instance, GuiHandler.encodeGuiData(GuiId.TileGui, page), player.worldObj, xCoord, yCoord, zCoord);
|
||||
public void flipPage(EntityPlayer player, short page) {
|
||||
GuiHandler.openGui(player, this, page);
|
||||
}
|
||||
|
||||
/* IStreamable */
|
||||
|
||||
@@ -24,7 +24,7 @@ public class TileMillRainmaker extends TileMill {
|
||||
private boolean reverse;
|
||||
|
||||
public TileMillRainmaker() {
|
||||
super(null, null);
|
||||
super(null);
|
||||
speed = 0.01f;
|
||||
setInternalInventory(new InventoryRainmaker(this));
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ import forestry.core.blocks.BlockStructure;
|
||||
import forestry.core.render.ParticleHelper;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.farming.render.EnumFarmBlockTexture;
|
||||
import forestry.farming.tiles.TileControl;
|
||||
import forestry.farming.tiles.TileFarm;
|
||||
import forestry.farming.tiles.TileFarmControl;
|
||||
import forestry.farming.tiles.TileFarmGearbox;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
import forestry.farming.tiles.TileFarmPlain;
|
||||
import forestry.farming.tiles.TileGearbox;
|
||||
import forestry.farming.tiles.TileHatch;
|
||||
import forestry.farming.tiles.TileValve;
|
||||
import forestry.farming.tiles.TileFarmValve;
|
||||
import forestry.plugins.PluginFarming;
|
||||
|
||||
public class BlockFarm extends BlockStructure {
|
||||
@@ -133,13 +133,13 @@ public class BlockFarm extends BlockStructure {
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
switch (metadata) {
|
||||
case 2:
|
||||
return new TileGearbox();
|
||||
return new TileFarmGearbox();
|
||||
case 3:
|
||||
return new TileHatch();
|
||||
return new TileFarmHatch();
|
||||
case 4:
|
||||
return new TileValve();
|
||||
return new TileFarmValve();
|
||||
case 5:
|
||||
return new TileControl();
|
||||
return new TileFarmControl();
|
||||
default:
|
||||
return new TileFarmPlain();
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ import forestry.farming.FarmHelper;
|
||||
import forestry.farming.FarmTarget;
|
||||
import forestry.farming.gui.IFarmLedgerDelegate;
|
||||
import forestry.farming.logic.FarmLogicArboreal;
|
||||
import forestry.farming.tiles.TileFarmGearbox;
|
||||
import forestry.farming.tiles.TileFarmPlain;
|
||||
import forestry.farming.tiles.TileGearbox;
|
||||
|
||||
public class FarmController extends RectangularMultiblockControllerBase implements IFarmControllerInternal, ILiquidTankTile {
|
||||
|
||||
@@ -212,7 +212,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
|
||||
boolean hasGearbox = false;
|
||||
for (IMultiblockComponent part : connectedParts) {
|
||||
if (part instanceof TileGearbox) {
|
||||
if (part instanceof TileFarmGearbox) {
|
||||
hasGearbox = true;
|
||||
break;
|
||||
}
|
||||
@@ -264,8 +264,8 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
boolean hasPower = false;
|
||||
for (Map.Entry<IFarmComponent.Active, Integer> entry : farmActiveComponents.entrySet()) {
|
||||
IFarmComponent.Active farmComponent = entry.getKey();
|
||||
if (farmComponent instanceof TileGearbox) {
|
||||
hasPower |= ((TileGearbox) farmComponent).getEnergyManager().getTotalEnergyStored() > 0;
|
||||
if (farmComponent instanceof TileFarmGearbox) {
|
||||
hasPower |= ((TileFarmGearbox) farmComponent).getEnergyManager().getTotalEnergyStored() > 0;
|
||||
}
|
||||
|
||||
int tickOffset = entry.getValue();
|
||||
|
||||
+4
-4
@@ -21,11 +21,11 @@ import forestry.api.farming.IFarmLogic;
|
||||
import forestry.api.multiblock.IFarmComponent;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
public class TileControl extends TileFarm implements IFarmComponent.Listener {
|
||||
public class TileFarmControl extends TileFarm implements IFarmComponent.Listener {
|
||||
|
||||
private final IFarmListener farmListener;
|
||||
|
||||
public TileControl() {
|
||||
public TileFarmControl() {
|
||||
this.farmListener = new ControlFarmListener(this);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ public class TileControl extends TileFarm implements IFarmComponent.Listener {
|
||||
}
|
||||
|
||||
private static class ControlFarmListener extends DefaultFarmListener {
|
||||
private final TileControl tile;
|
||||
private final TileFarmControl tile;
|
||||
|
||||
public ControlFarmListener(TileControl tile) {
|
||||
public ControlFarmListener(TileFarmControl tile) {
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import forestry.api.multiblock.IFarmController;
|
||||
import forestry.core.tiles.IPowerHandler;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
public class TileGearbox extends TileFarm implements IPowerHandler, IFarmComponent.Active {
|
||||
public class TileFarmGearbox extends TileFarm implements IPowerHandler, IFarmComponent.Active {
|
||||
|
||||
private static final int WORK_CYCLES = 4;
|
||||
private static final int ENERGY_PER_OPERATION = WORK_CYCLES * 50;
|
||||
@@ -30,7 +30,7 @@ public class TileGearbox extends TileFarm implements IPowerHandler, IFarmCompone
|
||||
private int previousDelays = 0;
|
||||
private int workCounter;
|
||||
|
||||
public TileGearbox() {
|
||||
public TileFarmGearbox() {
|
||||
energyManager = new EnergyManager(200, 10000);
|
||||
}
|
||||
|
||||
+2
-2
@@ -33,14 +33,14 @@ import buildcraft.api.statements.ITriggerInternal;
|
||||
import buildcraft.api.statements.ITriggerProvider;
|
||||
|
||||
@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements")
|
||||
public class TileHatch extends TileFarm implements ISidedInventory, IFarmComponent.Active, ITriggerProvider {
|
||||
public class TileFarmHatch extends TileFarm implements ISidedInventory, IFarmComponent.Active, ITriggerProvider {
|
||||
|
||||
private static final ForgeDirection[] dumpDirections = new ForgeDirection[]{ForgeDirection.DOWN};
|
||||
|
||||
private final AdjacentTileCache tileCache;
|
||||
private final AdjacentInventoryCache inventoryCache;
|
||||
|
||||
public TileHatch() {
|
||||
public TileFarmHatch() {
|
||||
this.tileCache = new AdjacentTileCache(this);
|
||||
this.inventoryCache = new AdjacentInventoryCache(this, tileCache, new AdjacentInventoryCache.ITileFilter() {
|
||||
@Override
|
||||
+1
-1
@@ -19,7 +19,7 @@ import net.minecraftforge.fluids.IFluidHandler;
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
|
||||
public class TileValve extends TileFarm implements ILiquidTankTile, IFluidHandler {
|
||||
public class TileFarmValve extends TileFarm implements ILiquidTankTile, IFluidHandler {
|
||||
|
||||
/* ILIQUIDTANKCONTAINER */
|
||||
@Override
|
||||
@@ -17,7 +17,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.farming.tiles.TileHatch;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
@@ -38,11 +38,11 @@ public class TriggerLowFertilizer extends Trigger {
|
||||
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
if (!(tile instanceof TileHatch)) {
|
||||
if (!(tile instanceof TileFarmHatch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileHatch tileHatch = (TileHatch) tile;
|
||||
TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
IInventory fertilizerInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getFertilizerInventory();
|
||||
return InventoryUtil.containsPercent(fertilizerInventory, threshold);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.farming.tiles.TileHatch;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
@@ -41,11 +41,11 @@ public class TriggerLowGermlings extends Trigger {
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
if (!(tile instanceof TileHatch)) {
|
||||
if (!(tile instanceof TileFarmHatch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileHatch tileHatch = (TileHatch) tile;
|
||||
TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
IInventory germlingsInventory = tileHatch.getMultiblockLogic().getController().getFarmInventory().getGermlingsInventory();
|
||||
return InventoryUtil.containsPercent(germlingsInventory, threshold);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.farming.tiles.TileHatch;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
@@ -42,11 +42,11 @@ public class TriggerLowLiquid extends Trigger {
|
||||
*/
|
||||
@Override
|
||||
public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) {
|
||||
if (!(tile instanceof TileHatch)) {
|
||||
if (!(tile instanceof TileFarmHatch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileHatch tileHatch = (TileHatch) tile;
|
||||
TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
ITankManager tankManager = tileHatch.getMultiblockLogic().getController().getTankManager();
|
||||
|
||||
IFluidTank tank = tankManager.getTank(0);
|
||||
|
||||
@@ -20,7 +20,7 @@ import forestry.api.farming.IFarmInventory;
|
||||
import forestry.api.multiblock.IFarmController;
|
||||
import forestry.core.triggers.Trigger;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.farming.tiles.TileHatch;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
@@ -60,11 +60,11 @@ public class TriggerLowSoil extends Trigger {
|
||||
parameter = parameters[0];
|
||||
}
|
||||
|
||||
if (!(tile instanceof TileHatch)) {
|
||||
if (!(tile instanceof TileFarmHatch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileHatch tileHatch = (TileHatch) tile;
|
||||
TileFarmHatch tileHatch = (TileFarmHatch) tile;
|
||||
IFarmController farmController = tileHatch.getMultiblockLogic().getController();
|
||||
IFarmInventory farmInventory = farmController.getFarmInventory();
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ItemLetter extends ItemWithGui {
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
|
||||
if (!world.isRemote) {
|
||||
if (itemstack.stackSize == 1) {
|
||||
openGui(world, entityplayer);
|
||||
openGui(entityplayer);
|
||||
} else {
|
||||
entityplayer.addChatMessage(new ChatComponentTranslation("for.chat.mail.wrongstacksize"));
|
||||
}
|
||||
|
||||
@@ -25,17 +25,15 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.mail.IMailAddress;
|
||||
import forestry.api.mail.IStamps;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.core.GuiHandler;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileBase;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
@@ -63,8 +61,8 @@ public class TileTrader extends TileBase {
|
||||
|
||||
@Override
|
||||
public void openGui(EntityPlayer player) {
|
||||
int data = isLinked() ? 0 : 1;
|
||||
player.openGui(ForestryAPI.instance, GuiHandler.encodeGuiData(GuiId.TileGui, data), worldObj, xCoord, yCoord, zCoord);
|
||||
short data = (short) (isLinked() ? 0 : 1);
|
||||
GuiHandler.openGui(player, this, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -69,19 +69,6 @@ import forestry.factory.triggers.FactoryTriggers;
|
||||
|
||||
@Plugin(pluginID = "Factory", name = "Factory", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.factory.description")
|
||||
public class PluginFactory extends ForestryPlugin {
|
||||
|
||||
private static MachineDefinition definitionBottler;
|
||||
private static MachineDefinition definitionCarpenter;
|
||||
private static MachineDefinition definitionCentrifuge;
|
||||
private static MachineDefinition definitionFermenter;
|
||||
private static MachineDefinition definitionMoistener;
|
||||
private static MachineDefinition definitionSqueezer;
|
||||
private static MachineDefinition definitionStill;
|
||||
private static MachineDefinition definitionRainmaker;
|
||||
private static MachineDefinition definitionFabricator;
|
||||
private static MachineDefinition definitionRaintank;
|
||||
private static MachineDefinition definitionWorktable;
|
||||
|
||||
public static BlockRegistryFactory blocks;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -63,11 +63,11 @@ import forestry.farming.logic.FarmableVanillaMushroom;
|
||||
import forestry.farming.logic.FarmableVanillaSapling;
|
||||
import forestry.farming.proxy.ProxyFarming;
|
||||
import forestry.farming.render.EnumFarmBlockTexture;
|
||||
import forestry.farming.tiles.TileControl;
|
||||
import forestry.farming.tiles.TileFarmControl;
|
||||
import forestry.farming.tiles.TileFarmGearbox;
|
||||
import forestry.farming.tiles.TileFarmHatch;
|
||||
import forestry.farming.tiles.TileFarmPlain;
|
||||
import forestry.farming.tiles.TileGearbox;
|
||||
import forestry.farming.tiles.TileHatch;
|
||||
import forestry.farming.tiles.TileValve;
|
||||
import forestry.farming.tiles.TileFarmValve;
|
||||
import forestry.farming.triggers.FarmingTriggers;
|
||||
|
||||
@Plugin(pluginID = "Farming", name = "Farming", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.farming.description")
|
||||
@@ -143,10 +143,10 @@ public class PluginFarming extends ForestryPlugin {
|
||||
super.doInit();
|
||||
|
||||
GameRegistry.registerTileEntity(TileFarmPlain.class, "forestry.Farm");
|
||||
GameRegistry.registerTileEntity(TileGearbox.class, "forestry.FarmGearbox");
|
||||
GameRegistry.registerTileEntity(TileHatch.class, "forestry.FarmHatch");
|
||||
GameRegistry.registerTileEntity(TileValve.class, "forestry.FarmValve");
|
||||
GameRegistry.registerTileEntity(TileControl.class, "forestry.FarmControl");
|
||||
GameRegistry.registerTileEntity(TileFarmGearbox.class, "forestry.FarmGearbox");
|
||||
GameRegistry.registerTileEntity(TileFarmHatch.class, "forestry.FarmHatch");
|
||||
GameRegistry.registerTileEntity(TileFarmValve.class, "forestry.FarmValve");
|
||||
GameRegistry.registerTileEntity(TileFarmControl.class, "forestry.FarmControl");
|
||||
|
||||
Circuit.farmArborealManaged = new CircuitFarmLogic("managedArboreal", FarmLogicArboreal.class);
|
||||
Circuit.farmShroomManaged = new CircuitFarmLogic("managedShroom", FarmLogicShroom.class);
|
||||
|
||||
@@ -34,6 +34,6 @@ public class ContainerNaturalistBackpack extends ContainerItemInventory<ItemInve
|
||||
|
||||
@Override
|
||||
public void handleSelectionRequest(EntityPlayerMP player, PacketGuiSelectRequest packet) {
|
||||
inventory.flipPage(player, packet.getPrimaryIndex());
|
||||
inventory.flipPage(player, (short) packet.getPrimaryIndex());
|
||||
}
|
||||
}
|
||||
@@ -13,18 +13,20 @@ package forestry.storage.inventory;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.GuiHandler;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.gui.IPagedInventory;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.storage.items.ItemBackpackNaturalist;
|
||||
|
||||
public class ItemInventoryBackpackPaged extends ItemInventoryBackpack implements IPagedInventory {
|
||||
public ItemInventoryBackpackPaged(EntityPlayer player, int size, ItemStack itemstack) {
|
||||
private final ItemBackpackNaturalist backpackNaturalist;
|
||||
|
||||
public ItemInventoryBackpackPaged(EntityPlayer player, int size, ItemStack itemstack, ItemBackpackNaturalist backpackNaturalist) {
|
||||
super(player, size, itemstack);
|
||||
this.backpackNaturalist = backpackNaturalist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flipPage(EntityPlayer player, int page) {
|
||||
player.openGui(ForestryAPI.instance, GuiHandler.encodeGuiData(GuiId.ItemGui, page), player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
public void flipPage(EntityPlayer player, short page) {
|
||||
GuiHandler.openGui(player, backpackNaturalist, page);
|
||||
}
|
||||
}
|
||||
@@ -28,18 +28,16 @@ import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.storage.BackpackStowEvent;
|
||||
import forestry.api.storage.EnumBackpackType;
|
||||
import forestry.api.storage.IBackpackDefinition;
|
||||
import forestry.core.GuiHandler;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.inventory.ItemInventory;
|
||||
import forestry.core.inventory.wrappers.IInvSlot;
|
||||
import forestry.core.inventory.wrappers.InventoryIterator;
|
||||
import forestry.core.items.ItemWithGui;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
@@ -69,15 +67,15 @@ public class ItemBackpack extends ItemWithGui {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void openGui(World world, EntityPlayer entityplayer) {
|
||||
entityplayer.openGui(ForestryAPI.instance, GuiHandler.encodeGuiData(GuiId.ItemGui, type.ordinal()), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ);
|
||||
protected void openGui(EntityPlayer entityplayer) {
|
||||
GuiHandler.openGui(entityplayer, this, (short) type.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) {
|
||||
if (!world.isRemote) {
|
||||
if (!player.isSneaking()) {
|
||||
openGui(world, player);
|
||||
openGui(player);
|
||||
} else {
|
||||
switchMode(itemstack);
|
||||
}
|
||||
|
||||
@@ -12,15 +12,13 @@ package forestry.storage.items;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.api.storage.EnumBackpackType;
|
||||
import forestry.api.storage.IBackpackDefinition;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.gui.GuiNaturalistInventory;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.storage.gui.ContainerNaturalistBackpack;
|
||||
import forestry.storage.inventory.ItemInventoryBackpackPaged;
|
||||
|
||||
@@ -33,20 +31,20 @@ public class ItemBackpackNaturalist extends ItemBackpack {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void openGui(World world, EntityPlayer entityplayer) {
|
||||
entityplayer.openGui(ForestryAPI.instance, GuiId.ItemGui.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ);
|
||||
protected void openGui(EntityPlayer entityplayer) {
|
||||
GuiHandler.openGui(entityplayer, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int page) {
|
||||
ItemInventoryBackpackPaged inventory = new ItemInventoryBackpackPaged(player, Constants.SLOTS_BACKPACK_APIARIST, heldItem);
|
||||
ItemInventoryBackpackPaged inventory = new ItemInventoryBackpackPaged(player, Constants.SLOTS_BACKPACK_APIARIST, heldItem, this);
|
||||
ContainerNaturalistBackpack container = new ContainerNaturalistBackpack(player, inventory, page);
|
||||
return new GuiNaturalistInventory(speciesRoot, player, container, inventory, page, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int page) {
|
||||
ItemInventoryBackpackPaged inventory = new ItemInventoryBackpackPaged(player, Constants.SLOTS_BACKPACK_APIARIST, heldItem);
|
||||
ItemInventoryBackpackPaged inventory = new ItemInventoryBackpackPaged(player, Constants.SLOTS_BACKPACK_APIARIST, heldItem, this);
|
||||
return new ContainerNaturalistBackpack(player, inventory, page);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user