mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
63 lines
1.8 KiB
Java
63 lines
1.8 KiB
Java
package com.hbm.packet;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashSet;
|
|
import java.util.List;
|
|
|
|
import com.hbm.handler.ImpactWorldHandler;
|
|
import com.hbm.potion.HbmPotion;
|
|
import com.hbm.saveddata.TomSaveData;
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
import net.minecraft.world.World;
|
|
|
|
/**
|
|
* Utility for permanently synchronizing values every tick with a player in the given context of a world.
|
|
* Uses the Byte Buffer directly instead of NBT to cut back on unnecessary data.
|
|
* @author hbm
|
|
*/
|
|
public class PermaSyncHandler {
|
|
|
|
public static HashSet<Integer> boykissers = new HashSet();
|
|
|
|
public static void writePacket(ByteBuf buf, World world, EntityPlayerMP player) {
|
|
|
|
/// TOM IMPACT DATA ///
|
|
TomSaveData data = TomSaveData.forWorld(world);
|
|
buf.writeFloat(data.fire);
|
|
buf.writeFloat(data.dust);
|
|
buf.writeBoolean(data.impact);
|
|
/// TOM IMPACT DATA ///
|
|
|
|
/// SHITTY MEMES ///
|
|
List<Integer> ids = new ArrayList();
|
|
for(Object o : world.playerEntities) {
|
|
EntityPlayer p = (EntityPlayer) o;
|
|
if(p.isPotionActive(HbmPotion.death.id)) {
|
|
ids.add(p.getEntityId());
|
|
}
|
|
}
|
|
buf.writeShort((short) ids.size());
|
|
for(Integer i : ids) buf.writeInt(i);
|
|
/// SHITTY MEMES ///
|
|
}
|
|
|
|
public static void readPacket(ByteBuf buf, World world, EntityPlayer player) {
|
|
|
|
/// TOM IMPACT DATA ///
|
|
ImpactWorldHandler.lastSyncWorld = player.worldObj;
|
|
ImpactWorldHandler.fire = buf.readFloat();
|
|
ImpactWorldHandler.dust = buf.readFloat();
|
|
ImpactWorldHandler.impact = buf.readBoolean();
|
|
/// TOM IMPACT DATA ///
|
|
|
|
/// SHITTY MEMES ///
|
|
boykissers.clear();
|
|
int ids = buf.readShort();
|
|
for(int i = 0; i < ids; i++) boykissers.add(buf.readInt());
|
|
/// SHITTY MEMES ///
|
|
}
|
|
}
|