SteamWar/SpigotCore
Archiviert
13
0

Add FallingBlock
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2023-01-10 19:08:37 +01:00
Ursprung 8886cc5562
Commit 81a77fd1de
3 geänderte Dateien mit 24 neuen und 34 gelöschten Zeilen

Datei anzeigen

@ -53,6 +53,9 @@ public class ProtocolWrapper18 implements ProtocolWrapper {
case ITEM_FRAME: case ITEM_FRAME:
spawnType.set(packet, EntityTypes.R); spawnType.set(packet, EntityTypes.R);
break; break;
case FALLING_BLOCK:
spawnType.set(packet, EntityTypes.C);
break;
case ARMOR_STAND: case ARMOR_STAND:
spawnLivingType.set(packet, 1); spawnLivingType.set(packet, 1);
break; break;

Datei anzeigen

@ -55,6 +55,9 @@ public class ProtocolWrapper19 implements ProtocolWrapper {
case ARMOR_STAND: case ARMOR_STAND:
spawnType.set(packet, EntityTypes.d); spawnType.set(packet, EntityTypes.d);
break; break;
case FALLING_BLOCK:
spawnType.set(packet, EntityTypes.E);
break;
default: default:
throw new IllegalArgumentException(type.name() + " is not implemented"); throw new IllegalArgumentException(type.name() + " is not implemented");
} }

Datei anzeigen

@ -23,6 +23,9 @@ import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import java.util.HashMap;
import java.util.Map;
public class ProtocolWrapper8 implements ProtocolWrapper { public class ProtocolWrapper8 implements ProtocolWrapper {
private static final Reflection.FieldAccessor<?> equipmentSlot; private static final Reflection.FieldAccessor<?> equipmentSlot;
@ -44,50 +47,31 @@ public class ProtocolWrapper8 implements ProtocolWrapper {
private static final Reflection.FieldAccessor<?> spawnType; private static final Reflection.FieldAccessor<?> spawnType;
private static final Reflection.FieldAccessor<Integer> spawnLivingType = Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1); private static final Reflection.FieldAccessor<Integer> spawnLivingType = Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1);
private static final Object tnt; private static final Map<EntityType, Object> types = new HashMap<>();
private static final Object arrow;
private static final Object fireball;
private static final Object itemFrame;
private static final int armorStand;
static { static {
if(Core.getVersion() < 14) { if(Core.getVersion() < 14) {
spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, Core.getVersion() > 8 ? 6 : 9); spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, Core.getVersion() > 8 ? 6 : 9);
tnt = 50; types.put(EntityType.PRIMED_TNT, 50);
arrow = 60; types.put(EntityType.ARMOR_STAND, 30);
fireball = 63; types.put(EntityType.ARROW, 60);
armorStand = 30; types.put(EntityType.FIREBALL, 63);
itemFrame = 18; types.put(EntityType.ITEM_FRAME, 18);
types.put(EntityType.FALLING_BLOCK, 21);
} else { } else {
Class<?> entityTypes = Reflection.getClass("{nms.world.entity}.EntityTypes"); Class<?> entityTypes = Reflection.getClass("{nms.world.entity}.EntityTypes");
spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, entityTypes, 0); spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, entityTypes, 0);
tnt = Reflection.getField(entityTypes, "TNT", entityTypes).get(null); types.put(EntityType.ARMOR_STAND, 1);
arrow = Reflection.getField(entityTypes, "ARROW", entityTypes).get(null); for(EntityType type : new EntityType[]{EntityType.PRIMED_TNT, EntityType.ARROW, EntityType.FIREBALL, EntityType.ITEM_FRAME, EntityType.FALLING_BLOCK})
fireball = Reflection.getField(entityTypes, "FIREBALL", entityTypes).get(null); types.put(type, Reflection.getField(entityTypes, type.name(), entityTypes).get(null));
itemFrame = Reflection.getField(entityTypes, "ITEM_FRAME", entityTypes).get(null);
armorStand = 1;
} }
} }
@Override @Override
public void setSpawnPacketType(Object packet, EntityType type) { public void setSpawnPacketType(Object packet, EntityType type) {
switch(type) { if(type.isAlive())
case PRIMED_TNT: spawnLivingType.set(packet, types.get(type));
spawnType.set(packet, tnt); else
break; spawnType.set(packet, types.get(type));
case ARROW:
spawnType.set(packet, arrow);
break;
case FIREBALL:
spawnType.set(packet, fireball);
break;
case ITEM_FRAME:
spawnType.set(packet, itemFrame);
break;
case ARMOR_STAND:
spawnLivingType.set(packet, armorStand);
break;
default:
throw new IllegalArgumentException(type.name() + " is not implemented");
}
} }
private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClass, playerInfoPacket, GameProfile.class, int.class, enumGamemode, iChatBaseComponent); private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClass, playerInfoPacket, GameProfile.class, int.class, enumGamemode, iChatBaseComponent);