Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-09-07 21:32:52 +02:00
Update Via API usage (#747)
Dieser Commit ist enthalten in:
Ursprung
4d6c6a2da1
Commit
8f92d55747
@ -227,8 +227,8 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
||||
|
||||
public PacketHandler getFallingBlockHandler() {
|
||||
return wrapper -> {
|
||||
final Optional<EntityTypes1_12.ObjectType> type = EntityTypes1_12.ObjectType.findById(wrapper.get(Types.BYTE, 0));
|
||||
if (type.isPresent() && type.get() == EntityTypes1_12.ObjectType.FALLING_BLOCK) {
|
||||
final EntityTypes1_12.ObjectType type = EntityTypes1_12.ObjectType.findById(wrapper.get(Types.BYTE, 0));
|
||||
if (type == EntityTypes1_12.ObjectType.FALLING_BLOCK) {
|
||||
final int objectData = wrapper.get(Types.INT, 0);
|
||||
|
||||
final IdAndData block = handleBlock(objectData & 4095, objectData >> 12 & 15);
|
||||
|
@ -56,14 +56,14 @@ public class EntityPacketRewriter1_10 extends LegacyEntityRewriter<ClientboundPa
|
||||
|
||||
// Track Entity
|
||||
handler(getObjectTrackerHandler());
|
||||
handler(getObjectRewriter(id -> EntityTypes1_11.ObjectType.findById(id).orElse(null)));
|
||||
handler(getObjectRewriter(EntityTypes1_11.ObjectType::findById));
|
||||
|
||||
handler(protocol.getItemRewriter().getFallingBlockHandler());
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.ADD_EXPERIENCE_ORB, EntityTypes1_10.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.ADD_GLOBAL_ENTITY, EntityTypes1_10.EntityType.WEATHER);
|
||||
registerTracker(ClientboundPackets1_9_3.ADD_GLOBAL_ENTITY, EntityTypes1_10.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.ADD_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
|
@ -51,12 +51,12 @@ public class EntityPacketRewriter1_11_1 extends LegacyEntityRewriter<Clientbound
|
||||
|
||||
// Track Entity
|
||||
handler(getObjectTrackerHandler());
|
||||
handler(getObjectRewriter(id -> EntityTypes1_11.ObjectType.findById(id).orElse(null)));
|
||||
handler(getObjectRewriter(EntityTypes1_11.ObjectType::findById));
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.ADD_EXPERIENCE_ORB, EntityTypes1_11.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.ADD_GLOBAL_ENTITY, EntityTypes1_11.EntityType.WEATHER);
|
||||
registerTracker(ClientboundPackets1_9_3.ADD_GLOBAL_ENTITY, EntityTypes1_11.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.ADD_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
@ -110,7 +110,7 @@ public class EntityPacketRewriter1_11_1 extends LegacyEntityRewriter<Clientbound
|
||||
@Override
|
||||
protected void registerRewrites() {
|
||||
// Handle non-existing firework metadata (index 7 entity id for boosting)
|
||||
filter().type(EntityTypes1_11.EntityType.FIREWORK).cancel(7);
|
||||
filter().type(EntityTypes1_11.EntityType.FIREWORK_ROCKET).cancel(7);
|
||||
|
||||
// Handle non-existing pig metadata (index 14 - boost time)
|
||||
filter().type(EntityTypes1_11.EntityType.PIG).cancel(14);
|
||||
|
@ -326,7 +326,7 @@ public class BlockItemPacketRewriter1_11 extends LegacyBlockItemRewriter<Clientb
|
||||
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
|
||||
EntityTracker entTracker = user.getEntityTracker(Protocol1_11To1_10.class);
|
||||
StoredEntityData entityData = entTracker.entityData(tracker.getEntityId());
|
||||
return entityData != null && entityData.type().is(EntityTypes1_11.EntityType.LIAMA);
|
||||
return entityData != null && entityData.type().is(EntityTypes1_11.EntityType.LLAMA);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -80,14 +80,14 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
|
||||
// Track Entity
|
||||
handler(getObjectTrackerHandler());
|
||||
handler(getObjectRewriter(id -> EntityTypes1_11.ObjectType.findById(id).orElse(null)));
|
||||
handler(getObjectRewriter(EntityTypes1_11.ObjectType::findById));
|
||||
|
||||
handler(protocol.getItemRewriter().getFallingBlockHandler());
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_9_3.ADD_EXPERIENCE_ORB, EntityTypes1_11.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_9_3.ADD_GLOBAL_ENTITY, EntityTypes1_11.EntityType.WEATHER);
|
||||
registerTracker(ClientboundPackets1_9_3.ADD_GLOBAL_ENTITY, EntityTypes1_11.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.ADD_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
@ -189,16 +189,16 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.SKELETON_HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(4)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.ZOMBIE_HORSE, EntityTypes1_11.EntityType.HORSE).spawnMetadata(storage -> storage.add(getHorseMetaType(3)));
|
||||
// New mobs
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOCATION_FANGS, EntityTypes1_11.EntityType.SHULKER);
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOCATION_ILLAGER, EntityTypes1_11.EntityType.VILLAGER).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOKER_FANGS, EntityTypes1_11.EntityType.SHULKER);
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.EVOKER, EntityTypes1_11.EntityType.VILLAGER).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.VEX, EntityTypes1_11.EntityType.BAT).plainName();
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.VINDICATOR, EntityTypes1_11.EntityType.VILLAGER).plainName().spawnMetadata(storage -> storage.add(new EntityData(13, EntityDataTypes1_9.VAR_INT, 4))); // Base Profession
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.LLAMA, EntityTypes1_11.EntityType.HORSE).plainName().spawnMetadata(storage -> storage.add(getHorseMetaType(1)));
|
||||
mapEntityTypeWithData(EntityTypes1_11.EntityType.LLAMA_SPIT, EntityTypes1_11.EntityType.SNOWBALL);
|
||||
|
||||
mapObjectType(EntityTypes1_11.ObjectType.LIAMA_SPIT, EntityTypes1_11.ObjectType.SNOWBALL, -1);
|
||||
mapObjectType(EntityTypes1_11.ObjectType.LLAMA_SPIT, EntityTypes1_11.ObjectType.SNOWBALL, -1);
|
||||
// Replace with endertorchthingies
|
||||
mapObjectType(EntityTypes1_11.ObjectType.EVOCATION_FANGS, EntityTypes1_11.ObjectType.FALLING_BLOCK, 198 | 1 << 12);
|
||||
mapObjectType(EntityTypes1_11.ObjectType.EVOKER_FANGS, EntityTypes1_11.ObjectType.FALLING_BLOCK, 198 | 1 << 12);
|
||||
|
||||
// Handle ElderGuardian & target metadata
|
||||
filter().type(EntityTypes1_11.EntityType.GUARDIAN).index(12).handler((event, meta) -> {
|
||||
@ -232,7 +232,7 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
});
|
||||
|
||||
// Handle Evocation Illager
|
||||
filter().type(EntityTypes1_11.EntityType.EVOCATION_ILLAGER).index(12).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.EVOKER).index(12).handler((event, meta) -> {
|
||||
event.setIndex(13);
|
||||
meta.setTypeAndValue(EntityDataTypes1_9.VAR_INT, ((Byte) meta.getValue()).intValue()); // Change the profession for the states
|
||||
});
|
||||
@ -243,7 +243,7 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
});
|
||||
|
||||
// Handle VindicationIllager
|
||||
filter().type(EntityTypes1_11.EntityType.VINDICATION_ILLAGER).index(12).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.VINDICATOR).index(12).handler((event, meta) -> {
|
||||
event.setIndex(13);
|
||||
meta.setTypeAndValue(EntityDataTypes1_9.VAR_INT, ((Number) meta.getValue()).intValue() == 1 ? 2 : 4);
|
||||
});
|
||||
@ -283,7 +283,7 @@ public class EntityPacketRewriter1_11 extends LegacyEntityRewriter<ClientboundPa
|
||||
});
|
||||
|
||||
// Get rid of Liama metadata
|
||||
filter().type(EntityTypes1_11.EntityType.LIAMA).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_11.EntityType.LLAMA).handler((event, meta) -> {
|
||||
StoredEntityData data = storedEntityData(event);
|
||||
ChestedHorseStorage storage = data.get(ChestedHorseStorage.class);
|
||||
|
||||
|
@ -59,14 +59,14 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
|
||||
|
||||
// Track Entity
|
||||
handler(getObjectTrackerHandler());
|
||||
handler(getObjectRewriter(id -> EntityTypes1_12.ObjectType.findById(id).orElse(null)));
|
||||
handler(getObjectRewriter(EntityTypes1_12.ObjectType::findById));
|
||||
|
||||
handler(protocol.getItemRewriter().getFallingBlockHandler());
|
||||
}
|
||||
});
|
||||
|
||||
registerTracker(ClientboundPackets1_12.ADD_EXPERIENCE_ORB, EntityTypes1_12.EntityType.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_12.ADD_GLOBAL_ENTITY, EntityTypes1_12.EntityType.WEATHER);
|
||||
registerTracker(ClientboundPackets1_12.ADD_GLOBAL_ENTITY, EntityTypes1_12.EntityType.LIGHTNING_BOLT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12.ADD_MOB, new PacketHandlers() {
|
||||
@Override
|
||||
@ -196,10 +196,9 @@ public class EntityPacketRewriter1_12 extends LegacyEntityRewriter<ClientboundPa
|
||||
});
|
||||
|
||||
// Handle Illager
|
||||
filter().type(EntityTypes1_12.EntityType.EVOCATION_ILLAGER).cancel(12);
|
||||
filter().type(EntityTypes1_12.EntityType.EVOCATION_ILLAGER).index(13).toIndex(12);
|
||||
filter().type(EntityTypes1_12.EntityType.EVOKER).removeIndex(12);
|
||||
|
||||
filter().type(EntityTypes1_12.EntityType.ILLUSION_ILLAGER).index(0).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_12.EntityType.ILLUSIONER).index(0).handler((event, meta) -> {
|
||||
byte mask = (byte) meta.getValue();
|
||||
|
||||
if ((mask & 0x20) == 0x20) {
|
||||
|
@ -155,7 +155,7 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter<Clientbound
|
||||
filter().type(EntityTypes1_13.EntityType.TRIDENT).index(8).toIndex(7);
|
||||
|
||||
// Rewrite Minecart blocks
|
||||
filter().type(EntityTypes1_13.EntityType.MINECART_ABSTRACT).index(9).handler((event, meta) -> {
|
||||
filter().type(EntityTypes1_13.EntityType.ABSTRACT_MINECART).index(9).handler((event, meta) -> {
|
||||
int data = (int) meta.getValue();
|
||||
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
|
||||
});
|
||||
|
@ -90,10 +90,7 @@ public class EntityPacketRewriter1_13 extends LegacyEntityRewriter<ClientboundPa
|
||||
handler(getObjectTrackerHandler());
|
||||
|
||||
handler(wrapper -> {
|
||||
Optional<EntityTypes1_13.ObjectType> optionalType = EntityTypes1_13.ObjectType.findById(wrapper.get(Types.BYTE, 0));
|
||||
if (optionalType.isEmpty()) return;
|
||||
|
||||
EntityTypes1_13.ObjectType type = optionalType.get();
|
||||
EntityTypes1_13.ObjectType type = EntityTypes1_13.ObjectType.findById(wrapper.get(Types.BYTE, 0));
|
||||
if (type == EntityTypes1_13.ObjectType.FALLING_BLOCK) {
|
||||
int blockState = wrapper.get(Types.INT, 0);
|
||||
int combined = Protocol1_13To1_12_2.MAPPINGS.getNewBlockStateId(blockState);
|
||||
@ -308,8 +305,8 @@ public class EntityPacketRewriter1_13 extends LegacyEntityRewriter<ClientboundPa
|
||||
filter().type(EntityTypes1_13.EntityType.TURTLE).cancel(18); // Traveling
|
||||
|
||||
// Remove additional fish meta
|
||||
filter().type(EntityTypes1_13.EntityType.ABSTRACT_FISHES).cancel(12);
|
||||
filter().type(EntityTypes1_13.EntityType.ABSTRACT_FISHES).cancel(13);
|
||||
filter().type(EntityTypes1_13.EntityType.ABSTRACT_FISH).cancel(12);
|
||||
filter().type(EntityTypes1_13.EntityType.ABSTRACT_FISH).cancel(13);
|
||||
|
||||
// Remove phantom size
|
||||
filter().type(EntityTypes1_13.EntityType.PHANTOM).cancel(12);
|
||||
|
@ -17,7 +17,6 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.v1_14to1_13_2.rewriter;
|
||||
|
||||
import com.viaversion.viabackwards.ViaBackwards;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityReplacement;
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityPositionHandler;
|
||||
import com.viaversion.viabackwards.api.rewriters.LegacyEntityRewriter;
|
||||
@ -36,7 +35,6 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
@ -141,8 +139,8 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
int id = wrapper.get(Types.BYTE, 0);
|
||||
int mappedId = newEntityId(id);
|
||||
EntityTypes1_13.EntityType entityType = EntityTypes1_13.getTypeFromId(mappedId, false);
|
||||
EntityTypes1_13.ObjectType objectType;
|
||||
if (entityType.isOrHasParent(EntityTypes1_13.EntityType.MINECART_ABSTRACT)) {
|
||||
EntityTypes1_13.ObjectType objectType = null;
|
||||
if (entityType.isOrHasParent(EntityTypes1_13.EntityType.ABSTRACT_MINECART)) {
|
||||
objectType = EntityTypes1_13.ObjectType.MINECART;
|
||||
int data = switch (entityType) {
|
||||
case CHEST_MINECART -> 1;
|
||||
@ -156,7 +154,12 @@ public class EntityPacketRewriter1_14 extends LegacyEntityRewriter<ClientboundPa
|
||||
if (data != 0)
|
||||
wrapper.set(Types.INT, 0, data);
|
||||
} else {
|
||||
objectType = EntityTypes1_13.ObjectType.fromEntityType(entityType).orElse(null);
|
||||
for (final EntityTypes1_13.ObjectType type : EntityTypes1_13.ObjectType.values()) {
|
||||
if (type.getType() == entityType) {
|
||||
objectType = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (objectType == null) return;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren