mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-22 19:58:35 +01:00
parent
2526950023
commit
b1d18d751d
1 changed files with 27 additions and 11 deletions
|
@ -13,6 +13,7 @@ import net.minecraftforge.fml.network.NetworkEvent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class PacketGhostSlot {
|
public class PacketGhostSlot {
|
||||||
|
@ -49,17 +50,32 @@ public class PacketGhostSlot {
|
||||||
|
|
||||||
@SuppressWarnings("Convert2Lambda")
|
@SuppressWarnings("Convert2Lambda")
|
||||||
public static void onMessage(PacketGhostSlot message, Supplier<NetworkEvent.Context> ctx) {
|
public static void onMessage(PacketGhostSlot message, Supplier<NetworkEvent.Context> ctx) {
|
||||||
ctx.get().enqueueWork(new Runnable() {
|
Consumer<PlayerEntity> doIt = p -> {
|
||||||
@Override
|
CraftingTerminalTileEntity tile = Utility.getTileEntity(CraftingTerminalTileEntity.class, p.world, message.pos);
|
||||||
public void run() {
|
if (tile != null)
|
||||||
PlayerEntity player = ctx.get().getSender();
|
tile.setGhostItems(message.stacks);
|
||||||
if (player == null)
|
};
|
||||||
player = Minecraft.getInstance().player;
|
|
||||||
CraftingTerminalTileEntity tile = Utility.getTileEntity(CraftingTerminalTileEntity.class, player.world, message.pos);
|
// this whole thing is a dirty hack for allowing the same packet to be used
|
||||||
if (tile != null)
|
// both client -> server and server -> client without any classloading issues
|
||||||
tile.setGhostItems(message.stacks);
|
PlayerEntity player = ctx.get().getSender();
|
||||||
}
|
// are we on the client?
|
||||||
});
|
if (player == null) {
|
||||||
|
ctx.get().enqueueWork(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
doIt.accept(Minecraft.getInstance().player);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ctx.get().enqueueWork(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
doIt.accept(player);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ctx.get().setPacketHandled(true);
|
ctx.get().setPacketHandled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue