Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
7ab25a6ddb
Commit
fce5b9c493
@ -50,7 +50,8 @@ public class TNTElement implements SimulatorElement {
|
||||
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
private final RFallingBlockEntity entity;
|
||||
private final REntityServer entityServer;
|
||||
private RFallingBlockEntity entity;
|
||||
TNTGroup tntGroup = null;
|
||||
|
||||
private final Vector position;
|
||||
@ -71,12 +72,14 @@ public class TNTElement implements SimulatorElement {
|
||||
private boolean disabled = false;
|
||||
|
||||
public TNTElement(Vector position, REntityServer entityServer) {
|
||||
this.entityServer = entityServer;
|
||||
this.position = position;
|
||||
this.entity = new RFallingBlockEntity(entityServer, position.toLocation(WORLD), Material.TNT);
|
||||
this.entity.setNoGravity(true);
|
||||
}
|
||||
|
||||
public TNTElement(YAPIONObject yapionObject, REntityServer entityServer) {
|
||||
this.entityServer = entityServer;
|
||||
this.position = new Vector(yapionObject.getDoubleOrDefault("x", yapionObject.getDoubleOrDefault("positionX", 0)), yapionObject.getDoubleOrDefault("y", yapionObject.getDoubleOrDefault("positionY", 0)), yapionObject.getDoubleOrDefault("z", yapionObject.getDoubleOrDefault("positionZ", 0)));
|
||||
this.disabled = yapionObject.getBooleanOrDefault("disabled", false);
|
||||
this.entity = new RFallingBlockEntity(entityServer, position.toLocation(WORLD), Material.TNT);
|
||||
@ -119,7 +122,7 @@ public class TNTElement implements SimulatorElement {
|
||||
@Override
|
||||
public void getEntity(List<SimulatorElement> elements, REntity entity) {
|
||||
if (disabled) return;
|
||||
if (this.entity.getEntityId() == entity.getEntityId() || getPosition().equals(new Vector(entity.getX(), entity.getY(), entity.getZ()))) {
|
||||
if (this.entity.getEntityId() == entity.getEntityId() || getPosition().distanceSquared(new Vector(entity.getX(), entity.getY(), entity.getZ())) < 0.01) {
|
||||
elements.add(this);
|
||||
}
|
||||
}
|
||||
@ -141,8 +144,12 @@ public class TNTElement implements SimulatorElement {
|
||||
}
|
||||
|
||||
void _updatePosition() {
|
||||
Vector position = getPosition();
|
||||
entity.move(position.getX(), position.getY(), position.getZ(), 0F, 0F, (byte) 0);
|
||||
if (disabled || (getParent() != null && getParent().isDisabled())) {
|
||||
entity.move(-200000, 0, -200000, 0F, 0F, (byte) 0);
|
||||
} else {
|
||||
Vector position = getPosition();
|
||||
entity.move(position.getX(), position.getY(), position.getZ(), 0F, 0F, (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
public int getTickOffset() {
|
||||
@ -172,7 +179,7 @@ public class TNTElement implements SimulatorElement {
|
||||
lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_DISABLED", p));
|
||||
}
|
||||
SWItem swItem = new SWItem(material, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_SPAWN_NAME", p), lore, disabled, null);
|
||||
if (!disabled) swItem.getItemStack().setAmount(tntCount());
|
||||
if (!disabled) swItem.getItemStack().setAmount(Math.max(tntCount(), 1));
|
||||
return swItem;
|
||||
}
|
||||
|
||||
@ -271,10 +278,6 @@ public class TNTElement implements SimulatorElement {
|
||||
|
||||
public void setDisabled(boolean disabled) {
|
||||
this.disabled = disabled;
|
||||
entity.setInvisible(disabled);
|
||||
}
|
||||
|
||||
void _setDisabled(boolean disabled) {
|
||||
entity.setInvisible(disabled);
|
||||
_updatePosition();
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ public class TNTGroup implements SimulatorElement {
|
||||
TNTElement tntElement = new TNTElement(element, entityServer);
|
||||
tntElement.tntGroup = this;
|
||||
this.elements.add(tntElement);
|
||||
tntElement._updatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,7 +136,7 @@ public class TNTGroup implements SimulatorElement {
|
||||
lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_DISABLED", p));
|
||||
}
|
||||
SWItem swItem = new SWItem(material, BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_GROUP_NAME", p), lore, disabled, null);
|
||||
if (!disabled) swItem.getItemStack().setAmount(tntCount());
|
||||
if (!disabled) swItem.getItemStack().setAmount(Math.max(tntCount(), 1));
|
||||
return swItem;
|
||||
}
|
||||
|
||||
@ -181,8 +182,6 @@ public class TNTGroup implements SimulatorElement {
|
||||
|
||||
public void setDisabled(boolean disabled) {
|
||||
this.disabled = disabled;
|
||||
elements.forEach(tntElement -> {
|
||||
tntElement._setDisabled(disabled);
|
||||
});
|
||||
elements.forEach(TNTElement::_updatePosition);
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren