fixed items traveling in pipes
This commit is contained in:
parent
f10e728b59
commit
f227dc2afc
4 changed files with 34 additions and 3 deletions
|
@ -30,10 +30,14 @@ public class BuildCraftMod {
|
|||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(entityplayer);
|
||||
channels.get(Side.SERVER).writeOutbound(packet);
|
||||
}
|
||||
|
||||
public void replyToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) {
|
||||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.REPLY);
|
||||
channels.get(Side.SERVER).writeOutbound(packet);
|
||||
}
|
||||
|
||||
public void sendToServer(BuildCraftPacket packet) {
|
||||
channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.TOSERVER);
|
||||
channels.get(Side.CLIENT).writeOutbound(packet);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,12 @@
|
|||
package buildcraft.core.network;
|
||||
|
||||
import buildcraft.builders.network.PacketLibraryAction;
|
||||
import buildcraft.transport.network.PacketFluidUpdate;
|
||||
import buildcraft.transport.network.PacketGateExpansionMap;
|
||||
import buildcraft.transport.network.PacketPipeTransportItemStack;
|
||||
import buildcraft.transport.network.PacketPipeTransportItemStackRequest;
|
||||
import buildcraft.transport.network.PacketPipeTransportTraveler;
|
||||
import buildcraft.transport.network.PacketPowerUpdate;
|
||||
import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
@ -9,6 +16,19 @@ public class BuildCraftChannelHandler extends FMLIndexedMessageToMessageCodec<Bu
|
|||
public BuildCraftChannelHandler() {
|
||||
addDiscriminator(0, PacketTileUpdate.class);
|
||||
addDiscriminator(1, PacketTileState.class);
|
||||
addDiscriminator(2, PacketCoordinates.class);
|
||||
addDiscriminator(3, PacketFluidUpdate.class);
|
||||
addDiscriminator(4, PacketLibraryAction.class);
|
||||
addDiscriminator(5, PacketNBT.class);
|
||||
addDiscriminator(6, PacketPowerUpdate.class);
|
||||
addDiscriminator(7, PacketSlotChange.class);
|
||||
addDiscriminator(8, PacketGateExpansionMap.class);
|
||||
addDiscriminator(9, PacketGuiReturn.class);
|
||||
addDiscriminator(10, PacketGuiWidget.class);
|
||||
addDiscriminator(11, PacketPipeTransportItemStack.class);
|
||||
addDiscriminator(12, PacketPipeTransportItemStackRequest.class);
|
||||
addDiscriminator(13, PacketPipeTransportTraveler.class);
|
||||
addDiscriminator(14, PacketUpdate.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,6 +15,7 @@ import buildcraft.api.transport.IPipeTile.PipeType;
|
|||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.IMachine;
|
||||
import buildcraft.core.inventory.Transactor;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.BCLog;
|
||||
import buildcraft.core.utils.BlockUtil;
|
||||
import buildcraft.core.utils.MathUtils;
|
||||
|
@ -416,12 +417,14 @@ public class PipeTransportItems extends PipeTransport {
|
|||
*/
|
||||
public void handleTravelerPacket(PacketPipeTransportTraveler packet) {
|
||||
TravelingItem item = TravelingItem.clientCache.get(packet.getTravelingEntityId());
|
||||
|
||||
if (item == null) {
|
||||
item = TravelingItem.make(packet.getTravelingEntityId());
|
||||
}
|
||||
|
||||
if (item.getContainer() != container)
|
||||
if (item.getContainer() != container) {
|
||||
items.add(item);
|
||||
}
|
||||
|
||||
if (packet.forceStackRefresh() || item.getItemStack() == null) {
|
||||
BuildCraftTransport.instance.sendToServer(new PacketPipeTransportItemStackRequest(packet.getTravelingEntityId()));
|
||||
|
|
|
@ -17,6 +17,10 @@ public class PacketPipeTransportItemStackRequest extends BuildCraftPacket {
|
|||
public int travelerID;
|
||||
TravelingItem item;
|
||||
|
||||
public PacketPipeTransportItemStackRequest() {
|
||||
|
||||
}
|
||||
|
||||
public PacketPipeTransportItemStackRequest(int travelerID) {
|
||||
this.travelerID = travelerID;
|
||||
}
|
||||
|
@ -35,7 +39,7 @@ public class PacketPipeTransportItemStackRequest extends BuildCraftPacket {
|
|||
|
||||
public void sendDataToPlayer (EntityPlayer player) {
|
||||
if (item != null) {
|
||||
BuildCraftTransport.instance.sendToPlayer(
|
||||
BuildCraftTransport.instance.replyToPlayer(
|
||||
player,
|
||||
new PacketPipeTransportItemStack(travelerID, item
|
||||
.getItemStack()));
|
||||
|
|
Loading…
Reference in a new issue