forked from SteamWar/SteamWar
Merge pull request 'fix(BauSystem): interaction with trace entity not showing details text' (#398) from BauSystem/fix-interaction-with-trace-entity into main
Reviewed-on: SteamWar/SteamWar#398 Reviewed-by: YoyoNow <4+yoyonow@noreply.localhost>
This commit is contained in:
@@ -144,14 +144,6 @@ public class Trace {
|
|||||||
} else {
|
} else {
|
||||||
entityServer = new REntityServer();
|
entityServer = new REntityServer();
|
||||||
entityServer.addPlayer(player);
|
entityServer.addPlayer(player);
|
||||||
entityServer.setCallback((p, rEntity, entityAction) -> {
|
|
||||||
if (entityAction != REntityAction.INTERACT) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (rEntity instanceof TraceEntity) {
|
|
||||||
((TraceEntity) rEntity).printIntoChat(p);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
entityServerMap.put(player, entityServer);
|
entityServerMap.put(player, entityServer);
|
||||||
}
|
}
|
||||||
render(getRecords(), entityServer, playerTraceShowData);
|
render(getRecords(), entityServer, playerTraceShowData);
|
||||||
@@ -168,14 +160,6 @@ public class Trace {
|
|||||||
REntityServer entityServer = entityServerMap.computeIfAbsent(player, k -> {
|
REntityServer entityServer = entityServerMap.computeIfAbsent(player, k -> {
|
||||||
REntityServer newEntityServer = new REntityServer();
|
REntityServer newEntityServer = new REntityServer();
|
||||||
newEntityServer.addPlayer(k);
|
newEntityServer.addPlayer(k);
|
||||||
newEntityServer.setCallback((p, rEntity, entityAction) -> {
|
|
||||||
if (entityAction != REntityAction.INTERACT) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (rEntity instanceof TraceEntity) {
|
|
||||||
((TraceEntity) rEntity).printIntoChat(p);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return newEntityServer;
|
return newEntityServer;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+18
@@ -25,7 +25,9 @@ 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;
|
||||||
import de.steamwar.entity.RBlockDisplay;
|
import de.steamwar.entity.RBlockDisplay;
|
||||||
|
import de.steamwar.entity.REntityAction;
|
||||||
import de.steamwar.entity.REntityServer;
|
import de.steamwar.entity.REntityServer;
|
||||||
|
import de.steamwar.entity.RInteraction;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -67,6 +69,7 @@ public class TraceEntity extends RBlockDisplay {
|
|||||||
private final String uniqueTntIdsString;
|
private final String uniqueTntIdsString;
|
||||||
|
|
||||||
private final Trace trace;
|
private final Trace trace;
|
||||||
|
private final RInteraction 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);
|
super(server, location);
|
||||||
@@ -74,8 +77,23 @@ public class TraceEntity extends RBlockDisplay {
|
|||||||
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(" "));
|
||||||
|
hitbox = new RInteraction(server, location);
|
||||||
|
hitbox.setInteractionHeight(TNT_VISUAL_SCALE);
|
||||||
|
hitbox.setInteractionWidth(TNT_VISUAL_SCALE);
|
||||||
|
hitbox.setCallback((player, action) -> {
|
||||||
|
if (action == REntityAction.INTERACT) {
|
||||||
|
printIntoChat(player);
|
||||||
|
}
|
||||||
|
});
|
||||||
setTransform(TNT_VISUAL_TRANSFORM);
|
setTransform(TNT_VISUAL_TRANSFORM);
|
||||||
setBlock(material.createBlockData());
|
setBlock(material.createBlockData());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void die() {
|
||||||
|
hitbox.die();
|
||||||
|
super.die();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user