mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-25 06:14:46 +00:00
Clean up network, clearly separate client and server packets
This commit is contained in:
1 parent
140643bec3
commit
614c13b4f3
90 files changed
+1326
-1056
No files matched your search
@@ -30,13 +30,7 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.Type;
|
||||
|
||||
import forestry.api.fuels.EngineBronzeFuel;
|
||||
import forestry.api.fuels.EngineCopperFuel;
|
||||
import forestry.api.fuels.FermenterFuel;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.fuels.GeneratorFuel;
|
||||
import forestry.api.fuels.MoistenerFuel;
|
||||
import forestry.api.fuels.RainSubstrate;
|
||||
import forestry.core.ForestryCore;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.ForestryItem;
|
||||
|
||||
@@ -11,18 +11,20 @@
|
||||
package forestry.apiculture.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.apiculture.items.ItemImprinter.ImprinterInventory;
|
||||
import forestry.apiculture.network.PacketImprintSelectionRequest;
|
||||
import forestry.apiculture.network.PacketImprintSelectionResponse;
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.IGuiSelectable;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.PacketGuiSelect;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class ContainerImprinter extends ContainerItemInventory<ImprinterInventory> implements IGuiSelectable {
|
||||
@@ -68,38 +70,39 @@ public class ContainerImprinter extends ContainerItemInventory<ImprinterInventor
|
||||
public void updateContainer(World world) {
|
||||
if (!isNetSynced && world.isRemote) {
|
||||
isNetSynced = true;
|
||||
Proxies.net.sendToServer(new ForestryPacket(PacketId.IMPRINT_SELECTION_GET));
|
||||
Proxies.net.sendToServer(new PacketImprintSelectionRequest());
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSelectionChange(int index, int advance) {
|
||||
ForestryPacket packet = new PacketGuiSelect(PacketId.GUI_SELECTION_CHANGE, index, advance);
|
||||
IForestryPacketServer packet = new PacketGuiSelectRequest(index, advance);
|
||||
Proxies.net.sendToServer(packet);
|
||||
isNetSynced = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelectionChange(EntityPlayer player, PacketGuiSelect packet) {
|
||||
if (packet.getSecondaryIndex() == 0) {
|
||||
if (packet.getPrimaryIndex() == 0) {
|
||||
public void handleSelectionRequest(EntityPlayerMP player, PacketGuiSelectRequest packetRequest) {
|
||||
if (packetRequest.getSecondaryIndex() == 0) {
|
||||
if (packetRequest.getPrimaryIndex() == 0) {
|
||||
inventory.advancePrimary();
|
||||
} else {
|
||||
inventory.advanceSecondary();
|
||||
}
|
||||
} else if (packet.getPrimaryIndex() == 0) {
|
||||
} else if (packetRequest.getPrimaryIndex() == 0) {
|
||||
inventory.regressPrimary();
|
||||
} else {
|
||||
inventory.regressSecondary();
|
||||
}
|
||||
|
||||
sendSelection(player);
|
||||
}
|
||||
|
||||
public void sendSelection(EntityPlayer player) {
|
||||
ForestryPacket packet = new PacketGuiSelect(PacketId.GUI_SELECTION_SET, inventory.getPrimaryIndex(), inventory.getSecondaryIndex());
|
||||
Proxies.net.sendToPlayer(packet, player);
|
||||
public void sendSelection(EntityPlayerMP player) {
|
||||
PacketImprintSelectionResponse packetResponse = new PacketImprintSelectionResponse(inventory.getPrimaryIndex(), inventory.getSecondaryIndex());
|
||||
Proxies.net.sendToPlayer(packetResponse, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(PacketGuiSelect packetPayload) {
|
||||
public void setSelection(PacketImprintSelectionResponse packetPayload) {
|
||||
inventory.setPrimaryIndex(packetPayload.getPrimaryIndex());
|
||||
inventory.setSecondaryIndex(packetPayload.getSecondaryIndex());
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
@@ -43,6 +44,7 @@ import forestry.api.core.IErrorSource;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.apiculture.network.PacketHabitatBiomePointer;
|
||||
import forestry.apiculture.render.TextureHabitatLocator;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.ForestryItem;
|
||||
@@ -118,7 +120,7 @@ public class ItemHabitatLocator extends ItemInventoried {
|
||||
removeInvalidBiomes(currentBiome, targetBiomes);
|
||||
|
||||
// reset the locator coordinates
|
||||
Proxies.common.setHabitatLocatorCoordinates(null, null);
|
||||
Proxies.common.setHabitatLocatorTexture(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,8 +142,8 @@ public class ItemHabitatLocator extends ItemInventoried {
|
||||
ChunkCoordinates target = findNearestBiome(player, targetBiomes);
|
||||
|
||||
// send an update if we find the biome
|
||||
if (target != null) {
|
||||
Proxies.common.setHabitatLocatorCoordinates(player, target);
|
||||
if (target != null && player instanceof EntityPlayerMP) {
|
||||
Proxies.net.sendToPlayer(new PacketHabitatBiomePointer(target), (EntityPlayerMP) player);
|
||||
biomeFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,29 +12,26 @@ package forestry.apiculture.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IActivatable;
|
||||
|
||||
public class PacketActiveUpdate extends PacketCoordinates {
|
||||
public class PacketActiveUpdate extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
private boolean active;
|
||||
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketActiveUpdate(data);
|
||||
}
|
||||
|
||||
private PacketActiveUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketActiveUpdate() {
|
||||
}
|
||||
|
||||
public PacketActiveUpdate(IActivatable tile) {
|
||||
super(PacketId.TILE_FORESTRY_ACTIVE, tile.getCoordinates());
|
||||
super(PacketIdClient.TILE_FORESTRY_ACTIVE, tile.getCoordinates());
|
||||
this.active = tile.isActive();
|
||||
}
|
||||
|
||||
@@ -45,11 +42,13 @@ public class PacketActiveUpdate extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
active = data.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) {
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof IActivatable) {
|
||||
((IActivatable) tile).setActive(active);
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.apiculture.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
@@ -19,23 +20,19 @@ import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.apiculture.BeekeepingLogic;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketBeekeepingLogicActive extends PacketCoordinates {
|
||||
public class PacketBeekeepingLogicActive extends PacketCoordinates implements IForestryPacketClient {
|
||||
private BeekeepingLogic beekeepingLogic;
|
||||
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketBeekeepingLogicActive(data);
|
||||
}
|
||||
|
||||
private PacketBeekeepingLogicActive(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketBeekeepingLogicActive() {
|
||||
}
|
||||
|
||||
public PacketBeekeepingLogicActive(IBeeHousing tile) {
|
||||
super(PacketId.BEE_LOGIC_ACTIVE, tile.getCoordinates());
|
||||
super(PacketIdClient.BEE_LOGIC_ACTIVE, tile.getCoordinates());
|
||||
this.beekeepingLogic = (BeekeepingLogic) tile.getBeekeepingLogic();
|
||||
}
|
||||
|
||||
@@ -46,9 +43,7 @@ public class PacketBeekeepingLogicActive extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof IBeeHousing) {
|
||||
IBeeHousing beeHousing = (IBeeHousing) tile;
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*******************************************************************************
|
||||
* 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.apiculture.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.apiculture.tiles.TileCandle;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketCandleUpdate extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
private int colour;
|
||||
private boolean lit;
|
||||
|
||||
public PacketCandleUpdate() {
|
||||
}
|
||||
|
||||
public PacketCandleUpdate(TileCandle tileCandle) {
|
||||
super(PacketIdClient.CANDLE_UPDATE, tileCandle);
|
||||
|
||||
colour = tileCandle.getColour();
|
||||
lit = tileCandle.isLit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeInt(colour);
|
||||
data.writeBoolean(lit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
colour = data.readInt();
|
||||
lit = data.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
TileEntity tileEntity = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tileEntity instanceof TileCandle) {
|
||||
((TileCandle) tileEntity).onPacketUpdate(colour, lit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*******************************************************************************
|
||||
* 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.apiculture.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketHabitatBiomePointer extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
public PacketHabitatBiomePointer() {
|
||||
}
|
||||
|
||||
public PacketHabitatBiomePointer(ChunkCoordinates coordinates) {
|
||||
super(PacketIdClient.HABITAT_BIOME_POINTER, coordinates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
Proxies.common.setHabitatLocatorTexture(player, getCoordinates());
|
||||
}
|
||||
}
|
||||
@@ -1,72 +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.apiculture.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.apiculture.gui.ContainerImprinter;
|
||||
import forestry.apiculture.tiles.TileCandle;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketHandlerApiculture implements IPacketHandler {
|
||||
|
||||
@Override
|
||||
public boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
|
||||
switch (packetID) {
|
||||
case HABITAT_BIOME_POINTER: {
|
||||
PacketCoordinates packet = new PacketCoordinates(data);
|
||||
Proxies.common.setHabitatLocatorCoordinates(player, packet.getCoordinates());
|
||||
return true;
|
||||
}
|
||||
case IMPRINT_SELECTION_GET: {
|
||||
onImprintSelectionGet(player);
|
||||
return true;
|
||||
}
|
||||
case CANDLE: {
|
||||
PacketUpdateCandle updateCandle = new PacketUpdateCandle(data);
|
||||
onCandleUpdate(updateCandle);
|
||||
return true;
|
||||
}
|
||||
case BEE_LOGIC_ACTIVE: {
|
||||
PacketBeekeepingLogicActive.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void onImprintSelectionGet(EntityPlayer playerEntity) {
|
||||
|
||||
if (!(playerEntity.openContainer instanceof ContainerImprinter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((ContainerImprinter) playerEntity.openContainer).sendSelection(playerEntity);
|
||||
|
||||
}
|
||||
|
||||
private static void onCandleUpdate(PacketUpdateCandle updateCandle) {
|
||||
TileEntity tileEntity = updateCandle.getTarget(Proxies.common.getRenderWorld());
|
||||
if (tileEntity instanceof TileCandle) {
|
||||
((TileCandle) tileEntity).onPacketUpdate(updateCandle);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*******************************************************************************
|
||||
* 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.apiculture.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import forestry.apiculture.gui.ContainerImprinter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
|
||||
public class PacketImprintSelectionRequest extends ForestryPacket implements IForestryPacketServer {
|
||||
|
||||
public PacketImprintSelectionRequest() {
|
||||
super(PacketIdServer.IMPRINT_SELECTION_REQUEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
if (!(player.openContainer instanceof ContainerImprinter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((ContainerImprinter) player.openContainer).sendSelection(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*******************************************************************************
|
||||
* 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.apiculture.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import forestry.apiculture.gui.ContainerImprinter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketGuiSelect;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
|
||||
public class PacketImprintSelectionResponse extends PacketGuiSelect implements IForestryPacketClient {
|
||||
|
||||
public PacketImprintSelectionResponse() {
|
||||
}
|
||||
|
||||
public PacketImprintSelectionResponse(int primaryIndex, int secondaryIndex) {
|
||||
super(PacketIdClient.IMPRINT_SELECTION_RESPONSE, primaryIndex, secondaryIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
Container container = player.openContainer;
|
||||
if (!(container instanceof ContainerImprinter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((ContainerImprinter) container).setSelection(this);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package forestry.apiculture.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.apiculture.tiles.TileCandle;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
|
||||
public class PacketUpdateCandle extends PacketCoordinates {
|
||||
|
||||
private int colour;
|
||||
private boolean lit;
|
||||
|
||||
public PacketUpdateCandle(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
}
|
||||
|
||||
public PacketUpdateCandle(TileCandle tileCandle) {
|
||||
super(PacketId.CANDLE, tileCandle);
|
||||
|
||||
colour = tileCandle.getColour();
|
||||
lit = tileCandle.isLit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeInt(colour);
|
||||
data.writeBoolean(lit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
colour = data.readInt();
|
||||
lit = data.readBoolean();
|
||||
}
|
||||
|
||||
public int getColour() {
|
||||
return colour;
|
||||
}
|
||||
|
||||
public boolean isLit() {
|
||||
return lit;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.apiculture.network.PacketUpdateCandle;
|
||||
import forestry.apiculture.network.PacketCandleUpdate;
|
||||
|
||||
public class TileCandle extends TileEntity {
|
||||
private int colour;
|
||||
@@ -28,13 +28,13 @@ public class TileCandle extends TileEntity {
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
PacketUpdateCandle updateCandle = new PacketUpdateCandle(this);
|
||||
PacketCandleUpdate updateCandle = new PacketCandleUpdate(this);
|
||||
return updateCandle.getPacket();
|
||||
}
|
||||
|
||||
public void onPacketUpdate(PacketUpdateCandle updateCandle) {
|
||||
colour = updateCandle.getColour();
|
||||
lit = updateCandle.isLit();
|
||||
public void onPacketUpdate(int colour, boolean isLit) {
|
||||
this.colour = colour;
|
||||
this.lit = isLit;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/*******************************************************************************
|
||||
* 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.arboriculture.network;
|
||||
|
||||
public interface IRipeningPacketReceiver {
|
||||
void fromRipeningPacket(int ripeningValue);
|
||||
}
|
||||
@@ -12,35 +12,32 @@ package forestry.arboriculture.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.arboriculture.tiles.TileFruitPod;
|
||||
import forestry.arboriculture.tiles.TileLeaves;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketRipeningUpdate extends PacketCoordinates {
|
||||
public class PacketRipeningUpdate extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
private int value;
|
||||
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketRipeningUpdate(data);
|
||||
}
|
||||
|
||||
private PacketRipeningUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketRipeningUpdate() {
|
||||
}
|
||||
|
||||
public PacketRipeningUpdate(TileFruitPod fruitPod) {
|
||||
super(PacketId.RIPENING_UPDATE, fruitPod);
|
||||
super(PacketIdClient.RIPENING_UPDATE, fruitPod);
|
||||
value = fruitPod.getMaturity();
|
||||
}
|
||||
|
||||
public PacketRipeningUpdate(TileLeaves leaves) {
|
||||
super(PacketId.RIPENING_UPDATE, leaves);
|
||||
super(PacketIdClient.RIPENING_UPDATE, leaves);
|
||||
value = leaves.getFruitColour();
|
||||
}
|
||||
|
||||
@@ -54,16 +51,13 @@ public class PacketRipeningUpdate extends PacketCoordinates {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
value = data.readVarInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof TileLeaves) {
|
||||
((TileLeaves) tile).fromRipeningPacket(value);
|
||||
} else if (tile instanceof TileFruitPod) {
|
||||
((TileFruitPod) tile).fromRipeningPacket(value);
|
||||
if (tile instanceof IRipeningPacketReceiver) {
|
||||
((IRipeningPacketReceiver) tile).fromRipeningPacket(value);
|
||||
}
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IFruitBearer;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.arboriculture.network.IRipeningPacketReceiver;
|
||||
import forestry.arboriculture.network.PacketRipeningUpdate;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
@@ -37,7 +38,7 @@ import forestry.core.network.PacketTileStream;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
|
||||
public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamable {
|
||||
public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamable, IRipeningPacketReceiver {
|
||||
|
||||
private static final short MAX_MATURITY = 2;
|
||||
|
||||
@@ -138,6 +139,7 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
|
||||
Proxies.net.sendNetworkPacket(new PacketRipeningUpdate(this), worldObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromRipeningPacket(int newMaturity) {
|
||||
if (newMaturity == maturity) {
|
||||
return;
|
||||
|
||||
@@ -52,6 +52,7 @@ import forestry.api.lepidopterology.IButterflyNursery;
|
||||
import forestry.api.lepidopterology.IButterflyRoot;
|
||||
import forestry.arboriculture.genetics.Tree;
|
||||
import forestry.arboriculture.genetics.TreeDefinition;
|
||||
import forestry.arboriculture.network.IRipeningPacketReceiver;
|
||||
import forestry.arboriculture.network.PacketRipeningUpdate;
|
||||
import forestry.core.genetics.alleles.Allele;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
@@ -63,7 +64,7 @@ import forestry.core.utils.ColourUtil;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
public class TileLeaves extends TileTreeContainer implements IPollinatable, IFruitBearer, IButterflyNursery {
|
||||
public class TileLeaves extends TileTreeContainer implements IPollinatable, IFruitBearer, IButterflyNursery, IRipeningPacketReceiver {
|
||||
|
||||
private int colourLeaves;
|
||||
private int colourLeavesPollinated;
|
||||
@@ -445,6 +446,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromRipeningPacket(int newColourFruits) {
|
||||
if (newColourFruits == colourFruits) {
|
||||
return;
|
||||
|
||||
@@ -24,8 +24,7 @@ import forestry.core.config.Config;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketAccessSwitch;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IRestrictedAccessTile;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
@@ -96,7 +95,7 @@ public final class AccessHandler implements IAccessHandler, IStreamable, INBTTag
|
||||
access = EnumAccess.values()[ordinal];
|
||||
|
||||
if (player.worldObj.isRemote) {
|
||||
Proxies.net.sendToServer(new PacketCoordinates(PacketId.ACCESS_SWITCH, tile.getCoordinates()));
|
||||
Proxies.net.sendToServer(new PacketAccessSwitch(tile.getCoordinates()));
|
||||
} else {
|
||||
tile.onSwitchAccess(oldAccess, access);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.core.circuits;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
import forestry.core.circuits.ItemSolderingIron.SolderingInventory;
|
||||
@@ -18,9 +19,10 @@ import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.IGuiSelectable;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.core.network.PacketGuiSelect;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketString;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketGuiLayoutSelect;
|
||||
import forestry.core.network.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class ContainerSolderingIron extends ContainerItemInventory<SolderingInventory> implements IGuiSelectable {
|
||||
@@ -54,12 +56,12 @@ public class ContainerSolderingIron extends ContainerItemInventory<SolderingInve
|
||||
}
|
||||
|
||||
private static void sendSelectionChange(int index, int advance) {
|
||||
PacketGuiSelect packet = new PacketGuiSelect(PacketId.GUI_SELECTION_CHANGE, index, advance);
|
||||
IForestryPacketServer packet = new PacketGuiSelectRequest(index, advance);
|
||||
Proxies.net.sendToServer(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelectionChange(EntityPlayer player, PacketGuiSelect packet) {
|
||||
public void handleSelectionRequest(EntityPlayerMP player, PacketGuiSelectRequest packet) {
|
||||
|
||||
if (packet.getSecondaryIndex() == 0) {
|
||||
if (packet.getPrimaryIndex() == 0) {
|
||||
@@ -69,16 +71,8 @@ public class ContainerSolderingIron extends ContainerItemInventory<SolderingInve
|
||||
inventory.regressLayout();
|
||||
}
|
||||
|
||||
sendSelection(player);
|
||||
}
|
||||
|
||||
private void sendSelection(EntityPlayer player) {
|
||||
PacketString packet = new PacketString(PacketId.GUI_LAYOUT_SELECT, inventory.getLayout().getUID());
|
||||
Proxies.net.sendToPlayer(packet, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(PacketGuiSelect packet) {
|
||||
IForestryPacketClient packetResponse = new PacketGuiLayoutSelect(inventory.getLayout().getUID());
|
||||
Proxies.net.sendToPlayer(packetResponse, player);
|
||||
}
|
||||
|
||||
public void setLayout(String layoutUID) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.WorldSavedData;
|
||||
|
||||
@@ -30,8 +31,7 @@ import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketNBT;
|
||||
import forestry.core.network.PacketGenomeTrackerUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class BreedingTracker extends WorldSavedData implements IBreedingTracker {
|
||||
@@ -85,13 +85,15 @@ public abstract class BreedingTracker extends WorldSavedData implements IBreedin
|
||||
|
||||
@Override
|
||||
public void synchToPlayer(EntityPlayer player) {
|
||||
IBreedingTracker breedingTracker = getBreedingTracker(player);
|
||||
String modeName = breedingTracker.getModeName();
|
||||
setModeName(modeName);
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
IBreedingTracker breedingTracker = getBreedingTracker(player);
|
||||
String modeName = breedingTracker.getModeName();
|
||||
setModeName(modeName);
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
encodeToNBT(nbttagcompound);
|
||||
Proxies.net.sendToPlayer(new PacketNBT(PacketId.GENOME_TRACKER_UPDATE, nbttagcompound), player);
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
encodeToNBT(nbttagcompound);
|
||||
Proxies.net.sendToPlayer(new PacketGenomeTrackerUpdate(nbttagcompound), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
/* HELPER FUNCTIONS TO PREVENT OBFUSCATION OF INTERFACE METHODS */
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.core.network.PacketGuiSelect;
|
||||
import forestry.core.network.PacketGuiSelectRequest;
|
||||
import forestry.core.tiles.TileEscritoire;
|
||||
|
||||
public class ContainerEscritoire extends ContainerTile<TileEscritoire> implements IGuiSelectable {
|
||||
@@ -54,7 +55,7 @@ public class ContainerEscritoire extends ContainerTile<TileEscritoire> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelectionChange(EntityPlayer player, PacketGuiSelect packet) {
|
||||
public void handleSelectionRequest(EntityPlayerMP player, PacketGuiSelectRequest packet) {
|
||||
if (!tile.getGame().isEnded()) {
|
||||
int index = packet.getPrimaryIndex();
|
||||
if (index == -1) {
|
||||
@@ -65,8 +66,4 @@ public class ContainerEscritoire extends ContainerTile<TileEscritoire> implement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(PacketGuiSelect packet) {
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.gui.slots.SlotForestry;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
|
||||
@@ -65,7 +65,7 @@ public abstract class ContainerForestry extends Container {
|
||||
|
||||
protected abstract boolean canAccess(EntityPlayer player);
|
||||
|
||||
protected final void sendPacketToCrafters(ForestryPacket packet) {
|
||||
protected final void sendPacketToCrafters(IForestryPacketClient packet) {
|
||||
for (Object crafter : crafters) {
|
||||
if (crafter instanceof EntityPlayer) {
|
||||
Proxies.net.sendToPlayer(packet, (EntityPlayer) crafter);
|
||||
|
||||
@@ -20,8 +20,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import forestry.api.core.IToolPipette;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketSlotClick;
|
||||
import forestry.core.network.PacketPipetteClick;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
|
||||
@@ -40,7 +39,7 @@ public class ContainerLiquidTanksHelper<T extends TileEntity & ILiquidTankTile>
|
||||
return;
|
||||
}
|
||||
|
||||
Proxies.net.sendToServer(new PacketSlotClick(PacketId.PIPETTE_CLICK, tile, slot));
|
||||
Proxies.net.sendToServer(new PacketPipetteClick(tile, slot));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.network.PacketGuiSelect;
|
||||
import forestry.core.network.PacketGuiSelectRequest;
|
||||
import forestry.core.tiles.TileNaturalistChest;
|
||||
|
||||
public class ContainerNaturalistInventory extends ContainerTile<TileNaturalistChest> implements IGuiSelectable {
|
||||
@@ -32,14 +33,10 @@ public class ContainerNaturalistInventory extends ContainerTile<TileNaturalistCh
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelectionChange(EntityPlayer player, PacketGuiSelect packet) {
|
||||
public void handleSelectionRequest(EntityPlayerMP player, PacketGuiSelectRequest packet) {
|
||||
tile.flipPage(player, packet.getPrimaryIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(PacketGuiSelect packet) {
|
||||
}
|
||||
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
tile.closeInventory();
|
||||
|
||||
@@ -17,9 +17,9 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuitBoard;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketSlotClick;
|
||||
import forestry.core.network.PacketChipsetClick;
|
||||
import forestry.core.network.PacketSocketUpdate;
|
||||
import forestry.core.network.PacketSolderingIronClick;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
|
||||
@@ -33,8 +33,7 @@ public class ContainerSocketedHelper<T extends TileEntity & ISocketable> impleme
|
||||
|
||||
@Override
|
||||
public void handleChipsetClick(int slot) {
|
||||
PacketSlotClick packet = new PacketSlotClick(PacketId.CHIPSET_CLICK, tile, slot);
|
||||
Proxies.net.sendToServer(packet);
|
||||
Proxies.net.sendToServer(new PacketChipsetClick(tile, slot));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,8 +76,7 @@ public class ContainerSocketedHelper<T extends TileEntity & ISocketable> impleme
|
||||
|
||||
@Override
|
||||
public void handleSolderingIronClick(int slot) {
|
||||
PacketSlotClick packet = new PacketSlotClick(PacketId.SOLDERING_IRON_CLICK, tile, slot);
|
||||
Proxies.net.sendToServer(packet);
|
||||
Proxies.net.sendToServer(new PacketSolderingIronClick(tile, slot));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,8 +26,7 @@ import org.lwjgl.opengl.GL11;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.gui.widgets.WidgetManager;
|
||||
import forestry.core.network.PacketGuiSelect;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.render.TextureManager;
|
||||
@@ -123,8 +122,7 @@ public class GuiEscritoire extends GuiForestry<ContainerEscritoire, TileEscritoi
|
||||
|
||||
@Override
|
||||
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
|
||||
PacketGuiSelect packet = new PacketGuiSelect(PacketId.GUI_SELECTION_CHANGE, index, 0);
|
||||
Proxies.net.sendToServer(packet);
|
||||
Proxies.net.sendToServer(new PacketGuiSelectRequest(index, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,8 +151,7 @@ public class GuiEscritoire extends GuiForestry<ContainerEscritoire, TileEscritoi
|
||||
@Override
|
||||
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
|
||||
pressed = true;
|
||||
PacketGuiSelect packet = new PacketGuiSelect(PacketId.GUI_SELECTION_CHANGE, -1, 0);
|
||||
Proxies.net.sendToServer(packet);
|
||||
Proxies.net.sendToServer(new PacketGuiSelectRequest(-1, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,9 +30,7 @@ import forestry.core.config.Constants;
|
||||
import forestry.core.genetics.mutations.EnumMutateChance;
|
||||
import forestry.core.gui.buttons.GuiBetterButton;
|
||||
import forestry.core.gui.buttons.StandardButtonTextureSets;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.PacketGuiSelect;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
@@ -94,8 +92,7 @@ public class GuiNaturalistInventory extends GuiForestry<Container, IPagedInvento
|
||||
}
|
||||
|
||||
private static void flipPage(int page) {
|
||||
ForestryPacket packet = new PacketGuiSelect(PacketId.GUI_SELECTION_CHANGE, page, 0);
|
||||
Proxies.net.sendToServer(packet);
|
||||
Proxies.net.sendToServer(new PacketGuiSelectRequest(page, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,12 +10,11 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import forestry.core.network.PacketGuiSelect;
|
||||
import forestry.core.network.PacketGuiSelectRequest;
|
||||
|
||||
public interface IGuiSelectable {
|
||||
void handleSelectionChange(EntityPlayer player, PacketGuiSelect packet);
|
||||
|
||||
void setSelection(PacketGuiSelect packetPayload);
|
||||
// server
|
||||
void handleSelectionRequest(EntityPlayerMP player, PacketGuiSelectRequest packetRequest);
|
||||
}
|
||||
@@ -17,17 +17,16 @@ import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class ForestryPacket {
|
||||
public class ForestryPacket implements IForestryPacket {
|
||||
|
||||
protected static final String channel = "FOR";
|
||||
private final PacketId id;
|
||||
|
||||
protected ForestryPacket(DataInputStreamForestry data) throws IOException {
|
||||
this.id = PacketId.INVALID;
|
||||
readData(data);
|
||||
private IPacketId id;
|
||||
|
||||
protected ForestryPacket() {
|
||||
}
|
||||
|
||||
public ForestryPacket(PacketId id) {
|
||||
public ForestryPacket(IPacketId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -48,6 +47,6 @@ public class ForestryPacket {
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
}
|
||||
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
}
|
||||
}
|
||||
+21
-36
@@ -1,36 +1,21 @@
|
||||
/*******************************************************************************
|
||||
* 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.arboriculture.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketId;
|
||||
|
||||
public class PacketHandlerArboriculture implements IPacketHandler {
|
||||
|
||||
@Override
|
||||
public boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
|
||||
switch (packetID) {
|
||||
case RIPENING_UPDATE: {
|
||||
PacketRipeningUpdate.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
|
||||
public interface IForestryPacket {
|
||||
void readData(DataInputStreamForestry data) throws IOException;
|
||||
|
||||
FMLProxyPacket getPacket();
|
||||
}
|
||||
+19
-22
@@ -1,22 +1,19 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public interface IPacketHandler {
|
||||
|
||||
/** Returns true if the packet has been handled */
|
||||
boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException;
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
public interface IForestryPacketClient extends IForestryPacket {
|
||||
void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
public interface IForestryPacketServer extends IForestryPacket {
|
||||
void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
public interface IPacketId {
|
||||
int ordinal();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
import forestry.apiculture.multiblock.IAlvearyController;
|
||||
import forestry.apiculture.multiblock.TileAlveary;
|
||||
import forestry.core.tiles.IRestrictedAccessTile;
|
||||
import forestry.farming.multiblock.IFarmController;
|
||||
import forestry.farming.tiles.TileFarm;
|
||||
|
||||
public class PacketAccessSwitch extends PacketCoordinates implements IForestryPacketServer {
|
||||
|
||||
public PacketAccessSwitch() {
|
||||
}
|
||||
|
||||
public PacketAccessSwitch(ChunkCoordinates coordinates) {
|
||||
super(PacketIdServer.ACCESS_SWITCH, coordinates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
TileEntity tile = getTarget(player.worldObj);
|
||||
|
||||
if (tile instanceof TileAlveary) {
|
||||
TileAlveary tileAlveary = (TileAlveary) tile;
|
||||
IAlvearyController alvearyController = tileAlveary.getAlvearyController();
|
||||
alvearyController.getAccessHandler().switchAccessRule(player);
|
||||
} else if (tile instanceof TileFarm) {
|
||||
TileFarm tileFarm = (TileFarm) tile;
|
||||
IFarmController farmController = tileFarm.getFarmController();
|
||||
farmController.getAccessHandler().switchAccessRule(player);
|
||||
} else if (tile instanceof IRestrictedAccessTile) {
|
||||
IRestrictedAccessTile restrictedAccessTile = (IRestrictedAccessTile) tile;
|
||||
restrictedAccessTile.getAccessHandler().switchAccessRule(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.circuits.ItemCircuitBoard;
|
||||
import forestry.core.gui.IContainerSocketed;
|
||||
|
||||
public class PacketChipsetClick extends PacketSlotClick implements IForestryPacketServer {
|
||||
|
||||
public PacketChipsetClick() {
|
||||
}
|
||||
|
||||
public PacketChipsetClick(TileEntity tile, int slot) {
|
||||
super(PacketIdServer.CHIPSET_CLICK, tile, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
if (!(player.openContainer instanceof IContainerSocketed)) {
|
||||
return;
|
||||
}
|
||||
ItemStack itemstack = player.inventory.getItemStack();
|
||||
if (!(itemstack.getItem() instanceof ItemCircuitBoard)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IContainerSocketed) player.openContainer).handleChipsetClickServer(getSlot(), player, itemstack);
|
||||
}
|
||||
}
|
||||
@@ -16,25 +16,24 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PacketCoordinates extends ForestryPacket implements ILocatedPacket {
|
||||
public abstract class PacketCoordinates extends ForestryPacket implements ILocatedPacket {
|
||||
|
||||
private int posX;
|
||||
private int posY;
|
||||
private int posZ;
|
||||
|
||||
public PacketCoordinates(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketCoordinates() {
|
||||
}
|
||||
|
||||
public PacketCoordinates(PacketId id, TileEntity tileEntity) {
|
||||
protected PacketCoordinates(IPacketId id, TileEntity tileEntity) {
|
||||
this(id, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
|
||||
}
|
||||
|
||||
public PacketCoordinates(PacketId id, ChunkCoordinates coordinates) {
|
||||
protected PacketCoordinates(IPacketId id, ChunkCoordinates coordinates) {
|
||||
this(id, coordinates.posX, coordinates.posY, coordinates.posZ);
|
||||
}
|
||||
|
||||
public PacketCoordinates(PacketId id, int posX, int posY, int posZ) {
|
||||
protected PacketCoordinates(IPacketId id, int posX, int posY, int posZ) {
|
||||
super(id);
|
||||
this.posX = posX;
|
||||
this.posY = posY;
|
||||
@@ -49,13 +48,13 @@ public class PacketCoordinates extends ForestryPacket implements ILocatedPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
posX = data.readVarInt();
|
||||
posY = data.readVarInt();
|
||||
posZ = data.readVarInt();
|
||||
}
|
||||
|
||||
public final ChunkCoordinates getCoordinates() {
|
||||
protected final ChunkCoordinates getCoordinates() {
|
||||
return new ChunkCoordinates(posX, posY, posZ);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
|
||||
public class PacketDummy implements IForestryPacketClient, IForestryPacketServer {
|
||||
|
||||
public static final PacketDummy instance = new PacketDummy();
|
||||
|
||||
private PacketDummy() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FMLProxyPacket getPacket() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -12,26 +12,22 @@ package forestry.core.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketErrorUpdate extends PacketCoordinates {
|
||||
public class PacketErrorUpdate extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
private IErrorLogic errorLogic;
|
||||
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketErrorUpdate(data);
|
||||
}
|
||||
|
||||
private PacketErrorUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketErrorUpdate() {
|
||||
}
|
||||
|
||||
public PacketErrorUpdate(TileEntity tile, IErrorLogicSource errorLogicSource) {
|
||||
super(PacketId.TILE_FORESTRY_ERROR_UPDATE, tile);
|
||||
super(PacketIdClient.ERROR_UPDATE, tile);
|
||||
this.errorLogic = errorLogicSource.getErrorLogic();
|
||||
}
|
||||
|
||||
@@ -42,9 +38,7 @@ public class PacketErrorUpdate extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof IErrorLogicSource) {
|
||||
IErrorLogicSource errorSourceTile = (IErrorLogicSource) tile;
|
||||
|
||||
@@ -13,12 +13,13 @@ package forestry.core.network;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketFXSignal extends PacketCoordinates {
|
||||
public class PacketFXSignal extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
public enum VisualFXType {
|
||||
NONE, BLOCK_DESTROY, SAPLING_PLACE
|
||||
@@ -44,8 +45,7 @@ public class PacketFXSignal extends PacketCoordinates {
|
||||
private Block block;
|
||||
private int meta;
|
||||
|
||||
public PacketFXSignal(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketFXSignal() {
|
||||
}
|
||||
|
||||
public PacketFXSignal(VisualFXType type, int xCoord, int yCoord, int zCoord, Block block, int meta) {
|
||||
@@ -57,7 +57,7 @@ public class PacketFXSignal extends PacketCoordinates {
|
||||
}
|
||||
|
||||
public PacketFXSignal(VisualFXType visualFX, SoundFXType soundFX, int xCoord, int yCoord, int zCoord, Block block, int meta) {
|
||||
super(PacketId.FX_SIGNAL, xCoord, yCoord, zCoord);
|
||||
super(PacketIdClient.FX_SIGNAL, xCoord, yCoord, zCoord);
|
||||
this.visualFX = visualFX;
|
||||
this.soundFX = soundFX;
|
||||
this.block = block;
|
||||
@@ -74,7 +74,7 @@ public class PacketFXSignal extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
this.visualFX = VisualFXType.values()[data.readShort()];
|
||||
this.soundFX = SoundFXType.values()[data.readShort()];
|
||||
@@ -82,7 +82,8 @@ public class PacketFXSignal extends PacketCoordinates {
|
||||
this.meta = data.readInt();
|
||||
}
|
||||
|
||||
public void executeFX() {
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
if (visualFX != VisualFXType.NONE) {
|
||||
Proxies.common.addBlockDestroyEffects(Proxies.common.getRenderWorld(), getPosX(), getPosY(), getPosZ(), block, meta);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import forestry.api.core.ForestryEvent;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.genetics.BreedingTracker;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketGenomeTrackerUpdate extends PacketNBT implements IForestryPacketClient {
|
||||
|
||||
public PacketGenomeTrackerUpdate() {
|
||||
}
|
||||
|
||||
public PacketGenomeTrackerUpdate(NBTTagCompound nbtTagCompound) {
|
||||
super(PacketIdClient.GENOME_TRACKER_UPDATE, nbtTagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
IBreedingTracker tracker = null;
|
||||
String type = getTagCompound().getString(BreedingTracker.TYPE_KEY);
|
||||
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(type);
|
||||
if (root != null) {
|
||||
tracker = root.getBreedingTracker(Proxies.common.getRenderWorld(), player.getGameProfile());
|
||||
}
|
||||
if (tracker != null) {
|
||||
tracker.decodeFromNBT(getTagCompound());
|
||||
MinecraftForge.EVENT_BUS.post(new ForestryEvent.SyncedBreedingTracker(tracker, player));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,27 +12,20 @@ package forestry.core.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.core.gui.ContainerTile;
|
||||
|
||||
public class PacketGuiEnergy extends ForestryPacket {
|
||||
public class PacketGuiEnergy extends ForestryPacket implements IForestryPacketClient {
|
||||
|
||||
private int windowId;
|
||||
private int value;
|
||||
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketGuiEnergy(data);
|
||||
}
|
||||
|
||||
private PacketGuiEnergy(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketGuiEnergy() {
|
||||
}
|
||||
|
||||
public PacketGuiEnergy(int windowId, int value) {
|
||||
super(PacketId.GUI_ENERGY);
|
||||
super(PacketIdClient.GUI_ENERGY);
|
||||
this.windowId = windowId;
|
||||
this.value = value;
|
||||
}
|
||||
@@ -44,12 +37,13 @@ public class PacketGuiEnergy extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
windowId = data.readVarInt();
|
||||
value = data.readVarInt();
|
||||
}
|
||||
|
||||
EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer;
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
if (player.openContainer instanceof ContainerTile && player.openContainer.windowId == windowId) {
|
||||
((ContainerTile) player.openContainer).onGuiEnergy(value);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import forestry.core.circuits.ContainerSolderingIron;
|
||||
|
||||
public class PacketGuiLayoutSelect extends PacketString implements IForestryPacketClient {
|
||||
|
||||
public PacketGuiLayoutSelect() {
|
||||
}
|
||||
|
||||
public PacketGuiLayoutSelect(String string) {
|
||||
super(PacketIdClient.GUI_LAYOUT_SELECT, string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
Container container = player.openContainer;
|
||||
if (!(container instanceof ContainerSolderingIron)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((ContainerSolderingIron) container).setLayout(getString());
|
||||
}
|
||||
}
|
||||
@@ -12,15 +12,14 @@ package forestry.core.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketGuiSelect extends ForestryPacket {
|
||||
public abstract class PacketGuiSelect extends ForestryPacket {
|
||||
private int primaryIndex;
|
||||
private int secondaryIndex;
|
||||
|
||||
public PacketGuiSelect(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
protected PacketGuiSelect() {
|
||||
}
|
||||
|
||||
public PacketGuiSelect(PacketId id, int primaryIndex, int secondaryIndex) {
|
||||
protected PacketGuiSelect(IPacketId id, int primaryIndex, int secondaryIndex) {
|
||||
super(id);
|
||||
this.primaryIndex = primaryIndex;
|
||||
this.secondaryIndex = secondaryIndex;
|
||||
@@ -34,7 +33,7 @@ public class PacketGuiSelect extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
primaryIndex = data.readInt();
|
||||
secondaryIndex = data.readInt();
|
||||
@@ -47,4 +46,5 @@ public class PacketGuiSelect extends ForestryPacket {
|
||||
public int getSecondaryIndex() {
|
||||
return secondaryIndex;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import forestry.core.gui.IGuiSelectable;
|
||||
|
||||
public class PacketGuiSelectRequest extends PacketGuiSelect implements IForestryPacketServer {
|
||||
|
||||
public PacketGuiSelectRequest() {
|
||||
}
|
||||
|
||||
public PacketGuiSelectRequest(int primaryIndex, int secondaryIndex) {
|
||||
super(PacketIdServer.GUI_SELECTION_REQUEST, primaryIndex, secondaryIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
Container container = player.openContainer;
|
||||
if (!(container instanceof IGuiSelectable)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IGuiSelectable) container).handleSelectionRequest(player, this);
|
||||
}
|
||||
}
|
||||
@@ -12,24 +12,20 @@ package forestry.core.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketGuiUpdate extends PacketCoordinates {
|
||||
public class PacketGuiUpdate extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
private IStreamableGui guiDataTile;
|
||||
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketGuiUpdate(data);
|
||||
}
|
||||
|
||||
private PacketGuiUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketGuiUpdate() {
|
||||
}
|
||||
|
||||
public PacketGuiUpdate(IStreamableGui guiDataTile) {
|
||||
super(PacketId.TILE_FORESTRY_GUI_OPENED, guiDataTile.getCoordinates());
|
||||
super(PacketIdClient.GUI_UPDATE, guiDataTile.getCoordinates());
|
||||
this.guiDataTile = guiDataTile;
|
||||
}
|
||||
|
||||
@@ -40,9 +36,7 @@ public class PacketGuiUpdate extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof IStreamableGui) {
|
||||
((IStreamableGui) tile).readGuiData(data);
|
||||
|
||||
@@ -14,14 +14,8 @@ import java.io.InputStream;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.network.FMLEventChannel;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent;
|
||||
@@ -29,25 +23,7 @@ import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
|
||||
import forestry.api.core.ForestryEvent;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.apiculture.multiblock.IAlvearyController;
|
||||
import forestry.apiculture.multiblock.TileAlveary;
|
||||
import forestry.apiculture.network.PacketActiveUpdate;
|
||||
import forestry.core.circuits.ContainerSolderingIron;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.circuits.ItemCircuitBoard;
|
||||
import forestry.core.genetics.BreedingTracker;
|
||||
import forestry.core.gui.IContainerLiquidTanks;
|
||||
import forestry.core.gui.IContainerSocketed;
|
||||
import forestry.core.gui.IGuiSelectable;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IRestrictedAccessTile;
|
||||
import forestry.farming.multiblock.IFarmController;
|
||||
import forestry.farming.tiles.TileFarm;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
import io.netty.buffer.ByteBufInputStream;
|
||||
|
||||
@@ -61,243 +37,49 @@ public class PacketHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPacket(ServerCustomPacketEvent event) {
|
||||
onPacketData(event.packet, ((NetHandlerPlayServer) event.handler).playerEntity);
|
||||
DataInputStreamForestry data = getStream(event.packet);
|
||||
EntityPlayerMP player = ((NetHandlerPlayServer) event.handler).playerEntity;
|
||||
|
||||
try {
|
||||
byte packetIdOrdinal = data.readByte();
|
||||
if (packetIdOrdinal >= PacketIdClient.VALUES.length) {
|
||||
return;
|
||||
}
|
||||
PacketIdServer packetId = PacketIdServer.VALUES[packetIdOrdinal];
|
||||
IForestryPacketServer packetHandler = packetId.getPacketHandler();
|
||||
packetHandler.readData(data);
|
||||
packetHandler.onPacketData(data, player);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPacket(ClientCustomPacketEvent event) {
|
||||
onPacketData(event.packet, Proxies.common.getPlayer());
|
||||
}
|
||||
|
||||
/** Returns true if the packet has been handled */
|
||||
private static boolean onPacketData(FMLProxyPacket fmlPacket, EntityPlayer player) {
|
||||
InputStream is = new ByteBufInputStream(fmlPacket.payload());
|
||||
DataInputStreamForestry data = new DataInputStreamForestry(is);
|
||||
DataInputStreamForestry data = getStream(event.packet);
|
||||
EntityPlayer player = Proxies.common.getPlayer();
|
||||
|
||||
try {
|
||||
int packetIdOrdinal = data.readByte();
|
||||
if (packetIdOrdinal >= PacketId.VALUES.length) {
|
||||
return false;
|
||||
}
|
||||
PacketId packetId = PacketId.VALUES[packetIdOrdinal];
|
||||
|
||||
switch (packetId) {
|
||||
|
||||
case TILE_FORESTRY_UPDATE: {
|
||||
PacketTileStream.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
case TILE_FORESTRY_ERROR_UPDATE: {
|
||||
PacketErrorUpdate.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
case TILE_FORESTRY_GUI_OPENED: {
|
||||
PacketGuiUpdate.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
case TILE_FORESTRY_ACTIVE: {
|
||||
PacketActiveUpdate.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
case SOCKET_UPDATE: {
|
||||
PacketSocketUpdate packetS = new PacketSocketUpdate(data);
|
||||
onSocketUpdate(packetS);
|
||||
return true;
|
||||
}
|
||||
case FX_SIGNAL: {
|
||||
PacketFXSignal packet = new PacketFXSignal(data);
|
||||
packet.executeFX();
|
||||
return true;
|
||||
}
|
||||
|
||||
case PIPETTE_CLICK: {
|
||||
PacketSlotClick packet = new PacketSlotClick(data);
|
||||
onPipetteClick(packet, (EntityPlayerMP) player);
|
||||
return true;
|
||||
}
|
||||
case SOLDERING_IRON_CLICK: {
|
||||
PacketSlotClick packet = new PacketSlotClick(data);
|
||||
onSolderingIronClick(packet, (EntityPlayerMP) player);
|
||||
return true;
|
||||
}
|
||||
case CHIPSET_CLICK: {
|
||||
PacketSlotClick packet = new PacketSlotClick(data);
|
||||
onChipsetClick(packet, (EntityPlayerMP) player);
|
||||
return true;
|
||||
}
|
||||
case ACCESS_SWITCH: {
|
||||
PacketCoordinates packet = new PacketCoordinates(data);
|
||||
onAccessSwitch(packet, player);
|
||||
return true;
|
||||
}
|
||||
case GUI_SELECTION_SET: {
|
||||
PacketGuiSelect packet = new PacketGuiSelect(data);
|
||||
onGuiSelection(packet);
|
||||
return true;
|
||||
}
|
||||
case GUI_SELECTION_CHANGE: {
|
||||
PacketGuiSelect packet = new PacketGuiSelect(data);
|
||||
onGuiChange(player, packet);
|
||||
return true;
|
||||
}
|
||||
case GUI_LAYOUT_SELECT: {
|
||||
PacketString packet = new PacketString(data);
|
||||
onGuiLayoutSelect(packet);
|
||||
return true;
|
||||
}
|
||||
case GENOME_TRACKER_UPDATE: {
|
||||
PacketNBT packet = new PacketNBT(data);
|
||||
onGenomeTrackerUpdate(packet);
|
||||
return true;
|
||||
}
|
||||
case GUI_PROGRESS_BAR: {
|
||||
PacketProgressBarUpdate.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
case GUI_ITEMSTACK: {
|
||||
PacketItemStackDisplay.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
case GUI_ENERGY: {
|
||||
PacketGuiEnergy.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
for (IPacketHandler handler : PluginManager.packetHandlers) {
|
||||
if (handler.onPacketData(packetId, data, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
byte packetIdOrdinal = data.readByte();
|
||||
if (packetIdOrdinal >= PacketIdClient.VALUES.length) {
|
||||
return;
|
||||
}
|
||||
PacketIdClient packetId = PacketIdClient.VALUES[packetIdOrdinal];
|
||||
IForestryPacketClient packetHandler = packetId.getPacketHandler();
|
||||
packetHandler.readData(data);
|
||||
packetHandler.onPacketData(data, player);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
private static DataInputStreamForestry getStream(FMLProxyPacket fmlPacket) {
|
||||
InputStream is = new ByteBufInputStream(fmlPacket.payload());
|
||||
return new DataInputStreamForestry(is);
|
||||
}
|
||||
|
||||
public void sendPacket(FMLProxyPacket packet, EntityPlayerMP player) {
|
||||
channel.sendTo(packet, player);
|
||||
}
|
||||
|
||||
private static void onGenomeTrackerUpdate(PacketNBT packet) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isClient();
|
||||
|
||||
EntityPlayer player = Proxies.common.getPlayer();
|
||||
IBreedingTracker tracker = null;
|
||||
String type = packet.getTagCompound().getString(BreedingTracker.TYPE_KEY);
|
||||
|
||||
ISpeciesRoot root = AlleleManager.alleleRegistry.getSpeciesRoot(type);
|
||||
if (root != null) {
|
||||
tracker = root.getBreedingTracker(Proxies.common.getRenderWorld(), player.getGameProfile());
|
||||
}
|
||||
if (tracker != null) {
|
||||
tracker.decodeFromNBT(packet.getTagCompound());
|
||||
MinecraftForge.EVENT_BUS.post(new ForestryEvent.SyncedBreedingTracker(tracker, player));
|
||||
}
|
||||
}
|
||||
|
||||
private static void onGuiChange(EntityPlayer player, PacketGuiSelect packet) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||
|
||||
if (!(player.openContainer instanceof IGuiSelectable)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IGuiSelectable) player.openContainer).handleSelectionChange(player, packet);
|
||||
}
|
||||
|
||||
private static void onGuiSelection(PacketGuiSelect packet) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isClient();
|
||||
|
||||
EntityPlayer player = Proxies.common.getPlayer();
|
||||
|
||||
Container container = player.openContainer;
|
||||
if (!(container instanceof IGuiSelectable)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IGuiSelectable) container).setSelection(packet);
|
||||
}
|
||||
|
||||
private static void onGuiLayoutSelect(PacketString packet) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isClient();
|
||||
|
||||
EntityPlayer player = Proxies.common.getPlayer();
|
||||
|
||||
Container container = player.openContainer;
|
||||
if (!(container instanceof ContainerSolderingIron)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((ContainerSolderingIron) container).setLayout(packet.getString());
|
||||
}
|
||||
|
||||
private static void onSocketUpdate(PacketSocketUpdate packet) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isClient();
|
||||
|
||||
TileEntity tile = packet.getTarget(Proxies.common.getRenderWorld());
|
||||
if (!(tile instanceof ISocketable)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ISocketable socketable = (ISocketable) tile;
|
||||
for (int i = 0; i < packet.itemStacks.length; i++) {
|
||||
socketable.setSocket(i, packet.itemStacks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private static void onChipsetClick(PacketSlotClick packet, EntityPlayerMP player) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||
|
||||
if (!(player.openContainer instanceof IContainerSocketed)) {
|
||||
return;
|
||||
}
|
||||
ItemStack itemstack = player.inventory.getItemStack();
|
||||
if (!(itemstack.getItem() instanceof ItemCircuitBoard)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IContainerSocketed) player.openContainer).handleChipsetClickServer(packet.getSlot(), player, itemstack);
|
||||
}
|
||||
|
||||
private static void onSolderingIronClick(PacketSlotClick packet, EntityPlayerMP player) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||
|
||||
if (!(player.openContainer instanceof IContainerSocketed)) {
|
||||
return;
|
||||
}
|
||||
ItemStack itemstack = player.inventory.getItemStack();
|
||||
|
||||
((IContainerSocketed) player.openContainer).handleSolderingIronClickServer(packet.getSlot(), player, itemstack);
|
||||
}
|
||||
|
||||
private static void onAccessSwitch(PacketCoordinates packet, EntityPlayer playerEntity) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||
|
||||
TileEntity tile = packet.getTarget(playerEntity.worldObj);
|
||||
|
||||
if (tile instanceof TileAlveary) {
|
||||
TileAlveary tileAlveary = (TileAlveary) tile;
|
||||
IAlvearyController alvearyController = tileAlveary.getAlvearyController();
|
||||
alvearyController.getAccessHandler().switchAccessRule(playerEntity);
|
||||
} else if (tile instanceof TileFarm) {
|
||||
TileFarm tileFarm = (TileFarm) tile;
|
||||
IFarmController farmController = tileFarm.getFarmController();
|
||||
farmController.getAccessHandler().switchAccessRule(playerEntity);
|
||||
} else if (tile instanceof IRestrictedAccessTile) {
|
||||
IRestrictedAccessTile restrictedAccessTile = (IRestrictedAccessTile) tile;
|
||||
|
||||
restrictedAccessTile.getAccessHandler().switchAccessRule(playerEntity);
|
||||
}
|
||||
}
|
||||
|
||||
private static void onPipetteClick(PacketSlotClick packet, EntityPlayerMP player) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||
|
||||
if ((player.openContainer instanceof IContainerLiquidTanks)) {
|
||||
((IContainerLiquidTanks) player.openContainer).handlePipetteClick(packet.getSlot(), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +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.network;
|
||||
|
||||
public enum PacketId {
|
||||
INVALID,
|
||||
|
||||
TILE_FORESTRY_UPDATE,
|
||||
TILE_FORESTRY_ERROR_UPDATE,
|
||||
TILE_FORESTRY_GUI_OPENED,
|
||||
TILE_FORESTRY_ACTIVE,
|
||||
FX_SIGNAL,
|
||||
|
||||
WORKTABLE_MEMORY_UPDATE,
|
||||
WORKTABLE_NEI_SELECT,
|
||||
|
||||
HABITAT_BIOME_POINTER,
|
||||
CANDLE,
|
||||
BEE_LOGIC_ACTIVE,
|
||||
|
||||
GUI_SELECTION_CHANGE,
|
||||
IMPRINT_SELECTION_GET,
|
||||
GUI_SELECTION_SET,
|
||||
GUI_LAYOUT_SELECT,
|
||||
GUI_PROGRESS_BAR,
|
||||
GUI_ITEMSTACK,
|
||||
GUI_ENERGY,
|
||||
|
||||
PIPETTE_CLICK,
|
||||
|
||||
ACCESS_SWITCH,
|
||||
|
||||
GENOME_TRACKER_UPDATE,
|
||||
GAME_TOKEN_SET,
|
||||
|
||||
CHIPSET_CLICK,
|
||||
SOLDERING_IRON_CLICK,
|
||||
SOCKET_UPDATE,
|
||||
|
||||
LETTER_REQUEST_INFO,
|
||||
LETTER_TEXT,
|
||||
TRADING_ADDRESS_SET,
|
||||
LETTER_INFO,
|
||||
POBOX_INFO,
|
||||
POBOX_INFO_REQUEST,
|
||||
|
||||
RIPENING_UPDATE,
|
||||
|
||||
// Propolis pipe
|
||||
PROP_SEND_FILTER_SET,
|
||||
PROP_REQUEST_FILTER_SET,
|
||||
PROP_SEND_FILTER_CHANGE_GENOME,
|
||||
PROP_SEND_FILTER_CHANGE_TYPE;
|
||||
|
||||
public static final PacketId[] VALUES = values();
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum PacketIdClient implements IPacketId {
|
||||
INVALID,
|
||||
|
||||
// Core Gui
|
||||
ERROR_UPDATE(new PacketErrorUpdate()),
|
||||
GUI_UPDATE(new PacketGuiUpdate()),
|
||||
GUI_LAYOUT_SELECT(new PacketGuiLayoutSelect()),
|
||||
GUI_PROGRESS_BAR(new PacketProgressBarUpdate()),
|
||||
GUI_ENERGY(new PacketGuiEnergy()),
|
||||
SOCKET_UPDATE(new PacketSocketUpdate()),
|
||||
|
||||
// Core Tile Entities
|
||||
TILE_FORESTRY_UPDATE(new PacketTileStream()),
|
||||
ITEMSTACK_DISPLAY(new PacketItemStackDisplay()),
|
||||
FX_SIGNAL(new PacketFXSignal()),
|
||||
|
||||
// Core Genome
|
||||
GENOME_TRACKER_UPDATE(new PacketGenomeTrackerUpdate()),
|
||||
|
||||
// Factory
|
||||
WORKTABLE_MEMORY_UPDATE,
|
||||
|
||||
// Apiculture
|
||||
TILE_FORESTRY_ACTIVE,
|
||||
BEE_LOGIC_ACTIVE,
|
||||
HABITAT_BIOME_POINTER,
|
||||
CANDLE_UPDATE,
|
||||
IMPRINT_SELECTION_RESPONSE,
|
||||
|
||||
// Arboriculture
|
||||
RIPENING_UPDATE,
|
||||
|
||||
// Mail
|
||||
TRADING_ADDRESS_RESPONSE,
|
||||
LETTER_INFO_RESPONSE,
|
||||
POBOX_INFO_RESPONSE;
|
||||
|
||||
public static final PacketIdClient[] VALUES = values();
|
||||
|
||||
@Nonnull
|
||||
private IForestryPacketClient packetHandler;
|
||||
|
||||
PacketIdClient() {
|
||||
this.packetHandler = PacketDummy.instance;
|
||||
}
|
||||
|
||||
PacketIdClient(@Nonnull IForestryPacketClient packetHandler) {
|
||||
this.packetHandler = packetHandler;
|
||||
}
|
||||
|
||||
public void setPacketHandler(@Nonnull IForestryPacketClient packetHandler) {
|
||||
this.packetHandler = packetHandler;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public IForestryPacketClient getPacketHandler() {
|
||||
return packetHandler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public enum PacketIdServer implements IPacketId {
|
||||
INVALID,
|
||||
|
||||
// Core Gui
|
||||
GUI_SELECTION_REQUEST(new PacketGuiSelectRequest()),
|
||||
PIPETTE_CLICK(new PacketPipetteClick()),
|
||||
ACCESS_SWITCH(new PacketAccessSwitch()),
|
||||
CHIPSET_CLICK(new PacketChipsetClick()),
|
||||
SOLDERING_IRON_CLICK(new PacketSolderingIronClick()),
|
||||
|
||||
// Apiculture
|
||||
IMPRINT_SELECTION_REQUEST,
|
||||
|
||||
// Factory
|
||||
WORKTABLE_NEI_SELECT,
|
||||
|
||||
// Mail
|
||||
LETTER_INFO_REQUEST,
|
||||
TRADING_ADDRESS_REQUEST,
|
||||
POBOX_INFO_REQUEST,
|
||||
LETTER_TEXT_SET;
|
||||
|
||||
public static final PacketIdServer[] VALUES = values();
|
||||
|
||||
@Nonnull
|
||||
private IForestryPacketServer packetHandler;
|
||||
|
||||
PacketIdServer() {
|
||||
this.packetHandler = PacketDummy.instance;
|
||||
}
|
||||
|
||||
PacketIdServer(@Nonnull IForestryPacketServer packetHandler) {
|
||||
this.packetHandler = packetHandler;
|
||||
}
|
||||
|
||||
public void setPacketHandler(@Nonnull IForestryPacketServer packetHandler) {
|
||||
this.packetHandler = packetHandler;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public IForestryPacketServer getPacketHandler() {
|
||||
return packetHandler;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package forestry.core.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@@ -19,20 +20,15 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IItemStackDisplay;
|
||||
import forestry.core.tiles.TileForestry;
|
||||
|
||||
public class PacketItemStackDisplay extends PacketCoordinates {
|
||||
public class PacketItemStackDisplay extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
private ItemStack itemStack;
|
||||
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketItemStackDisplay(data);
|
||||
}
|
||||
|
||||
private PacketItemStackDisplay(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketItemStackDisplay() {
|
||||
}
|
||||
|
||||
public <T extends TileForestry & IItemStackDisplay> PacketItemStackDisplay(T tile, ItemStack itemStack) {
|
||||
super(PacketId.GUI_ITEMSTACK, tile);
|
||||
super(PacketIdClient.ITEMSTACK_DISPLAY, tile);
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
@@ -43,10 +39,13 @@ public class PacketItemStackDisplay extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
itemStack = data.readItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof IItemStackDisplay) {
|
||||
((IItemStackDisplay) tile).handleItemStackForDisplay(itemStack);
|
||||
|
||||
@@ -14,15 +14,14 @@ import java.io.IOException;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class PacketNBT extends ForestryPacket {
|
||||
public abstract class PacketNBT extends ForestryPacket {
|
||||
|
||||
private NBTTagCompound nbttagcompound;
|
||||
|
||||
public PacketNBT(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
protected PacketNBT() {
|
||||
}
|
||||
|
||||
public PacketNBT(PacketId id, NBTTagCompound nbttagcompound) {
|
||||
protected PacketNBT(IPacketId id, NBTTagCompound nbttagcompound) {
|
||||
super(id);
|
||||
this.nbttagcompound = nbttagcompound;
|
||||
}
|
||||
@@ -33,11 +32,11 @@ public class PacketNBT extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
this.nbttagcompound = data.readNBTTagCompound();
|
||||
}
|
||||
|
||||
public NBTTagCompound getTagCompound() {
|
||||
protected NBTTagCompound getTagCompound() {
|
||||
return this.nbttagcompound;
|
||||
}
|
||||
}
|
||||
@@ -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.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.gui.IContainerLiquidTanks;
|
||||
|
||||
public class PacketPipetteClick extends PacketSlotClick implements IForestryPacketServer {
|
||||
|
||||
public PacketPipetteClick() {
|
||||
}
|
||||
|
||||
public PacketPipetteClick(TileEntity tile, int slot) {
|
||||
super(PacketIdServer.PIPETTE_CLICK, tile, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
if ((player.openContainer instanceof IContainerLiquidTanks)) {
|
||||
((IContainerLiquidTanks) player.openContainer).handlePipetteClick(getSlot(), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,28 +12,21 @@ package forestry.core.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
/**
|
||||
* @author CovertJaguar <http://www.railcraft.info>
|
||||
*/
|
||||
|
||||
public class PacketProgressBarUpdate extends ForestryPacket {
|
||||
public class PacketProgressBarUpdate extends ForestryPacket implements IForestryPacketClient {
|
||||
|
||||
private int windowId, dataId, value;
|
||||
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketProgressBarUpdate(data);
|
||||
}
|
||||
|
||||
private PacketProgressBarUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketProgressBarUpdate() {
|
||||
}
|
||||
|
||||
public PacketProgressBarUpdate(int windowId, int dataId, int value) {
|
||||
super(PacketId.GUI_PROGRESS_BAR);
|
||||
super(PacketIdClient.GUI_PROGRESS_BAR);
|
||||
this.windowId = windowId;
|
||||
this.dataId = dataId;
|
||||
this.value = value;
|
||||
@@ -47,13 +40,14 @@ public class PacketProgressBarUpdate extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
windowId = data.readByte();
|
||||
dataId = data.readByte();
|
||||
value = data.readInt();
|
||||
}
|
||||
|
||||
EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer;
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
if (player.openContainer != null && player.openContainer.windowId == windowId) {
|
||||
player.openContainer.updateProgressBar(dataId, value);
|
||||
}
|
||||
|
||||
@@ -14,20 +14,19 @@ import java.io.IOException;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class PacketSlotClick extends PacketCoordinates {
|
||||
public abstract class PacketSlotClick extends PacketCoordinates {
|
||||
private int slot;
|
||||
|
||||
public PacketSlotClick(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
protected PacketSlotClick() {
|
||||
}
|
||||
|
||||
public PacketSlotClick(PacketId id, TileEntity tile, int slot) {
|
||||
protected PacketSlotClick(IPacketId id, TileEntity tile, int slot) {
|
||||
super(id, tile);
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
this.slot = data.readVarInt();
|
||||
}
|
||||
|
||||
@@ -12,21 +12,22 @@ package forestry.core.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketSocketUpdate extends PacketCoordinates {
|
||||
public class PacketSocketUpdate extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
public ItemStack[] itemStacks;
|
||||
private ItemStack[] itemStacks;
|
||||
|
||||
public PacketSocketUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketSocketUpdate() {
|
||||
}
|
||||
|
||||
public <T extends TileEntity & ISocketable> PacketSocketUpdate(T tile) {
|
||||
super(PacketId.SOCKET_UPDATE, tile);
|
||||
super(PacketIdClient.SOCKET_UPDATE, tile);
|
||||
|
||||
itemStacks = new ItemStack[tile.getSocketCount()];
|
||||
for (int i = 0; i < tile.getSocketCount(); i++) {
|
||||
@@ -37,14 +38,25 @@ public class PacketSocketUpdate extends PacketCoordinates {
|
||||
@Override
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
|
||||
data.writeItemStacks(itemStacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
itemStacks = data.readItemStacks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (!(tile instanceof ISocketable)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ISocketable socketable = (ISocketable) tile;
|
||||
for (int i = 0; i < itemStacks.length; i++) {
|
||||
socketable.setSocket(i, itemStacks[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*******************************************************************************
|
||||
* 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.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.gui.IContainerSocketed;
|
||||
|
||||
public class PacketSolderingIronClick extends PacketSlotClick implements IForestryPacketServer {
|
||||
|
||||
public PacketSolderingIronClick() {
|
||||
}
|
||||
|
||||
public PacketSolderingIronClick(TileEntity tile, int slot) {
|
||||
super(PacketIdServer.SOLDERING_IRON_CLICK, tile, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
if (!(player.openContainer instanceof IContainerSocketed)) {
|
||||
return;
|
||||
}
|
||||
ItemStack itemstack = player.inventory.getItemStack();
|
||||
|
||||
((IContainerSocketed) player.openContainer).handleSolderingIronClickServer(getSlot(), player, itemstack);
|
||||
}
|
||||
}
|
||||
@@ -12,15 +12,14 @@ package forestry.core.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketString extends ForestryPacket {
|
||||
public abstract class PacketString extends ForestryPacket {
|
||||
|
||||
private String string;
|
||||
|
||||
public PacketString(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
protected PacketString() {
|
||||
}
|
||||
|
||||
public PacketString(PacketId id, String string) {
|
||||
protected PacketString(IPacketId id, String string) {
|
||||
super(id);
|
||||
this.string = string;
|
||||
}
|
||||
@@ -32,7 +31,7 @@ public class PacketString extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
string = data.readUTF();
|
||||
}
|
||||
|
||||
@@ -12,24 +12,20 @@ package forestry.core.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class PacketTileStream extends PacketCoordinates {
|
||||
public class PacketTileStream extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
private IStreamable streamable;
|
||||
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketTileStream(data);
|
||||
}
|
||||
|
||||
private PacketTileStream(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketTileStream() {
|
||||
}
|
||||
|
||||
public <T extends TileEntity & IStreamable> PacketTileStream(T streamable) {
|
||||
super(PacketId.TILE_FORESTRY_UPDATE, streamable);
|
||||
super(PacketIdClient.TILE_FORESTRY_UPDATE, streamable);
|
||||
this.streamable = streamable;
|
||||
}
|
||||
|
||||
@@ -40,9 +36,7 @@ public class PacketTileStream extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof IStreamable) {
|
||||
((IStreamable) tile).readData(data);
|
||||
|
||||
@@ -18,7 +18,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -49,15 +48,12 @@ import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.VersionParser;
|
||||
import cpw.mods.fml.common.versioning.VersionRange;
|
||||
|
||||
import forestry.Forestry;
|
||||
import forestry.core.TickHandlerCoreServer;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.multiblock.MultiblockServerTickHandler;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketFXSignal;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.StringUtil;
|
||||
@@ -162,10 +158,7 @@ public class ProxyCommon {
|
||||
player.dropPlayerItemWithRandomChoice(stack, true);
|
||||
}
|
||||
|
||||
public void setHabitatLocatorCoordinates(Entity player, ChunkCoordinates coordinates) {
|
||||
if (coordinates != null) {
|
||||
Forestry.packetHandler.sendPacket(new PacketCoordinates(PacketId.HABITAT_BIOME_POINTER, coordinates).getPacket(), (EntityPlayerMP) player);
|
||||
}
|
||||
public void setHabitatLocatorTexture(Entity player, ChunkCoordinates coordinates) {
|
||||
}
|
||||
|
||||
public void removePotionEffect(EntityPlayer player, Potion effect) {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ProxyCommonClient extends ProxyCommon {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHabitatLocatorCoordinates(Entity player, ChunkCoordinates coordinates) {
|
||||
public void setHabitatLocatorTexture(Entity player, ChunkCoordinates coordinates) {
|
||||
TextureHabitatLocator.getInstance().setTargetCoordinates(coordinates);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,13 @@ import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
import forestry.Forestry;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.ILocatedPacket;
|
||||
|
||||
public class ProxyNetwork {
|
||||
|
||||
public <P extends ForestryPacket & ILocatedPacket> void sendNetworkPacket(P packet, World world) {
|
||||
public <P extends IForestryPacketClient & ILocatedPacket> void sendNetworkPacket(P packet, World world) {
|
||||
if (packet == null || !(world instanceof WorldServer)) {
|
||||
return;
|
||||
}
|
||||
@@ -40,13 +41,13 @@ public class ProxyNetwork {
|
||||
EntityPlayerMP player = (EntityPlayerMP) playerObj;
|
||||
|
||||
if (playerManager.isPlayerWatchingChunk(player, chunkX, chunkZ)) {
|
||||
Forestry.packetHandler.sendPacket(packet.getPacket(), player);
|
||||
sendToPlayer(packet, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendToPlayer(ForestryPacket packet, EntityPlayer entityplayer) {
|
||||
public void sendToPlayer(IForestryPacketClient packet, EntityPlayer entityplayer) {
|
||||
if (!(entityplayer instanceof EntityPlayerMP) || (entityplayer instanceof FakePlayer)) {
|
||||
return;
|
||||
}
|
||||
@@ -55,7 +56,7 @@ public class ProxyNetwork {
|
||||
Forestry.packetHandler.sendPacket(packet.getPacket(), player);
|
||||
}
|
||||
|
||||
public void sendToServer(ForestryPacket packet) {
|
||||
public void sendToServer(IForestryPacketServer packet) {
|
||||
}
|
||||
|
||||
public void inventoryChangeNotify(EntityPlayer player) {
|
||||
|
||||
@@ -12,12 +12,12 @@ package forestry.core.proxy;
|
||||
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
|
||||
public class ProxyNetworkClient extends ProxyNetwork {
|
||||
|
||||
@Override
|
||||
public void sendToServer(ForestryPacket packet) {
|
||||
public void sendToServer(IForestryPacketServer packet) {
|
||||
NetHandlerPlayClient netHandler = Proxies.common.getClientInstance().getNetHandler();
|
||||
if (netHandler != null) {
|
||||
netHandler.addToSendQueue(packet.getPacket());
|
||||
|
||||
@@ -17,8 +17,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketNBT;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
import codechicken.nei.LayoutManager;
|
||||
@@ -71,7 +69,7 @@ public class CustomOverlayHandler implements IOverlayHandler {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setTag("stacks", stacksnbt);
|
||||
|
||||
Proxies.net.sendToServer(new PacketNBT(PacketId.WORKTABLE_NEI_SELECT, data));
|
||||
Proxies.net.sendToServer(new PacketWorktableNEISelect(data));
|
||||
} else {
|
||||
IStackPositioner positioner = new OffsetPositioner(xOffs, yOffs);
|
||||
LayoutManager.overlayRenderer = new DefaultOverlayRenderer(ingr, positioner);
|
||||
|
||||
+14
-22
@@ -8,40 +8,32 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.factory.network;
|
||||
package forestry.core.recipes.nei;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.core.gui.slots.SlotCraftMatrix;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.core.network.PacketNBT;
|
||||
import forestry.core.recipes.nei.SetRecipeCommandHandler;
|
||||
import forestry.factory.gui.ContainerWorktable;
|
||||
|
||||
public class PacketHandlerFactory implements IPacketHandler {
|
||||
|
||||
public class PacketWorktableNEISelect extends PacketNBT implements IForestryPacketServer {
|
||||
private static final SetRecipeCommandHandler worktableNEISelectHandler = new SetRecipeCommandHandler(ContainerWorktable.class, SlotCraftMatrix.class);
|
||||
|
||||
public PacketWorktableNEISelect() {
|
||||
}
|
||||
|
||||
public PacketWorktableNEISelect(NBTTagCompound nbttagcompound) {
|
||||
super(PacketIdServer.WORKTABLE_NEI_SELECT, nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
|
||||
switch (packetID) {
|
||||
case WORKTABLE_MEMORY_UPDATE: {
|
||||
PacketWorktableMemoryUpdate.onPacketData(data);
|
||||
return true;
|
||||
}
|
||||
case WORKTABLE_NEI_SELECT: {
|
||||
PacketNBT packet = new PacketNBT(data);
|
||||
worktableNEISelectHandler.handle(packet.getTagCompound(), (EntityPlayerMP) player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
worktableNEISelectHandler.handle(getTagCompound(), player);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.factory.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
@@ -21,8 +22,7 @@ import forestry.core.gui.IContainerCrafting;
|
||||
import forestry.core.gui.IGuiSelectable;
|
||||
import forestry.core.gui.slots.SlotCraftMatrix;
|
||||
import forestry.core.gui.slots.SlotCrafter;
|
||||
import forestry.core.network.PacketGuiSelect;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.factory.network.PacketWorktableMemoryUpdate;
|
||||
@@ -105,12 +105,11 @@ public class ContainerWorktable extends ContainerTile<TileWorktable> implements
|
||||
}
|
||||
|
||||
public static void sendRecipeClick(int mouseButton, int recipeIndex) {
|
||||
PacketGuiSelect packet = new PacketGuiSelect(PacketId.GUI_SELECTION_CHANGE, mouseButton, recipeIndex);
|
||||
Proxies.net.sendToServer(packet);
|
||||
Proxies.net.sendToServer(new PacketGuiSelectRequest(mouseButton, recipeIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelectionChange(EntityPlayer player, PacketGuiSelect packet) {
|
||||
public void handleSelectionRequest(EntityPlayerMP player, PacketGuiSelectRequest packet) {
|
||||
if (packet.getPrimaryIndex() > 0) {
|
||||
tile.getMemory().toggleLock(player.worldObj, packet.getSecondaryIndex());
|
||||
} else {
|
||||
@@ -119,8 +118,4 @@ public class ContainerWorktable extends ContainerTile<TileWorktable> implements
|
||||
updateRecipe();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(PacketGuiSelect packet) {
|
||||
}
|
||||
}
|
||||
@@ -12,30 +12,27 @@ package forestry.factory.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.factory.recipes.RecipeMemory;
|
||||
import forestry.factory.tiles.TileWorktable;
|
||||
|
||||
public class PacketWorktableMemoryUpdate extends PacketCoordinates {
|
||||
public class PacketWorktableMemoryUpdate extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
private RecipeMemory recipeMemory;
|
||||
|
||||
public static void onPacketData(DataInputStreamForestry data) throws IOException {
|
||||
new PacketWorktableMemoryUpdate(data);
|
||||
}
|
||||
|
||||
private PacketWorktableMemoryUpdate(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketWorktableMemoryUpdate() {
|
||||
}
|
||||
|
||||
public PacketWorktableMemoryUpdate(TileWorktable worktable) {
|
||||
super(PacketId.WORKTABLE_MEMORY_UPDATE, worktable);
|
||||
super(PacketIdClient.WORKTABLE_MEMORY_UPDATE, worktable);
|
||||
this.recipeMemory = worktable.getMemory();
|
||||
}
|
||||
|
||||
@@ -46,9 +43,7 @@ public class PacketWorktableMemoryUpdate extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof TileWorktable) {
|
||||
((TileWorktable) tile).getMemory().readData(data);
|
||||
|
||||
@@ -1,125 +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.mail;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketString;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.mail.gui.ContainerCatalogue;
|
||||
import forestry.mail.gui.ContainerLetter;
|
||||
import forestry.mail.gui.GuiMailboxInfo;
|
||||
import forestry.mail.network.PacketLetterInfo;
|
||||
import forestry.mail.network.PacketPOBoxInfo;
|
||||
import forestry.mail.network.PacketRequestLetterInfo;
|
||||
import forestry.mail.network.PacketTraderAddress;
|
||||
import forestry.mail.tiles.TileTrader;
|
||||
|
||||
public class PacketHandlerMail implements IPacketHandler {
|
||||
|
||||
@Override
|
||||
public boolean onPacketData(PacketId packetID, DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
|
||||
switch (packetID) {
|
||||
case LETTER_INFO: {
|
||||
PacketLetterInfo packet = new PacketLetterInfo(data);
|
||||
onLetterInfo(packet);
|
||||
return true;
|
||||
}
|
||||
case POBOX_INFO: {
|
||||
PacketPOBoxInfo packet = new PacketPOBoxInfo(data);
|
||||
onPOBoxInfo(packet);
|
||||
return true;
|
||||
}
|
||||
case LETTER_REQUEST_INFO: {
|
||||
PacketRequestLetterInfo packet = new PacketRequestLetterInfo(data);
|
||||
onLetterRequestInfo(player, packet);
|
||||
return true;
|
||||
}
|
||||
case LETTER_TEXT: {
|
||||
PacketString packet = new PacketString(data);
|
||||
onLetterText(player, packet);
|
||||
return true;
|
||||
}
|
||||
case TRADING_ADDRESS_SET: {
|
||||
PacketTraderAddress packet = new PacketTraderAddress(data);
|
||||
handleTradeAddressSet(player, packet);
|
||||
return true;
|
||||
}
|
||||
case POBOX_INFO_REQUEST: {
|
||||
onPOBoxInfoRequest(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void onLetterInfo(PacketLetterInfo packet) {
|
||||
|
||||
Container container = Proxies.common.getClientInstance().thePlayer.openContainer;
|
||||
if (container instanceof ContainerLetter) {
|
||||
((ContainerLetter) container).handleLetterInfoUpdate(packet);
|
||||
} else if (container instanceof ContainerCatalogue) {
|
||||
((ContainerCatalogue) container).handleTradeInfoUpdate(packet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void onPOBoxInfo(PacketPOBoxInfo packet) {
|
||||
GuiMailboxInfo.instance.setPOBoxInfo(packet.poboxInfo);
|
||||
}
|
||||
|
||||
private static void handleTradeAddressSet(EntityPlayer player, PacketTraderAddress packet) {
|
||||
TileEntity tile = packet.getTarget(player.worldObj);
|
||||
if (!(tile instanceof TileTrader)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String addressName = packet.getAddressName();
|
||||
|
||||
((TileTrader) tile).handleSetAddress(addressName);
|
||||
}
|
||||
|
||||
private static void onLetterText(EntityPlayer player, PacketString packet) {
|
||||
if (!(player.openContainer instanceof ContainerLetter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((ContainerLetter) player.openContainer).handleSetText(packet);
|
||||
}
|
||||
|
||||
private static void onLetterRequestInfo(EntityPlayer player, PacketRequestLetterInfo packet) {
|
||||
if (!(player.openContainer instanceof ContainerLetter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((ContainerLetter) player.openContainer).handleRequestLetterInfo(player, packet);
|
||||
}
|
||||
|
||||
private static void onPOBoxInfoRequest(EntityPlayer player) {
|
||||
MailAddress address = new MailAddress(player.getGameProfile());
|
||||
POBox pobox = PostRegistry.getOrCreatePOBox(player.worldObj, address);
|
||||
if (pobox == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfo(pobox.getPOBoxInfo()), player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,7 +33,7 @@ import forestry.api.mail.PostManager;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.mail.items.ItemLetter;
|
||||
import forestry.mail.network.PacketPOBoxInfo;
|
||||
import forestry.mail.network.PacketPOBoxInfoResponse;
|
||||
|
||||
public class PostRegistry implements IPostRegistry {
|
||||
|
||||
@@ -75,7 +75,7 @@ public class PostRegistry implements IPostRegistry {
|
||||
|
||||
EntityPlayer player = Proxies.common.getPlayer(world, address.getPlayerProfile());
|
||||
if (player != null) {
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfo(pobox.getPOBoxInfo()), player);
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.mail;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
@@ -28,7 +29,7 @@ import forestry.api.mail.PostManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.mail.network.PacketPOBoxInfo;
|
||||
import forestry.mail.network.PacketPOBoxInfoResponse;
|
||||
|
||||
public class PostalCarrier implements IPostalCarrier {
|
||||
|
||||
@@ -85,8 +86,8 @@ public class PostalCarrier implements IPostalCarrier {
|
||||
return EnumDeliveryState.MAILBOX_FULL;
|
||||
} else {
|
||||
EntityPlayer player = Proxies.common.getPlayer(world, recipient.getPlayerProfile());
|
||||
if (player != null) {
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfo(pobox.getPOBoxInfo()), player);
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,9 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent;
|
||||
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.mail.gui.GuiMailboxInfo;
|
||||
import forestry.mail.network.PacketPOBoxInfoRequest;
|
||||
|
||||
public class TickHandlerMailClient {
|
||||
public TickHandlerMailClient() {
|
||||
@@ -34,7 +33,7 @@ public class TickHandlerMailClient {
|
||||
if (GuiMailboxInfo.instance.hasPOBoxInfo()) {
|
||||
GuiMailboxInfo.instance.render(0, 0);
|
||||
} else {
|
||||
Proxies.net.sendToServer(new ForestryPacket(PacketId.POBOX_INFO_REQUEST));
|
||||
Proxies.net.sendToServer(new PacketPOBoxInfoRequest());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
|
||||
@@ -29,13 +30,12 @@ import forestry.api.mail.ITradeStation;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.api.mail.TradeStationInfo;
|
||||
import forestry.core.gui.IGuiSelectable;
|
||||
import forestry.core.network.PacketGuiSelect;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.mail.EnumStationState;
|
||||
import forestry.mail.network.PacketLetterInfo;
|
||||
import forestry.mail.network.PacketLetterInfoResponse;
|
||||
|
||||
public class ContainerCatalogue extends Container implements IGuiSelectable {
|
||||
public class ContainerCatalogue extends Container implements IGuiSelectable, ILetterInfoReceiver {
|
||||
|
||||
private final EntityPlayer player;
|
||||
private final List<ITradeStation> stations = new ArrayList<>();
|
||||
@@ -131,8 +131,7 @@ public class ContainerCatalogue extends Container implements IGuiSelectable {
|
||||
|
||||
public void cycleFilter() {
|
||||
if (player.worldObj.isRemote) {
|
||||
PacketGuiSelect packet = new PacketGuiSelect(PacketId.GUI_SELECTION_CHANGE, 2, 0);
|
||||
Proxies.net.sendToServer(packet);
|
||||
Proxies.net.sendToServer(new PacketGuiSelectRequest(2, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -143,8 +142,7 @@ public class ContainerCatalogue extends Container implements IGuiSelectable {
|
||||
|
||||
private static void sendSelection(boolean advance) {
|
||||
int value = advance ? 0 : 1;
|
||||
PacketGuiSelect packet = new PacketGuiSelect(PacketId.GUI_SELECTION_CHANGE, value, 0);
|
||||
Proxies.net.sendToServer(packet);
|
||||
Proxies.net.sendToServer(new PacketGuiSelectRequest(value, 0));
|
||||
}
|
||||
|
||||
/* Managing Trade info */
|
||||
@@ -163,7 +161,8 @@ public class ContainerCatalogue extends Container implements IGuiSelectable {
|
||||
needsSynch = true;
|
||||
}
|
||||
|
||||
public void handleTradeInfoUpdate(PacketLetterInfo packet) {
|
||||
@Override
|
||||
public void handleLetterInfoUpdate(PacketLetterInfoResponse packet) {
|
||||
setTradeInfo(packet.tradeInfo);
|
||||
}
|
||||
|
||||
@@ -187,7 +186,7 @@ public class ContainerCatalogue extends Container implements IGuiSelectable {
|
||||
crafter.sendProgressBarUpdate(this, 2, currentFilter);
|
||||
}
|
||||
|
||||
Proxies.net.sendToPlayer(new PacketLetterInfo(EnumAddressee.TRADER, currentTrade, null), player);
|
||||
Proxies.net.sendToPlayer(new PacketLetterInfoResponse(EnumAddressee.TRADER, currentTrade, null), player);
|
||||
needsSynch = false;
|
||||
}
|
||||
}
|
||||
@@ -213,7 +212,7 @@ public class ContainerCatalogue extends Container implements IGuiSelectable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelectionChange(EntityPlayer player, PacketGuiSelect packet) {
|
||||
public void handleSelectionRequest(EntityPlayerMP player, PacketGuiSelectRequest packet) {
|
||||
|
||||
switch (packet.getPrimaryIndex()) {
|
||||
case 0:
|
||||
@@ -229,8 +228,4 @@ public class ContainerCatalogue extends Container implements IGuiSelectable {
|
||||
|
||||
needsSynch = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(PacketGuiSelect packet) {
|
||||
}
|
||||
}
|
||||
@@ -28,15 +28,14 @@ import forestry.api.mail.PostManager;
|
||||
import forestry.api.mail.TradeStationInfo;
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketString;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.mail.Letter;
|
||||
import forestry.mail.items.ItemLetter.LetterInventory;
|
||||
import forestry.mail.network.PacketLetterInfo;
|
||||
import forestry.mail.network.PacketRequestLetterInfo;
|
||||
import forestry.mail.network.PacketLetterInfoResponse;
|
||||
import forestry.mail.network.PacketLetterTextSet;
|
||||
|
||||
public class ContainerLetter extends ContainerItemInventory<LetterInventory> {
|
||||
public class ContainerLetter extends ContainerItemInventory<LetterInventory> implements ILetterInfoReceiver {
|
||||
|
||||
private EnumAddressee carrierType = EnumAddressee.PLAYER;
|
||||
private TradeStationInfo tradeInfo = null;
|
||||
@@ -121,10 +120,7 @@ public class ContainerLetter extends ContainerItemInventory<LetterInventory> {
|
||||
setCarrierType(postal.getType());
|
||||
}
|
||||
|
||||
public void handleRequestLetterInfo(EntityPlayer player, PacketRequestLetterInfo packet) {
|
||||
String recipientName = packet.getRecipientName();
|
||||
EnumAddressee type = packet.getAddressType();
|
||||
|
||||
public void handleRequestLetterInfo(EntityPlayer player, String recipientName, EnumAddressee type) {
|
||||
IMailAddress recipient = getRecipient(recipientName, type);
|
||||
|
||||
getLetter().setRecipient(recipient);
|
||||
@@ -135,7 +131,7 @@ public class ContainerLetter extends ContainerItemInventory<LetterInventory> {
|
||||
}
|
||||
|
||||
// Update info on client
|
||||
Proxies.net.sendToPlayer(new PacketLetterInfo(type, tradeInfo, recipient), player);
|
||||
Proxies.net.sendToPlayer(new PacketLetterInfoResponse(type, tradeInfo, recipient), player);
|
||||
}
|
||||
|
||||
private static IMailAddress getRecipient(String recipientName, EnumAddressee type) {
|
||||
@@ -170,9 +166,7 @@ public class ContainerLetter extends ContainerItemInventory<LetterInventory> {
|
||||
public void setText(String text) {
|
||||
getLetter().setText(text);
|
||||
|
||||
PacketString packet = new PacketString(PacketId.LETTER_TEXT, text);
|
||||
Proxies.net.sendToServer(packet);
|
||||
|
||||
Proxies.net.sendToServer(new PacketLetterTextSet(text));
|
||||
}
|
||||
|
||||
public void handleSetText(PacketString packet) {
|
||||
@@ -201,7 +195,8 @@ public class ContainerLetter extends ContainerItemInventory<LetterInventory> {
|
||||
setTradeInfo(station.getTradeInfo());
|
||||
}
|
||||
|
||||
public void handleLetterInfoUpdate(PacketLetterInfo packet) {
|
||||
@Override
|
||||
public void handleLetterInfoUpdate(PacketLetterInfoResponse packet) {
|
||||
carrierType = packet.type;
|
||||
if (packet.type == EnumAddressee.PLAYER) {
|
||||
getLetter().setRecipient(packet.address);
|
||||
|
||||
@@ -21,7 +21,7 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
import forestry.mail.POBox;
|
||||
import forestry.mail.POBoxInfo;
|
||||
import forestry.mail.network.PacketPOBoxInfo;
|
||||
import forestry.mail.network.PacketPOBoxInfoResponse;
|
||||
import forestry.mail.tiles.TileMailbox;
|
||||
|
||||
public class ContainerMailbox extends ContainerTile<TileMailbox> {
|
||||
@@ -55,7 +55,7 @@ public class ContainerMailbox extends ContainerTile<TileMailbox> {
|
||||
if (SlotUtil.isSlotInRange(slotIndex, SLOT_LETTERS, SLOT_LETTERS_COUNT)) {
|
||||
if (!player.worldObj.isRemote && mailInventory != null) {
|
||||
POBoxInfo info = mailInventory.getPOBoxInfo();
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfo(info), player);
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(info), player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.mail.items.ItemLetter.LetterInventory;
|
||||
import forestry.mail.network.PacketRequestLetterInfo;
|
||||
import forestry.mail.network.PacketLetterInfoRequest;
|
||||
|
||||
public class GuiLetter extends GuiForestry<ContainerLetter, LetterInventory> {
|
||||
|
||||
@@ -239,7 +239,7 @@ public class GuiLetter extends GuiForestry<ContainerLetter, LetterInventory> {
|
||||
return;
|
||||
}
|
||||
|
||||
PacketRequestLetterInfo packet = new PacketRequestLetterInfo(recipientName, type);
|
||||
PacketLetterInfoRequest packet = new PacketLetterInfoRequest(recipientName, type);
|
||||
Proxies.net.sendToServer(packet);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.mail.network.PacketTraderAddress;
|
||||
import forestry.mail.network.PacketTraderAddressRequest;
|
||||
import forestry.mail.tiles.TileTrader;
|
||||
|
||||
public class GuiTradeName extends GuiForestry<ContainerTradeName, TileTrader> {
|
||||
@@ -84,7 +84,7 @@ public class GuiTradeName extends GuiForestry<ContainerTradeName, TileTrader> {
|
||||
private void setAddress() {
|
||||
String address = addressNameField.getText();
|
||||
if (StringUtils.isNotBlank(address)) {
|
||||
PacketTraderAddress packet = new PacketTraderAddress(inventory, address);
|
||||
PacketTraderAddressRequest packet = new PacketTraderAddressRequest(inventory, address);
|
||||
Proxies.net.sendToServer(packet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*******************************************************************************
|
||||
* 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.mail.gui;
|
||||
|
||||
import forestry.mail.network.PacketLetterInfoResponse;
|
||||
|
||||
public interface ILetterInfoReceiver {
|
||||
void handleLetterInfoUpdate(PacketLetterInfoResponse packet);
|
||||
}
|
||||
+20
-16
@@ -12,46 +12,50 @@ package forestry.mail.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import forestry.api.mail.EnumAddressee;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.mail.gui.ContainerLetter;
|
||||
|
||||
public class PacketRequestLetterInfo extends ForestryPacket {
|
||||
public class PacketLetterInfoRequest extends ForestryPacket implements IForestryPacketServer {
|
||||
|
||||
private String recipientName;
|
||||
private short addressType;
|
||||
private EnumAddressee addressType;
|
||||
|
||||
public PacketRequestLetterInfo(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketLetterInfoRequest() {
|
||||
}
|
||||
|
||||
public PacketRequestLetterInfo(String recipientName, EnumAddressee addressType) {
|
||||
super(PacketId.LETTER_REQUEST_INFO);
|
||||
public PacketLetterInfoRequest(String recipientName, EnumAddressee addressType) {
|
||||
super(PacketIdServer.LETTER_INFO_REQUEST);
|
||||
this.recipientName = recipientName;
|
||||
this.addressType = (short) addressType.ordinal();
|
||||
this.addressType = addressType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeUTF(recipientName);
|
||||
data.writeShort(addressType);
|
||||
data.writeByte(addressType.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
recipientName = data.readUTF();
|
||||
addressType = data.readShort();
|
||||
addressType = EnumAddressee.values()[data.readByte()];
|
||||
}
|
||||
|
||||
public String getRecipientName() {
|
||||
return recipientName;
|
||||
}
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
if (!(player.openContainer instanceof ContainerLetter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
public EnumAddressee getAddressType() {
|
||||
return EnumAddressee.values()[addressType];
|
||||
((ContainerLetter) player.openContainer).handleRequestLetterInfo(player, recipientName, addressType);
|
||||
}
|
||||
}
|
||||
+16
-6
@@ -13,6 +13,8 @@ package forestry.mail.network;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
@@ -24,21 +26,22 @@ import forestry.api.mail.TradeStationInfo;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.mail.EnumStationState;
|
||||
import forestry.mail.gui.ILetterInfoReceiver;
|
||||
|
||||
public class PacketLetterInfo extends ForestryPacket {
|
||||
public class PacketLetterInfoResponse extends ForestryPacket implements IForestryPacketClient {
|
||||
|
||||
public EnumAddressee type;
|
||||
public TradeStationInfo tradeInfo;
|
||||
public IMailAddress address;
|
||||
|
||||
public PacketLetterInfo(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketLetterInfoResponse() {
|
||||
}
|
||||
|
||||
public PacketLetterInfo(EnumAddressee type, TradeStationInfo info, IMailAddress address) {
|
||||
super(PacketId.LETTER_INFO);
|
||||
public PacketLetterInfoResponse(EnumAddressee type, TradeStationInfo info, IMailAddress address) {
|
||||
super(PacketIdClient.LETTER_INFO_RESPONSE);
|
||||
this.type = type;
|
||||
if (type == EnumAddressee.TRADER) {
|
||||
this.tradeInfo = info;
|
||||
@@ -126,4 +129,11 @@ public class PacketLetterInfo extends ForestryPacket {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
Container container = player.openContainer;
|
||||
if (container instanceof ILetterInfoReceiver) {
|
||||
((ILetterInfoReceiver) container).handleLetterInfoUpdate(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* 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.mail.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.core.network.PacketString;
|
||||
import forestry.mail.gui.ContainerLetter;
|
||||
|
||||
public class PacketLetterTextSet extends PacketString implements IForestryPacketServer {
|
||||
|
||||
public PacketLetterTextSet() {
|
||||
}
|
||||
|
||||
public PacketLetterTextSet(String string) {
|
||||
super(PacketIdServer.LETTER_TEXT_SET, string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
if (!(player.openContainer instanceof ContainerLetter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((ContainerLetter) player.openContainer).handleSetText(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* 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.mail.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.mail.MailAddress;
|
||||
import forestry.mail.POBox;
|
||||
import forestry.mail.PostRegistry;
|
||||
|
||||
public class PacketPOBoxInfoRequest extends ForestryPacket implements IForestryPacketServer {
|
||||
|
||||
public PacketPOBoxInfoRequest() {
|
||||
super(PacketIdServer.POBOX_INFO_REQUEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
MailAddress address = new MailAddress(player.getGameProfile());
|
||||
POBox pobox = PostRegistry.getOrCreatePOBox(player.worldObj, address);
|
||||
if (pobox != null) {
|
||||
Proxies.net.sendToPlayer(new PacketPOBoxInfoResponse(pobox.getPOBoxInfo()), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable → Regular
+15
-8
@@ -12,22 +12,25 @@ package forestry.mail.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.mail.POBoxInfo;
|
||||
import forestry.mail.gui.GuiMailboxInfo;
|
||||
|
||||
public class PacketPOBoxInfo extends ForestryPacket {
|
||||
public class PacketPOBoxInfoResponse extends ForestryPacket implements IForestryPacketClient {
|
||||
|
||||
public POBoxInfo poboxInfo;
|
||||
|
||||
public PacketPOBoxInfo(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketPOBoxInfoResponse() {
|
||||
}
|
||||
|
||||
public PacketPOBoxInfo(POBoxInfo info) {
|
||||
super(PacketId.POBOX_INFO);
|
||||
public PacketPOBoxInfoResponse(POBoxInfo info) {
|
||||
super(PacketIdClient.POBOX_INFO_RESPONSE);
|
||||
this.poboxInfo = info;
|
||||
}
|
||||
|
||||
@@ -44,8 +47,7 @@ public class PacketPOBoxInfo extends ForestryPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
short isNotNull = data.readShort();
|
||||
if (isNotNull < 0) {
|
||||
return;
|
||||
@@ -54,4 +56,9 @@ public class PacketPOBoxInfo extends ForestryPacket {
|
||||
this.poboxInfo = new POBoxInfo(data.readInt(), data.readInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
GuiMailboxInfo.instance.setPOBoxInfo(poboxInfo);
|
||||
}
|
||||
|
||||
}
|
||||
+16
-11
@@ -12,23 +12,25 @@ package forestry.mail.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.mail.tiles.TileTrader;
|
||||
|
||||
public class PacketTraderAddress extends PacketCoordinates {
|
||||
public class PacketTraderAddressRequest extends PacketCoordinates implements IForestryPacketServer {
|
||||
|
||||
private String addressName;
|
||||
|
||||
public PacketTraderAddress(DataInputStreamForestry data) throws IOException {
|
||||
super(data);
|
||||
public PacketTraderAddressRequest() {
|
||||
}
|
||||
|
||||
public PacketTraderAddress(TileTrader tile, String addressName) {
|
||||
super(PacketId.TRADING_ADDRESS_SET, tile);
|
||||
|
||||
public PacketTraderAddressRequest(TileTrader tile, String addressName) {
|
||||
super(PacketIdServer.TRADING_ADDRESS_REQUEST, tile);
|
||||
this.addressName = addressName;
|
||||
}
|
||||
|
||||
@@ -39,13 +41,16 @@ public class PacketTraderAddress extends PacketCoordinates {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readData(DataInputStreamForestry data) throws IOException {
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
|
||||
addressName = data.readUTF();
|
||||
}
|
||||
|
||||
public String getAddressName() {
|
||||
return addressName;
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException {
|
||||
TileEntity tile = getTarget(player.worldObj);
|
||||
if ((tile instanceof TileTrader)) {
|
||||
((TileTrader) tile).handleSetAddressRequest(addressName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*******************************************************************************
|
||||
* 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.mail.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.PacketCoordinates;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.mail.tiles.TileTrader;
|
||||
|
||||
public class PacketTraderAddressResponse extends PacketCoordinates implements IForestryPacketClient {
|
||||
|
||||
private String addressName;
|
||||
|
||||
public PacketTraderAddressResponse() {
|
||||
}
|
||||
|
||||
public PacketTraderAddressResponse(TileTrader tile, String addressName) {
|
||||
super(PacketIdClient.TRADING_ADDRESS_RESPONSE, tile);
|
||||
this.addressName = addressName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
data.writeUTF(addressName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
addressName = data.readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketData(DataInputStreamForestry data, EntityPlayer player) throws IOException {
|
||||
TileEntity tile = getTarget(player.worldObj);
|
||||
if ((tile instanceof TileTrader)) {
|
||||
((TileTrader) tile).handleSetAddressResponse(addressName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,7 +40,7 @@ import forestry.core.tiles.TileBase;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.mail.MailAddress;
|
||||
import forestry.mail.TradeStation;
|
||||
import forestry.mail.network.PacketTraderAddress;
|
||||
import forestry.mail.network.PacketTraderAddressResponse;
|
||||
import forestry.mail.triggers.MailTriggers;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
@@ -255,22 +255,25 @@ public class TileTrader extends TileBase {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void handleSetAddress(String addressName) {
|
||||
public void handleSetAddressRequest(String addressName) {
|
||||
IMailAddress address = PostManager.postRegistry.getMailAddress(addressName);
|
||||
setAddress(address);
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
IMailAddress newAddress = getAddress();
|
||||
if (newAddress != null) {
|
||||
String newAddressName = newAddress.getName();
|
||||
if (newAddressName != null && newAddressName.equals(addressName)) {
|
||||
PacketTraderAddress packetResponse = new PacketTraderAddress(this, addressName);
|
||||
Proxies.net.sendNetworkPacket(packetResponse, worldObj);
|
||||
}
|
||||
IMailAddress newAddress = getAddress();
|
||||
if (newAddress != null) {
|
||||
String newAddressName = newAddress.getName();
|
||||
if (newAddressName != null && newAddressName.equals(addressName)) {
|
||||
PacketTraderAddressResponse packetResponse = new PacketTraderAddressResponse(this, addressName);
|
||||
Proxies.net.sendNetworkPacket(packetResponse, worldObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSetAddressResponse(String addressName) {
|
||||
IMailAddress address = PostManager.postRegistry.getMailAddress(addressName);
|
||||
setAddress(address);
|
||||
}
|
||||
|
||||
private void setAddress(IMailAddress address) {
|
||||
if (address == null) {
|
||||
throw new NullPointerException("address must not be null");
|
||||
|
||||
@@ -24,7 +24,6 @@ import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import forestry.core.IPickupHandler;
|
||||
import forestry.core.IResupplyHandler;
|
||||
import forestry.core.ISaveEventHandler;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
public abstract class ForestryPlugin {
|
||||
@@ -94,8 +93,8 @@ public abstract class ForestryPlugin {
|
||||
public void populateChunkRetroGen(World world, Random rand, int chunkX, int chunkZ) {
|
||||
}
|
||||
|
||||
public IPacketHandler getPacketHandler() {
|
||||
return null;
|
||||
public void registerPacketHandlers() {
|
||||
|
||||
}
|
||||
|
||||
public IPickupHandler getPickupHandler() {
|
||||
|
||||
@@ -54,7 +54,6 @@ import forestry.Forestry;
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.apiculture.hives.HiveManager;
|
||||
import forestry.api.core.Tabs;
|
||||
@@ -117,7 +116,12 @@ import forestry.apiculture.multiblock.TileAlvearyPlain;
|
||||
import forestry.apiculture.multiblock.TileAlvearySieve;
|
||||
import forestry.apiculture.multiblock.TileAlvearyStabiliser;
|
||||
import forestry.apiculture.multiblock.TileAlvearySwarmer;
|
||||
import forestry.apiculture.network.PacketHandlerApiculture;
|
||||
import forestry.apiculture.network.PacketActiveUpdate;
|
||||
import forestry.apiculture.network.PacketBeekeepingLogicActive;
|
||||
import forestry.apiculture.network.PacketCandleUpdate;
|
||||
import forestry.apiculture.network.PacketHabitatBiomePointer;
|
||||
import forestry.apiculture.network.PacketImprintSelectionRequest;
|
||||
import forestry.apiculture.network.PacketImprintSelectionResponse;
|
||||
import forestry.apiculture.proxy.ProxyApiculture;
|
||||
import forestry.apiculture.tiles.TileApiaristChest;
|
||||
import forestry.apiculture.tiles.TileApiary;
|
||||
@@ -145,7 +149,8 @@ import forestry.core.items.ItemForestry;
|
||||
import forestry.core.items.ItemOverlay;
|
||||
import forestry.core.items.ItemOverlay.OverlayInfo;
|
||||
import forestry.core.items.ItemScoop;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.recipes.ShapedRecipeCustom;
|
||||
import forestry.core.tiles.MachineDefinition;
|
||||
@@ -495,8 +500,14 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacketHandler getPacketHandler() {
|
||||
return new PacketHandlerApiculture();
|
||||
public void registerPacketHandlers() {
|
||||
PacketIdServer.IMPRINT_SELECTION_REQUEST.setPacketHandler(new PacketImprintSelectionRequest());
|
||||
|
||||
PacketIdClient.IMPRINT_SELECTION_RESPONSE.setPacketHandler(new PacketImprintSelectionResponse());
|
||||
PacketIdClient.TILE_FORESTRY_ACTIVE.setPacketHandler(new PacketActiveUpdate());
|
||||
PacketIdClient.BEE_LOGIC_ACTIVE.setPacketHandler(new PacketBeekeepingLogicActive());
|
||||
PacketIdClient.HABITAT_BIOME_POINTER.setPacketHandler(new PacketHabitatBiomePointer());
|
||||
PacketIdClient.CANDLE_UPDATE.setPacketHandler(new PacketCandleUpdate());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -73,7 +73,7 @@ import forestry.arboriculture.items.ItemBlockWood;
|
||||
import forestry.arboriculture.items.ItemGermlingGE;
|
||||
import forestry.arboriculture.items.ItemGrafter;
|
||||
import forestry.arboriculture.items.ItemTreealyzer;
|
||||
import forestry.arboriculture.network.PacketHandlerArboriculture;
|
||||
import forestry.arboriculture.network.PacketRipeningUpdate;
|
||||
import forestry.arboriculture.proxy.ProxyArboriculture;
|
||||
import forestry.arboriculture.tiles.TileArboristChest;
|
||||
import forestry.arboriculture.tiles.TileFruitPod;
|
||||
@@ -90,7 +90,7 @@ import forestry.core.fluids.Fluids;
|
||||
import forestry.core.genetics.alleles.Allele;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
import forestry.core.items.ItemFruit.EnumFruit;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.recipes.ShapedRecipeCustom;
|
||||
@@ -407,8 +407,8 @@ public class PluginArboriculture extends ForestryPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacketHandler getPacketHandler() {
|
||||
return new PacketHandlerArboriculture();
|
||||
public void registerPacketHandlers() {
|
||||
PacketIdClient.RIPENING_UPDATE.setPacketHandler(new PacketRipeningUpdate());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,17 +36,19 @@ import forestry.core.config.GameMode;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
import forestry.core.items.ItemBlockNBT;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.recipes.ShapedRecipeCustom;
|
||||
import forestry.core.recipes.craftguide.CraftGuideIntegration;
|
||||
import forestry.core.recipes.nei.PacketWorktableNEISelect;
|
||||
import forestry.core.tiles.MachineDefinition;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.factory.DummyManagers;
|
||||
import forestry.factory.GuiHandlerFactory;
|
||||
import forestry.factory.circuits.CircuitSpeedUpgrade;
|
||||
import forestry.factory.network.PacketHandlerFactory;
|
||||
import forestry.factory.network.PacketWorktableMemoryUpdate;
|
||||
import forestry.factory.tiles.TileBottler;
|
||||
import forestry.factory.tiles.TileCarpenter;
|
||||
import forestry.factory.tiles.TileCentrifuge;
|
||||
@@ -92,8 +94,10 @@ public class PluginFactory extends ForestryPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacketHandler getPacketHandler() {
|
||||
return new PacketHandlerFactory();
|
||||
public void registerPacketHandlers() {
|
||||
PacketIdServer.WORKTABLE_NEI_SELECT.setPacketHandler(new PacketWorktableNEISelect());
|
||||
|
||||
PacketIdClient.WORKTABLE_MEMORY_UPDATE.setPacketHandler(new PacketWorktableMemoryUpdate());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,12 +31,12 @@ import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.core.network.PacketIdServer;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.recipes.ShapedRecipeCustom;
|
||||
import forestry.core.tiles.MachineDefinition;
|
||||
import forestry.mail.GuiHandlerMail;
|
||||
import forestry.mail.PacketHandlerMail;
|
||||
import forestry.mail.PostRegistry;
|
||||
import forestry.mail.PostalCarrier;
|
||||
import forestry.mail.SaveEventHandlerMail;
|
||||
@@ -46,6 +46,13 @@ import forestry.mail.items.ItemCatalogue;
|
||||
import forestry.mail.items.ItemLetter;
|
||||
import forestry.mail.items.ItemStamps;
|
||||
import forestry.mail.items.ItemStamps.StampInfo;
|
||||
import forestry.mail.network.PacketLetterInfoRequest;
|
||||
import forestry.mail.network.PacketLetterInfoResponse;
|
||||
import forestry.mail.network.PacketLetterTextSet;
|
||||
import forestry.mail.network.PacketPOBoxInfoRequest;
|
||||
import forestry.mail.network.PacketPOBoxInfoResponse;
|
||||
import forestry.mail.network.PacketTraderAddressRequest;
|
||||
import forestry.mail.network.PacketTraderAddressResponse;
|
||||
import forestry.mail.tiles.TileMailbox;
|
||||
import forestry.mail.tiles.TilePhilatelist;
|
||||
import forestry.mail.tiles.TileTrader;
|
||||
@@ -124,8 +131,15 @@ public class PluginMail extends ForestryPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPacketHandler getPacketHandler() {
|
||||
return new PacketHandlerMail();
|
||||
public void registerPacketHandlers() {
|
||||
PacketIdServer.LETTER_INFO_REQUEST.setPacketHandler(new PacketLetterInfoRequest());
|
||||
PacketIdServer.TRADING_ADDRESS_REQUEST.setPacketHandler(new PacketTraderAddressRequest());
|
||||
PacketIdServer.POBOX_INFO_REQUEST.setPacketHandler(new PacketPOBoxInfoRequest());
|
||||
PacketIdServer.LETTER_TEXT_SET.setPacketHandler(new PacketLetterTextSet());
|
||||
|
||||
PacketIdClient.LETTER_INFO_RESPONSE.setPacketHandler(new PacketLetterInfoResponse());
|
||||
PacketIdClient.TRADING_ADDRESS_RESPONSE.setPacketHandler(new PacketTraderAddressResponse());
|
||||
PacketIdClient.POBOX_INFO_RESPONSE.setPacketHandler(new PacketPOBoxInfoResponse());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,6 @@ import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.IPickupHandler;
|
||||
import forestry.core.IResupplyHandler;
|
||||
import forestry.core.ISaveEventHandler;
|
||||
import forestry.core.network.IPacketHandler;
|
||||
import forestry.core.utils.Log;
|
||||
|
||||
public class PluginManager {
|
||||
@@ -51,7 +50,6 @@ public class PluginManager {
|
||||
private static final String CATEGORY_MODULES = "modules";
|
||||
|
||||
public static final ArrayList<IGuiHandler> guiHandlers = Lists.newArrayList();
|
||||
public static final ArrayList<IPacketHandler> packetHandlers = Lists.newArrayList();
|
||||
public static final ArrayList<IPickupHandler> pickupHandlers = Lists.newArrayList();
|
||||
public static final ArrayList<ISaveEventHandler> saveEventHandlers = Lists.newArrayList();
|
||||
public static final ArrayList<IResupplyHandler> resupplyHandlers = Lists.newArrayList();
|
||||
@@ -151,10 +149,7 @@ public class PluginManager {
|
||||
guiHandlers.add(guiHandler);
|
||||
}
|
||||
|
||||
IPacketHandler packetHandler = plugin.getPacketHandler();
|
||||
if (packetHandler != null) {
|
||||
packetHandlers.add(packetHandler);
|
||||
}
|
||||
plugin.registerPacketHandlers();
|
||||
|
||||
IPickupHandler pickupHandler = plugin.getPickupHandler();
|
||||
if (pickupHandler != null) {
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
package forestry.storage.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.IGuiSelectable;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.network.PacketGuiSelect;
|
||||
import forestry.core.network.PacketGuiSelectRequest;
|
||||
import forestry.storage.GuiHandlerStorage.PagedBackpackInventory;
|
||||
|
||||
public class ContainerNaturalistBackpack extends ContainerItemInventory<PagedBackpackInventory> implements IGuiSelectable {
|
||||
@@ -32,11 +33,7 @@ public class ContainerNaturalistBackpack extends ContainerItemInventory<PagedBac
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelectionChange(EntityPlayer player, PacketGuiSelect packet) {
|
||||
public void handleSelectionRequest(EntityPlayerMP player, PacketGuiSelectRequest packet) {
|
||||
inventory.flipPage(player, packet.getPrimaryIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelection(PacketGuiSelect packet) {
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user