Fixed the Speed and Jump rituals so that they correctly update the player's motion

This commit is contained in:
WayofTime 2016-04-13 11:05:17 -04:00
parent 81e9452a21
commit c0b39039cc
6 changed files with 115 additions and 29 deletions

View file

@ -17,6 +17,7 @@ public class BloodMagicPacketHandler
{
INSTANCE.registerMessage(ChatUtil.PacketNoSpamChat.Handler.class, ChatUtil.PacketNoSpamChat.class, 0, Side.CLIENT);
INSTANCE.registerMessage(ItemRouterButtonPacketProcessor.class, ItemRouterButtonPacketProcessor.class, 1, Side.SERVER);
INSTANCE.registerMessage(PlayerVelocityPacketProcessor.class, PlayerVelocityPacketProcessor.class, 2, Side.CLIENT);
}
public static void sendToAllAround(IMessage message, TileEntity te, int range)

View file

@ -0,0 +1,67 @@
package WayofTime.bloodmagic.network;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.PacketBuffer;
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;
public class PlayerVelocityPacketProcessor implements IMessage, IMessageHandler<PlayerVelocityPacketProcessor, IMessage>
{
private double motionX;
private double motionY;
private double motionZ;
public PlayerVelocityPacketProcessor()
{
}
public PlayerVelocityPacketProcessor(double motionX, double motionY, double motionZ)
{
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
}
@Override
public void fromBytes(ByteBuf buffer)
{
PacketBuffer buff = new PacketBuffer(buffer);
motionX = buff.readDouble();
motionY = buff.readDouble();
motionZ = buff.readDouble();
}
@Override
public void toBytes(ByteBuf buffer)
{
PacketBuffer buff = new PacketBuffer(buffer);
buff.writeDouble(motionX);
buff.writeDouble(motionY);
buff.writeDouble(motionZ);
}
@Override
public IMessage onMessage(PlayerVelocityPacketProcessor message, MessageContext ctx)
{
if (ctx.side == Side.CLIENT)
{
message.onMessageFromServer();
}
return null;
}
@SideOnly(Side.CLIENT)
public void onMessageFromServer()
{
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
player.motionX = motionX;
player.motionY = motionY;
player.motionZ = motionZ;
}
}