Add BasicShowMode
Dieser Commit ist enthalten in:
Ursprung
33584589a5
Commit
4824893d79
@ -1,10 +1,9 @@
|
||||
package de.steamwar.bausystem.tracer;
|
||||
|
||||
import net.minecraft.server.v1_12_R1.Blocks;
|
||||
import net.minecraft.server.v1_12_R1.EntityFallingBlock;
|
||||
import net.minecraft.server.v1_12_R1.EnumMoveType;
|
||||
import net.minecraft.server.v1_12_R1.*;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TNTEntity_12 extends EntityFallingBlock implements AbstractTNTEntity {
|
||||
@ -30,6 +29,15 @@ public class TNTEntity_12 extends EntityFallingBlock implements AbstractTNTEntit
|
||||
|
||||
@Override
|
||||
public AbstractTNTEntity display(Player player) {
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(this, 0);
|
||||
ReflectionUtils.setValue("f", packetPlayOutSpawnEntity, 0);
|
||||
ReflectionUtils.setValue("g", packetPlayOutSpawnEntity, 0);
|
||||
ReflectionUtils.setValue("h", packetPlayOutSpawnEntity, 0);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
package de.steamwar.bausystem.tracer;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.Blocks;
|
||||
import net.minecraft.server.v1_15_R1.EntityFallingBlock;
|
||||
import net.minecraft.server.v1_15_R1.EnumMoveType;
|
||||
import net.minecraft.server.v1_15_R1.Vec3D;
|
||||
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;
|
||||
|
||||
public class TNTEntity_15 extends EntityFallingBlock implements AbstractTNTEntity {
|
||||
@ -31,11 +29,23 @@ public class TNTEntity_15 extends EntityFallingBlock implements AbstractTNTEntit
|
||||
|
||||
@Override
|
||||
public AbstractTNTEntity display(Player player) {
|
||||
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(this);
|
||||
ReflectionUtils.setValue("f", packetPlayOutSpawnEntity, 0);
|
||||
ReflectionUtils.setValue("g", packetPlayOutSpawnEntity, 0);
|
||||
ReflectionUtils.setValue("h", packetPlayOutSpawnEntity, 0);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutSpawnEntity);
|
||||
|
||||
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityMetadata);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractTNTEntity hide(Player player) {
|
||||
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -43,4 +53,5 @@ public class TNTEntity_15 extends EntityFallingBlock implements AbstractTNTEntit
|
||||
public void remove() {
|
||||
killEntity();
|
||||
}
|
||||
|
||||
}
|
||||
|
13
BauSystem_API/src/de/steamwar/bausystem/tracer/ReflectionUtils.java
Normale Datei
13
BauSystem_API/src/de/steamwar/bausystem/tracer/ReflectionUtils.java
Normale Datei
@ -0,0 +1,13 @@
|
||||
package de.steamwar.bausystem.tracer;
|
||||
|
||||
public class ReflectionUtils {
|
||||
|
||||
static void setValue(String field, Object object, Object value) {
|
||||
try {
|
||||
object.getClass().getDeclaredField(field).set(object, value);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package de.steamwar.bausystem.tracer.show;
|
||||
|
||||
import de.steamwar.bausystem.tracer.TNTPosition;
|
||||
import net.minecraft.server.v1_15_R1.*;
|
||||
|
||||
public class TNTEntity extends EntityFallingBlock {
|
||||
|
||||
private TNTPosition TNTPosition;
|
||||
|
||||
public TNTEntity(World world, TNTPosition TNTPosition) {
|
||||
super(world, TNTPosition.getLocation().getX(), TNTPosition.getLocation().getY(), TNTPosition.getLocation().getZ(), Blocks.TNT.getBlockData());
|
||||
this.TNTPosition = TNTPosition;
|
||||
|
||||
this.setNoGravity(true);
|
||||
this.ticksLived = -12000;
|
||||
this.dropItem = false;
|
||||
this.setCustomNameVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package de.steamwar.bausystem.tracer.show;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.tracer.TNTPosition;
|
||||
import de.steamwar.bausystem.tracer.show.mode.BasicShowMode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -18,7 +19,7 @@ public class TraceShowManager implements Listener {
|
||||
|
||||
public static void show(Player player){
|
||||
hide(player);
|
||||
ShowMode showMode;
|
||||
ShowMode showMode = new BasicShowMode(player);
|
||||
StoredRecords.showAll(showMode);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ public class BasicShowMode implements ShowMode {
|
||||
public void show(TNTPosition position) {
|
||||
switch (Core.getVersion()) {
|
||||
case 12:
|
||||
tntEntitySet.add(new TNTEntity_12(player.getWorld(), position, player));
|
||||
// tntEntitySet.add(new TNTEntity_12(player.getWorld(), position, player));
|
||||
break;
|
||||
default:
|
||||
tntEntitySet.add(new TNTEntity_15(player.getWorld(), position, player));
|
||||
@ -36,6 +36,8 @@ public class BasicShowMode implements ShowMode {
|
||||
@Override
|
||||
public void hide() {
|
||||
tntEntitySet.forEach(abstractTNTEntity -> abstractTNTEntity.hide(player));
|
||||
tntEntitySet.forEach(AbstractTNTEntity::remove);
|
||||
tntEntitySet.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren