3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-07-26 00:48:03 +02:00

Configurable particle mappings, map areaeffectcloud data

Dieser Commit ist enthalten in:
KennyTV 2020-09-21 11:23:10 +02:00
Ursprung 4817bf7e2b
Commit 922afc12a5
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
16 geänderte Dateien mit 65 neuen und 89 gelöschten Zeilen

Datei anzeigen

@ -12,6 +12,7 @@ import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
import org.jetbrains.annotations.Nullable;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.ParticleMappings;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.entities.EntityType;
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
@ -21,6 +22,7 @@ import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.Particle;
import us.myles.ViaVersion.exception.CancelException;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.viaversion.libs.fastutil.ints.Int2IntMap;
@ -262,6 +264,20 @@ public abstract class EntityRewriterBase<T extends BackwardsProtocol> extends Re
return user.get(EntityTracker.class).get(getProtocol());
}
protected void rewriteParticle(Particle particle) {
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
int id = particle.getId();
if (id == mappings.getBlockId() || id == mappings.getFallingDustId()) {
Particle.ParticleData data = particle.getArguments().get(0);
data.setValue(protocol.getMappingData().getNewBlockStateId(data.get()));
} else if (id == mappings.getItemId()) {
Particle.ParticleData data = particle.getArguments().get(0);
data.setValue(protocol.getMappingData().getNewItemId(data.get()));
}
particle.setId(protocol.getMappingData().getNewParticleId(id));
}
protected abstract EntityType getTypeFromId(int typeId);
public int getOldEntityId(int newId) {

Datei anzeigen

@ -496,8 +496,7 @@ public class BlockItemPackets1_14 extends nl.matsv.viabackwards.api.rewriters.It
}
});
blockRewriter.registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, 3, 23, 32,
EntityPackets1_14::getOldParticleId, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM, Type.FLOAT);
itemRewriter.registerSpawnParticle(ClientboundPackets1_14.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.FLOAT);
protocol.registerOutgoing(ClientboundPackets1_14.MAP_DATA, new PacketRemapper() {
@Override

Datei anzeigen

@ -391,8 +391,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
registerMetaHandler().filter(Entity1_14Types.EntityType.AREA_EFFECT_CLOUD, 10).handle(e -> {
Metadata meta = e.getData();
Particle particle = (Particle) meta.getValue();
particle.setId(getOldParticleId(particle.getId()));
rewriteParticle((Particle) meta.getValue());
return meta;
});
@ -549,28 +548,6 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
}
}
public static int getOldParticleId(int id) {
if (id == 56 || id == 57) return 5; // campfire cosy smoke, signal smoke -> cloud
if (id >= 45) {
id -= 1; // new 39 -> 44
}
if (id >= 30) {
id -= 1; // skip new short happy villager
}
if (id >= 28) {
id -= 1; // new 24 -> 27
}
if (id >= 13) {
id -= 1; // new water drip 11 -> 13
}
if (id == 10 || id == 11) {
id = 9; // set both landing/falling lava to dripping lava
} else if (id > 11) {
id -= 2;
}
return id;
}
@Override
protected EntityType getTypeFromId(int typeId) {
return Entity1_14Types.getTypeFromId(typeId);

Datei anzeigen

@ -13,6 +13,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.Particle;
import us.myles.ViaVersion.api.type.types.version.Types1_13;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
@ -128,15 +129,15 @@ public class EntityPackets1_13_1 extends LegacyEntityRewriter<Protocol1_13To1_13
// Rewrite items & blocks
registerMetaHandler().handle(e -> {
Metadata meta = e.getData();
if (meta.getMetaType() == MetaType1_13.Slot) {
InventoryPackets1_13_1.toClient((Item) meta.getValue());
} else if (meta.getMetaType() == MetaType1_13.BlockID) {
// Convert to new block id
int data = (int) meta.getValue();
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));
} else if (meta.getMetaType() == MetaType1_13.PARTICLE) {
rewriteParticle((Particle) meta.getValue());
}
return meta;
});

Datei anzeigen

@ -59,6 +59,8 @@ public class InventoryPackets1_13_1 {
itemRewriter.registerEntityEquipment(ClientboundPackets1_13.ENTITY_EQUIPMENT, Type.FLAT_ITEM);
itemRewriter.registerClickWindow(ServerboundPackets1_13.CLICK_WINDOW, Type.FLAT_ITEM);
itemRewriter.registerCreativeInvAction(ServerboundPackets1_13.CREATIVE_INVENTORY_ACTION, Type.FLAT_ITEM);
itemRewriter.registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, Type.FLAT_ITEM, Type.FLOAT);
}
public static void toClient(Item item) {

Datei anzeigen

@ -42,6 +42,5 @@ public class WorldPackets1_13_1 {
blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE);
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001);
blockRewriter.registerSpawnParticle(ClientboundPackets1_13.SPAWN_PARTICLE, 3, 20, 27, InventoryPackets1_13_1::toClient, Type.FLAT_ITEM, Type.FLOAT);
}
}

Datei anzeigen

@ -1,19 +0,0 @@
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data;
public class ParticleMapping {
public static int getOldId(int newId) {
switch (newId) {
case 58: // dripping honey -> dripping lava
return 9;
case 59: // falling honey -> falling lava
return 10;
case 60: // landing honey -> landing lava
return 11;
case 61: // falling nectar -> falling water
return 13;
default:
return newId;
}
}
}

Datei anzeigen

