SteamWar/BauSystem
Archiviert
13
0

Tracer-entity #147

Manuell gemergt
YoyoNow hat 47 Commits von Tracer-entity nach master 2020-12-27 22:16:04 +01:00 zusammengeführt
6 geänderte Dateien mit 44 neuen und 34 gelöschten Zeilen
Nur Änderungen aus Commit 4824893d79 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -1,10 +1,9 @@
package de.steamwar.bausystem.tracer; package de.steamwar.bausystem.tracer;
import net.minecraft.server.v1_12_R1.Blocks; import net.minecraft.server.v1_12_R1.*;
import net.minecraft.server.v1_12_R1.EntityFallingBlock;
import net.minecraft.server.v1_12_R1.EnumMoveType;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld; import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class TNTEntity_12 extends EntityFallingBlock implements AbstractTNTEntity { public class TNTEntity_12 extends EntityFallingBlock implements AbstractTNTEntity {
@ -30,6 +29,15 @@ public class TNTEntity_12 extends EntityFallingBlock implements AbstractTNTEntit
@Override @Override
public AbstractTNTEntity display(Player player) { 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; return this;
} }

Datei anzeigen

@ -1,11 +1,9 @@
package de.steamwar.bausystem.tracer; package de.steamwar.bausystem.tracer;
import net.minecraft.server.v1_15_R1.Blocks; import net.minecraft.server.v1_15_R1.*;
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 org.bukkit.World; import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; 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.entity.Player;
public class TNTEntity_15 extends EntityFallingBlock implements AbstractTNTEntity { public class TNTEntity_15 extends EntityFallingBlock implements AbstractTNTEntity {
@ -31,11 +29,23 @@ public class TNTEntity_15 extends EntityFallingBlock implements AbstractTNTEntit
@Override @Override
public AbstractTNTEntity display(Player player) { 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; return this;
} }
@Override @Override
public AbstractTNTEntity hide(Player player) { public AbstractTNTEntity hide(Player player) {
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy);
return this; return this;
} }
@ -43,4 +53,5 @@ public class TNTEntity_15 extends EntityFallingBlock implements AbstractTNTEntit
public void remove() { public void remove() {
killEntity(); killEntity();
} }
} }

Datei anzeigen

@ -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) {
}
}
}

Datei anzeigen

@ -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) {
}
}

Datei anzeigen

@ -2,6 +2,7 @@ package de.steamwar.bausystem.tracer.show;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.tracer.TNTPosition; import de.steamwar.bausystem.tracer.TNTPosition;
import de.steamwar.bausystem.tracer.show.mode.BasicShowMode;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -18,7 +19,7 @@ public class TraceShowManager implements Listener {
public static void show(Player player){ public static void show(Player player){
hide(player); hide(player);
ShowMode showMode; ShowMode showMode = new BasicShowMode(player);
StoredRecords.showAll(showMode); StoredRecords.showAll(showMode);
} }

Datei anzeigen

@ -25,7 +25,7 @@ public class BasicShowMode implements ShowMode {
public void show(TNTPosition position) { public void show(TNTPosition position) {
switch (Core.getVersion()) { switch (Core.getVersion()) {
case 12: case 12:
tntEntitySet.add(new TNTEntity_12(player.getWorld(), position, player)); // tntEntitySet.add(new TNTEntity_12(player.getWorld(), position, player));
break; break;
default: default:
tntEntitySet.add(new TNTEntity_15(player.getWorld(), position, player)); tntEntitySet.add(new TNTEntity_15(player.getWorld(), position, player));
@ -36,6 +36,8 @@ public class BasicShowMode implements ShowMode {
@Override @Override
public void hide() { public void hide() {
tntEntitySet.forEach(abstractTNTEntity -> abstractTNTEntity.hide(player)); tntEntitySet.forEach(abstractTNTEntity -> abstractTNTEntity.hide(player));
tntEntitySet.forEach(AbstractTNTEntity::remove);
tntEntitySet.clear();
} }
} }