3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 00:22:51 +01:00

Fix reddust, particle metadata rewriting, translations

Dieser Commit ist enthalten in:
creeper123123321 2019-02-02 11:21:19 -02:00
Ursprung 9ba70424e8
Commit a203c17e06
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1
4 geänderte Dateien mit 19 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -98,7 +98,9 @@ public class MetadataRewriter {
// Handle AreaEffectCloud outside the loop // Handle AreaEffectCloud outside the loop
if (type != null && type.is(Entity1_13Types.EntityType.AREA_EFFECT_CLOUD) && particleId != -1) { if (type != null && type.is(Entity1_13Types.EntityType.AREA_EFFECT_CLOUD) && particleId != -1) {
Particle particle = ParticleRewriter.rewriteParticle(particleId, new Integer[]{parameter1, parameter2}); Particle particle = ParticleRewriter.rewriteParticle(particleId, new Integer[]{parameter1, parameter2});
if (particle != null && particle.getId() != -1) {
metadatas.add(new Metadata(9, MetaType1_13.PARTICLE, particle)); metadatas.add(new Metadata(9, MetaType1_13.PARTICLE, particle));
} }
} }
}
} }

Datei anzeigen

@ -67,7 +67,7 @@ public class MappingData {
String[] keyAndTranslation = line.split("=", 2); String[] keyAndTranslation = line.split("=", 2);
if (keyAndTranslation.length != 2) continue; if (keyAndTranslation.length != 2) continue;
String key = keyAndTranslation[0]; String key = keyAndTranslation[0];
String translation = keyAndTranslation[1]; String translation = keyAndTranslation[1].replaceAll("%(\\d\\$)?d", "%$1s");
if (!translateData.containsKey(key)) { if (!translateData.containsKey(key)) {
translateMapping.put(key, translation); translateMapping.put(key, translation);
} else { } else {

Datei anzeigen

@ -11,11 +11,10 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.concurrent.ThreadLocalRandom;
public class ParticleRewriter { public class ParticleRewriter {
private static List<NewParticle> particles = new LinkedList<>(); private static List<NewParticle> particles = new LinkedList<>();
private static Random rand = new Random();
static { static {
add(34); // (0->34) explode -> minecraft:poof add(34); // (0->34) explode -> minecraft:poof
@ -108,17 +107,17 @@ public class ParticleRewriter {
return new ParticleDataHandler() { return new ParticleDataHandler() {
@Override @Override
public Particle handler(Particle particle, Integer[] data) { public Particle handler(Particle particle, Integer[] data) {
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, randomFloat())); // Red 0 - 1 particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, randomBool() ? 1f : 0f)); // Red 0 - 1
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, randomFloat())); // Green 0 - 1 particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, 0f)); // Green 0 - 1
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, randomFloat())); // Blue 0 - 1 particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, randomBool() ? 1f : 0f)); // Blue 0 - 1
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, 1));// Scale 0.01 - 4 particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, 1f));// Scale 0.01 - 4
return particle; return particle;
} }
}; };
} }
private static float randomFloat() { private static boolean randomBool() {
return rand.nextFloat(); return ThreadLocalRandom.current().nextBoolean();
} }
// Rewrite IconCrack items to new format :) // Rewrite IconCrack items to new format :)

Datei anzeigen

@ -415,15 +415,20 @@ public class WorldPackets {
if (particle.getId() == 11) { if (particle.getId() == 11) {
int count = wrapper.get(Type.INT, 1); int count = wrapper.get(Type.INT, 1);
float speed = wrapper.get(Type.FLOAT, 6); float speed = wrapper.get(Type.FLOAT, 6);
// Only handle for count = 0 & speed = 1 // Only handle for count = 0
if (count == 0 && speed == 1) { if (count == 0) {
wrapper.set(Type.INT, 1, 1); wrapper.set(Type.INT, 1, 1);
wrapper.set(Type.FLOAT, 6, 0f); wrapper.set(Type.FLOAT, 6, 0f);
List<Particle.ParticleData> arguments = particle.getArguments(); List<Particle.ParticleData> arguments = particle.getArguments();
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
//RGB values are represented by the X/Y/Z offset //RGB values are represented by the X/Y/Z offset
arguments.get(i).setValue(wrapper.get(Type.FLOAT, i + 3)); float colorValue = wrapper.get(Type.FLOAT, i + 3) * speed;
if (colorValue == 0 && i == 0) {
// https://minecraft.gamepedia.com/User:Alphappy/reddust
colorValue = 1;
}
arguments.get(i).setValue(colorValue);
wrapper.set(Type.FLOAT, i + 3, 0f); wrapper.set(Type.FLOAT, i + 3, 0f);
} }
} }