@ -2,7 +2,6 @@ package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets;
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ParticleMapping;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
@ -117,11 +116,6 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int id = wrapper.get(Type.INT, 0);
int mappedId = ParticleMapping.getOldId(id);
if (id != mappedId) {
wrapper.set(Type.INT, 0, mappedId);
}
if (id == 3 || id == 23) {
int data = wrapper.passthrough(Type.VAR_INT);
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
@ -129,6 +123,11 @@ public class BlockItemPackets1_15 extends nl.matsv.viabackwards.api.rewriters.It
Item item = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));
wrapper.write(Type.FLAT_VAR_INT_ITEM, item);
}
int mappedId = protocol.getMappingData().getNewParticleId(id);
if (id != mappedId) {
wrapper.set(Type.INT, 0, mappedId);
}
}
});
}

Datei anzeigen

@ -5,7 +5,6 @@ import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ParticleMapping;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.entities.Entity1_15Types;
import us.myles.ViaVersion.api.entities.EntityType;
@ -193,8 +192,7 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
int blockstate = (int) meta.getValue();
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockstate));
} else if (type == MetaType1_14.PARTICLE) {
Particle particle = (Particle) meta.getValue();
particle.setId(ParticleMapping.getOldId(particle.getId()));
rewriteParticle((Particle) meta.getValue());
}
return meta;
});

Datei anzeigen

@ -176,8 +176,8 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
});
blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001);
blockRewriter.registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, 3, 23, 34,
BlockItemPackets1_16::getNewParticleId, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
itemRewriter.registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
protocol.registerOutgoing(ClientboundPackets1_16.WINDOW_PROPERTY, new PacketRemapper() {
@Override
@ -291,31 +291,6 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It
}
}
public static int getNewParticleId(int id) {
switch (id) {
case 27: // soul flame -> flame
return 26;
case 28: // soul -> smoke
return 42;
case 64: // ash, crimson spore, warped spore -> mycelium
case 65:
case 66:
return 37;
case 67: // dripping obsidian tear -> dripping lava
return 9;
case 68: // falling obsidian tear
return 10;
case 69: // landing obsidian tear
return 11;
case 70: // reversed portal -> portal
return 40;
}
if (id > 27) {
id -= 2;
}
return id;
}
@Override
protected void registerRewrites() {
enchantmentRewriter = new EnchantmentRewriter(nbtTagName);

Datei anzeigen

@ -1,7 +1,6 @@
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets;
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ParticleMapping;
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.entities.Entity1_15Types;
@ -192,8 +191,7 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
} else if (type == MetaType1_14.BlockID) {
meta.setValue(protocol.getMappingData().getNewBlockStateId((int) meta.getValue()));
} else if (type == MetaType1_14.PARTICLE) {
Particle particle = (Particle) meta.getValue();
particle.setId(ParticleMapping.getOldId(particle.getId()));
rewriteParticle((Particle) meta.getValue());
} else if (type == MetaType1_14.OptChat) {
JsonElement text = meta.getCastedValue();
if (text != null) {

Datei anzeigen

@ -133,8 +133,8 @@ public class BlockItemPackets1_16_2 extends nl.matsv.viabackwards.api.rewriters.
});
blockRewriter.registerEffect(ClientboundPackets1_16_2.EFFECT, 1010, 2001);
blockRewriter.registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, 3, 23, 34,
null, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
itemRewriter.registerSpawnParticle(ClientboundPackets1_16_2.SPAWN_PARTICLE, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
itemRewriter.registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);

Datei anzeigen

@ -12,6 +12,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.Particle;
import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.EntityPackets;
@ -103,6 +104,8 @@ public class EntityPackets1_16_2 extends EntityRewriter<Protocol1_16_1To1_16_2>
if (text != null) {
protocol.getTranslatableRewriter().processText(text);
}
} else if (type == MetaType1_14.PARTICLE) {
rewriteParticle((Particle) meta.getValue());
}
return meta;
});

Datei anzeigen

@ -998,5 +998,15 @@
"entity.parrot.imitate.panda": "",
"entity.parrot.imitate.pillager": "",
"entity.parrot.imitate.ravager": ""
},
"particles": {
"falling_lava": "dripping_lava",
"landing_lava": "dripping_lava",
"falling_water": "dripping_water",
"composter": "happy_villager",
"flash": "explosion",
"sneeze": "spit",
"campfire_cosy_smoke": "cloud",
"campfire_signal_smoke": "cloud"
}
}

Datei anzeigen

@ -88,5 +88,11 @@
"item.honey_bottle.drink": "entity.generic.drink",
"entity.iron_golem.damage": "entity.item.break",
"entity.iron_golem.repair": "entity.iron_golem.step"
},
"particles": {
"dripping_honey": "dripping_lava",
"falling_honey": "falling_lava",
"landing_honey": "landing_lava",
"falling_nectar": "falling_water"
}
}

Datei anzeigen

@ -6230,5 +6230,17 @@
"entity.parrot.imitate.hoglin": "entity.ravager.ambient",
"entity.parrot.imitate.piglin": "entity.zombie_pigman.ambient",
"entity.parrot.imitate.zoglin": "entity.ravager.ambient"
},
"particles": {
"soul_fire_flame": "flame",
"soul": "smoke",
"ash": "mycelium",
"crimson_spore": "mycelium",
"warped_spore": "mycelium",
"dripping_obsidian_tear": "dripping_lava",
"falling_obsidian_tear": "falling_lava",
"landing_obsidian_tear": "landing_lava",
"reverse_portal": "portal",
"white_ash": "mycelium"
}
}