mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
more radar crap
This commit is contained in:
parent
e13e926ae3
commit
64c53be869
@ -1,3 +1,6 @@
|
||||
## Changed
|
||||
* Light oil and cracked light oil can now be refomred into large quantities of aromatic hydrocarbons a well as some reformate gas
|
||||
|
||||
## Fixed
|
||||
* Fixed thorium bedrock ore using the wrong ore dict key, making it unable to be processed via centrifuge or acidizer
|
||||
* Fixed custom machine NEI slots going out of bounds after the third slot
|
||||
@ -1,5 +1,7 @@
|
||||
package api.hbm.entity;
|
||||
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@ -12,6 +14,8 @@ public class RadarEntry {
|
||||
public int posZ;
|
||||
public int dim;
|
||||
|
||||
public RadarEntry() { } //blank ctor for packets
|
||||
|
||||
public RadarEntry(String name, int level, int x, int y, int z, int dim) {
|
||||
this.unlocalizedName = name;
|
||||
this.blipLevel = level;
|
||||
@ -32,4 +36,22 @@ public class RadarEntry {
|
||||
public RadarEntry(EntityPlayer player) {
|
||||
this(player.getDisplayName(), IRadarDetectableNT.PLAYER, (int) Math.floor(player.posX), (int) Math.floor(player.posY), (int) Math.floor(player.posZ), player.dimension);
|
||||
}
|
||||
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.unlocalizedName = ByteBufUtils.readUTF8String(buf);
|
||||
this.blipLevel = buf.readShort();
|
||||
this.posX = buf.readInt();
|
||||
this.posY = buf.readInt();
|
||||
this.posZ = buf.readInt();
|
||||
this.dim = buf.readShort();
|
||||
}
|
||||
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteBufUtils.writeUTF8String(buf, this.unlocalizedName);
|
||||
buf.writeShort(this.blipLevel);
|
||||
buf.writeInt(this.posX);
|
||||
buf.writeInt(this.posY);
|
||||
buf.writeInt(this.posZ);
|
||||
buf.writeShort(this.dim);
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,16 @@ public class ReformingRecipes extends SerializableRecipe {
|
||||
new FluidStack(Fluids.AROMATICS, 10),
|
||||
new FluidStack(Fluids.HYDROGEN, 5)
|
||||
));
|
||||
recipes.put(Fluids.LIGHTOIL, new Triplet(
|
||||
new FluidStack(Fluids.AROMATICS, 50),
|
||||
new FluidStack(Fluids.REFORMGAS, 10),
|
||||
new FluidStack(Fluids.HYDROGEN, 15)
|
||||
));
|
||||
recipes.put(Fluids.LIGHTOIL_CRACK, new Triplet(
|
||||
new FluidStack(Fluids.AROMATICS, 50),
|
||||
new FluidStack(Fluids.REFORMGAS, 5),
|
||||
new FluidStack(Fluids.HYDROGEN, 20)
|
||||
));
|
||||
recipes.put(Fluids.PETROLEUM, new Triplet(
|
||||
new FluidStack(Fluids.UNSATURATEDS, 85),
|
||||
new FluidStack(Fluids.REFORMGAS, 10),
|
||||
|
||||
56
src/main/java/com/hbm/packet/BufPacket.java
Normal file
56
src/main/java/com/hbm/packet/BufPacket.java
Normal file
@ -0,0 +1,56 @@
|
||||
package com.hbm.packet;
|
||||
|
||||
import com.hbm.tileentity.IBufPacketReceiver;
|
||||
|
||||
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 io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class BufPacket implements IMessage {
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
IBufPacketReceiver rec;
|
||||
ByteBuf buf;
|
||||
|
||||
public BufPacket() { }
|
||||
|
||||
public BufPacket(int x, int y, int z, IBufPacketReceiver rec) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.rec = rec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.buf = buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
this.rec.serialize(buf);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<BufPacket, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(BufPacket m, MessageContext ctx) {
|
||||
|
||||
if(Minecraft.getMinecraft().theWorld == null)
|
||||
return null;
|
||||
|
||||
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
|
||||
|
||||
if(te instanceof IBufPacketReceiver) {
|
||||
((IBufPacketReceiver) te).deserialize(m.buf);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -14,6 +14,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
|
||||
@Deprecated // rest in peace sweet little prince
|
||||
public class NBTPacket implements IMessage {
|
||||
|
||||
PacketBuffer buffer;
|
||||
|
||||
@ -21,8 +21,6 @@ public class PacketDispatcher {
|
||||
wrapper.registerMessage(TEDrillPacket.Handler.class, TEDrillPacket.class, i++, Side.CLIENT);
|
||||
//Mining drill torque for sounds
|
||||
wrapper.registerMessage(TEDrillSoundPacket.Handler.class, TEDrillSoundPacket.class, i++, Side.CLIENT);
|
||||
//Assembler cog rotation for rendering
|
||||
wrapper.registerMessage(TEAssemblerPacket.Handler.class, TEAssemblerPacket.class, i++, Side.CLIENT);
|
||||
//Missile type for rendering
|
||||
wrapper.registerMessage(TEMissilePacket.Handler.class, TEMissilePacket.class, i++, Side.CLIENT);
|
||||
//Fluid packet for GUI
|
||||
@ -33,16 +31,12 @@ public class PacketDispatcher {
|
||||
wrapper.registerMessage(ItemFolderPacket.Handler.class, ItemFolderPacket.class, i++, Side.SERVER);
|
||||
//Electricity gauge for GUI rendering
|
||||
wrapper.registerMessage(AuxElectricityPacket.Handler.class, AuxElectricityPacket.class, i++, Side.CLIENT);
|
||||
//Universal package for machine gauges and states
|
||||
wrapper.registerMessage(AuxGaugePacket.Handler.class, AuxGaugePacket.class, i++, Side.CLIENT);
|
||||
//Siren packet for looped sounds
|
||||
wrapper.registerMessage(TESirenPacket.Handler.class, TESirenPacket.class, i++, Side.CLIENT);
|
||||
//Signals server to change ItemStacks
|
||||
wrapper.registerMessage(ItemDesignatorPacket.Handler.class, ItemDesignatorPacket.class, i++, Side.SERVER);
|
||||
//Siren packet for looped sounds
|
||||
wrapper.registerMessage(TERadarPacket.Handler.class, TERadarPacket.class, i++, Side.CLIENT);
|
||||
//Siren packet for looped sounds
|
||||
wrapper.registerMessage(TERadarDestructorPacket.Handler.class, TERadarDestructorPacket.class, i++, Side.CLIENT);
|
||||
//Signals server to perform orbital strike, among other things
|
||||
wrapper.registerMessage(SatLaserPacket.Handler.class, SatLaserPacket.class, i++, Side.SERVER);
|
||||
//Universal package for sending small info packs back to server
|
||||
@ -57,7 +51,7 @@ public class PacketDispatcher {
|
||||
wrapper.registerMessage(ExtPropPacket.Handler.class, ExtPropPacket.class, i++, Side.CLIENT);
|
||||
//Entity sound packet that keeps client and server separated
|
||||
wrapper.registerMessage(LoopedEntitySoundPacket.Handler.class, LoopedEntitySoundPacket.class, i++, Side.CLIENT);
|
||||
//Entity sound packet that keeps client and server separated
|
||||
//Packet for force fields
|
||||
wrapper.registerMessage(TEFFPacket.Handler.class, TEFFPacket.class, i++, Side.CLIENT);
|
||||
//Sends button information for ItemGunBase
|
||||
wrapper.registerMessage(GunButtonPacket.Handler.class, GunButtonPacket.class, i++, Side.SERVER);
|
||||
@ -67,8 +61,6 @@ public class PacketDispatcher {
|
||||
wrapper.registerMessage(ItemBobmazonPacket.Handler.class, ItemBobmazonPacket.class, i++, Side.SERVER);
|
||||
//Packet to send missile multipart information to TEs
|
||||
wrapper.registerMessage(TEMissileMultipartPacket.Handler.class, TEMissileMultipartPacket.class, i++, Side.CLIENT);
|
||||
//Packet to send NBT data to tile entities
|
||||
wrapper.registerMessage(NBTPacket.Handler.class, NBTPacket.class, i++, Side.CLIENT);
|
||||
//Aux Particle Packet, New Technology: like the APP but with NBT
|
||||
wrapper.registerMessage(AuxParticlePacketNT.Handler.class, AuxParticlePacketNT.class, i++, Side.CLIENT);
|
||||
//Signals server to do coord based satellite stuff
|
||||
@ -97,6 +89,11 @@ public class PacketDispatcher {
|
||||
wrapper.registerMessage(PermaSyncPacket.Handler.class, PermaSyncPacket.class, i++, Side.CLIENT);
|
||||
//Syncs biome information for single positions or entire chunks
|
||||
wrapper.registerMessage(BiomeSyncPacket.Handler.class, BiomeSyncPacket.class, i++, Side.CLIENT);
|
||||
|
||||
//Tile sync
|
||||
wrapper.registerMessage(AuxGaugePacket.Handler.class, AuxGaugePacket.class, i++, Side.CLIENT); //The horrid one
|
||||
wrapper.registerMessage(NBTPacket.Handler.class, NBTPacket.class, i++, Side.CLIENT); //The convenient but laggy one
|
||||
wrapper.registerMessage(BufPacket.Handler.class, BufPacket.class, i++, Side.CLIENT); //The not-so-convenient but not laggy one
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
package com.hbm.packet;
|
||||
|
||||
import com.hbm.tileentity.machine.TileEntityMachineAssembler;
|
||||
|
||||
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 io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TEAssemblerPacket implements IMessage {
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
boolean progress;
|
||||
|
||||
public TEAssemblerPacket()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TEAssemblerPacket(int x, int y, int z, boolean bool)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.progress = bool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
progress = buf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeBoolean(progress);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<TEAssemblerPacket, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(TEAssemblerPacket m, MessageContext ctx) {
|
||||
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
|
||||
|
||||
if (te != null && te instanceof TileEntityMachineAssembler) {
|
||||
|
||||
TileEntityMachineAssembler gen = (TileEntityMachineAssembler) te;
|
||||
gen.isProgressing = m.progress;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
package com.hbm.packet;
|
||||
|
||||
import com.hbm.tileentity.machine.TileEntityMachineRadar;
|
||||
|
||||
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 cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TERadarDestructorPacket implements IMessage {
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
|
||||
public TERadarDestructorPacket() {
|
||||
|
||||
}
|
||||
|
||||
public TERadarDestructorPacket(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<TERadarDestructorPacket, IMessage> {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IMessage onMessage(TERadarDestructorPacket m, MessageContext ctx) {
|
||||
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
|
||||
|
||||
try {
|
||||
if (te != null && te instanceof TileEntityMachineRadar) {
|
||||
|
||||
TileEntityMachineRadar radar = (TileEntityMachineRadar) te;
|
||||
radar.nearbyMissiles.clear();
|
||||
}
|
||||
} catch (Exception x) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
src/main/java/com/hbm/tileentity/IBufPacketReceiver.java
Normal file
9
src/main/java/com/hbm/tileentity/IBufPacketReceiver.java
Normal file
@ -0,0 +1,9 @@
|
||||
package com.hbm.tileentity;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public interface IBufPacketReceiver {
|
||||
|
||||
public void serialize(ByteBuf buf);
|
||||
public void deserialize(ByteBuf buf);
|
||||
}
|
||||
@ -2,10 +2,12 @@ package com.hbm.tileentity;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.packet.AuxGaugePacket;
|
||||
import com.hbm.packet.BufPacket;
|
||||
import com.hbm.packet.NBTPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -14,7 +16,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
public abstract class TileEntityMachineBase extends TileEntityLoadedBase implements ISidedInventory, INBTPacketReceiver {
|
||||
public abstract class TileEntityMachineBase extends TileEntityLoadedBase implements ISidedInventory, INBTPacketReceiver, IBufPacketReceiver {
|
||||
|
||||
public ItemStack slots[];
|
||||
|
||||
@ -147,23 +149,23 @@ public abstract class TileEntityMachineBase extends TileEntityLoadedBase impleme
|
||||
@Override
|
||||
public abstract void updateEntity();
|
||||
|
||||
@Deprecated
|
||||
public void updateGauge(int val, int id, int range) {
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxGaugePacket(xCoord, yCoord, zCoord, val, id), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
||||
@Deprecated public void updateGauge(int val, int id, int range) {
|
||||
if(!worldObj.isRemote) PacketDispatcher.wrapper.sendToAllAround(new AuxGaugePacket(xCoord, yCoord, zCoord, val, id), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
||||
}
|
||||
@Deprecated public void processGauge(int val, int id) { }
|
||||
|
||||
@Deprecated public void networkPack(NBTTagCompound nbt, int range) {
|
||||
if(!worldObj.isRemote) PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
||||
}
|
||||
@Deprecated public void networkUnpack(NBTTagCompound nbt) { }
|
||||
|
||||
/** Sends a sync packet that uses ByteBuf for efficient information-cramming */
|
||||
public void networkPackNT(int range) {
|
||||
if(!worldObj.isRemote) PacketDispatcher.wrapper.sendToAllAround(new BufPacket(xCoord, yCoord, zCoord, this), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void processGauge(int val, int id) { }
|
||||
|
||||
public void networkPack(NBTTagCompound nbt, int range) {
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
||||
}
|
||||
|
||||
public void networkUnpack(NBTTagCompound nbt) { }
|
||||
@Override public void serialize(ByteBuf buf) { }
|
||||
@Override public void deserialize(ByteBuf buf) { }
|
||||
|
||||
@Deprecated
|
||||
public void handleButtonPacket(int value, int meta) { }
|
||||
|
||||
@ -231,6 +231,9 @@ public class TileMappings {
|
||||
putMachines();
|
||||
putPile();
|
||||
putRBMK();
|
||||
|
||||
TileEntityMachineRadarNT.registerEntityClasses();
|
||||
TileEntityMachineRadarNT.registerConverters();
|
||||
}
|
||||
|
||||
private static void putBombs() {
|
||||
|
||||
@ -1,25 +1,33 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.extprop.HbmLivingProps;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.IConfigurableMachine;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.Tuple.Pair;
|
||||
|
||||
import api.hbm.entity.IRadarDetectable;
|
||||
import api.hbm.entity.IRadarDetectableNT;
|
||||
import api.hbm.entity.RadarEntry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
/**
|
||||
* Now with SmЯt™ lag-free entity detection!
|
||||
* Now with SmЯt™ lag-free entity detection! (patent pending)
|
||||
* @author hbm
|
||||
*/
|
||||
public class TileEntityMachineRadarNT extends TileEntityMachineBase {
|
||||
public class TileEntityMachineRadarNT extends TileEntityMachineBase implements IConfigurableMachine {
|
||||
|
||||
public boolean scanMissiles = true;
|
||||
public boolean scanPlayers = true;
|
||||
@ -28,6 +36,42 @@ public class TileEntityMachineRadarNT extends TileEntityMachineBase {
|
||||
|
||||
public boolean jammed = false;
|
||||
|
||||
public float prevRotation;
|
||||
public float rotation;
|
||||
|
||||
public long power = 0;
|
||||
|
||||
public static int maxPower = 100_000;
|
||||
public static int consumption = 500;
|
||||
public static int radarRange = 1_000;
|
||||
public static int radarBuffer = 30;
|
||||
public static int radarAltitude = 55;
|
||||
|
||||
public List<RadarEntry> entries = new ArrayList();
|
||||
|
||||
@Override
|
||||
public String getConfigName() {
|
||||
return "radar";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readIfPresent(JsonObject obj) {
|
||||
maxPower = IConfigurableMachine.grab(obj, "L:powerCap", maxPower);
|
||||
consumption = IConfigurableMachine.grab(obj, "L:consumption", consumption);
|
||||
radarRange = IConfigurableMachine.grab(obj, "I:radarRange", radarRange);
|
||||
radarBuffer = IConfigurableMachine.grab(obj, "I:radarBuffer", radarBuffer);
|
||||
radarAltitude = IConfigurableMachine.grab(obj, "I:radarAltitude", radarAltitude);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeConfig(JsonWriter writer) throws IOException {
|
||||
writer.name("L:powerCap").value(maxPower);
|
||||
writer.name("L:consumption").value(consumption);
|
||||
writer.name("I:radarRange").value(radarRange);
|
||||
writer.name("I:radarBuffer").value(radarBuffer);
|
||||
writer.name("I:radarAltitude").value(radarAltitude);
|
||||
}
|
||||
|
||||
public TileEntityMachineRadarNT() {
|
||||
super(1);
|
||||
}
|
||||
@ -40,10 +84,81 @@ public class TileEntityMachineRadarNT extends TileEntityMachineBase {
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
this.power = Library.chargeTEFromItems(slots, 0, power, maxPower);
|
||||
this.jammed = false;
|
||||
allocateTargets();
|
||||
|
||||
this.networkPackNT(25);
|
||||
}
|
||||
}
|
||||
|
||||
//List of lambdas that are supplied a Pair with the entity and radar in question to generate a RadarEntry
|
||||
//The converters coming first have the highest priority
|
||||
protected void allocateTargets() {
|
||||
this.entries.clear();
|
||||
|
||||
if(this.yCoord < radarAltitude) return;
|
||||
if(this.power <= consumption) return;
|
||||
this.power -= consumption;
|
||||
|
||||
int scan = this.scanRange();
|
||||
|
||||
for(Entity e : matchingEntities) {
|
||||
|
||||
if(e.dimension == worldObj.provider.dimensionId && Math.abs(e.posX - (xCoord + 0.5)) <= scan && Math.abs(e.posZ - (zCoord + 0.5)) <= scan && e.posY - yCoord < radarBuffer) {
|
||||
|
||||
if(e instanceof EntityLivingBase && HbmLivingProps.getDigamma((EntityLivingBase) e) > 0.001) {
|
||||
this.jammed = true;
|
||||
entries.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
for(Function<Pair<Entity, Object>, RadarEntry> converter : converters) {
|
||||
|
||||
RadarEntry entry = converter.apply(new Pair(e, this));
|
||||
if(entry != null) {
|
||||
this.entries.add(entry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int scanRange() {
|
||||
return radarRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(ByteBuf buf) {
|
||||
buf.writeLong(this.power);
|
||||
buf.writeBoolean(this.scanMissiles);
|
||||
buf.writeBoolean(this.scanPlayers);
|
||||
buf.writeBoolean(this.smartMode);
|
||||
buf.writeBoolean(this.redMode);
|
||||
buf.writeBoolean(this.jammed);
|
||||
buf.writeInt(entries.size());
|
||||
for(RadarEntry entry : entries) entry.toBytes(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(ByteBuf buf) {
|
||||
this.power = buf.readLong();
|
||||
this.scanMissiles = buf.readBoolean();
|
||||
this.scanPlayers = buf.readBoolean();
|
||||
this.smartMode = buf.readBoolean();
|
||||
this.redMode = buf.readBoolean();
|
||||
this.jammed = buf.readBoolean();
|
||||
int count = buf.readInt();
|
||||
for(int i = 0; i < count; i++) {
|
||||
RadarEntry entry = new RadarEntry();
|
||||
entry.fromBytes(buf);
|
||||
this.entries.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
/** List of lambdas that are supplied a Pair with the entity and radar in question to generate a RadarEntry
|
||||
The converters coming first have the highest priority */
|
||||
public static List<Function<Pair<Entity, Object>, RadarEntry>> converters = new ArrayList();
|
||||
public static List<Class> classes = new ArrayList();
|
||||
public static List<Entity> matchingEntities = new ArrayList();
|
||||
@ -87,18 +202,12 @@ public class TileEntityMachineRadarNT extends TileEntityMachineBase {
|
||||
});
|
||||
//IRadarDetectable, Legacy
|
||||
converters.add(x -> {
|
||||
Entity e = x.getKey();
|
||||
if(e instanceof IRadarDetectable) {
|
||||
return new RadarEntry((IRadarDetectable) e, e);
|
||||
}
|
||||
if(x.getKey() instanceof IRadarDetectable) return new RadarEntry((IRadarDetectable) x.getKey(), x.getKey());
|
||||
return null;
|
||||
});
|
||||
//Players
|
||||
converters.add(x -> {
|
||||
Entity e = x.getKey();
|
||||
if(e instanceof EntityPlayer) {
|
||||
return new RadarEntry((EntityPlayer) e);
|
||||
}
|
||||
if(x.getKey() instanceof EntityPlayer) return new RadarEntry((EntityPlayer) x.getKey());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user