mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 13:10:13 +00:00
* Decrease number of Farming Station particles * Set default values for range & number of particles to original
59 lines
1.7 KiB
Java
59 lines
1.7 KiB
Java
package crazypants.enderio.machine.farm;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Random;
|
|
|
|
import com.enderio.core.common.util.BlockCoord;
|
|
|
|
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
|
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
|
import crazypants.enderio.config.Config;
|
|
import crazypants.util.ClientUtil;
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
public class PacketFarmAction implements IMessage, IMessageHandler<PacketFarmAction, IMessage> {
|
|
|
|
private static Random rand = new Random();
|
|
|
|
private List<BlockCoord> coords;
|
|
|
|
public PacketFarmAction() {}
|
|
|
|
public PacketFarmAction(List<BlockCoord> coords) {
|
|
this.coords = coords;
|
|
}
|
|
|
|
public PacketFarmAction(BlockCoord bc) {
|
|
this.coords = new ArrayList<BlockCoord>(1);
|
|
this.coords.add(bc);
|
|
}
|
|
|
|
@Override
|
|
public void toBytes(ByteBuf buffer) {
|
|
int size = coords.size();
|
|
buffer.writeInt(size);
|
|
for (BlockCoord coord : coords) {
|
|
buffer.writeInt(coord.x);
|
|
buffer.writeInt(coord.y);
|
|
buffer.writeInt(coord.z);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void fromBytes(ByteBuf buffer) {
|
|
int size = buffer.readInt();
|
|
coords = new ArrayList<BlockCoord>(size);
|
|
for (int i = 0; i < size; i++) {
|
|
coords.add(new BlockCoord(buffer.readInt(), buffer.readInt(), buffer.readInt()));
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public IMessage onMessage(PacketFarmAction message, MessageContext ctx) {
|
|
ClientUtil.spawnFarmParticles(rand, message.coords, Config.farmParticlesCount);
|
|
return null;
|
|
}
|
|
}
|