mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
radar rewrite, first attempt
This commit is contained in:
parent
0d37bfe8fc
commit
fc7f230ddb
@ -1,5 +1,6 @@
|
|||||||
package api.hbm.entity;
|
package api.hbm.entity;
|
||||||
|
|
||||||
|
@Deprecated //Use IRadarDetectableNT instead, old interface will still work though
|
||||||
public interface IRadarDetectable {
|
public interface IRadarDetectable {
|
||||||
|
|
||||||
public static enum RadarTargetType {
|
public static enum RadarTargetType {
|
||||||
@ -15,7 +16,7 @@ public interface IRadarDetectable {
|
|||||||
MISSILE_20("Size 20 Custom Missile"), //size 20 custom missiles
|
MISSILE_20("Size 20 Custom Missile"), //size 20 custom missiles
|
||||||
MISSILE_AB("Anti-Ballistic Missile"), //anti ballistic missile
|
MISSILE_AB("Anti-Ballistic Missile"), //anti ballistic missile
|
||||||
PLAYER("Player"), //airborne players
|
PLAYER("Player"), //airborne players
|
||||||
ARTILLERY("Artillery Shell"); //airborne players
|
ARTILLERY("Artillery Shell"); //artillery shells
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
|
|||||||
22
src/main/java/api/hbm/entity/IRadarDetectableNT.java
Normal file
22
src/main/java/api/hbm/entity/IRadarDetectableNT.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package api.hbm.entity;
|
||||||
|
|
||||||
|
public interface IRadarDetectableNT {
|
||||||
|
|
||||||
|
public static final int TIER0 = 0;
|
||||||
|
public static final int TIER1 = 1;
|
||||||
|
public static final int TIER2 = 2;
|
||||||
|
public static final int TIER3 = 3;
|
||||||
|
public static final int TIER4 = 4;
|
||||||
|
public static final int TIER10 = 5;
|
||||||
|
public static final int TIER10_15 = 6;
|
||||||
|
public static final int TIER15 = 7;
|
||||||
|
public static final int TIER15_20 = 8;
|
||||||
|
public static final int TIER20 = 9;
|
||||||
|
public static final int TIER_AB = 10;
|
||||||
|
public static final int PLAYER = 11;
|
||||||
|
public static final int ARTY = 12;
|
||||||
|
|
||||||
|
public String getUnlocalizedName();
|
||||||
|
public int getBlipLevel();
|
||||||
|
public boolean canBeSeenBy(Object radar);
|
||||||
|
}
|
||||||
35
src/main/java/api/hbm/entity/RadarEntry.java
Normal file
35
src/main/java/api/hbm/entity/RadarEntry.java
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package api.hbm.entity;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
|
||||||
|
public class RadarEntry {
|
||||||
|
|
||||||
|
public String unlocalizedName;
|
||||||
|
public int blipLevel;
|
||||||
|
public int posX;
|
||||||
|
public int posY;
|
||||||
|
public int posZ;
|
||||||
|
public int dim;
|
||||||
|
|
||||||
|
public RadarEntry(String name, int level, int x, int y, int z, int dim) {
|
||||||
|
this.unlocalizedName = name;
|
||||||
|
this.blipLevel = level;
|
||||||
|
this.posX = x;
|
||||||
|
this.posY = y;
|
||||||
|
this.posZ = z;
|
||||||
|
this.dim = dim;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RadarEntry(IRadarDetectableNT detectable, Entity entity) {
|
||||||
|
this(detectable.getUnlocalizedName(), detectable.getBlipLevel(), (int) Math.floor(entity.posX), (int) Math.floor(entity.posY), (int) Math.floor(entity.posZ), entity.dimension);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RadarEntry(IRadarDetectable detectable, Entity entity) {
|
||||||
|
this(detectable.getTargetType().name, detectable.getTargetType().ordinal(), (int) Math.floor(entity.posX), (int) Math.floor(entity.posY), (int) Math.floor(entity.posZ), entity.dimension);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
package com.hbm.tileentity.machine;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
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 net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.world.WorldServer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Now with SmЯt™ lag-free entity detection!
|
||||||
|
* @author hbm
|
||||||
|
*/
|
||||||
|
public class TileEntityMachineRadarNT extends TileEntityMachineBase {
|
||||||
|
|
||||||
|
public boolean scanMissiles = true;
|
||||||
|
public boolean scanPlayers = true;
|
||||||
|
public boolean smartMode = true;
|
||||||
|
public boolean redMode = true;
|
||||||
|
|
||||||
|
public boolean jammed = false;
|
||||||
|
|
||||||
|
public TileEntityMachineRadarNT() {
|
||||||
|
super(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//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();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterates over every entity in the world and add them to the matchingEntities list if the class is in the detectable list
|
||||||
|
* From this compiled list, radars can easily grab the required entities since we can assume that the total amount of detectable entities is comparatively low
|
||||||
|
*/
|
||||||
|
public static void updateSystem() {
|
||||||
|
matchingEntities.clear();
|
||||||
|
|
||||||
|
for(WorldServer world : Minecraft.getMinecraft().getIntegratedServer().worldServers) {
|
||||||
|
for(Object entity : world.loadedEntityList) {
|
||||||
|
for(Class clazz : classes) {
|
||||||
|
if(clazz.isAssignableFrom(entity.getClass())) {
|
||||||
|
matchingEntities.add((Entity) entity);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Registers a class that if an entity inherits that class, it is picked up by the system */
|
||||||
|
public static void registerEntityClasses() {
|
||||||
|
classes.add(IRadarDetectableNT.class);
|
||||||
|
classes.add(IRadarDetectable.class);
|
||||||
|
classes.add(EntityPlayer.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Registers converters. Converters are used to go over the list of detected entities and turn them into a RadarEntry using the entity instance and the radar's instance. */
|
||||||
|
public static void registerConverters() {
|
||||||
|
//IRadarDetectableNT
|
||||||
|
converters.add(x -> {
|
||||||
|
Entity e = x.getKey();
|
||||||
|
if(e instanceof IRadarDetectableNT) {
|
||||||
|
IRadarDetectableNT detectable = (IRadarDetectableNT) e;
|
||||||
|
if(detectable.canBeSeenBy(x.getValue())) return new RadarEntry(detectable, e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
//IRadarDetectable, Legacy
|
||||||
|
converters.add(x -> {
|
||||||
|
Entity e = x.getKey();
|
||||||
|
if(e instanceof IRadarDetectable) {
|
||||||
|
return new RadarEntry((IRadarDetectable) e, e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
//Players
|
||||||
|
converters.add(x -> {
|
||||||
|
Entity e = x.getKey();
|
||||||
|
if(e instanceof EntityPlayer) {
|
||||||
|
return new RadarEntry((EntityPlayer) e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
4253
src/main/resources/assets/hbm/models/machines/exposure_chamber.obj
Normal file
4253
src/main/resources/assets/hbm/models/machines/exposure_chamber.obj
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 6.7 KiB |
Loading…
x
Reference in New Issue
Block a user