add distance check and begin work on radar OC compat!!!!

This commit is contained in:
BallOfEnergy 2024-06-10 22:35:23 -05:00
parent 3dbb81f337
commit f1ed151f6b
3 changed files with 23 additions and 2 deletions

View File

@ -37,11 +37,13 @@ import api.hbm.entity.IRadarDetectable;
import api.hbm.entity.IRadarDetectableNT;
import api.hbm.entity.IRadarDetectableNT.RadarScanParams;
import api.hbm.entity.RadarEntry;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import li.cil.oc.api.network.SimpleComponent;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@ -60,7 +62,8 @@ import net.minecraft.world.WorldServer;
* Now with SmЯt lag-free entity detection! (patent pending)
* @author hbm
*/
public class TileEntityMachineRadarNT extends TileEntityMachineBase implements IEnergyReceiverMK2, IGUIProvider, IConfigurableMachine, IControlReceiver {
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
public class TileEntityMachineRadarNT extends TileEntityMachineBase implements IEnergyReceiverMK2, IGUIProvider, IConfigurableMachine, IControlReceiver, SimpleComponent {
public boolean scanMissiles = true;
public boolean scanShells = true;
@ -592,4 +595,13 @@ public class TileEntityMachineRadarNT extends TileEntityMachineBase implements I
return null;
});
}
//OC compat!
@Override
public String getComponentName() {
return "ntm_radar";
}
//soon :tm:
}

View File

@ -472,7 +472,9 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen
@Optional.Method(modid = "OpenComputers")
public Object[] addCoords(Context context, Arguments args) {
this.mode = MODE_MANUAL;
if(Math.sqrt(Math.pow(xCoord - args.checkDouble(0), 2)+Math.pow(yCoord - args.checkDouble(1), 2)+Math.pow(zCoord - args.checkDouble(2), 2)) >= this.getDecetorRange()) // check distance against range
return new Object[] {false};
targetQueue.add(Vec3.createVectorHelper(args.checkDouble(0), args.checkDouble(1), args.checkDouble(2)));
return new Object[] {};
return new Object[] {true};
}
}

View File

@ -79,9 +79,16 @@ public abstract class TileEntityTurretBaseArtillery extends TileEntityTurretBase
public String getComponentName() {
return "ntm_artillery";
}
@Callback(direct = true)
@Optional.Method(modid = "OpenComputers")
public Object[] getCurrentTarget(Context context, Arguments args) {
return new Object[] {targetQueue.get(0).xCoord, targetQueue.get(0).yCoord, targetQueue.get(0).zCoord};
}
@Callback(direct = true)
@Optional.Method(modid = "OpenComputers")
public Object[] getTargetDistance(Context context, Arguments args) {
return new Object[] {Math.sqrt(Math.pow(xCoord - args.checkDouble(0), 2)+Math.pow(yCoord - args.checkDouble(1), 2)+Math.pow(zCoord - args.checkDouble(2), 2))};
}
}