Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package halestormxv.eAngelus.network.packets;
- import halestormxv.eAngelus.capabilities.Interfaces.IMorality;
- import halestormxv.eAngelus.capabilities.MoralityCapability.moralityProvider;
- import io.netty.buffer.ByteBuf;
- import net.minecraft.entity.player.EntityPlayerMP;
- import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
- import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
- import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- /**
- * Created by Blaze on 7/13/2017.
- */
- public class SyncMorality implements IMessage
- {
- private int moralityValue;
- public SyncMorality(){ }
- public SyncMorality(int moralityValue)
- {
- this.moralityValue = moralityValue;
- }
- @Override
- public void fromBytes(ByteBuf buf)
- {
- this.moralityValue = buf.readInt();
- }
- @Override
- public void toBytes(ByteBuf buf)
- {
- buf.writeInt(moralityValue);
- }
- public static class Handler implements IMessageHandler<SyncMorality, IMessage>
- {
- @Override
- public IMessage onMessage(SyncMorality message, MessageContext ctx) {
- EntityPlayerMP player = ctx.getServerHandler().playerEntity;
- player.mcServer.addScheduledTask(() ->
- {
- IMorality morality = player.getCapability(moralityProvider.MORALITY_CAP, null);
- morality.set(message.moralityValue);
- System.out.println("The morality has been synced to: "+message.moralityValue);
- });
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement