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 static final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
private final RFallingBlockEntity entity;
|
private final REntityServer entityServer;
|
||||||
|
private RFallingBlockEntity entity;
|
||||||
TNTGroup tntGroup = null;
|
TNTGroup tntGroup = null;
|
||||||
|
|
||||||
private final Vector position;
|
private final Vector position;
|
||||||
@ -71,12 +72,14 @@ public class TNTElement implements SimulatorElement {
|
|||||||
private boolean disabled = false;
|
private boolean disabled = false;
|
||||||
|
|
||||||
public TNTElement(Vector position, REntityServer entityServer) {
|
public TNTElement(Vector position, REntityServer entityServer) {
|
||||||
|
this.entityServer = entityServer;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.entity = new RFallingBlockEntity(entityServer, position.toLocation(WORLD), Material.TNT);
|
this.entity = new RFallingBlockEntity(entityServer, position.toLocation(WORLD), Material.TNT);
|
||||||
this.entity.setNoGravity(true);
|
this.entity.setNoGravity(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TNTElement(YAPIONObject yapionObject, REntityServer entityServer) {
|
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.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.disabled = yapionObject.getBooleanOrDefault("disabled", false);
|
||||||
this.entity = new RFallingBlockEntity(entityServer, position.toLocation(WORLD), Material.TNT);
|
this.entity = new RFallingBlockEntity(entityServer, position.toLocation(WORLD), Material.TNT);
|
||||||
@ -119,7 +122,7 @@ public class TNTElement implements SimulatorElement {
|
|||||||
@Override
|
@Override
|
||||||
public void getEntity(List<SimulatorElement> elements, REntity entity) {
|
public void getEntity(List<SimulatorElement> elements, REntity entity) {
|
||||||
if (disabled) return;
|
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);
|
elements.add(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,8 +144,12 @@ public class TNTElement implements SimulatorElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _updatePosition() {
|
void _updatePosition() {
|
||||||
Vector position = getPosition();
|
if (disabled || (getParent() != null && getParent().isDisabled())) {
|
||||||
entity.move(position.getX(), position.getY(), position.getZ(), 0F, 0F, (byte) 0);
|
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() {
|
public int getTickOffset() {
|
||||||
@ -172,7 +179,7 @@ public class TNTElement implements SimulatorElement {
|
|||||||
lore.add(BauSystem.MESSAGE.parse("SIMULATOR_GUI_TNT_DISABLED", p));
|
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);
|
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;
|
return swItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,10 +278,6 @@ public class TNTElement implements SimulatorElement {
|
|||||||
|
|
||||||
public void setDisabled(boolean disabled) {
|
public void setDisabled(boolean disabled) {
|
||||||
this.disabled = disabled;
|
this.disabled = disabled;
|
||||||
entity.setInvisible(disabled);
|
_updatePosition();
|
||||||
}
|
|
||||||
|
|
||||||
void _setDisabled(boolean disabled) {
|
|
||||||
entity.setInvisible(disabled);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ public class TNTGroup implements SimulatorElement {
|
|||||||
TNTElement tntElement = new TNTElement(element, entityServer);
|
TNTElement tntElement = new TNTElement(element, entityServer);
|
||||||
tntElement.tntGroup = this;
|
tntElement.tntGroup = this;
|
||||||
this.elements.add(tntElement);
|
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));
|
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);
|
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;
|
return swItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,8 +182,6 @@ public class TNTGroup implements SimulatorElement {
|
|||||||
|
|
||||||
public void setDisabled(boolean disabled) {
|
public void setDisabled(boolean disabled) {
|
||||||
this.disabled = disabled;
|
this.disabled = disabled;
|
||||||
elements.forEach(tntElement -> {
|
elements.forEach(TNTElement::_updatePosition);
|
||||||
tntElement._setDisabled(disabled);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren