Merge pull request #1185 from creeper123123321/fixparticleandtranslations

Fix particles and translations with %d
This commit is contained in:
Myles 2019-02-06 20:54:26 +00:00 committed by GitHub
commit 7534904737
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 14 deletions

View File

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

View File

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

View File

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

View File

@ -615,7 +615,7 @@ public class InventoryPackets {
ench.add(enchEntry);
}
}
tag.remove("Enchantment");
tag.remove("Enchantments");
tag.put(ench);
}
if (tag.get("StoredEnchantments") instanceof ListTag) {

View File

@ -415,15 +415,20 @@ public class WorldPackets {
if (particle.getId() == 11) {
int count = wrapper.get(Type.INT, 1);
float speed = wrapper.get(Type.FLOAT, 6);
// Only handle for count = 0 & speed = 1
if (count == 0 && speed == 1) {
// Only handle for count = 0
if (count == 0) {
wrapper.set(Type.INT, 1, 1);
wrapper.set(Type.FLOAT, 6, 0f);
List<Particle.ParticleData> arguments = particle.getArguments();
for (int i = 0; i < 3; i++) {
//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);
}
}