Initial 1.11.2 update
This commit is contained in:
@@ -12,13 +12,14 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
/** <b>[Server -> Client]</b> This packet is sent when a player casts the clairvoyance spell to allow pathing to chunks
|
||||
* outside the render distance. */
|
||||
/**
|
||||
* <b>[Server -> Client]</b> This packet is sent when a player casts the clairvoyance spell to allow pathing to chunks
|
||||
* outside the render distance.
|
||||
*/
|
||||
public class PacketClairvoyance implements IMessageHandler<Message, IMessage> {
|
||||
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(Message message, MessageContext ctx)
|
||||
{
|
||||
public IMessage onMessage(Message message, MessageContext ctx){
|
||||
// Just to make sure that the side is correct
|
||||
if(ctx.side.isClient()){
|
||||
// Using a fully qualified name is a good course of action here; we don't really want to clutter the proxy
|
||||
@@ -38,40 +39,41 @@ public class PacketClairvoyance implements IMessageHandler<Message, IMessage> {
|
||||
|
||||
public Path path;
|
||||
public float durationMultiplier;
|
||||
|
||||
|
||||
// This constructor is required otherwise you'll get errors (used somewhere in fml through reflection)
|
||||
public Message() {}
|
||||
public Message(){
|
||||
}
|
||||
|
||||
public Message(Path path, float durationMultiplier){
|
||||
|
||||
|
||||
this.path = path;
|
||||
this.durationMultiplier = durationMultiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf){
|
||||
|
||||
|
||||
// The order is important
|
||||
this.durationMultiplier = buf.readFloat();
|
||||
|
||||
|
||||
List<PathPoint> points = new ArrayList<PathPoint>();
|
||||
|
||||
|
||||
while(buf.isReadable()){
|
||||
points.add(new PathPoint(buf.readInt(), buf.readInt(), buf.readInt()));
|
||||
}
|
||||
|
||||
|
||||
this.path = new Path(points.toArray(new PathPoint[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf){
|
||||
|
||||
|
||||
buf.writeFloat(durationMultiplier);
|
||||
|
||||
for(int i=0; i<path.getCurrentPathLength(); i++){
|
||||
|
||||
|
||||
for(int i = 0; i < path.getCurrentPathLength(); i++){
|
||||
|
||||
PathPoint point = path.getPathPointFromIndex(i);
|
||||
|
||||
|
||||
buf.writeInt(point.xCoord);
|
||||
buf.writeInt(point.yCoord);
|
||||
buf.writeInt(point.zCoord);
|
||||
|
||||
Reference in New Issue
Block a user