Fix interaction with trace entity not showing detail text

This commit is contained in:
D4rkr34lm
2026-05-25 18:20:42 +02:00
parent 52e95e2649
commit 9711b48f2f
3 changed files with 76 additions and 1 deletions
@@ -24,6 +24,11 @@ import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.features.tracer.TNTPoint; import de.steamwar.bausystem.features.tracer.TNTPoint;
import de.steamwar.bausystem.features.tracer.Trace; import de.steamwar.bausystem.features.tracer.Trace;
import de.steamwar.bausystem.features.tracer.TraceManager; import de.steamwar.bausystem.features.tracer.TraceManager;
<<<<<<< Updated upstream
=======
import de.steamwar.entity.RBlockDisplay;
import de.steamwar.entity.RInteractionEntity;
>>>>>>> Stashed changes
import de.steamwar.entity.REntityServer; import de.steamwar.entity.REntityServer;
import de.steamwar.entity.RFallingBlockEntity; import de.steamwar.entity.RFallingBlockEntity;
import lombok.Getter; import lombok.Getter;
@@ -55,13 +60,26 @@ public class TraceEntity extends RFallingBlockEntity {
private final String uniqueTntIdsString; private final String uniqueTntIdsString;
private final Trace trace; private final Trace trace;
private final RInteractionEntity hitbox;
public TraceEntity(REntityServer server, Location location, boolean isExplosion, List<TNTPoint> records, Trace trace) { public TraceEntity(REntityServer server, Location location, boolean isExplosion, List<TNTPoint> records, Trace trace) {
super(server, location, isExplosion ? Material.RED_STAINED_GLASS : Material.TNT); super(server, location, isExplosion ? Material.RED_STAINED_GLASS : Material.TNT);
this.records = records; this.records = records;
this.trace = trace; this.trace = trace;
uniqueTntIdsString = records.stream().map(TNTPoint::getTntId).distinct().map(Object::toString).collect(Collectors.joining(" ")); uniqueTntIdsString = records.stream().map(TNTPoint::getTntId).distinct().map(Object::toString).collect(Collectors.joining(" "));
<<<<<<< Updated upstream
setNoGravity(true); setNoGravity(true);
=======
hitbox = new RInteractionEntity(server, location, TNT_VISUAL_SCALE, TNT_VISUAL_SCALE, this);
setTransform(TNT_VISUAL_TRANSFORM);
setBlock(material.createBlockData());
>>>>>>> Stashed changes
}
@Override
public void die() {
hitbox.die();
super.die();
} }
/** /**
@@ -57,14 +57,16 @@ public class REntityServer implements Listener {
private final BiFunction<Player, ServerboundInteractPacket, Object> filter = (player, packet) -> { private final BiFunction<Player, ServerboundInteractPacket, Object> filter = (player, packet) -> {
REntity entity = entityMap.get(packet.getEntityId()); REntity entity = entityMap.get(packet.getEntityId());
if (entity == null) return packet; if (entity == null) return packet;
REntity targetEntity = entity instanceof RInteractionEntity ? ((RInteractionEntity) entity).getOwner() : entity;
if (playersThatClicked.contains(player)) return null; if (playersThatClicked.contains(player)) return null;
playersThatClicked.add(player); playersThatClicked.add(player);
EntityAction action = packet.isAttack() ? EntityAction.ATTACK : EntityAction.INTERACT; EntityAction action = packet.isAttack() ? EntityAction.ATTACK : EntityAction.INTERACT;
Bukkit.getScheduler().runTask(Core.getInstance(), () -> { Bukkit.getScheduler().runTask(Core.getInstance(), () -> {
playersThatClicked.remove(player); playersThatClicked.remove(player);
callback.onAction(player, entity, action); callback.onAction(player, targetEntity, action);
}); });
return null; return null;
}; };
@@ -0,0 +1,55 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.entity;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import java.util.function.Consumer;
public class RInteractionEntity extends REntity {
private static final EntityDataAccessor<Float> widthWatcher = new EntityDataAccessor<>(8, EntityDataSerializers.FLOAT);
private static final EntityDataAccessor<Float> heightWatcher = new EntityDataAccessor<>(9, EntityDataSerializers.FLOAT);
private float width;
private float height;
private final REntity owner;
public RInteractionEntity(REntityServer server, Location location, float width, float height, REntity owner) {
super(server, EntityType.INTERACTION, location, 0);
this.width = width;
this.height = height;
this.owner = owner;
server.addEntity(this);
}
@Override
protected void postSpawn(Consumer<Object> packetSink) {
super.postSpawn(packetSink);
packetSink.accept(getDataWatcherPacket(widthWatcher, width, heightWatcher, height));
}
public REntity getOwner() {
return owner;
}
}