-
-
Save RandomOnlineName/419646ca18bf5c093a2db8a22984e2a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void encode(updateBlockStateMessage message, PacketBuffer buffer) { | |
buffer.writeInt(message.entity); | |
buffer.writeFloat(message.BlockStateID); | |
} | |
@Override | |
public updateBlockStateMessage decode(PacketBuffer buffer) { | |
return new updateBlockStateMessage(buffer.readInt(), buffer.readFloat()); | |
} | |
@Override | |
public void handle(updateBlockStateMessage message, Supplier<NetworkEvent.Context> contextSupplier) { | |
NetworkEvent.Context context = contextSupplier.get(); | |
Optional<World> world; | |
world = LogicalSidedProvider.CLIENTWORLD.get(context.getDirection().getReceptionSide()); | |
if(context.getDirection() == NetworkDirection.PLAY_TO_CLIENT){ | |
try { | |
context.enqueueWork(() -> | |
((FlexibleBlockEntity) world.get().getEntityByID(message.entity)) | |
.blockState = Block.getStateById((int) message.BlockStateID)); | |
context.setPacketHandled(true); | |
}catch (NullPointerException nullPointerException){ | |
FlexibleBlockMod.LOGGER.info(nullPointerException); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment