Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-26 16:12:43 +01:00
Update entity mapping usage
Dieser Commit ist enthalten in:
Ursprung
fedda03062
Commit
5bd8786737
@ -23,7 +23,6 @@ import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityData;
|
||||
import com.viaversion.viabackwards.api.entities.storage.WrappedMetadata;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.Int2IntMapMappings;
|
||||
import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.data.entity.TrackedEntity;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
@ -163,28 +162,6 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps entity ids based on the enum constant's names.
|
||||
*
|
||||
* @param oldTypes entity types of the higher version
|
||||
* @param newTypeClass entity types enum class of the lower version
|
||||
* @param <E> new enum type
|
||||
*/
|
||||
@Override
|
||||
public <E extends Enum<E> & EntityType> void mapTypes(EntityType[] oldTypes, Class<E> newTypeClass) {
|
||||
if (typeMappings == null) {
|
||||
typeMappings = Int2IntMapMappings.of();
|
||||
}
|
||||
for (EntityType oldType : oldTypes) {
|
||||
try {
|
||||
E newType = Enum.valueOf(newTypeClass, oldType.name());
|
||||
typeMappings.setNewId(oldType.getId(), newType.getId());
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
// Don't warn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerMetaTypeHandler(
|
||||
@Nullable MetaType itemType,
|
||||
@Nullable MetaType blockStateType,
|
||||
|
@ -331,16 +331,6 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
mapTypes(EntityTypes1_14.values(), EntityTypes1_13.EntityType.class);
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_14.CAT, EntityTypes1_14.OCELOT).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.TRADER_LLAMA, EntityTypes1_14.LLAMA).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.FOX, EntityTypes1_14.WOLF).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.PANDA, EntityTypes1_14.POLAR_BEAR).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.PILLAGER, EntityTypes1_14.VILLAGER).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.WANDERING_TRADER, EntityTypes1_14.VILLAGER).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.RAVAGER, EntityTypes1_14.COW).jsonName();
|
||||
|
||||
filter().handler((event, meta) -> {
|
||||
int typeId = meta.metaType().typeId();
|
||||
if (typeId <= 15) {
|
||||
@ -499,6 +489,19 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<ClientboundPackets1_
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMappingDataLoaded() {
|
||||
mapTypes();
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_14.CAT, EntityTypes1_14.OCELOT).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.TRADER_LLAMA, EntityTypes1_14.LLAMA).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.FOX, EntityTypes1_14.WOLF).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.PANDA, EntityTypes1_14.POLAR_BEAR).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.PILLAGER, EntityTypes1_14.VILLAGER).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.WANDERING_TRADER, EntityTypes1_14.VILLAGER).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_14.RAVAGER, EntityTypes1_14.COW).jsonName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return EntityTypes1_14.getTypeFromId(typeId);
|
||||
|
@ -26,7 +26,6 @@ import com.viaversion.viaversion.api.data.entity.StoredEntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
@ -253,14 +252,6 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
|
||||
}
|
||||
});
|
||||
|
||||
mapEntityType(EntityTypes1_16.ZOMBIFIED_PIGLIN, EntityTypes1_15.ZOMBIE_PIGMAN);
|
||||
mapTypes(EntityTypes1_16.values(), EntityTypes1_15.class);
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_16.HOGLIN, EntityTypes1_16.COW).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_16.ZOGLIN, EntityTypes1_16.COW).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_16.PIGLIN, EntityTypes1_16.ZOMBIFIED_PIGLIN).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_16.STRIDER, EntityTypes1_16.MAGMA_CUBE).jsonName();
|
||||
|
||||
filter().type(EntityTypes1_16.ZOGLIN).cancel(16);
|
||||
filter().type(EntityTypes1_16.HOGLIN).cancel(15);
|
||||
|
||||
@ -308,6 +299,16 @@ public class EntityPackets1_16 extends EntityRewriter<ClientboundPackets1_16, Pr
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMappingDataLoaded() {
|
||||
mapTypes();
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_16.HOGLIN, EntityTypes1_16.COW).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_16.ZOGLIN, EntityTypes1_16.COW).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_16.PIGLIN, EntityTypes1_16.ZOMBIFIED_PIGLIN).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_16.STRIDER, EntityTypes1_16.MAGMA_CUBE).jsonName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return EntityTypes1_16.getTypeFromId(typeId);
|
||||
|
@ -23,7 +23,6 @@ import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.storage.BiomeStorage;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
@ -124,13 +123,17 @@ public class EntityPackets1_16_2 extends EntityRewriter<ClientboundPackets1_16_2
|
||||
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null,
|
||||
Types1_16.META_TYPES.particleType, Types1_16.META_TYPES.componentType, Types1_16.META_TYPES.optionalComponentType);
|
||||
|
||||
mapTypes(EntityTypes1_16_2.values(), EntityTypes1_16.class);
|
||||
mapEntityTypeWithData(EntityTypes1_16_2.PIGLIN_BRUTE, EntityTypes1_16_2.PIGLIN).jsonName();
|
||||
|
||||
filter().type(EntityTypes1_16_2.ABSTRACT_PIGLIN).index(15).toIndex(16);
|
||||
filter().type(EntityTypes1_16_2.ABSTRACT_PIGLIN).index(16).toIndex(15);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMappingDataLoaded() {
|
||||
mapTypes();
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_16_2.PIGLIN_BRUTE, EntityTypes1_16_2.PIGLIN).jsonName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return EntityTypes1_16_2.getTypeFromId(typeId);
|
||||
|
@ -22,7 +22,6 @@ import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.Protocol1_16_4To1_17;
|
||||
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
@ -178,7 +177,6 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
||||
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, null,
|
||||
Types1_16.META_TYPES.componentType, Types1_16.META_TYPES.optionalComponentType);
|
||||
|
||||
mapTypes(EntityTypes1_17.values(), EntityTypes1_16_2.class);
|
||||
filter().type(EntityTypes1_17.AXOLOTL).cancel(17);
|
||||
filter().type(EntityTypes1_17.AXOLOTL).cancel(18);
|
||||
filter().type(EntityTypes1_17.AXOLOTL).cancel(19);
|
||||
@ -187,17 +185,21 @@ public final class EntityPackets1_17 extends EntityRewriter<ClientboundPackets1_
|
||||
|
||||
filter().type(EntityTypes1_17.GOAT).cancel(17);
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_17.AXOLOTL, EntityTypes1_17.TROPICAL_FISH).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_17.GOAT, EntityTypes1_17.SHEEP).jsonName();
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_17.GLOW_SQUID, EntityTypes1_17.SQUID).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_17.GLOW_ITEM_FRAME, EntityTypes1_17.ITEM_FRAME);
|
||||
|
||||
filter().type(EntityTypes1_17.SHULKER).addIndex(17); // TODO Handle attachment pos?
|
||||
|
||||
filter().removeIndex(7); // Ticks frozen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMappingDataLoaded() {
|
||||
mapTypes();
|
||||
|
||||
mapEntityTypeWithData(EntityTypes1_17.AXOLOTL, EntityTypes1_17.TROPICAL_FISH).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_17.GOAT, EntityTypes1_17.SHEEP).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_17.GLOW_SQUID, EntityTypes1_17.SQUID).jsonName();
|
||||
mapEntityTypeWithData(EntityTypes1_17.GLOW_ITEM_FRAME, EntityTypes1_17.ITEM_FRAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(int typeId) {
|
||||
return EntityTypes1_17.getTypeFromId(typeId);
|
||||
|
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren