Make converted worms immediately targetable before their first entity tick
This commit is contained in:
parent
a4366107c7
commit
ebd17867be
2 changed files with 2 additions and 2 deletions
|
|
@ -20,7 +20,7 @@ final class WormTransport implements Listener,AutoCloseable {
|
|||
private final Plugin plugin;private final NamespacedKey wild,modelKey;private final Map<UUID,Rig> rigs=new HashMap<>();private final Map<UUID,Integer> actions=new HashMap<>();
|
||||
private final class Rig {
|
||||
final HappyGhast body;final SandwormModel model;final WormHitboxes hitboxes;final List<ArmorStand> seats=new ArrayList<>();
|
||||
Rig(HappyGhast body){this.body=body;model=new SandwormModel(body.getLocation(),body.getLocation().clone().add(body.getLocation().getDirection()),modelKey,.5);model.tick(body.getLocation());hitboxes=new WormHitboxes(plugin,body,model,.5);body.setInvisible(true);}
|
||||
Rig(HappyGhast body){this.body=body;model=new SandwormModel(body.getLocation(),body.getLocation().clone().add(body.getLocation().getDirection()),modelKey,.5);model.tick(body.getLocation());hitboxes=new WormHitboxes(plugin,body,model,.5);hitboxes.tick();body.setInvisible(true);}
|
||||
int riders(){return body.getPassengers().size()+seats.stream().mapToInt(s->s.getPassengers().size()).sum();}
|
||||
void close(){for(var seat:seats){seat.eject();seat.remove();}hitboxes.close();model.removeNow();body.eject();if(body.isValid()){body.setAI(false);body.setInvisible(false);}}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public final class WormTransportProbe extends JavaPlugin implements Listener {
|
|||
World world=Bukkit.getWorlds().getFirst();Location at=world.getSpawnLocation().clone().add(2,2,0);NamespacedKey wild=new NamespacedKey("dunerealms","sandworm");
|
||||
transport=new WormTransport(this,wild,new NamespacedKey(this,"sandworm_model"));UUID owner=UUID.randomUUID();Sniffer body=world.spawn(at,Sniffer.class,e->e.getPersistentDataContainer().set(wild,PersistentDataType.BYTE,(byte)1));
|
||||
HappyGhast pet=transport.convert(body,owner);check(pet!=null&&body.isDead()&&deaths==1,"Conversion must use one native death event");check(owner.toString().equals(pet.getPersistentDataContainer().get(WormTransport.OWNER,PersistentDataType.STRING)),"Owner not retained");check(pet.getEquipment().getItem(EquipmentSlot.BODY).getType()==Material.BROWN_HARNESS,"Native harness absent");check(pet.getAttribute(Attribute.SCALE).getBaseValue()==.5&&pet.getAttribute(Attribute.MAX_HEALTH).getBaseValue()==250,"Wrong half-size native carrier");transport.tick();
|
||||
var boxes=world.getEntitiesByClass(Slime.class).stream().filter(e->e.getPersistentDataContainer().has(WormHitboxes.TARGET,PersistentDataType.STRING)).toList();check(boxes.size()==15,"Missing full body damage boxes");check(boxes.stream().allMatch(e->WormHitboxes.target(e)==pet),"Damage target mismatch");
|
||||
var boxes=world.getEntitiesByClass(Slime.class).stream().filter(e->pet.getUniqueId().toString().equals(e.getPersistentDataContainer().get(WormHitboxes.TARGET,PersistentDataType.STRING))).toList();check(boxes.size()==15,"Missing full body damage boxes: "+boxes.size());check(boxes.stream().allMatch(e->WormHitboxes.target(e)==pet),"Damage target mismatch");
|
||||
double health=pet.getHealth();boxes.getFirst().damage(3,world.spawn(at,Cow.class));check(pet.getHealth()<health,"Body hit did not reach native health pool");
|
||||
var config=Files.readString(Path.of("plugins/ExecutableCrafting/recipes/contaminated_spice_block.yml"));var json=com.google.gson.JsonParser.parseString(config).getAsJsonObject();for(var e:json.entrySet())if(e.getKey().startsWith("input")||e.getKey().equals("result"))check(!Bukkit.getItemFactory().createItemStack(e.getValue().getAsString()).isEmpty(),"Invalid native recipe command");
|
||||
transport.close();check(world.getEntitiesByClass(Slime.class).stream().noneMatch(e->e.getPersistentDataContainer().has(WormHitboxes.TARGET,PersistentDataType.STRING)),"Damage proxy leaked on disable");
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff