Make worm hitboxes easier to hit

Boxes are 35% larger by default (worm.hitbox-scale, 1.0-2.0) and the tail never drops below 1.4 wide, so thin tail segments can be hit. Not compiled or tested in-game.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012wQrHUdrwThVfoqXVv4TT2
This commit is contained in:
Claude 2026-11-28 16:14:10 +01:00 • committed by DuneRealms Development
commit 3a5e101fe2
2 changed files with 7 additions and 3 deletions

View file

@ -12,15 +12,15 @@ import org.bukkit.plugin.Plugin;
/** Real native damage boxes along the visible body, forwarding to one health pool. */
final class WormHitboxes implements Listener,AutoCloseable {
static final NamespacedKey TARGET=new NamespacedKey("dunerealms","worm_hitbox_target");
private final Plugin owner;private final LivingEntity target;private final SandwormModel model;private final double size;private final List<Slime> boxes=new ArrayList<>();
WormHitboxes(Plugin owner,LivingEntity target,SandwormModel model,double size){this.owner=owner;this.target=target;this.model=model;this.size=size;Bukkit.getPluginManager().registerEvents(this,owner);}
private final Plugin owner;private final LivingEntity target;private final SandwormModel model;private final double size;private final List<Slime> boxes=new ArrayList<>();private final double scale;
WormHitboxes(Plugin owner,LivingEntity target,SandwormModel model,double size){this.owner=owner;this.target=target;this.model=model;this.size=size;this.scale=Math.max(1.0,Math.min(2.0,owner.getConfig().getDouble("worm.hitbox-scale",1.35)));Bukkit.getPluginManager().registerEvents(this,owner);}
static Entity target(Entity candidate){String id=candidate.getPersistentDataContainer().get(TARGET,PersistentDataType.STRING);if(id==null)return candidate;try{return Bukkit.getEntity(UUID.fromString(id));}catch(IllegalArgumentException invalid){return null;}}
void tick(){
var positions=model.surfacePositions();
for(int i=0;i<positions.size();i++){
var at=positions.get(i).clone().subtract(0,size*.5,0);int index=i;
if(i>=boxes.size()){
Slime box=at.getWorld().spawn(at,Slime.class,e->{e.setSize(Math.max(1,(int)Math.ceil((index==0?3.0:Math.max(.9,3.0-2.1*(index-1)/13.0))*size/.52)));e.setAI(false);e.setGravity(false);e.setSilent(true);e.setInvisible(true);e.setCollidable(false);e.setPersistent(false);e.setRemoveWhenFarAway(false);e.getAttribute(Attribute.MAX_HEALTH).setBaseValue(1024);e.setHealth(1024);e.getPersistentDataContainer().set(TARGET,PersistentDataType.STRING,target.getUniqueId().toString());e.setMetadata("NPC",new FixedMetadataValue(owner,true));});
Slime box=at.getWorld().spawn(at,Slime.class,e->{e.setSize(Math.max(1,(int)Math.ceil((index==0?3.0:Math.max(1.4,3.0-2.1*(index-1)/13.0))*size*scale/.52)));e.setAI(false);e.setGravity(false);e.setSilent(true);e.setInvisible(true);e.setCollidable(false);e.setPersistent(false);e.setRemoveWhenFarAway(false);e.getAttribute(Attribute.MAX_HEALTH).setBaseValue(1024);e.setHealth(1024);e.getPersistentDataContainer().set(TARGET,PersistentDataType.STRING,target.getUniqueId().toString());e.setMetadata("NPC",new FixedMetadataValue(owner,true));});
if(box==null)return;boxes.add(box);
}else if(boxes.get(i).isValid())boxes.get(i).teleport(at);
}

View file

@ -71,3 +71,7 @@ website:
exchange-channel-id: ""
news-channel-id: ""
diplomacy-channel-id: ""
# Worm damage boxes follow the visible body. 1.0 = original size, 2.0 = double. Applies to worms spawned after a restart.
worm:
hitbox-scale: 1.35