12
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:
spawnType.set(packet, EntityTypes.R);
break;
case FALLING_BLOCK:
spawnType.set(packet, EntityTypes.C);
break;
case ARMOR_STAND:
spawnLivingType.set(packet, 1);
break;

Datei anzeigen

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