Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 00:50:13 +01:00
Add getSpawnParticleHandler method to ItemRewriter
Dieser Commit ist enthalten in:
Ursprung
52b95eab28
Commit
a4d1ac3b95
@ -205,27 +205,31 @@ public class ItemRewriter {
|
|||||||
map(Type.FLOAT); // 7 - Offset Z
|
map(Type.FLOAT); // 7 - Offset Z
|
||||||
map(Type.FLOAT); // 8 - Particle Data
|
map(Type.FLOAT); // 8 - Particle Data
|
||||||
map(Type.INT); // 9 - Particle Count
|
map(Type.INT); // 9 - Particle Count
|
||||||
handler(wrapper -> {
|
handler(getSpawnParticleHandler(itemType, coordType));
|
||||||
int id = wrapper.get(Type.INT, 0);
|
|
||||||
if (id == -1) return;
|
|
||||||
|
|
||||||
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
|
|
||||||
if (id == mappings.getBlockId() || id == mappings.getFallingDustId()) {
|
|
||||||
int data = wrapper.passthrough(Type.VAR_INT);
|
|
||||||
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
|
|
||||||
} else if (id == mappings.getItemId()) {
|
|
||||||
toClient.rewrite(wrapper.passthrough(itemType));
|
|
||||||
}
|
|
||||||
|
|
||||||
int newId = protocol.getMappingData().getNewParticleId(id);
|
|
||||||
if (newId != id) {
|
|
||||||
wrapper.set(Type.INT, 0, newId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PacketHandler getSpawnParticleHandler(Type<Item> itemType, Type<?> coordType) {
|
||||||
|
return wrapper -> {
|
||||||
|
int id = wrapper.get(Type.INT, 0);
|
||||||
|
if (id == -1) return;
|
||||||
|
|
||||||
|
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
|
||||||
|
if (id == mappings.getBlockId() || id == mappings.getFallingDustId()) {
|
||||||
|
int data = wrapper.passthrough(Type.VAR_INT);
|
||||||
|
wrapper.set(Type.VAR_INT, 0, protocol.getMappingData().getNewBlockStateId(data));
|
||||||
|
} else if (id == mappings.getItemId()) {
|
||||||
|
toClient.rewrite(wrapper.passthrough(itemType));
|
||||||
|
}
|
||||||
|
|
||||||
|
int newId = protocol.getMappingData().getNewParticleId(id);
|
||||||
|
if (newId != id) {
|
||||||
|
wrapper.set(Type.INT, 0, newId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Only sent to the client
|
// Only sent to the client
|
||||||
public PacketHandler itemArrayHandler(Type<Item[]> type) {
|
public PacketHandler itemArrayHandler(Type<Item[]> type) {
|
||||||
return wrapper -> {
|
return wrapper -> {
|
||||||
|
@ -43,8 +43,8 @@ public class EntityPackets {
|
|||||||
dimensionName = "minecraft:overworld";
|
dimensionName = "minecraft:overworld";
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.write(Type.STRING, dimensionName); // dimension type
|
|
||||||
wrapper.write(Type.STRING, dimensionName); // dimension
|
wrapper.write(Type.STRING, dimensionName); // dimension
|
||||||
|
wrapper.write(Type.STRING, dimensionName); // world
|
||||||
};
|
};
|
||||||
public static final CompoundTag DIMENSIONS_TAG = new CompoundTag("");
|
public static final CompoundTag DIMENSIONS_TAG = new CompoundTag("");
|
||||||
private static final String[] WORLD_NAMES = {"minecraft:overworld", "minecraft:the_nether", "minecraft:the_end"};
|
private static final String[] WORLD_NAMES = {"minecraft:overworld", "minecraft:the_nether", "minecraft:the_end"};
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren