REntity #148
@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 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.bausystem.entities;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
|
|
||||||
import net.minecraft.server.v1_15_R1.*;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public class DetonatorEntity15 extends EntityFallingBlock implements AbstractDetonatorEntity {
|
|
||||||
|
|
||||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
|
||||||
private final Vector position;
|
|
||||||
private int references = 0;
|
|
||||||
|
|
||||||
public DetonatorEntity15(World world, Vector position) {
|
|
||||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.RED_STAINED_GLASS.getBlockData());
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
this.h(true);
|
|
||||||
this.setNoGravity(true);
|
|
||||||
this.ticksLived = -12000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void display(Player player) {
|
|
||||||
if (references++ > 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, Block.getCombinedId(Blocks.RED_STAINED_GLASS.getBlockData()), ZERO);
|
|
||||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
|
||||||
playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
|
||||||
|
|
||||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
|
||||||
playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hide(Player player, boolean force) {
|
|
||||||
if (!force && --references > 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
sendDestroy(player);
|
|
||||||
die();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendDestroy(Player player) {
|
|
||||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendEntity(Player player) {
|
|
||||||
display(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendEntityDestroy(Player player) {
|
|
||||||
hide(player, false);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 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.bausystem.entities;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
|
|
||||||
import de.steamwar.bausystem.shared.BaseEntity15;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public class SimulatorEntity15 extends BaseEntity15 implements AbstractSimulatorEntity {
|
|
||||||
|
|
||||||
private boolean printed = false;
|
|
||||||
|
|
||||||
public SimulatorEntity15(World world, Vector position, boolean highlight) {
|
|
||||||
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
|
|
||||||
|
|
||||||
this.setNoGravity(true);
|
|
||||||
this.ticksLived = -12000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void display(Player player) {
|
|
||||||
if (printed) return;
|
|
||||||
printed = true;
|
|
||||||
|
|
||||||
sendEntity(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPosition(Vector position) {
|
|
||||||
this.position = position;
|
|
||||||
setPosition(position.getX(), position.getY(), position.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hide(Player player, boolean force) {
|
|
||||||
if (!printed) return false;
|
|
||||||
printed = false;
|
|
||||||
|
|
||||||
|
|
||||||
sendEntityDestroy(player);
|
|
||||||
die();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.bausystem.features.simulator;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
|
||||||
|
|
||||||
public class SimulatorPreview15 implements SimulatorPreview {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Record simulate(TNTSimulator tntSimulator) {
|
|
||||||
return new Record(null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 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.bausystem.shared;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_15_R1.*;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public class BaseEntity15 extends EntityFallingBlock implements AbstractEntity {
|
|
||||||
|
|
||||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
|
||||||
|
|
||||||
private final IBlockData iBlockData;
|
|
||||||
protected Vector position;
|
|
||||||
|
|
||||||
public BaseEntity15(World world, Vector position, Material blockType) {
|
|
||||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), ((CraftBlockData) blockType.createBlockData()).getState());
|
|
||||||
this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState();
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
this.setNoGravity(true);
|
|
||||||
this.ticksLived = -12000;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendEntity(Player player) {
|
|
||||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, Block.getCombinedId(iBlockData), ZERO);
|
|
||||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
|
||||||
playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
|
||||||
|
|
||||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
|
||||||
playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendEntityDestroy(Player player) {
|
|
||||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 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.bausystem.entities;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
|
||||||
import net.minecraft.server.network.PlayerConnection;
|
|
||||||
import net.minecraft.world.entity.EntityTypes;
|
|
||||||
import net.minecraft.world.entity.item.EntityFallingBlock;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.Blocks;
|
|
||||||
import net.minecraft.world.phys.Vec3D;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public class DetonatorEntity18 extends EntityFallingBlock implements AbstractDetonatorEntity {
|
|
||||||
|
|
||||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
|
||||||
private final Vector position;
|
|
||||||
private int references = 0;
|
|
||||||
|
|
||||||
public DetonatorEntity18(World world, Vector position) {
|
|
||||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.du.n());
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
this.h(true);
|
|
||||||
this.e(true);
|
|
||||||
this.S = -12000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getId() {
|
|
||||||
return ae();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void display(Player player) {
|
|
||||||
if (references++ > 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.C, Block.i(Blocks.du.n()), ZERO);
|
|
||||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
|
||||||
playerConnection.a(packetPlayOutSpawnEntity);
|
|
||||||
|
|
||||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), Y, true);
|
|
||||||
playerConnection.a(packetPlayOutEntityMetadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hide(Player player, boolean force) {
|
|
||||||
if (!force && --references > 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
sendDestroy(player);
|
|
||||||
ag();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendDestroy(Player player) {
|
|
||||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
|
||||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendEntity(Player player) {
|
|
||||||
display(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendEntityDestroy(Player player) {
|
|
||||||
hide(player, false);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 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.bausystem.entities;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
|
|
||||||
import de.steamwar.bausystem.shared.BaseEntity18;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public class SimulatorEntity18 extends BaseEntity18 implements AbstractSimulatorEntity {
|
|
||||||
|
|
||||||
private boolean printed = false;
|
|
||||||
|
|
||||||
public SimulatorEntity18(World world, Vector position, boolean highlight) {
|
|
||||||
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
|
|
||||||
|
|
||||||
this.e(true);
|
|
||||||
this.S = -12000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getId() {
|
|
||||||
return ae();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void display(Player player) {
|
|
||||||
if (printed) return;
|
|
||||||
printed = true;
|
|
||||||
|
|
||||||
sendEntity(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPosition(Vector position) {
|
|
||||||
this.position = position;
|
|
||||||
e(position.getX(), position.getY(), position.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hide(Player player, boolean force) {
|
|
||||||
if (!printed) return false;
|
|
||||||
printed = false;
|
|
||||||
|
|
||||||
sendEntityDestroy(player);
|
|
||||||
ag();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 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.bausystem.shared;
|
|
||||||
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
|
||||||
import net.minecraft.server.network.PlayerConnection;
|
|
||||||
import net.minecraft.world.entity.EntityTypes;
|
|
||||||
import net.minecraft.world.entity.item.EntityFallingBlock;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.state.IBlockData;
|
|
||||||
import net.minecraft.world.phys.Vec3D;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData;
|
|
||||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public class BaseEntity18 extends EntityFallingBlock implements AbstractEntity {
|
|
||||||
|
|
||||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
|
||||||
|
|
||||||
private final IBlockData iBlockData;
|
|
||||||
protected Vector position;
|
|
||||||
|
|
||||||
public BaseEntity18(World world, Vector position, Material blockType) {
|
|
||||||
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), ((CraftBlockData) blockType.createBlockData()).getState());
|
|
||||||
this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState();
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
this.e(true);
|
|
||||||
this.S = -12000;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendEntity(Player player) {
|
|
||||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.C, Block.i(iBlockData), ZERO);
|
|
||||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
|
||||||
playerConnection.a(packetPlayOutSpawnEntity);
|
|
||||||
|
|
||||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true);
|
|
||||||
playerConnection.a(packetPlayOutEntityMetadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendEntityDestroy(Player player) {
|
|
||||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae());
|
|
||||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,124 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 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.bausystem.entities;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity;
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
|
||||||
import net.minecraft.server.network.PlayerConnection;
|
|
||||||
import net.minecraft.world.entity.EntityTypes;
|
|
||||||
import net.minecraft.world.entity.item.EntityFallingBlock;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.state.IBlockData;
|
|
||||||
import net.minecraft.world.phys.Vec3D;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class DetonatorEntity19 extends EntityFallingBlock implements AbstractDetonatorEntity {
|
|
||||||
|
|
||||||
private static final Field ao;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
ao = EntityFallingBlock.class.getDeclaredField("ao");
|
|
||||||
ao.setAccessible(true);
|
|
||||||
} catch (NoSuchFieldException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
|
||||||
private final Vector position;
|
|
||||||
private int references = 0;
|
|
||||||
private IBlockData iBlockData;
|
|
||||||
|
|
||||||
public DetonatorEntity19(World world, Vector position) {
|
|
||||||
super(EntityTypes.E, ((CraftWorld) world).getHandle());
|
|
||||||
try {
|
|
||||||
ao.set(this, ((CraftBlockData) Material.RED_STAINED_GLASS.createBlockData()).getState());
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
this.q = true;
|
|
||||||
e(position.getX(), position.getY(), position.getZ());
|
|
||||||
f(Vec3D.b);
|
|
||||||
t = position.getX();
|
|
||||||
u = position.getY();
|
|
||||||
v = position.getZ();
|
|
||||||
a(this.db());
|
|
||||||
|
|
||||||
this.iBlockData = ((CraftBlockData) Material.RED_STAINED_GLASS.createBlockData()).getState();
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
this.e(true);
|
|
||||||
this.S = -12000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getId() {
|
|
||||||
return ae();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void display(Player player) {
|
|
||||||
if (references++ > 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), co(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.E, Block.i(iBlockData), ZERO, 0.0);
|
|
||||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
|
||||||
playerConnection.a(packetPlayOutSpawnEntity);
|
|
||||||
|
|
||||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), Y, true);
|
|
||||||
playerConnection.a(packetPlayOutEntityMetadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hide(Player player, boolean force) {
|
|
||||||
if (!force && --references > 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
sendDestroy(player);
|
|
||||||
ag();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendDestroy(Player player) {
|
|
||||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
|
||||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendEntity(Player player) {
|
|
||||||
display(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendEntityDestroy(Player player) {
|
|
||||||
hide(player, false);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 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.bausystem.entities;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
|
|
||||||
import de.steamwar.bausystem.shared.BaseEntity19;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public class SimulatorEntity19 extends BaseEntity19 implements AbstractSimulatorEntity {
|
|
||||||
|
|
||||||
private boolean printed = false;
|
|
||||||
|
|
||||||
public SimulatorEntity19(World world, Vector position, boolean highlight) {
|
|
||||||
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
|
|
||||||
|
|
||||||
this.e(true);
|
|
||||||
this.S = -12000;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getId() {
|
|
||||||
return ae();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void display(Player player) {
|
|
||||||
if (printed) return;
|
|
||||||
printed = true;
|
|
||||||
|
|
||||||
sendEntity(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPosition(Vector position) {
|
|
||||||
this.position = position;
|
|
||||||
e(position.getX(), position.getY(), position.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hide(Player player, boolean force) {
|
|
||||||
if (!printed) return false;
|
|
||||||
printed = false;
|
|
||||||
|
|
||||||
sendEntityDestroy(player);
|
|
||||||
ag();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,165 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.bausystem.features.simulator;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
|
||||||
import net.minecraft.core.BlockPosition;
|
|
||||||
import net.minecraft.util.RandomSource;
|
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.player.EntityHuman;
|
|
||||||
import net.minecraft.world.level.Explosion;
|
|
||||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
|
||||||
import net.minecraft.world.level.World;
|
|
||||||
import net.minecraft.world.level.gameevent.GameEvent;
|
|
||||||
import net.minecraft.world.phys.Vec3D;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class FakeExplosion19 extends Explosion {
|
|
||||||
|
|
||||||
private List<FakeTNT19> fakeTNT19s;
|
|
||||||
private boolean c;
|
|
||||||
private Explosion.Effect d;
|
|
||||||
private RandomSource e;
|
|
||||||
private World f;
|
|
||||||
private double g;
|
|
||||||
private double h;
|
|
||||||
private double i;
|
|
||||||
@Nullable
|
|
||||||
public Entity j;
|
|
||||||
private float k;
|
|
||||||
private DamageSource l;
|
|
||||||
private ExplosionDamageCalculator m;
|
|
||||||
private ObjectArrayList<BlockPosition> n;
|
|
||||||
private Map<EntityHuman, Vec3D> o;
|
|
||||||
public boolean wasCanceled;
|
|
||||||
|
|
||||||
public FakeExplosion19(List<FakeTNT19> fakeTNT19s, World world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.Effect destructionType) {
|
|
||||||
super(world, entity, damageSource, behavior, x, y, z, power, createFire, destructionType);
|
|
||||||
this.fakeTNT19s = fakeTNT19s;
|
|
||||||
this.wasCanceled = false;
|
|
||||||
this.e = RandomSource.a();
|
|
||||||
this.n = new ObjectArrayList();
|
|
||||||
this.o = Maps.newHashMap();
|
|
||||||
this.f = world;
|
|
||||||
this.j = entity;
|
|
||||||
this.k = (float) Math.max((double) power, 0.0D);
|
|
||||||
this.g = x;
|
|
||||||
this.h = y;
|
|
||||||
this.i = z;
|
|
||||||
this.c = createFire;
|
|
||||||
this.d = destructionType;
|
|
||||||
this.l = damageSource == null ? DamageSource.a(this) : damageSource;
|
|
||||||
this.m = new ExplosionDamageCalculator();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getBlockDensity(Vec3D vec3d, Entity entity) {
|
|
||||||
return a(vec3d, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void a() {
|
|
||||||
if ((this.k) >= 0.1F) {
|
|
||||||
this.f.a(this.j, GameEvent.w, new Vec3D(this.g, this.h, this.i));
|
|
||||||
/*
|
|
||||||
Set<BlockPosition> set = Sets.newHashSet();
|
|
||||||
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
for (int k = 0; k < 16; ++k) {
|
|
||||||
for (i = 0; i < 16; ++i) {
|
|
||||||
for (j = 0; j < 16; ++j) {
|
|
||||||
if (k == 0 || k == 15 || i == 0 || i == 15 || j == 0 || j == 15) {
|
|
||||||
double d0 = (double) ((float) k / 15.0F * 2.0F - 1.0F);
|
|
||||||
double d1 = (double) ((float) i / 15.0F * 2.0F - 1.0F);
|
|
||||||
double d2 = (double) ((float) j / 15.0F * 2.0F - 1.0F);
|
|
||||||
double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
|
|
||||||
d0 /= d3;
|
|
||||||
d1 /= d3;
|
|
||||||
d2 /= d3;
|
|
||||||
float f = this.k * (0.7F + this.f.w.i() * 0.6F);
|
|
||||||
double d4 = this.g;
|
|
||||||
double d5 = this.h;
|
|
||||||
double d6 = this.i;
|
|
||||||
|
|
||||||
for (float var21 = 0.3F; f > 0.0F; f -= 0.22500001F) {
|
|
||||||
BlockPosition blockposition = new BlockPosition(d4, d5, d6);
|
|
||||||
IBlockData iblockdata = this.f.a_(blockposition);
|
|
||||||
Fluid fluid = iblockdata.p();
|
|
||||||
if (!this.f.j(blockposition)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Optional<Float> optional = this.m.a(this, this.f, blockposition, iblockdata, fluid);
|
|
||||||
if (optional.isPresent()) {
|
|
||||||
f -= ((Float) optional.get() + 0.3F) * 0.3F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (f > 0.0F && this.m.a(this, this.f, blockposition, iblockdata, f)) {
|
|
||||||
set.add(blockposition);
|
|
||||||
}
|
|
||||||
|
|
||||||
d4 += d0 * 0.30000001192092896D;
|
|
||||||
d5 += d1 * 0.30000001192092896D;
|
|
||||||
d6 += d2 * 0.30000001192092896D;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.n.addAll(set);
|
|
||||||
*/
|
|
||||||
|
|
||||||
float f2 = this.k * 2.0F;
|
|
||||||
Vec3D vec3d = new Vec3D(this.g, this.h, this.i);
|
|
||||||
for (int l1 = 0; l1 < fakeTNT19s.size(); ++l1) {
|
|
||||||
Entity entity = (Entity) fakeTNT19s.get(l1);
|
|
||||||
if (!entity.cF()) {
|
|
||||||
double d7 = Math.sqrt(entity.e(vec3d)) / (double) f2;
|
|
||||||
if (d7 <= 1.0D) {
|
|
||||||
double d8 = entity.df() - this.g;
|
|
||||||
double d9 = entity.dh() - this.h;
|
|
||||||
double d10 = entity.dl() - this.i;
|
|
||||||
double d11 = Math.sqrt(d8 * d8 + d9 * d9 + d10 * d10);
|
|
||||||
if (d11 != 0.0D) {
|
|
||||||
d8 /= d11;
|
|
||||||
d9 /= d11;
|
|
||||||
d10 /= d11;
|
|
||||||
double d12 = (double) this.getBlockDensity(vec3d, entity);
|
|
||||||
|
|
||||||
double d13 = (1.0D - d7) * d12;
|
|
||||||
entity.lastDamageCancelled = false;
|
|
||||||
CraftEventFactory.entityDamage = null;
|
|
||||||
entity.f(entity.dd().b(d8 * d13, d9 * d13, d10 * d13));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,257 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.bausystem.features.simulator;
|
|
||||||
|
|
||||||
import net.minecraft.core.BlockPosition;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
|
||||||
import net.minecraft.network.syncher.DataWatcher;
|
|
||||||
import net.minecraft.network.syncher.DataWatcherObject;
|
|
||||||
import net.minecraft.network.syncher.DataWatcherRegistry;
|
|
||||||
import net.minecraft.util.MathHelper;
|
|
||||||
import net.minecraft.world.damagesource.DamageSource;
|
|
||||||
import net.minecraft.world.entity.*;
|
|
||||||
import net.minecraft.world.entity.item.EntityTNTPrimed;
|
|
||||||
import net.minecraft.world.level.Explosion;
|
|
||||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
|
||||||
import net.minecraft.world.level.World;
|
|
||||||
import net.minecraft.world.level.block.state.IBlockData;
|
|
||||||
import net.minecraft.world.phys.AxisAlignedBB;
|
|
||||||
import net.minecraft.world.phys.Vec3D;
|
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
||||||
import org.bukkit.entity.Explosive;
|
|
||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class FakeTNT19 extends EntityTNTPrimed {
|
|
||||||
private static final DataWatcherObject<Integer> b;
|
|
||||||
private static final int c = 80;
|
|
||||||
private List<FakeTNT19> fakeTNT19s;
|
|
||||||
private List<FakeTNT19> spawnList = new ArrayList<>();
|
|
||||||
private int count;
|
|
||||||
@Nullable
|
|
||||||
public EntityLiving d;
|
|
||||||
public float yield;
|
|
||||||
public boolean isIncendiary;
|
|
||||||
|
|
||||||
public FakeTNT19(List<FakeTNT19> fakeTNT19s, EntityTypes<? extends EntityTNTPrimed> type, World world) {
|
|
||||||
super(type, world);
|
|
||||||
this.fakeTNT19s = fakeTNT19s;
|
|
||||||
this.yield = 4.0F;
|
|
||||||
this.isIncendiary = false;
|
|
||||||
super.q = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FakeTNT19(List<FakeTNT19> fakeTNT19s, World world, double x, double y, double z, int fuse, int count) {
|
|
||||||
this(fakeTNT19s, EntityTypes.av, world);
|
|
||||||
this.e(x, y, z);
|
|
||||||
double d3 = world.w.j() * 6.2831854820251465D;
|
|
||||||
this.n(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D);
|
|
||||||
this.a(fuse);
|
|
||||||
super.t = x;
|
|
||||||
super.u = y;
|
|
||||||
super.v = z;
|
|
||||||
this.d = null;
|
|
||||||
this.count = count;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void a_() {
|
|
||||||
super.Y.a(b, 80);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected MovementEmission aO() {
|
|
||||||
return MovementEmission.a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean bl() {
|
|
||||||
return !this.dt();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Vec3D g(Vec3D vec3d) {
|
|
||||||
AxisAlignedBB axisalignedbb = this.cz();
|
|
||||||
List<VoxelShape> list = this.s.b(this, axisalignedbb.b(vec3d));
|
|
||||||
Vec3D vec3d1 = vec3d.g() == 0.0 ? vec3d : a(this, vec3d, axisalignedbb, this.s, list);
|
|
||||||
boolean flag = vec3d.c != vec3d1.c;
|
|
||||||
boolean flag1 = vec3d.d != vec3d1.d;
|
|
||||||
boolean flag2 = vec3d.e != vec3d1.e;
|
|
||||||
boolean flag3 = this.y || flag1 && vec3d.d < 0.0;
|
|
||||||
if (this.P > 0.0F && flag3 && (flag || flag2)) {
|
|
||||||
Vec3D vec3d2 = a(this, new Vec3D(vec3d.c, (double)this.P, vec3d.e), axisalignedbb, this.s, list);
|
|
||||||
Vec3D vec3d3 = a(this, new Vec3D(0.0, (double)this.P, 0.0), axisalignedbb.b(vec3d.c, 0.0, vec3d.e), this.s, list);
|
|
||||||
if (vec3d3.d < (double)this.P) {
|
|
||||||
Vec3D vec3d4 = a(this, new Vec3D(vec3d.c, 0.0, vec3d.e), axisalignedbb.c(vec3d3), this.s, list).e(vec3d3);
|
|
||||||
if (vec3d4.i() > vec3d2.i()) {
|
|
||||||
vec3d2 = vec3d4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vec3d2.i() > vec3d1.i()) {
|
|
||||||
return vec3d2.e(a(this, new Vec3D(0.0, -vec3d2.d + vec3d.d, 0.0), axisalignedbb.c(vec3d2), this.s, list));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vec3d1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void a(EnumMoveType enummovetype, Vec3D vec3d) {
|
|
||||||
if (this.E.g() > 1.0E-7) {
|
|
||||||
vec3d = vec3d.h(this.E);
|
|
||||||
this.E = Vec3D.b;
|
|
||||||
this.f(Vec3D.b);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vec3D vec3d1 = this.g(vec3d);
|
|
||||||
double d0 = vec3d1.g();
|
|
||||||
if (d0 > 1.0E-7) {
|
|
||||||
this.e(this.df() + vec3d1.c, this.dg() + vec3d1.d, this.dl() + vec3d1.e);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean flag = !MathHelper.b(vec3d.c, vec3d1.c);
|
|
||||||
boolean flag1 = !MathHelper.b(vec3d.e, vec3d1.e);
|
|
||||||
this.z = flag || flag1;
|
|
||||||
this.A = vec3d.d != vec3d1.d;
|
|
||||||
this.B = this.A && vec3d.d < 0.0;
|
|
||||||
if (this.z) {
|
|
||||||
this.C = this.b(vec3d1);
|
|
||||||
} else {
|
|
||||||
this.C = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.y = this.A && vec3d.d < 0.0;
|
|
||||||
BlockPosition blockposition = this.aA();
|
|
||||||
IBlockData iblockdata = this.s.a_(blockposition);
|
|
||||||
// this.a(vec3d1.d, this.y, iblockdata, blockposition);
|
|
||||||
if (!this.dt()) {
|
|
||||||
if (this.z) {
|
|
||||||
Vec3D vec3d2 = this.dd();
|
|
||||||
this.n(flag ? 0.0 : vec3d2.c, vec3d2.d, flag1 ? 0.0 : vec3d2.e);
|
|
||||||
}
|
|
||||||
|
|
||||||
net.minecraft.world.level.block.Block block = iblockdata.b();
|
|
||||||
if (vec3d.d != vec3d1.d) {
|
|
||||||
block.a(this.s, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.y) {
|
|
||||||
block.a(this.s, blockposition, iblockdata, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ax();
|
|
||||||
float f2 = this.aD();
|
|
||||||
this.f(this.dd().d((double)f2, 1.0, (double)f2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void k(List<FakeTNT19> spawnList) {
|
|
||||||
if (!this.aN()) {
|
|
||||||
this.f(this.dd().b(0.0D, -0.04D, 0.0D));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.a(EnumMoveType.a, this.dd());
|
|
||||||
this.f(this.dd().a(0.98D));
|
|
||||||
if (super.y) {
|
|
||||||
this.f(this.dd().d(0.7D, -0.5D, 0.7D));
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = this.i() - 1;
|
|
||||||
this.a(i);
|
|
||||||
if (i <= 0) {
|
|
||||||
if (!super.s.y) {
|
|
||||||
this.j1();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ah();
|
|
||||||
} else {
|
|
||||||
this.aY();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == 1 && count > 1) {
|
|
||||||
for (int c = 0; c < count - 1; c++) {
|
|
||||||
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, this.s, this.df(), this.dh(), this.dl(), i, 1);
|
|
||||||
fakeTNT19.y = this.y;
|
|
||||||
fakeTNT19.f(new Vec3D(this.dd().c, this.dd().d, this.dd().e));
|
|
||||||
spawnList.add(fakeTNT19);
|
|
||||||
}
|
|
||||||
count = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void j1() {
|
|
||||||
ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) this.getBukkitEntity());
|
|
||||||
super.s.getCraftServer().getPluginManager().callEvent(event);
|
|
||||||
if (!event.isCancelled()) {
|
|
||||||
this.a(this, this.df(), this.e(0.0625D), this.dl(), event.getRadius(), event.getFire(), Explosion.Effect.b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FakeExplosion19 a(@Nullable Entity entity, double x, double y, double z, float power, boolean createFire, Explosion.Effect destructionType) {
|
|
||||||
return this.a(entity, (DamageSource) null, (ExplosionDamageCalculator) null, x, y, z, power, createFire, destructionType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FakeExplosion19 a(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.Effect destructionType) {
|
|
||||||
FakeExplosion19 explosion = new FakeExplosion19(fakeTNT19s, SimulatorPreview19.WORLD, entity, damageSource, behavior, x, y, z, power, createFire, destructionType);
|
|
||||||
explosion.a();
|
|
||||||
// explosion.a(true);
|
|
||||||
return explosion;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void b(NBTTagCompound nbt) {
|
|
||||||
nbt.a("Fuse", (short) this.i());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void a(NBTTagCompound nbt) {
|
|
||||||
this.a(nbt.g("Fuse"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public EntityLiving h() {
|
|
||||||
return this.d;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected float a(EntityPose pose, EntitySize dimensions) {
|
|
||||||
return 0.15F;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void a(int fuse) {
|
|
||||||
super.Y.b(b, fuse);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int i() {
|
|
||||||
return (Integer) super.Y.a(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Packet<?> S() {
|
|
||||||
return new PacketPlayOutSpawnEntity(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean cr() {
|
|
||||||
return super.cr();
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
b = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.b);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,136 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.bausystem.features.simulator;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
|
||||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
|
||||||
import net.minecraft.world.level.World;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
|
||||||
import org.bukkit.entity.TNTPrimed;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class SimulatorPreview19 implements SimulatorPreview {
|
|
||||||
|
|
||||||
public static final World WORLD = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Record simulate(TNTSimulator tntSimulator) {
|
|
||||||
if (true) {
|
|
||||||
return new Record(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<Integer, Map<Integer, Set<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> result = new HashMap<>();
|
|
||||||
for (SimulatorElement element : tntSimulator.getTntElementList()) {
|
|
||||||
element.locations(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
AtomicInteger maxTick = new AtomicInteger(0);
|
|
||||||
Map<Integer, List<List<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> toSpawn = new HashMap<>();
|
|
||||||
AtomicInteger tntCount = new AtomicInteger(0);
|
|
||||||
result.forEach((integer, integerSetMap) -> {
|
|
||||||
List<Pair<Integer, Set<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> internal = new ArrayList<>();
|
|
||||||
integerSetMap.forEach((integer1, pairs) -> {
|
|
||||||
internal.add(new Pair<>(integer1, pairs));
|
|
||||||
});
|
|
||||||
internal.sort(Comparator.comparingInt(Pair::getKey));
|
|
||||||
|
|
||||||
toSpawn.put(integer, internal.stream().map(Pair::getValue).peek(pairs -> {
|
|
||||||
tntCount.addAndGet(pairs.stream().mapToInt(Pair::getValue).sum());
|
|
||||||
}).map(ArrayList::new).peek(Collections::shuffle).collect(Collectors.toList()));
|
|
||||||
|
|
||||||
if (maxTick.get() < integer) {
|
|
||||||
maxTick.set(integer);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (tntCount.get() > 500) {
|
|
||||||
return new Record(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<FakeTNT19> fakeTNT19s = new ArrayList<>();
|
|
||||||
Record record = new Record(null);
|
|
||||||
Map<FakeTNT19, Record.TNTRecord> tntRecords = new HashMap<>();
|
|
||||||
|
|
||||||
int maxTickToCalc = maxTick.get() + 160;
|
|
||||||
for (int tick = 0; tick < maxTickToCalc; tick++) {
|
|
||||||
List<List<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>> toSpawnInTick = toSpawn.get(tick);
|
|
||||||
try {
|
|
||||||
if (toSpawnInTick == null) continue;
|
|
||||||
toSpawnInTick.forEach(pairs -> {
|
|
||||||
AtomicBoolean hasSomeLeft = new AtomicBoolean(true);
|
|
||||||
while(hasSomeLeft.get()) {
|
|
||||||
hasSomeLeft.set(false);
|
|
||||||
pairs.forEach(pair -> {
|
|
||||||
SimulatorPreview.SimulatorPreviewTNTData previewTNTData = pair.getKey();
|
|
||||||
if (!previewTNTData.isXVelocity() && !previewTNTData.isZVelocity()) {
|
|
||||||
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, WORLD, previewTNTData.getX(), previewTNTData.getY(), previewTNTData.getZ(), previewTNTData.getFuseTicks(), pair.getValue());
|
|
||||||
TNTPrimed tntPrimed = (TNTPrimed) fakeTNT19.getBukkitEntity();
|
|
||||||
if (!previewTNTData.isXVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
|
|
||||||
if (!previewTNTData.isYVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0));
|
|
||||||
if (!previewTNTData.isZVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0));
|
|
||||||
fakeTNT19s.add(fakeTNT19);
|
|
||||||
pair.setValue(0);
|
|
||||||
} else if (pair.getValue() > 0) {
|
|
||||||
hasSomeLeft.set(true);
|
|
||||||
FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, WORLD, previewTNTData.getX(), previewTNTData.getY(), previewTNTData.getZ(), previewTNTData.getFuseTicks(), 1);
|
|
||||||
TNTPrimed tntPrimed = (TNTPrimed) fakeTNT19.getBukkitEntity();
|
|
||||||
if (!previewTNTData.isXVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
|
|
||||||
if (!previewTNTData.isYVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0));
|
|
||||||
if (!previewTNTData.isZVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0));
|
|
||||||
fakeTNT19s.add(fakeTNT19);
|
|
||||||
pair.setValue(pair.getValue() - 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
calculateTick(fakeTNT19s, record, tntRecords);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return record;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void calculateTick(List<FakeTNT19> fakeTNT19s, Record record, Map<FakeTNT19, Record.TNTRecord> tntRecords) {
|
|
||||||
int i = 0;
|
|
||||||
while (i < fakeTNT19s.size()) {
|
|
||||||
List<FakeTNT19> spawnList = new ArrayList<>();
|
|
||||||
FakeTNT19 fakeTNT19 = fakeTNT19s.get(i);
|
|
||||||
fakeTNT19.k(spawnList);
|
|
||||||
TNTPrimed tntPrimed = ((TNTPrimed) (fakeTNT19.getBukkitEntity()));
|
|
||||||
if (tntPrimed.getFuseTicks() <= 0) {
|
|
||||||
tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn(0)).explode(tntPrimed);
|
|
||||||
fakeTNT19s.remove(i);
|
|
||||||
i--;
|
|
||||||
} else {
|
|
||||||
tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn(0)).explode(tntPrimed);
|
|
||||||
}
|
|
||||||
if (!spawnList.isEmpty()) {
|
|
||||||
fakeTNT19s.addAll(i, spawnList);
|
|
||||||
i += spawnList.size();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 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.bausystem.shared;
|
|
||||||
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
|
||||||
import net.minecraft.server.network.PlayerConnection;
|
|
||||||
import net.minecraft.world.entity.EntityTypes;
|
|
||||||
import net.minecraft.world.entity.item.EntityFallingBlock;
|
|
||||||
import net.minecraft.world.level.block.Block;
|
|
||||||
import net.minecraft.world.level.block.state.IBlockData;
|
|
||||||
import net.minecraft.world.phys.Vec3D;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData;
|
|
||||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class BaseEntity19 extends EntityFallingBlock implements AbstractEntity {
|
|
||||||
|
|
||||||
private static final Field ao;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
ao = EntityFallingBlock.class.getDeclaredField("ao");
|
|
||||||
ao.setAccessible(true);
|
|
||||||
} catch (NoSuchFieldException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Vec3D ZERO = new Vec3D(0, 0, 0);
|
|
||||||
|
|
||||||
private final IBlockData iBlockData;
|
|
||||||
protected Vector position;
|
|
||||||
|
|
||||||
public BaseEntity19(World world, Vector position, Material blockType) {
|
|
||||||
super(EntityTypes.E, ((CraftWorld) world).getHandle());
|
|
||||||
try {
|
|
||||||
ao.set(this, ((CraftBlockData) blockType.createBlockData()).getState());
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
this.q = true;
|
|
||||||
e(position.getX(), position.getY(), position.getZ());
|
|
||||||
f(Vec3D.b);
|
|
||||||
t = position.getX();
|
|
||||||
u = position.getY();
|
|
||||||
v = position.getZ();
|
|
||||||
a(this.db());
|
|
||||||
|
|
||||||
this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState();
|
|
||||||
this.position = position;
|
|
||||||
|
|
||||||
this.e(true);
|
|
||||||
this.S = -12000;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendEntity(Player player) {
|
|
||||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), co(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.E, Block.i(iBlockData), ZERO, 0.0);
|
|
||||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b;
|
|
||||||
playerConnection.a(packetPlayOutSpawnEntity);
|
|
||||||
|
|
||||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true);
|
|
||||||
playerConnection.a(packetPlayOutEntityMetadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendEntityDestroy(Player player) {
|
|
||||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae());
|
|
||||||
((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 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.bausystem.features.detonator;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.shared.AbstractEntity;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public interface AbstractDetonatorEntity extends AbstractEntity {
|
|
||||||
|
|
||||||
void display(Player player);
|
|
||||||
|
|
||||||
boolean hide(Player player, boolean always);
|
|
||||||
|
|
||||||
int getId();
|
|
||||||
|
|
||||||
Entity getBukkitEntity();
|
|
||||||
}
|
|
@ -26,6 +26,9 @@ import de.steamwar.bausystem.features.autostart.AutostartListener;
|
|||||||
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
||||||
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
|
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
|
||||||
import de.steamwar.bausystem.utils.NMSWrapper;
|
import de.steamwar.bausystem.utils.NMSWrapper;
|
||||||
|
import de.steamwar.entity.REntity;
|
||||||
|
import de.steamwar.entity.REntityServer;
|
||||||
|
import de.steamwar.entity.RFallingBlockEntity;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -44,7 +47,7 @@ import java.util.*;
|
|||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class Detonator {
|
public class Detonator {
|
||||||
|
|
||||||
private static final Map<Player, List<AbstractDetonatorEntity>> ENTITIES_MAP = new HashMap<>();
|
private static final Map<Player, REntityServer> ENTITIES_MAP = new HashMap<>();
|
||||||
private static final Vector HALF = new Vector(0.5, 0, 0.5);
|
private static final Vector HALF = new Vector(0.5, 0, 0.5);
|
||||||
|
|
||||||
public static boolean isDetonator(ItemStack itemStack) {
|
public static boolean isDetonator(ItemStack itemStack) {
|
||||||
@ -52,18 +55,19 @@ public class Detonator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void showDetonator(Player p, List<Location> locs) {
|
public static void showDetonator(Player p, List<Location> locs) {
|
||||||
List<AbstractDetonatorEntity> entities = new LinkedList<>();
|
if (ENTITIES_MAP.containsKey(p)) return;
|
||||||
locs.stream().map(Location::toVector).forEach(vector -> entities.add(NMSWrapper.impl.constructDetonator(p.getWorld(), vector.add(HALF))));
|
REntityServer entities = new REntityServer();
|
||||||
entities.forEach(abstractDetonatorEntity -> abstractDetonatorEntity.display(p));
|
entities.addPlayer(p);
|
||||||
ENTITIES_MAP.putIfAbsent(p, entities);
|
ENTITIES_MAP.put(p, entities);
|
||||||
|
|
||||||
|
locs.forEach(location -> {
|
||||||
|
RFallingBlockEntity entity = new RFallingBlockEntity(entities, location.clone().add(HALF), Material.RED_STAINED_GLASS);
|
||||||
|
entity.setNoGravity(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void hideDetonator(Player p) {
|
public static void hideDetonator(Player p) {
|
||||||
ENTITIES_MAP.remove(p).forEach(abstractDetonatorEntity -> abstractDetonatorEntity.hide(p, true));
|
ENTITIES_MAP.remove(p).close();
|
||||||
}
|
|
||||||
|
|
||||||
public static List<AbstractDetonatorEntity> getDetoEntities(Player p) {
|
|
||||||
return ENTITIES_MAP.getOrDefault(p, new ArrayList<>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasActiveDetonatorShow(Player p) {
|
public static boolean hasActiveDetonatorShow(Player p) {
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.detonator;
|
package de.steamwar.bausystem.features.detonator;
|
||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
||||||
@ -38,38 +36,13 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class DetonatorListener implements Listener {
|
public class DetonatorListener implements Listener {
|
||||||
|
|
||||||
public static final Class<?> useEntity = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity");
|
|
||||||
private static final Reflection.FieldAccessor<Integer> entityIdFieldAccessor = Reflection.getField(useEntity, int.class, 0);
|
|
||||||
|
|
||||||
private static final Set<Player> HAS_UPDATED = new HashSet<>();
|
private static final Set<Player> HAS_UPDATED = new HashSet<>();
|
||||||
|
|
||||||
public DetonatorListener() {
|
|
||||||
TinyProtocol.instance.addFilter(useEntity, (player, o) -> {
|
|
||||||
List<AbstractDetonatorEntity> entities = Detonator.getDetoEntities(player);
|
|
||||||
if (entities.isEmpty()) {
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
int entityId = entityIdFieldAccessor.get(o);
|
|
||||||
AbstractDetonatorEntity entity = entities.stream().filter(abstractDetonatorEntity -> abstractDetonatorEntity.getId() == entityId).findFirst().orElse(null);
|
|
||||||
|
|
||||||
if (entity == null) {
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location location = entity.getBukkitEntity().getLocation().getBlock().getLocation();
|
|
||||||
addLocationToDetonator(location, player);
|
|
||||||
HAS_UPDATED.add(player);
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addLocationToDetonator(Location location, Player p) {
|
private static void addLocationToDetonator(Location location, Player p) {
|
||||||
Detoblock detoblock = Detonator.getBlock(location.getBlock());
|
Detoblock detoblock = Detonator.getBlock(location.getBlock());
|
||||||
if (detoblock == Detoblock.INVALID) {
|
if (detoblock == Detoblock.INVALID) {
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.bausystem.features.simulator;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.shared.AbstractEntity;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public interface AbstractSimulatorEntity extends AbstractEntity {
|
|
||||||
|
|
||||||
void display(Player player);
|
|
||||||
|
|
||||||
void setPosition(Vector position);
|
|
||||||
|
|
||||||
boolean hide(Player player, boolean always);
|
|
||||||
|
|
||||||
int getId();
|
|
||||||
|
|
||||||
Entity getBukkitEntity();
|
|
||||||
}
|
|
@ -20,13 +20,17 @@
|
|||||||
package de.steamwar.bausystem.features.simulator;
|
package de.steamwar.bausystem.features.simulator;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode;
|
|
||||||
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
||||||
|
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||||
|
import de.steamwar.entity.REntityServer;
|
||||||
|
import de.steamwar.entity.RFallingBlockEntity;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.RayTraceResult;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -36,13 +40,14 @@ import java.util.Map;
|
|||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class SimulatorCursor {
|
public class SimulatorCursor {
|
||||||
|
|
||||||
private Map<Player, AbstractSimulatorEntity> cursors = new HashMap<>();
|
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
|
private Map<Player, REntityServer> rEntityServerMap = new HashMap<>();
|
||||||
|
|
||||||
public void show(Player player, TNTSimulator tntSimulator, RayTraceResult result) {
|
public void show(Player player, TNTSimulator tntSimulator, RayTraceUtils.RRayTraceResult result) {
|
||||||
AbstractSimulatorEntity cursor = cursors.get(player);
|
REntityServer cursor = rEntityServerMap.get(player);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.hide(player, false);
|
cursor.close();
|
||||||
|
|
||||||
tntSimulator.show(player);
|
tntSimulator.show(player);
|
||||||
|
|
||||||
@ -53,9 +58,11 @@ public class SimulatorCursor {
|
|||||||
List<SimulatorElement> elements = tntSimulator.getEntity(result.getHitEntity());
|
List<SimulatorElement> elements = tntSimulator.getEntity(result.getHitEntity());
|
||||||
tntSimulator.hide(player, elements);
|
tntSimulator.hide(player, elements);
|
||||||
|
|
||||||
cursor = SimulatorEntityShowMode.createEntity(elements.isEmpty() ? getPos(player, result) : elements.get(0).getPosition(), true);
|
cursor = new REntityServer();
|
||||||
cursor.display(player);
|
RFallingBlockEntity entity = new RFallingBlockEntity(cursor, (elements.isEmpty() ? getPos(player, result) : elements.get(0).getPosition()).toLocation(WORLD), Material.WHITE_STAINED_GLASS);
|
||||||
cursors.put(player, cursor);
|
entity.setNoGravity(true);
|
||||||
|
cursor.addPlayer(player);
|
||||||
|
rEntityServerMap.put(player, cursor);
|
||||||
BauSystem.MESSAGE.sendPrefixless("SIMULATOR_POSITION_EDIT", player, ChatMessageType.ACTION_BAR);
|
BauSystem.MESSAGE.sendPrefixless("SIMULATOR_POSITION_EDIT", player, ChatMessageType.ACTION_BAR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -64,25 +71,27 @@ public class SimulatorCursor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor = SimulatorEntityShowMode.createEntity(getPos(player, result), false);
|
cursor = new REntityServer();
|
||||||
cursor.display(player);
|
RFallingBlockEntity entity = new RFallingBlockEntity(cursor, getPos(player, result).toLocation(WORLD), Material.TNT);
|
||||||
cursors.put(player, cursor);
|
entity.setNoGravity(true);
|
||||||
|
cursor.addPlayer(player);
|
||||||
|
rEntityServerMap.put(player, cursor);
|
||||||
BauSystem.MESSAGE.sendPrefixless("SIMULATOR_POSITION_ADD", player, ChatMessageType.ACTION_BAR);
|
BauSystem.MESSAGE.sendPrefixless("SIMULATOR_POSITION_ADD", player, ChatMessageType.ACTION_BAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide(Player player, TNTSimulator tntSimulator) {
|
public void hide(Player player, TNTSimulator tntSimulator) {
|
||||||
AbstractSimulatorEntity cursor = cursors.get(player);
|
REntityServer cursor = rEntityServerMap.get(player);
|
||||||
|
|
||||||
if (cursor != null)
|
if (cursor != null)
|
||||||
cursor.hide(player, false);
|
cursor.close();
|
||||||
|
|
||||||
if (tntSimulator != null) {
|
if (tntSimulator != null) {
|
||||||
tntSimulator.remove(player);
|
tntSimulator.hide(player);
|
||||||
}
|
}
|
||||||
cursors.remove(player);
|
rEntityServerMap.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector getPos(Player player, RayTraceResult result) {
|
public static Vector getPos(Player player, RayTraceUtils.RRayTraceResult result) {
|
||||||
Vector pos = result.getHitPosition();
|
Vector pos = result.getHitPosition();
|
||||||
|
|
||||||
BlockFace face = result.getHitBlockFace();
|
BlockFace face = result.getHitBlockFace();
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.bausystem.features.simulator;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
|
||||||
import de.steamwar.core.VersionDependent;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
public interface SimulatorPreview {
|
|
||||||
SimulatorPreview impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
class SimulatorPreviewTNTData {
|
|
||||||
private double x;
|
|
||||||
private double y;
|
|
||||||
private double z;
|
|
||||||
private int fuseTicks;
|
|
||||||
private boolean xVelocity;
|
|
||||||
private boolean yVelocity;
|
|
||||||
private boolean zVelocity;
|
|
||||||
}
|
|
||||||
|
|
||||||
Record simulate(TNTSimulator tntSimulator);
|
|
||||||
}
|
|
@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2022 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.bausystem.features.simulator;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.tracer.TNTPosition;
|
|
||||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
|
||||||
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
|
|
||||||
import de.steamwar.bausystem.features.tracer.show.EntityShowMode;
|
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
|
||||||
import de.steamwar.bausystem.shared.ShowMode;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
public class SimulatorPreviewStorage {
|
|
||||||
private Map<TNTSimulator, Pair<Record, Set<Player>>> previews = new HashMap<>();
|
|
||||||
private Map<Player, Pair<TNTSimulator, ShowMode<TNTPosition>>> showModes = new HashMap<>();
|
|
||||||
|
|
||||||
public void show(Player player, TNTSimulator tntSimulator) {
|
|
||||||
if (showModes.containsKey(player)) {
|
|
||||||
Pair<TNTSimulator, ShowMode<TNTPosition>> pair = showModes.get(player);
|
|
||||||
if (pair.getKey() != tntSimulator) {
|
|
||||||
pair.getValue().hide();
|
|
||||||
Pair<Record, Set<Player>> setPair = previews.get(pair.getKey());
|
|
||||||
setPair.getValue().remove(player);
|
|
||||||
if (setPair.getValue().isEmpty()) {
|
|
||||||
previews.remove(pair.getKey());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Pair<Record, Set<Player>> pair = previews.computeIfAbsent(tntSimulator, k -> new Pair<>(SimulatorPreview.impl.simulate(k), new HashSet<>()));
|
|
||||||
pair.getValue().add(player);
|
|
||||||
|
|
||||||
ShowModeParameter showModeParameter = new ShowModeParameter();
|
|
||||||
EntityShowMode showMode = new EntityShowMode(player, showModeParameter, 10);
|
|
||||||
pair.getKey().showAll(showMode);
|
|
||||||
showModes.put(player, new Pair<>(tntSimulator, showMode));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hide(Player player) {
|
|
||||||
if (showModes.containsKey(player)) {
|
|
||||||
Pair<TNTSimulator, ShowMode<TNTPosition>> pair = showModes.get(player);
|
|
||||||
pair.getValue().hide();
|
|
||||||
Pair<Record, Set<Player>> setPair = previews.get(pair.getKey());
|
|
||||||
setPair.getValue().remove(player);
|
|
||||||
if (setPair.getValue().isEmpty()) {
|
|
||||||
previews.remove(pair.getKey());
|
|
||||||
}
|
|
||||||
showModes.remove(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void recalculate(TNTSimulator tntSimulator) {
|
|
||||||
Pair<Record, Set<Player>> pair = previews.get(tntSimulator);
|
|
||||||
if (pair == null) return;
|
|
||||||
pair.setKey(SimulatorPreview.impl.simulate(tntSimulator));
|
|
||||||
pair.getValue().forEach(player -> {
|
|
||||||
Pair<TNTSimulator, ShowMode<TNTPosition>> setPair = showModes.get(player);
|
|
||||||
setPair.getValue().hide();
|
|
||||||
pair.getKey().showAll(setPair.getValue());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void recalculateAll() {
|
|
||||||
previews.keySet().forEach(SimulatorPreviewStorage::recalculate);
|
|
||||||
}
|
|
||||||
}
|
|
@ -31,12 +31,13 @@ import de.steamwar.bausystem.features.tracer.record.Recorder;
|
|||||||
import de.steamwar.bausystem.features.tracer.record.SingleTraceRecorder;
|
import de.steamwar.bausystem.features.tracer.record.SingleTraceRecorder;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
|
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||||
|
import de.steamwar.entity.REntityServer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.RayTraceResult;
|
|
||||||
import yapion.hierarchy.types.YAPIONArray;
|
import yapion.hierarchy.types.YAPIONArray;
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
import yapion.hierarchy.types.YAPIONType;
|
import yapion.hierarchy.types.YAPIONType;
|
||||||
@ -49,7 +50,8 @@ import java.util.stream.Collectors;
|
|||||||
@Getter
|
@Getter
|
||||||
public class TNTSimulator {
|
public class TNTSimulator {
|
||||||
|
|
||||||
private Map<Player, SimulatorEntityShowMode> playerShowMode = new HashMap<>();
|
private Set<Player> players = new HashSet<>();
|
||||||
|
private REntityServer entityServer = new REntityServer();
|
||||||
|
|
||||||
private Material material = Material.TNT;
|
private Material material = Material.TNT;
|
||||||
|
|
||||||
@ -82,38 +84,13 @@ public class TNTSimulator {
|
|||||||
return yapionObject;
|
return yapionObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide() {
|
public void close() {
|
||||||
playerShowMode.forEach((player, simulatorEntityShowMode) -> {
|
entityServer.close();
|
||||||
simulatorEntityShowMode.hide();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void show() {
|
|
||||||
playerShowMode.forEach((player, simulatorEntityShowMode) -> {
|
|
||||||
for (SimulatorElement element : tntElementList) {
|
|
||||||
element.show(simulatorEntityShowMode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide(Player player) {
|
public void hide(Player player) {
|
||||||
SimulatorEntityShowMode showMode = playerShowMode.get(player);
|
entityServer.removePlayer(player);
|
||||||
if (showMode == null) {
|
players.remove(player);
|
||||||
return;
|
|
||||||
}
|
|
||||||
tntElementList.forEach(simulatorElement -> {
|
|
||||||
simulatorElement.hide(showMode);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(Player player) {
|
|
||||||
SimulatorEntityShowMode showMode = playerShowMode.remove(player);
|
|
||||||
if (showMode == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tntElementList.forEach(simulatorElement -> {
|
|
||||||
simulatorElement.hide(showMode);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide(Player player, List<SimulatorElement> simulatorElements) {
|
public void hide(Player player, List<SimulatorElement> simulatorElements) {
|
||||||
@ -133,10 +110,8 @@ public class TNTSimulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void show(Player player) {
|
public void show(Player player) {
|
||||||
SimulatorEntityShowMode showMode = playerShowMode.computeIfAbsent(player, SimulatorEntityShowMode::new);
|
entityServer.addPlayer(player);
|
||||||
tntElementList.forEach(simulatorElement -> {
|
players.add(player);
|
||||||
simulatorElement.show(showMode);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(SimulatorElement simulatorElement) {
|
public void show(SimulatorElement simulatorElement) {
|
||||||
@ -185,7 +160,7 @@ public class TNTSimulator {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void edit(Player player, RayTraceResult result) {
|
public void edit(Player player, RayTraceUtils.RRayTraceResult result) {
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
TNTSimulatorGui.open(player, this, null, this::getTntElementList, null);
|
TNTSimulatorGui.open(player, this, null, this::getTntElementList, null);
|
||||||
return;
|
return;
|
||||||
@ -212,9 +187,6 @@ public class TNTSimulator {
|
|||||||
TNTElement tntElement = new TNTElement(SimulatorCursor.getPos(player, result));
|
TNTElement tntElement = new TNTElement(SimulatorCursor.getPos(player, result));
|
||||||
tntElementList.add(tntElement);
|
tntElementList.add(tntElement);
|
||||||
TNTElementGUI.open(player, tntElement, null);
|
TNTElementGUI.open(player, tntElement, null);
|
||||||
playerShowMode.forEach((p, simulatorEntityShowMode) -> {
|
|
||||||
show(p);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(Player p) {
|
public void start(Player p) {
|
||||||
@ -230,7 +202,7 @@ public class TNTSimulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AtomicBoolean needsAutoTrace = new AtomicBoolean();
|
AtomicBoolean needsAutoTrace = new AtomicBoolean();
|
||||||
playerShowMode.forEach((player, simulatorEntityShowMode) -> {
|
players.forEach(player -> {
|
||||||
boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false);
|
boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false);
|
||||||
if (simulatorAutoTrace) {
|
if (simulatorAutoTrace) {
|
||||||
needsAutoTrace.set(true);
|
needsAutoTrace.set(true);
|
||||||
|
@ -25,13 +25,10 @@ import de.steamwar.bausystem.features.simulator.gui.SimulatorSelectionGUI;
|
|||||||
import de.steamwar.bausystem.utils.ItemUtils;
|
import de.steamwar.bausystem.utils.ItemUtils;
|
||||||
import de.steamwar.bausystem.utils.RayTraceUtils;
|
import de.steamwar.bausystem.utils.RayTraceUtils;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
@ -50,19 +47,14 @@ public class TNTSimulatorListener implements Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static RayTraceResult trace(Player player, Location to, TNTSimulator simulator) {
|
static RayTraceUtils.RRayTraceResult trace(Player player, Location to, TNTSimulator simulator) {
|
||||||
return RayTraceUtils.trace(player, to, simulator.getEntities());
|
return RayTraceUtils.traceREntity(player, to, simulator.getEntities());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent e) {
|
public void onPlayerMove(PlayerMoveEvent e) {
|
||||||
if (ItemUtils.isItem(e.getPlayer().getInventory().getItemInMainHand(), "simulator")) {
|
if (ItemUtils.isItem(e.getPlayer().getInventory().getItemInMainHand(), "simulator")) {
|
||||||
simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getTo());
|
simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getTo());
|
||||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(e.getPlayer().getInventory().getItemInOffHand());
|
|
||||||
if (tntSimulator == null) SimulatorPreviewStorage.hide(e.getPlayer());
|
|
||||||
} else {
|
|
||||||
TNTSimulator tntSimulator = simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInOffHand, e.getTo());
|
|
||||||
if (tntSimulator != null) SimulatorPreviewStorage.show(e.getPlayer(), tntSimulator);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,11 +83,6 @@ public class TNTSimulatorListener implements Listener {
|
|||||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
if (ItemUtils.isItem(e.getPlayer().getInventory().getItemInMainHand(), "simulator")) {
|
if (ItemUtils.isItem(e.getPlayer().getInventory().getItemInMainHand(), "simulator")) {
|
||||||
simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getPlayer().getLocation());
|
simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getPlayer().getLocation());
|
||||||
} else {
|
|
||||||
TNTSimulator tntSimulator = simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInOffHand, e.getPlayer().getLocation());
|
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
|
||||||
if (tntSimulator != null) SimulatorPreviewStorage.show(e.getPlayer(), tntSimulator);
|
|
||||||
}, 10);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,29 +90,8 @@ public class TNTSimulatorListener implements Listener {
|
|||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
SimulatorCursor.hide(event.getPlayer(), null);
|
SimulatorCursor.hide(event.getPlayer(), null);
|
||||||
SimulatorStorage.getSimulatorNames().forEach(s -> {
|
SimulatorStorage.getSimulatorNames().forEach(s -> {
|
||||||
SimulatorStorage.getSimulator(s).remove(event.getPlayer());
|
SimulatorStorage.getSimulator(s).hide(event.getPlayer());
|
||||||
});
|
});
|
||||||
SimulatorPreviewStorage.hide(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
|
|
||||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(event.getOffHandItem());
|
|
||||||
if (tntSimulator == null) {
|
|
||||||
SimulatorPreviewStorage.hide(event.getPlayer());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SimulatorPreviewStorage.show(event.getPlayer(), tntSimulator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), SimulatorPreviewStorage::recalculateAll, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
|
||||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), SimulatorPreviewStorage::recalculateAll, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -49,7 +49,7 @@ public class SimulatorSelectionGUI {
|
|||||||
SWListInv<TNTSimulator> inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("SIMULATOR_GUI_SELECT_SIM", player), false, swListEntryList, (clickType, tntSimulator) -> {
|
SWListInv<TNTSimulator> inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("SIMULATOR_GUI_SELECT_SIM", player), false, swListEntryList, (clickType, tntSimulator) -> {
|
||||||
TNTSimulator current = SimulatorStorage.getSimulator(hand);
|
TNTSimulator current = SimulatorStorage.getSimulator(hand);
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
current.remove(player);
|
current.hide(player);
|
||||||
}
|
}
|
||||||
SimulatorStorage.setSimulator(player, hand, tntSimulator);
|
SimulatorStorage.setSimulator(player, hand, tntSimulator);
|
||||||
player.getInventory().setItemInMainHand(hand);
|
player.getInventory().setItemInMainHand(hand);
|
||||||
@ -64,7 +64,7 @@ public class SimulatorSelectionGUI {
|
|||||||
if (SimulatorCommand.createSimulator(player, s)) {
|
if (SimulatorCommand.createSimulator(player, s)) {
|
||||||
TNTSimulator current = SimulatorStorage.getSimulator(hand);
|
TNTSimulator current = SimulatorStorage.getSimulator(hand);
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
current.remove(player);
|
current.hide(player);
|
||||||
}
|
}
|
||||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(s);
|
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(s);
|
||||||
SimulatorStorage.setSimulator(player, hand, tntSimulator);
|
SimulatorStorage.setSimulator(player, hand, tntSimulator);
|
||||||
|
@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.simulator.gui;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.simulator.OrderUtils;
|
import de.steamwar.bausystem.features.simulator.OrderUtils;
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorPreviewStorage;
|
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
||||||
import de.steamwar.bausystem.features.simulator.TNTSimulator;
|
import de.steamwar.bausystem.features.simulator.TNTSimulator;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.components.ChangeMaterial;
|
import de.steamwar.bausystem.features.simulator.gui.components.ChangeMaterial;
|
||||||
@ -42,7 +41,6 @@ import org.bukkit.util.Vector;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
import static de.steamwar.bausystem.features.simulator.gui.ItemUtils.unique;
|
import static de.steamwar.bausystem.features.simulator.gui.ItemUtils.unique;
|
||||||
|
|
||||||
@ -66,7 +64,6 @@ public class TNTElementGUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||||
AtomicBoolean recalculate = new AtomicBoolean(false);
|
|
||||||
Runnable editObserver = () -> {
|
Runnable editObserver = () -> {
|
||||||
List<String> locationLore = new ArrayList<>();
|
List<String> locationLore = new ArrayList<>();
|
||||||
locationLore.add("");
|
locationLore.add("");
|
||||||
@ -76,7 +73,6 @@ public class TNTElementGUI {
|
|||||||
inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_LOCATION", player), locationLore, false, clickType -> {
|
inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_LOCATION", player), locationLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
editLocation(player, tntElement, () -> open(player, tntElement, back));
|
editLocation(player, tntElement, () -> open(player, tntElement, back));
|
||||||
recalculate.set(true);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
List<String> propertiesLore = new ArrayList<>();
|
List<String> propertiesLore = new ArrayList<>();
|
||||||
@ -91,7 +87,6 @@ public class TNTElementGUI {
|
|||||||
inv.setItem(22, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_PROPERTIES", player), propertiesLore, false, clickType -> {
|
inv.setItem(22, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_PROPERTIES", player), propertiesLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
editProperties(player, tntElement, () -> open(player, tntElement, back));
|
editProperties(player, tntElement, () -> open(player, tntElement, back));
|
||||||
recalculate.set(true);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
List<String> otherLore = new ArrayList<>();
|
List<String> otherLore = new ArrayList<>();
|
||||||
@ -105,13 +100,11 @@ public class TNTElementGUI {
|
|||||||
inv.setItem(24, new SWItem(Material.ANVIL, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_OTHER", player), otherLore, false, clickType -> {
|
inv.setItem(24, new SWItem(Material.ANVIL, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_OTHER", player), otherLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
editOther(player, tntElement, () -> open(player, tntElement, back));
|
editOther(player, tntElement, () -> open(player, tntElement, back));
|
||||||
recalculate.set(true);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Delete tnt
|
// Delete tnt
|
||||||
inv.setItem(44, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_REMOVE_TNT", player), clickType -> {
|
inv.setItem(44, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_REMOVE_TNT", player), clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntSimulator.remove(tntElement);
|
tntSimulator.remove(tntElement);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
}));
|
}));
|
||||||
@ -120,9 +113,6 @@ public class TNTElementGUI {
|
|||||||
tntElement.register(editObserver, player::closeInventory);
|
tntElement.register(editObserver, player::closeInventory);
|
||||||
inv.addCloseRunnable(() -> {
|
inv.addCloseRunnable(() -> {
|
||||||
tntElement.unregister(editObserver);
|
tntElement.unregister(editObserver);
|
||||||
if (recalculate.get()) {
|
|
||||||
SimulatorPreviewStorage.recalculate(tntSimulator);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
inv.open();
|
inv.open();
|
||||||
@ -135,14 +125,12 @@ public class TNTElementGUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||||
AtomicBoolean recalculate = new AtomicBoolean(false);
|
|
||||||
Runnable editObserver = () -> {
|
Runnable editObserver = () -> {
|
||||||
ChangePosition.show(inv, player, recalculate, tntSimulator, tntElement, tntElement::getOwnPosition, x -> x - tntElement.getParentPosition().getX(), y -> y - tntElement.getParentPosition().getY(), z -> z - tntElement.getParentPosition().getZ(), () -> editLocation(player, tntElement, back));
|
ChangePosition.show(inv, player, tntSimulator, tntElement, tntElement::getOwnPosition, x -> x - tntElement.getParentPosition().getX(), y -> y - tntElement.getParentPosition().getY(), z -> z - tntElement.getParentPosition().getZ(), () -> editLocation(player, tntElement, back));
|
||||||
|
|
||||||
// Alignment
|
// Alignment
|
||||||
inv.setItem(23, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_Z", player), clickType -> { // Z negative
|
inv.setItem(23, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_Z", player), clickType -> { // Z negative
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntSimulator.hide(tntElement);
|
tntSimulator.hide(tntElement);
|
||||||
Vector position = tntElement.getPosition();
|
Vector position = tntElement.getPosition();
|
||||||
align(position, new Vector(0, 0, 0.49));
|
align(position, new Vector(0, 0, 0.49));
|
||||||
@ -152,7 +140,6 @@ public class TNTElementGUI {
|
|||||||
}));
|
}));
|
||||||
inv.setItem(25, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_Z", player), clickType -> { // Z positive
|
inv.setItem(25, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_Z", player), clickType -> { // Z positive
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntSimulator.hide(tntElement);
|
tntSimulator.hide(tntElement);
|
||||||
Vector position = tntElement.getPosition();
|
Vector position = tntElement.getPosition();
|
||||||
align(position, new Vector(0, 0, 0.51));
|
align(position, new Vector(0, 0, 0.51));
|
||||||
@ -162,7 +149,6 @@ public class TNTElementGUI {
|
|||||||
}));
|
}));
|
||||||
inv.setItem(15, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_X", player), clickType -> { // X positive
|
inv.setItem(15, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_X", player), clickType -> { // X positive
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntSimulator.hide(tntElement);
|
tntSimulator.hide(tntElement);
|
||||||
Vector position = tntElement.getPosition();
|
Vector position = tntElement.getPosition();
|
||||||
align(position, new Vector(0.51, 0, 0));
|
align(position, new Vector(0.51, 0, 0));
|
||||||
@ -172,7 +158,6 @@ public class TNTElementGUI {
|
|||||||
}));
|
}));
|
||||||
inv.setItem(33, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_X", player), clickType -> { // X negative
|
inv.setItem(33, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_X", player), clickType -> { // X negative
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntSimulator.hide(tntElement);
|
tntSimulator.hide(tntElement);
|
||||||
Vector position = tntElement.getPosition();
|
Vector position = tntElement.getPosition();
|
||||||
align(position, new Vector(0.49, 0, 0));
|
align(position, new Vector(0.49, 0, 0));
|
||||||
@ -182,7 +167,6 @@ public class TNTElementGUI {
|
|||||||
}));
|
}));
|
||||||
inv.setItem(24, new SWItem(Material.SUNFLOWER, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_CENTER", player), clickType -> { // CENTER
|
inv.setItem(24, new SWItem(Material.SUNFLOWER, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_CENTER", player), clickType -> { // CENTER
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntSimulator.hide(tntElement);
|
tntSimulator.hide(tntElement);
|
||||||
Vector position = tntElement.getPosition();
|
Vector position = tntElement.getPosition();
|
||||||
align(position, new Vector(0.5, 0, 0.5));
|
align(position, new Vector(0.5, 0, 0.5));
|
||||||
@ -196,9 +180,6 @@ public class TNTElementGUI {
|
|||||||
tntElement.register(editObserver, player::closeInventory);
|
tntElement.register(editObserver, player::closeInventory);
|
||||||
inv.addCloseRunnable(() -> {
|
inv.addCloseRunnable(() -> {
|
||||||
tntElement.unregister(editObserver);
|
tntElement.unregister(editObserver);
|
||||||
if (recalculate.get()) {
|
|
||||||
SimulatorPreviewStorage.recalculate(tntSimulator);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
inv.open();
|
inv.open();
|
||||||
@ -236,18 +217,15 @@ public class TNTElementGUI {
|
|||||||
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player));
|
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player));
|
||||||
|
|
||||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||||
AtomicBoolean recalculate = new AtomicBoolean(false);
|
|
||||||
Runnable editObserver = () -> {
|
Runnable editObserver = () -> {
|
||||||
// Change Count of spawned TNT
|
// Change Count of spawned TNT
|
||||||
inv.setItem(10, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
|
inv.setItem(10, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntElement.setCount(tntElement.getCount() + ((clickType.isShiftClick()) ? 5 : 1));
|
tntElement.setCount(tntElement.getCount() + ((clickType.isShiftClick()) ? 5 : 1));
|
||||||
tntElement.change();
|
tntElement.change();
|
||||||
})));
|
})));
|
||||||
SWItem countItem = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT", player, tntElement.getCount()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT_ANVIL_GUI_NAME", player), tntElement.getCount(), c -> {
|
SWItem countItem = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT", player, tntElement.getCount()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT_ANVIL_GUI_NAME", player), tntElement.getCount(), c -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntElement.setCount(c);
|
tntElement.setCount(c);
|
||||||
tntElement.change();
|
tntElement.change();
|
||||||
editProperties(player, tntElement, back);
|
editProperties(player, tntElement, back);
|
||||||
@ -256,7 +234,6 @@ public class TNTElementGUI {
|
|||||||
inv.setItem(19, countItem);
|
inv.setItem(19, countItem);
|
||||||
inv.setItem(28, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
|
inv.setItem(28, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntElement.setCount(tntElement.getCount() - ((clickType.isShiftClick()) ? 5 : 1));
|
tntElement.setCount(tntElement.getCount() - ((clickType.isShiftClick()) ? 5 : 1));
|
||||||
tntElement.change();
|
tntElement.change();
|
||||||
})));
|
})));
|
||||||
@ -264,13 +241,11 @@ public class TNTElementGUI {
|
|||||||
// Change TickOffset
|
// Change TickOffset
|
||||||
inv.setItem(11, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
|
inv.setItem(11, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntElement.setTickOffset(tntElement.getOwnTickOffset() + (clickType.isShiftClick() ? 5 : 1));
|
tntElement.setTickOffset(tntElement.getOwnTickOffset() + (clickType.isShiftClick() ? 5 : 1));
|
||||||
tntElement.change();
|
tntElement.change();
|
||||||
})));
|
})));
|
||||||
SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntElement.getTickOffset()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK_ANVIL_GUI_NAME", player), tntElement.getTickOffset(), tick -> {
|
SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntElement.getTickOffset()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK_ANVIL_GUI_NAME", player), tntElement.getTickOffset(), tick -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntElement.setTickOffset(tick - tntElement.getParentTickOffset());
|
tntElement.setTickOffset(tick - tntElement.getParentTickOffset());
|
||||||
tntElement.change();
|
tntElement.change();
|
||||||
editProperties(player, tntElement, back);
|
editProperties(player, tntElement, back);
|
||||||
@ -279,7 +254,6 @@ public class TNTElementGUI {
|
|||||||
inv.setItem(20, tickItem);
|
inv.setItem(20, tickItem);
|
||||||
inv.setItem(29, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
|
inv.setItem(29, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntElement.setTickOffset(tntElement.getOwnTickOffset() - (clickType.isShiftClick() ? 5 : 1));
|
tntElement.setTickOffset(tntElement.getOwnTickOffset() - (clickType.isShiftClick() ? 5 : 1));
|
||||||
tntElement.change();
|
tntElement.change();
|
||||||
})));
|
})));
|
||||||
@ -287,13 +261,11 @@ public class TNTElementGUI {
|
|||||||
// Change FuseTicks
|
// Change FuseTicks
|
||||||
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
|
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntElement.setFuseTicks(tntElement.getFuseTicks() + (clickType.isShiftClick() ? 5 : 1));
|
tntElement.setFuseTicks(tntElement.getFuseTicks() + (clickType.isShiftClick() ? 5 : 1));
|
||||||
tntElement.change();
|
tntElement.change();
|
||||||
})));
|
})));
|
||||||
SWItem fuseTickItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE", player, tntElement.getFuseTicks()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE_ANVIL_GUI_NAME", player), tntElement.getFuseTicks(), tick -> {
|
SWItem fuseTickItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE", player, tntElement.getFuseTicks()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE_ANVIL_GUI_NAME", player), tntElement.getFuseTicks(), tick -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntElement.setFuseTicks(tick);
|
tntElement.setFuseTicks(tick);
|
||||||
tntElement.change();
|
tntElement.change();
|
||||||
editProperties(player, tntElement, back);
|
editProperties(player, tntElement, back);
|
||||||
@ -302,7 +274,6 @@ public class TNTElementGUI {
|
|||||||
inv.setItem(21, fuseTickItem);
|
inv.setItem(21, fuseTickItem);
|
||||||
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
|
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntElement.setFuseTicks(tntElement.getFuseTicks() - (clickType.isShiftClick() ? 5 : 1));
|
tntElement.setFuseTicks(tntElement.getFuseTicks() - (clickType.isShiftClick() ? 5 : 1));
|
||||||
tntElement.change();
|
tntElement.change();
|
||||||
})));
|
})));
|
||||||
@ -310,7 +281,6 @@ public class TNTElementGUI {
|
|||||||
// Velocity Settings
|
// Velocity Settings
|
||||||
inv.setItem(24, Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_NAME", player), clickType -> {
|
inv.setItem(24, Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_NAME", player), clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
if (tntElement.isXVelocity() || tntElement.isYVelocity() || tntElement.isZVelocity()) {
|
if (tntElement.isXVelocity() || tntElement.isYVelocity() || tntElement.isZVelocity()) {
|
||||||
tntElement.setXVelocity(false);
|
tntElement.setXVelocity(false);
|
||||||
tntElement.setYVelocity(false);
|
tntElement.setYVelocity(false);
|
||||||
@ -324,19 +294,16 @@ public class TNTElementGUI {
|
|||||||
});
|
});
|
||||||
inv.setItem(32, new SWItem(getWool(tntElement.isXVelocity()), getColor(tntElement.isXVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_X", player, active(player, tntElement.isXVelocity())), clickType -> {
|
inv.setItem(32, new SWItem(getWool(tntElement.isXVelocity()), getColor(tntElement.isXVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_X", player, active(player, tntElement.isXVelocity())), clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntElement.setXVelocity(!tntElement.isXVelocity());
|
tntElement.setXVelocity(!tntElement.isXVelocity());
|
||||||
tntElement.change();
|
tntElement.change();
|
||||||
}));
|
}));
|
||||||
inv.setItem(15, new SWItem(getWool(tntElement.isYVelocity()), getColor(tntElement.isYVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Y", player, active(player, tntElement.isYVelocity())), clickType -> {
|
inv.setItem(15, new SWItem(getWool(tntElement.isYVelocity()), getColor(tntElement.isYVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Y", player, active(player, tntElement.isYVelocity())), clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntElement.setYVelocity(!tntElement.isYVelocity());
|
tntElement.setYVelocity(!tntElement.isYVelocity());
|
||||||
tntElement.change();
|
tntElement.change();
|
||||||
}));
|
}));
|
||||||
inv.setItem(34, new SWItem(getWool(tntElement.isZVelocity()), getColor(tntElement.isZVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Z", player, active(player, tntElement.isZVelocity())), clickType -> {
|
inv.setItem(34, new SWItem(getWool(tntElement.isZVelocity()), getColor(tntElement.isZVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Z", player, active(player, tntElement.isZVelocity())), clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntElement.setZVelocity(!tntElement.isZVelocity());
|
tntElement.setZVelocity(!tntElement.isZVelocity());
|
||||||
tntElement.change();
|
tntElement.change();
|
||||||
}));
|
}));
|
||||||
@ -345,9 +312,6 @@ public class TNTElementGUI {
|
|||||||
tntElement.register(editObserver, player::closeInventory);
|
tntElement.register(editObserver, player::closeInventory);
|
||||||
inv.addCloseRunnable(() -> {
|
inv.addCloseRunnable(() -> {
|
||||||
tntElement.unregister(editObserver);
|
tntElement.unregister(editObserver);
|
||||||
if (recalculate.get()) {
|
|
||||||
SimulatorPreviewStorage.recalculate(tntSimulator);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
inv.open();
|
inv.open();
|
||||||
@ -360,11 +324,9 @@ public class TNTElementGUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||||
AtomicBoolean recalculate = new AtomicBoolean(false);
|
|
||||||
Runnable editObserver = () -> {
|
Runnable editObserver = () -> {
|
||||||
inv.setItem(19, new SWItem(tntElement.getOrder(), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ACTIVATED_NAME", player), OrderUtils.orderList(tntElement.getOrder(), player), false, clickType -> {
|
inv.setItem(19, new SWItem(tntElement.getOrder(), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ACTIVATED_NAME", player), OrderUtils.orderList(tntElement.getOrder(), player), false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
if (clickType.isShiftClick()) {
|
if (clickType.isShiftClick()) {
|
||||||
tntElement.setOrder(OrderUtils.previous(tntElement.getOrder()));
|
tntElement.setOrder(OrderUtils.previous(tntElement.getOrder()));
|
||||||
} else {
|
} else {
|
||||||
@ -374,12 +336,11 @@ public class TNTElementGUI {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
ChangeMaterial.show(inv, player, 21, tntElement, Material.BARREL, () -> editOther(player, tntElement, back));
|
ChangeMaterial.show(inv, player, 21, tntElement, Material.BARREL, () -> editOther(player, tntElement, back));
|
||||||
Disabled.show(inv, player, recalculate, 22, tntSimulator, tntElement);
|
Disabled.show(inv, player, 22, tntSimulator, tntElement);
|
||||||
|
|
||||||
if (!tntElement.hasParent()) {
|
if (!tntElement.hasParent()) {
|
||||||
inv.setItem(24, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE", player), Arrays.asList(), false, clickType -> {
|
inv.setItem(24, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE", player), Arrays.asList(), false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
// Create TNTGroup
|
// Create TNTGroup
|
||||||
tntSimulator.getTntElementList().remove(tntElement);
|
tntSimulator.getTntElementList().remove(tntElement);
|
||||||
Vector vector = tntElement.getOwnPosition().clone();
|
Vector vector = tntElement.getOwnPosition().clone();
|
||||||
@ -409,7 +370,6 @@ public class TNTElementGUI {
|
|||||||
|
|
||||||
inv.setItem(25, new SWItem(Material.DISPENSER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_TNT", player), clickType -> {
|
inv.setItem(25, new SWItem(Material.DISPENSER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_TNT", player), clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
Vector vector = tntElement.getOwnPosition().clone();
|
Vector vector = tntElement.getOwnPosition().clone();
|
||||||
TNTElement newElement = new TNTElement(vector);
|
TNTElement newElement = new TNTElement(vector);
|
||||||
if (tntElement.hasParent()) {
|
if (tntElement.hasParent()) {
|
||||||
@ -427,7 +387,6 @@ public class TNTElementGUI {
|
|||||||
// Delete tnt
|
// Delete tnt
|
||||||
inv.setItem(44, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_REMOVE_TNT", player), clickType -> {
|
inv.setItem(44, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_REMOVE_TNT", player), clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntSimulator.remove(tntElement);
|
tntSimulator.remove(tntElement);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
}));
|
}));
|
||||||
@ -436,9 +395,6 @@ public class TNTElementGUI {
|
|||||||
tntElement.register(editObserver, player::closeInventory);
|
tntElement.register(editObserver, player::closeInventory);
|
||||||
inv.addCloseRunnable(() -> {
|
inv.addCloseRunnable(() -> {
|
||||||
tntElement.unregister(editObserver);
|
tntElement.unregister(editObserver);
|
||||||
if (recalculate.get()) {
|
|
||||||
SimulatorPreviewStorage.recalculate(tntSimulator);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
inv.open();
|
inv.open();
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.bausystem.features.simulator.gui;
|
package de.steamwar.bausystem.features.simulator.gui;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorPreviewStorage;
|
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
||||||
import de.steamwar.bausystem.features.simulator.TNTSimulator;
|
import de.steamwar.bausystem.features.simulator.TNTSimulator;
|
||||||
import de.steamwar.bausystem.features.simulator.gui.components.ChangeMaterial;
|
import de.steamwar.bausystem.features.simulator.gui.components.ChangeMaterial;
|
||||||
@ -41,7 +40,6 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
import static de.steamwar.bausystem.features.simulator.gui.ItemUtils.unique;
|
import static de.steamwar.bausystem.features.simulator.gui.ItemUtils.unique;
|
||||||
@ -80,51 +78,39 @@ public class TNTGroupEditGUI {
|
|||||||
// X Position
|
// X Position
|
||||||
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
|
||||||
moveAll(simulatorElements, clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
moveAll(simulatorElements, clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||||
tntSimulator.show();
|
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
})));
|
})));
|
||||||
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, vector.getX()), lore, false, clickType -> {}));
|
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, vector.getX()), lore, false, clickType -> {}));
|
||||||
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
|
||||||
moveAll(simulatorElements, (clickType.isShiftClick() ? X_VECTOR : FX_VECTOR).clone().multiply(-1));
|
moveAll(simulatorElements, (clickType.isShiftClick() ? X_VECTOR : FX_VECTOR).clone().multiply(-1));
|
||||||
tntSimulator.show();
|
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
})));
|
})));
|
||||||
|
|
||||||
// Y Position
|
// Y Position
|
||||||
inv.setItem(13, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(13, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
|
||||||
moveAll(simulatorElements, clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
moveAll(simulatorElements, clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||||
tntSimulator.show();
|
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
})));
|
})));
|
||||||
inv.setItem(22, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, vector.getY()), lore, false, clickType -> {}));
|
inv.setItem(22, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, vector.getY()), lore, false, clickType -> {}));
|
||||||
inv.setItem(31, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(31, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
|
||||||
moveAll(simulatorElements, (clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR).clone().multiply(-1));
|
moveAll(simulatorElements, (clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR).clone().multiply(-1));
|
||||||
tntSimulator.show();
|
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
})));
|
})));
|
||||||
|
|
||||||
// Z Position
|
// Z Position
|
||||||
inv.setItem(14, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(14, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
|
||||||
moveAll(simulatorElements, clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
moveAll(simulatorElements, clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||||
tntSimulator.show();
|
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
})));
|
})));
|
||||||
inv.setItem(23, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, vector.getZ()), lore, false, clickType -> {}));
|
inv.setItem(23, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, vector.getZ()), lore, false, clickType -> {}));
|
||||||
inv.setItem(32, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(32, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
|
||||||
moveAll(simulatorElements, (clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR).clone().multiply(-1));
|
moveAll(simulatorElements, (clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR).clone().multiply(-1));
|
||||||
tntSimulator.show();
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
inv.open();
|
inv.open();
|
||||||
@ -161,22 +147,19 @@ public class TNTGroupEditGUI {
|
|||||||
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player));
|
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player));
|
||||||
|
|
||||||
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player);
|
||||||
AtomicBoolean recalculate = new AtomicBoolean(false);
|
|
||||||
Runnable editObserver = () -> {
|
Runnable editObserver = () -> {
|
||||||
ChangePosition.show(inv, player, recalculate, tntSimulator, tntGroup, tntGroup::getPosition, UnaryOperator.identity(), UnaryOperator.identity(), UnaryOperator.identity(), () -> open(player, tntGroup, back));
|
ChangePosition.show(inv, player, tntSimulator, tntGroup, tntGroup::getPosition, UnaryOperator.identity(), UnaryOperator.identity(), UnaryOperator.identity(), () -> open(player, tntGroup, back));
|
||||||
ChangeMaterial.show(inv, player, 14, tntGroup, Material.BARREL, () -> open(player, tntGroup, back));
|
ChangeMaterial.show(inv, player, 14, tntGroup, Material.BARREL, () -> open(player, tntGroup, back));
|
||||||
Disabled.show(inv, player, recalculate, 32, tntSimulator, tntGroup);
|
Disabled.show(inv, player, 32, tntSimulator, tntGroup);
|
||||||
|
|
||||||
// Change TickOffset
|
// Change TickOffset
|
||||||
inv.setItem(16, new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
|
inv.setItem(16, new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntGroup.setTickOffset(tntGroup.getTickOffset() + (clickType.isShiftClick() ? 5 : 1));
|
tntGroup.setTickOffset(tntGroup.getTickOffset() + (clickType.isShiftClick() ? 5 : 1));
|
||||||
tntGroup.change();
|
tntGroup.change();
|
||||||
}));
|
}));
|
||||||
SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntGroup.getTickOffset()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK_ANVIL_GUI_NAME", player), tntGroup.getTickOffset(), tick -> {
|
SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntGroup.getTickOffset()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK_ANVIL_GUI_NAME", player), tntGroup.getTickOffset(), tick -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntGroup.setTickOffset(tick);
|
tntGroup.setTickOffset(tick);
|
||||||
tntGroup.change();
|
tntGroup.change();
|
||||||
open(player, tntGroup, back);
|
open(player, tntGroup, back);
|
||||||
@ -185,7 +168,6 @@ public class TNTGroupEditGUI {
|
|||||||
inv.setItem(25, tickItem);
|
inv.setItem(25, tickItem);
|
||||||
inv.setItem(34, new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
|
inv.setItem(34, new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
tntGroup.setTickOffset(tntGroup.getTickOffset() - (clickType.isShiftClick() ? 5 : 1));
|
tntGroup.setTickOffset(tntGroup.getTickOffset() - (clickType.isShiftClick() ? 5 : 1));
|
||||||
tntGroup.change();
|
tntGroup.change();
|
||||||
}));
|
}));
|
||||||
@ -194,7 +176,6 @@ public class TNTGroupEditGUI {
|
|||||||
tntGroup.register(editObserver, player::closeInventory);
|
tntGroup.register(editObserver, player::closeInventory);
|
||||||
inv.addCloseRunnable(() -> {
|
inv.addCloseRunnable(() -> {
|
||||||
tntGroup.unregister(editObserver);
|
tntGroup.unregister(editObserver);
|
||||||
SimulatorPreviewStorage.recalculate(tntSimulator);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
inv.open();
|
inv.open();
|
||||||
|
@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.simulator.gui;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorPreviewStorage;
|
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
||||||
import de.steamwar.bausystem.features.simulator.TNTSimulator;
|
import de.steamwar.bausystem.features.simulator.TNTSimulator;
|
||||||
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement;
|
||||||
@ -117,7 +116,6 @@ public class TNTSimulatorGui {
|
|||||||
currentTntGroup.register(editObserver, player::closeInventory);
|
currentTntGroup.register(editObserver, player::closeInventory);
|
||||||
inv.addCloseRunnable(() -> {
|
inv.addCloseRunnable(() -> {
|
||||||
currentTntGroup.unregister(editObserver);
|
currentTntGroup.unregister(editObserver);
|
||||||
SimulatorPreviewStorage.recalculate(currentTntSimulator);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!elements.isEmpty()) {
|
if (!elements.isEmpty()) {
|
||||||
@ -126,15 +124,11 @@ public class TNTSimulatorGui {
|
|||||||
TNTGroupEditGUI.open(player, tntSimulator, elements, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back));
|
TNTGroupEditGUI.open(player, tntSimulator, elements, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
inv.addCloseCallback(clickType -> {
|
|
||||||
SimulatorPreviewStorage.recalculate(currentTntSimulator);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentTntSimulator != null || currentTntGroup != null) {
|
if (currentTntSimulator != null || currentTntGroup != null) {
|
||||||
inv.setItem(51, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_GUI_DELETE", player), clickType -> {
|
inv.setItem(51, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_GUI_DELETE", player), clickType -> {
|
||||||
if (currentTntSimulator != null) {
|
if (currentTntSimulator != null) {
|
||||||
currentTntSimulator.hide();
|
|
||||||
currentTntSimulator.getTntElementList().forEach(SimulatorElement::close);
|
currentTntSimulator.getTntElementList().forEach(SimulatorElement::close);
|
||||||
currentTntSimulator.getTntElementList().clear();
|
currentTntSimulator.getTntElementList().clear();
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
@ -169,51 +163,40 @@ public class TNTSimulatorGui {
|
|||||||
// X Position
|
// X Position
|
||||||
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
|
||||||
moveAll(tntSimulator, clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
moveAll(tntSimulator, clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||||
tntSimulator.show();
|
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
})));
|
})));
|
||||||
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_X", player), lore, false, clickType -> {}));
|
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_X", player), lore, false, clickType -> {}));
|
||||||
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
|
||||||
moveAll(tntSimulator, (clickType.isShiftClick() ? X_VECTOR : FX_VECTOR).clone().multiply(-1));
|
moveAll(tntSimulator, (clickType.isShiftClick() ? X_VECTOR : FX_VECTOR).clone().multiply(-1));
|
||||||
tntSimulator.show();
|
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
})));
|
})));
|
||||||
|
|
||||||
// Y Position
|
// Y Position
|
||||||
inv.setItem(13, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(13, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
|
||||||
moveAll(tntSimulator, clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
moveAll(tntSimulator, clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||||
tntSimulator.show();
|
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
})));
|
})));
|
||||||
inv.setItem(22, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_Y", player), lore, false, clickType -> {}));
|
inv.setItem(22, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_Y", player), lore, false, clickType -> {}));
|
||||||
inv.setItem(31, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(31, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
|
||||||
moveAll(tntSimulator, (clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR).clone().multiply(-1));
|
moveAll(tntSimulator, (clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR).clone().multiply(-1));
|
||||||
tntSimulator.show();
|
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
})));
|
})));
|
||||||
|
|
||||||
// Z Position
|
// Z Position
|
||||||
inv.setItem(14, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(14, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
|
||||||
moveAll(tntSimulator, clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
moveAll(tntSimulator, clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||||
tntSimulator.show();
|
|
||||||
tntSimulator.change();
|
tntSimulator.change();
|
||||||
})));
|
})));
|
||||||
inv.setItem(23, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_Z", player), lore, false, clickType -> {}));
|
inv.setItem(23, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_Z", player), lore, false, clickType -> {}));
|
||||||
inv.setItem(32, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(32, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
tntSimulator.hide();
|
|
||||||
moveAll(tntSimulator, (clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR).clone().multiply(-1));
|
moveAll(tntSimulator, (clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR).clone().multiply(-1));
|
||||||
tntSimulator.show();
|
tntSimulator.change();
|
||||||
})));
|
})));
|
||||||
|
|
||||||
inv.open();
|
inv.open();
|
||||||
|
@ -51,7 +51,7 @@ public class ChangePosition {
|
|||||||
private static final Vector FY_VECTOR = new Vector(0, 1, 0);
|
private static final Vector FY_VECTOR = new Vector(0, 1, 0);
|
||||||
private static final Vector FZ_VECTOR = new Vector(0, 0, 1);
|
private static final Vector FZ_VECTOR = new Vector(0, 0, 1);
|
||||||
|
|
||||||
public void show(SWInventory inv, Player player, AtomicBoolean recalculate, TNTSimulator tntSimulator, SimulatorElement simulatorElement, Supplier<Vector> toChangeVector, UnaryOperator<Double> calculatePositionX, UnaryOperator<Double> calculatePositionY, UnaryOperator<Double> calculatePositionZ, Runnable back) {
|
public void show(SWInventory inv, Player player, TNTSimulator tntSimulator, SimulatorElement simulatorElement, Supplier<Vector> toChangeVector, UnaryOperator<Double> calculatePositionX, UnaryOperator<Double> calculatePositionY, UnaryOperator<Double> calculatePositionZ, Runnable back) {
|
||||||
String plusOneName = BauSystem.MESSAGE.parse("SIMULATOR_PLUS_ONE", player);
|
String plusOneName = BauSystem.MESSAGE.parse("SIMULATOR_PLUS_ONE", player);
|
||||||
String minusOneName = BauSystem.MESSAGE.parse("SIMULATOR_MINUS_ONE", player);
|
String minusOneName = BauSystem.MESSAGE.parse("SIMULATOR_MINUS_ONE", player);
|
||||||
List<String> plusOnePixelShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_PLUS_PIXEL_SHIFT", player));
|
List<String> plusOnePixelShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_PLUS_PIXEL_SHIFT", player));
|
||||||
@ -61,7 +61,6 @@ public class ChangePosition {
|
|||||||
// X Position
|
// X Position
|
||||||
inv.setItem(10, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(10, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||||
toChangeVector.get().add(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
toChangeVector.get().add(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||||
@ -69,7 +68,6 @@ public class ChangePosition {
|
|||||||
})));
|
})));
|
||||||
inv.setItem(19, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, simulatorElement.getPosition().getX()), lore, false, clickType -> {
|
inv.setItem(19, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, simulatorElement.getPosition().getX()), lore, false, clickType -> {
|
||||||
changePosition(player, simulatorElement.getPosition().getX(), x -> {
|
changePosition(player, simulatorElement.getPosition().getX(), x -> {
|
||||||
recalculate.set(true);
|
|
||||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||||
toChangeVector.get().setX(clamp(calculatePositionX.apply(x)));
|
toChangeVector.get().setX(clamp(calculatePositionX.apply(x)));
|
||||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||||
@ -79,7 +77,6 @@ public class ChangePosition {
|
|||||||
}));
|
}));
|
||||||
inv.setItem(28, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(28, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||||
toChangeVector.get().subtract(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
toChangeVector.get().subtract(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR);
|
||||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||||
@ -89,7 +86,6 @@ public class ChangePosition {
|
|||||||
// Y Position
|
// Y Position
|
||||||
inv.setItem(11, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(11, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||||
toChangeVector.get().add(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
toChangeVector.get().add(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||||
@ -97,7 +93,6 @@ public class ChangePosition {
|
|||||||
})));
|
})));
|
||||||
inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, simulatorElement.getPosition().getY()), lore, false, clickType -> {
|
inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, simulatorElement.getPosition().getY()), lore, false, clickType -> {
|
||||||
changePosition(player, simulatorElement.getPosition().getY(), y -> {
|
changePosition(player, simulatorElement.getPosition().getY(), y -> {
|
||||||
recalculate.set(true);
|
|
||||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||||
toChangeVector.get().setY(clamp(calculatePositionY.apply(y)));
|
toChangeVector.get().setY(clamp(calculatePositionY.apply(y)));
|
||||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||||
@ -107,7 +102,6 @@ public class ChangePosition {
|
|||||||
}));
|
}));
|
||||||
inv.setItem(29, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(29, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||||
toChangeVector.get().subtract(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
toChangeVector.get().subtract(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR);
|
||||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||||
@ -117,7 +111,6 @@ public class ChangePosition {
|
|||||||
// Z Position
|
// Z Position
|
||||||
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||||
toChangeVector.get().add(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
toChangeVector.get().add(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||||
@ -125,7 +118,6 @@ public class ChangePosition {
|
|||||||
})));
|
})));
|
||||||
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, simulatorElement.getPosition().getZ()), lore, false, clickType -> {
|
inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, simulatorElement.getPosition().getZ()), lore, false, clickType -> {
|
||||||
changePosition(player, simulatorElement.getPosition().getZ(), z -> {
|
changePosition(player, simulatorElement.getPosition().getZ(), z -> {
|
||||||
recalculate.set(true);
|
|
||||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||||
toChangeVector.get().setZ(clamp(calculatePositionZ.apply(z)));
|
toChangeVector.get().setZ(clamp(calculatePositionZ.apply(z)));
|
||||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||||
@ -135,7 +127,6 @@ public class ChangePosition {
|
|||||||
}));
|
}));
|
||||||
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> {
|
||||||
if (clickType == ClickType.DOUBLE_CLICK) return;
|
if (clickType == ClickType.DOUBLE_CLICK) return;
|
||||||
recalculate.set(true);
|
|
||||||
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
if (tntSimulator != null) tntSimulator.hide(simulatorElement);
|
||||||
toChangeVector.get().subtract(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
toChangeVector.get().subtract(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR);
|
||||||
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
if (tntSimulator != null) tntSimulator.show(simulatorElement);
|
||||||
|
@ -29,14 +29,12 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class Disabled {
|
public class Disabled {
|
||||||
|
|
||||||
public void show(SWInventory inv, Player player, AtomicBoolean recalculate, int position, TNTSimulator tntSimulator, SimulatorElement simulatorElement) {
|
public void show(SWInventory inv, Player player, int position, TNTSimulator tntSimulator, SimulatorElement simulatorElement) {
|
||||||
inv.setItem(position, new SWItem(simulatorElement.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, BauSystem.MESSAGE.parse(simulatorElement.isDisabled() ? "SIMULATOR_TNT_SPAWN_DISABLED" : "SIMULATOR_TNT_SPAWN_ENABLED", player), new ArrayList<>(), !simulatorElement.isDisabled(), clickType -> {
|
inv.setItem(position, new SWItem(simulatorElement.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, BauSystem.MESSAGE.parse(simulatorElement.isDisabled() ? "SIMULATOR_TNT_SPAWN_DISABLED" : "SIMULATOR_TNT_SPAWN_ENABLED", player), new ArrayList<>(), !simulatorElement.isDisabled(), clickType -> {
|
||||||
recalculate.set(true);
|
|
||||||
if (!simulatorElement.isDisabled()) {
|
if (!simulatorElement.isDisabled()) {
|
||||||
tntSimulator.hide(simulatorElement);
|
tntSimulator.hide(simulatorElement);
|
||||||
}
|
}
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
package de.steamwar.bausystem.features.simulator.show;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
|
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
|
|
||||||
import de.steamwar.bausystem.shared.Position;
|
|
||||||
import de.steamwar.bausystem.shared.RoundedPosition;
|
|
||||||
import de.steamwar.bausystem.shared.ShowMode;
|
|
||||||
import de.steamwar.bausystem.utils.NMSWrapper;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class SimulatorEntityShowMode implements ShowMode<Position> {
|
|
||||||
|
|
||||||
protected final Player player;
|
|
||||||
|
|
||||||
private final Map<RoundedPosition, AbstractSimulatorEntity> entityMap = new HashMap<>();
|
|
||||||
|
|
||||||
public SimulatorEntityShowMode(Player player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show(Position position) {
|
|
||||||
RoundedPosition roundedPosition = new RoundedPosition(position);
|
|
||||||
AbstractSimulatorEntity entity = entityMap.computeIfAbsent(roundedPosition, pos -> createEntity(position.getLocation(), false));
|
|
||||||
entity.display(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AbstractSimulatorEntity createEntity(Vector position, boolean highlight) {
|
|
||||||
return NMSWrapper.impl.createSimulator(SimulatorStorage.WORLD, position, highlight);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hide(Position position) {
|
|
||||||
RoundedPosition roundedPosition = new RoundedPosition(position);
|
|
||||||
AbstractSimulatorEntity abstractSimulatorEntity = entityMap.get(roundedPosition);
|
|
||||||
if (abstractSimulatorEntity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (abstractSimulatorEntity.hide(player, false)) {
|
|
||||||
entityMap.remove(roundedPosition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
entityMap.forEach((roundedPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
|
|
||||||
entityMap.clear();
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.simulator.tnt;
|
package de.steamwar.bausystem.features.simulator.tnt;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.simulator.SimulatorPreview;
|
|
||||||
import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode;
|
import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
@ -51,7 +50,6 @@ public interface SimulatorElement {
|
|||||||
|
|
||||||
SWItem menu(Player p);
|
SWItem menu(Player p);
|
||||||
boolean locations(Map<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result, Region region, Location location); // Ticks to subtick order to spawning runnable to count of activations
|
boolean locations(Map<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result, Region region, Location location); // Ticks to subtick order to spawning runnable to count of activations
|
||||||
void locations(Map<Integer, Map<Integer, Set<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> result);
|
|
||||||
int tntCount();
|
int tntCount();
|
||||||
int tick();
|
int tick();
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|||||||
import de.steamwar.bausystem.region.utils.RegionType;
|
import de.steamwar.bausystem.region.utils.RegionType;
|
||||||
import de.steamwar.bausystem.shared.Pair;
|
import de.steamwar.bausystem.shared.Pair;
|
||||||
import de.steamwar.bausystem.shared.Position;
|
import de.steamwar.bausystem.shared.Position;
|
||||||
|
import de.steamwar.entity.RFallingBlockEntity;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -48,7 +49,7 @@ import java.util.*;
|
|||||||
@Getter
|
@Getter
|
||||||
public class TNTElement implements SimulatorElement {
|
public class TNTElement implements SimulatorElement {
|
||||||
|
|
||||||
private final AbstractSimulatorEntity entity;
|
private final RFallingBlockEntity entity;
|
||||||
TNTGroup tntGroup = null;
|
TNTGroup tntGroup = null;
|
||||||
|
|
||||||
private final Vector position;
|
private final Vector position;
|
||||||
@ -199,17 +200,6 @@ public class TNTElement implements SimulatorElement {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void locations(Map<Integer, Map<Integer, Set<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> result) {
|
|
||||||
if (disabled) return;
|
|
||||||
Location location = getPosition().toLocation(SimulatorStorage.WORLD);
|
|
||||||
result.computeIfAbsent(getTickOffset(), ignore -> new HashMap<>())
|
|
||||||
.computeIfAbsent(OrderUtils.order(order), ignore -> new HashSet<>())
|
|
||||||
.add(new Pair<>(
|
|
||||||
new SimulatorPreview.SimulatorPreviewTNTData(location.getX(), location.getY(), location.getZ(), fuseTicks, xVelocity, yVelocity, zVelocity),
|
|
||||||
count));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int tntCount() {
|
public int tntCount() {
|
||||||
return disabled ? 0 : count;
|
return disabled ? 0 : count;
|
||||||
|
@ -152,14 +152,6 @@ public class TNTGroup implements SimulatorElement {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void locations(Map<Integer, Map<Integer, Set<Pair<SimulatorPreview.SimulatorPreviewTNTData, Integer>>>> result) {
|
|
||||||
if (disabled) return;
|
|
||||||
for (TNTElement element : elements) {
|
|
||||||
element.locations(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int tntCount() {
|
public int tntCount() {
|
||||||
if (disabled) return 0;
|
if (disabled) return 0;
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 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.bausystem.shared;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public interface AbstractEntity {
|
|
||||||
void sendEntity(Player player);
|
|
||||||
void sendEntityDestroy(Player player);
|
|
||||||
}
|
|
@ -92,6 +92,7 @@ public class RayTraceUtils {
|
|||||||
for (REntity entity: entityList) {
|
for (REntity entity: entityList) {
|
||||||
if (!isOccluded(startPos.toVector(), direction, new Vector(entity.getX(), entity.getY() + 0.5, entity.getZ()))) continue;
|
if (!isOccluded(startPos.toVector(), direction, new Vector(entity.getX(), entity.getY() + 0.5, entity.getZ()))) continue;
|
||||||
double distanceSq = new Vector(entity.getX(), entity.getY() + 0.5, entity.getZ()).distanceSquared(startPos.toVector());
|
double distanceSq = new Vector(entity.getX(), entity.getY() + 0.5, entity.getZ()).distanceSquared(startPos.toVector());
|
||||||
|
if (distanceSq > 100.0) continue;
|
||||||
if (distanceSq < nearestDistanceSq) {
|
if (distanceSq < nearestDistanceSq) {
|
||||||
nearestHitEntity = entity;
|
nearestHitEntity = entity;
|
||||||
nearestHitResult = new RRayTraceResult(new Vector(entity.getX(), entity.getY() + 0.5, entity.getZ()), null, null, entity);
|
nearestHitResult = new RRayTraceResult(new Vector(entity.getX(), entity.getY() + 0.5, entity.getZ()), null, null, entity);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren