Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Handle particles with 0 parameters
Dieser Commit ist enthalten in:
Ursprung
c0c1a6bbcf
Commit
d066c2596b
@ -80,8 +80,8 @@ public class ParticleRewriter {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Particle rewriteParticle(int particleId, int[] data) {
|
public static Particle rewriteParticle(int particleId, Integer[] data) {
|
||||||
if (particles.size() >= particleId) {
|
if (particleId >= particles.size()) {
|
||||||
Via.getPlatform().getLogger().severe("Failed to transform particles with id " + particleId + " and data " + Arrays.toString(data));
|
Via.getPlatform().getLogger().severe("Failed to transform particles with id " + particleId + " and data " + Arrays.toString(data));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -99,14 +99,14 @@ public class ParticleRewriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ParticleDataHandler {
|
interface ParticleDataHandler {
|
||||||
Particle handler(Particle particle, int[] data);
|
Particle handler(Particle particle, Integer[] data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO TEST
|
// TODO TEST
|
||||||
private static ParticleDataHandler reddustHandler() {
|
private static ParticleDataHandler reddustHandler() {
|
||||||
return new ParticleDataHandler() {
|
return new ParticleDataHandler() {
|
||||||
@Override
|
@Override
|
||||||
public Particle handler(Particle particle, int[] data) {
|
public Particle handler(Particle particle, Integer[] data) {
|
||||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, 1)); // Red 0 - 1
|
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, 1)); // Red 0 - 1
|
||||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, 0)); // Green 0 - 1
|
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, 0)); // Green 0 - 1
|
||||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, 0)); // Blue 0 - 1
|
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, 0)); // Blue 0 - 1
|
||||||
@ -120,12 +120,12 @@ public class ParticleRewriter {
|
|||||||
private static ParticleDataHandler iconcrackHandler() {
|
private static ParticleDataHandler iconcrackHandler() {
|
||||||
return new ParticleDataHandler() {
|
return new ParticleDataHandler() {
|
||||||
@Override
|
@Override
|
||||||
public Particle handler(Particle particle, int[] data) {
|
public Particle handler(Particle particle, Integer[] data) {
|
||||||
Item item;
|
Item item;
|
||||||
if (data.length == 1)
|
if (data.length == 1)
|
||||||
item = new Item((short) data[0], (byte) 1, (short) 0, null);
|
item = new Item(data[0].shortValue(), (byte) 1, (short) 0, null);
|
||||||
else if (data.length == 2)
|
else if (data.length == 2)
|
||||||
item = new Item((short) data[0], (byte) 1, (short) data[1], null);
|
item = new Item(data[0].shortValue(), (byte) 1, data[1].shortValue(), null);
|
||||||
else
|
else
|
||||||
return particle;
|
return particle;
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ public class ParticleRewriter {
|
|||||||
private static ParticleDataHandler blockHandler() {
|
private static ParticleDataHandler blockHandler() {
|
||||||
return new ParticleDataHandler() {
|
return new ParticleDataHandler() {
|
||||||
@Override
|
@Override
|
||||||
public Particle handler(Particle particle, int[] data) {
|
public Particle handler(Particle particle, Integer[] data) {
|
||||||
return particle;
|
return particle;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -149,7 +149,7 @@ public class ParticleRewriter {
|
|||||||
private static ParticleDataHandler blockdustHandler() {
|
private static ParticleDataHandler blockdustHandler() {
|
||||||
return new ParticleDataHandler() {
|
return new ParticleDataHandler() {
|
||||||
@Override
|
@Override
|
||||||
public Particle handler(Particle particle, int[] data) {
|
public Particle handler(Particle particle, Integer[] data) {
|
||||||
return particle;
|
return particle;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -159,7 +159,7 @@ public class ParticleRewriter {
|
|||||||
private static ParticleDataHandler fallingdustHandler() {
|
private static ParticleDataHandler fallingdustHandler() {
|
||||||
return new ParticleDataHandler() {
|
return new ParticleDataHandler() {
|
||||||
@Override
|
@Override
|
||||||
public Particle handler(Particle particle, int[] data) {
|
public Particle handler(Particle particle, Integer[] data) {
|
||||||
return particle;
|
return particle;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -171,7 +171,7 @@ public class ParticleRewriter {
|
|||||||
private final int id;
|
private final int id;
|
||||||
private final ParticleDataHandler handler;
|
private final ParticleDataHandler handler;
|
||||||
|
|
||||||
public Particle handle(Particle particle, int[] data) {
|
public Particle handle(Particle particle, Integer[] data) {
|
||||||
if (handler != null)
|
if (handler != null)
|
||||||
return handler.handler(particle, data);
|
return handler.handler(particle, data);
|
||||||
return particle;
|
return particle;
|
||||||
|
@ -17,6 +17,8 @@ import us.myles.ViaVersion.packets.State;
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.MappingData;
|
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.MappingData;
|
||||||
|
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.Particle;
|
||||||
|
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.data.ParticleRewriter;
|
||||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEntityProvider;
|
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.BlockEntityProvider;
|
||||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.PaintingProvider;
|
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.providers.PaintingProvider;
|
||||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage;
|
import us.myles.ViaVersion.protocols.protocolsnapshotto1_12_2.storage.BlockStorage;
|
||||||
@ -191,11 +193,50 @@ public class WorldPackets {
|
|||||||
protocol.registerOutgoing(State.PLAY, 0x22, 0x23, new PacketRemapper() {
|
protocol.registerOutgoing(State.PLAY, 0x22, 0x23, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
// TODO: This packet has changed
|
map(Type.INT); // 0 - Particle ID
|
||||||
|
map(Type.BOOLEAN); // 1 - Long Distance
|
||||||
|
map(Type.FLOAT); // 2 - X
|
||||||
|
map(Type.FLOAT); // 3 - Y
|
||||||
|
map(Type.FLOAT); // 4 - Z
|
||||||
|
map(Type.FLOAT); // 5 - Offset X
|
||||||
|
map(Type.FLOAT); // 6 - Offset Y
|
||||||
|
map(Type.FLOAT); // 7 - Offset Z
|
||||||
|
map(Type.FLOAT); // 8 - Particle Data
|
||||||
|
map(Type.INT); // 9 - Particle Count
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int particleId = wrapper.get(Type.INT, 0);
|
||||||
|
|
||||||
|
// Get the data (Arrays are overrated)
|
||||||
|
int dataCount = 0;
|
||||||
|
// Particles with 1 data [BlockCrack,BlockDust,FallingDust]
|
||||||
|
if (particleId == 37 || particleId == 38 || particleId == 46)
|
||||||
|
dataCount = 1;
|
||||||
|
// Particles with 2 data [IconCrack]
|
||||||
|
else if (particleId == 36)
|
||||||
|
dataCount = 2;
|
||||||
|
|
||||||
|
Integer[] data = new Integer[dataCount];
|
||||||
|
for (int i = 0; i < data.length; i++)
|
||||||
|
data[i] = wrapper.read(Type.VAR_INT);
|
||||||
|
|
||||||
|
Particle particle = ParticleRewriter.rewriteParticle(particleId, data);
|
||||||
|
|
||||||
|
// Cancel if null
|
||||||
|
if (particle == null) {
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// System.out.println("Old particle " + particleId + " " + Arrays.toString(data) + " new Particle" + particle);
|
||||||
|
|
||||||
|
|
||||||
|
wrapper.set(Type.INT, 0, particle.getId());
|
||||||
|
for (Particle.ParticleData particleData : particle.getArguments())
|
||||||
|
wrapper.write(particleData.getType(), particleData.getValue());
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren