Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 00:50:13 +01:00
Clean up Particle
Dieser Commit ist enthalten in:
Ursprung
c7c38e70c0
Commit
faedf26b5b
@ -20,17 +20,19 @@
|
|||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.type.types;
|
package com.viaversion.viaversion.api.minecraft;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Particle {
|
public final class Particle {
|
||||||
private List<ParticleData> arguments = new ArrayList<>(4);
|
private final List<ParticleData<?>> arguments = new ArrayList<>(4);
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
public Particle(int id) {
|
public Particle(final int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,50 +40,50 @@ public class Particle {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int id) {
|
public void setId(final int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ParticleData> getArguments() {
|
public <T> ParticleData<T> getArgument(final int id) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (ParticleData<T>) arguments.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ParticleData<?>> getArguments() {
|
||||||
return arguments;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated/*(forRemoval = true)*/
|
public <T> void add(final Type<T> type, final T value) {
|
||||||
public void setArguments(List<ParticleData> arguments) {
|
arguments.add(new ParticleData<>(type, value));
|
||||||
this.arguments = arguments;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void add(Type<T> type, T value) {
|
public static final class ParticleData<T> {
|
||||||
arguments.add(new ParticleData(type, value));
|
private final Type<T> type;
|
||||||
}
|
private T value;
|
||||||
|
|
||||||
public static class ParticleData {
|
public ParticleData(final Type<T> type, final T value) {
|
||||||
private Type type;
|
|
||||||
private Object value;
|
|
||||||
|
|
||||||
public ParticleData(Type type, Object value) {
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type<T> getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(Type type) {
|
public T getValue() {
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getValue() {
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T get() {
|
public void setValue(final T value) {
|
||||||
return (T) value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(Object value) {
|
public void write(final ByteBuf buf) throws Exception {
|
||||||
this.value = value;
|
type.write(buf, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(final PacketWrapper wrapper) {
|
||||||
|
wrapper.write(type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -209,7 +209,7 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
|
|||||||
private final String typeName;
|
private final String typeName;
|
||||||
|
|
||||||
protected Type(Class<? super T> outputClass) {
|
protected Type(Class<? super T> outputClass) {
|
||||||
this(outputClass.getSimpleName(), outputClass);
|
this(null, outputClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Type(String typeName, Class<? super T> outputClass) {
|
protected Type(String typeName, Class<? super T> outputClass) {
|
||||||
@ -232,7 +232,7 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
|
|||||||
* @return type name
|
* @return type name
|
||||||
*/
|
*/
|
||||||
public String getTypeName() {
|
public String getTypeName() {
|
||||||
return typeName;
|
return typeName != null ? typeName : this.getClass().getSimpleName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,6 +247,9 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return typeName;
|
return "Type{" +
|
||||||
|
"outputClass=" + outputClass +
|
||||||
|
", typeName='" + typeName + '\'' +
|
||||||
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class ChunkSectionType1_13 extends Type<ChunkSection> {
|
|||||||
private static final int GLOBAL_PALETTE = 14;
|
private static final int GLOBAL_PALETTE = 14;
|
||||||
|
|
||||||
public ChunkSectionType1_13() {
|
public ChunkSectionType1_13() {
|
||||||
super("Chunk Section Type", ChunkSection.class);
|
super(ChunkSection.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,7 +34,7 @@ public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
|||||||
private static final int GLOBAL_PALETTE = 15;
|
private static final int GLOBAL_PALETTE = 15;
|
||||||
|
|
||||||
public ChunkSectionType1_16() {
|
public ChunkSectionType1_16() {
|
||||||
super("Chunk Section Type", ChunkSection.class);
|
super(ChunkSection.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,7 +34,7 @@ public final class ChunkSectionType1_18 extends Type<ChunkSection> {
|
|||||||
private final PaletteType1_18 biomePaletteType;
|
private final PaletteType1_18 biomePaletteType;
|
||||||
|
|
||||||
public ChunkSectionType1_18(final int globalPaletteBlockBits, final int globalPaletteBiomeBits) {
|
public ChunkSectionType1_18(final int globalPaletteBlockBits, final int globalPaletteBiomeBits) {
|
||||||
super("Chunk Section Type", ChunkSection.class);
|
super(ChunkSection.class);
|
||||||
this.blockPaletteType = new PaletteType1_18(PaletteType.BLOCKS, globalPaletteBlockBits);
|
this.blockPaletteType = new PaletteType1_18(PaletteType.BLOCKS, globalPaletteBlockBits);
|
||||||
this.biomePaletteType = new PaletteType1_18(PaletteType.BIOMES, globalPaletteBiomeBits);
|
this.biomePaletteType = new PaletteType1_18(PaletteType.BIOMES, globalPaletteBiomeBits);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import java.nio.ByteOrder;
|
|||||||
public class ChunkSectionType1_8 extends Type<ChunkSection> {
|
public class ChunkSectionType1_8 extends Type<ChunkSection> {
|
||||||
|
|
||||||
public ChunkSectionType1_8() {
|
public ChunkSectionType1_8() {
|
||||||
super("Chunk Section Type", ChunkSection.class);
|
super(ChunkSection.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,7 +34,7 @@ public class ChunkSectionType1_9 extends Type<ChunkSection> {
|
|||||||
private static final int GLOBAL_PALETTE = 13;
|
private static final int GLOBAL_PALETTE = 13;
|
||||||
|
|
||||||
public ChunkSectionType1_9() {
|
public ChunkSectionType1_9() {
|
||||||
super("Chunk Section Type", ChunkSection.class);
|
super(ChunkSection.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,7 +30,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
|
|
||||||
public class ItemType1_13 extends Type<Item> {
|
public class ItemType1_13 extends Type<Item> {
|
||||||
public ItemType1_13() {
|
public ItemType1_13() {
|
||||||
super("FlatItem", Item.class);
|
super(Item.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,7 +30,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
|
|
||||||
public class ItemType1_13_2 extends Type<Item> {
|
public class ItemType1_13_2 extends Type<Item> {
|
||||||
public ItemType1_13_2() {
|
public ItemType1_13_2() {
|
||||||
super("FlatVarIntItem", Item.class);
|
super(Item.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,7 +31,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
public class ItemType1_20_2 extends Type<Item> {
|
public class ItemType1_20_2 extends Type<Item> {
|
||||||
|
|
||||||
public ItemType1_20_2() {
|
public ItemType1_20_2() {
|
||||||
super("ItemType1_20_2", Item.class);
|
super(Item.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,7 +31,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
public class ItemType1_8 extends Type<Item> {
|
public class ItemType1_8 extends Type<Item> {
|
||||||
|
|
||||||
public ItemType1_8() {
|
public ItemType1_8() {
|
||||||
super("Item", Item.class);
|
super(Item.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.data.ParticleMappings;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
|
||||||
@ -57,8 +57,8 @@ public class ParticleType extends Type<Particle> {
|
|||||||
@Override
|
@Override
|
||||||
public void write(final ByteBuf buffer, final Particle object) throws Exception {
|
public void write(final ByteBuf buffer, final Particle object) throws Exception {
|
||||||
Type.VAR_INT.writePrimitive(buffer, object.getId());
|
Type.VAR_INT.writePrimitive(buffer, object.getId());
|
||||||
for (final Particle.ParticleData data : object.getArguments()) {
|
for (final Particle.ParticleData<?> data : object.getArguments()) {
|
||||||
data.getType().write(buffer, data.getValue());
|
data.write(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
|
@ -21,7 +21,7 @@ import com.viaversion.viaversion.api.Via;
|
|||||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets.WorldPackets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -121,10 +121,10 @@ public class ParticleRewriter {
|
|||||||
// Randomized because the previous one was a lot of different colors at once! :)
|
// Randomized because the previous one was a lot of different colors at once! :)
|
||||||
private static ParticleDataHandler reddustHandler() {
|
private static ParticleDataHandler reddustHandler() {
|
||||||
return (particle, data) -> {
|
return (particle, data) -> {
|
||||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, randomBool() ? 1f : 0f)); // Red 0 - 1
|
particle.add(Type.FLOAT, randomBool() ? 1f : 0f); // Red 0 - 1
|
||||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, 0f)); // Green 0 - 1
|
particle.add(Type.FLOAT, 0f); // Green 0 - 1
|
||||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, randomBool() ? 1f : 0f)); // Blue 0 - 1
|
particle.add(Type.FLOAT, randomBool() ? 1f : 0f); // Blue 0 - 1
|
||||||
particle.getArguments().add(new Particle.ParticleData(Type.FLOAT, 1f));// Scale 0.01 - 4
|
particle.add(Type.FLOAT, 1f);// Scale 0.01 - 4
|
||||||
return particle;
|
return particle;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ public class ParticleRewriter {
|
|||||||
// Transform to new Item
|
// Transform to new Item
|
||||||
Via.getManager().getProtocolManager().getProtocol(Protocol1_13To1_12_2.class).getItemRewriter().handleItemToClient(item);
|
Via.getManager().getProtocolManager().getProtocol(Protocol1_13To1_12_2.class).getItemRewriter().handleItemToClient(item);
|
||||||
|
|
||||||
particle.getArguments().add(new Particle.ParticleData(Type.ITEM1_13, item)); // Item Slot The item that will be used.
|
particle.add(Type.ITEM1_13, item); // Item Slot The item that will be used.
|
||||||
return particle;
|
return particle;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ public class ParticleRewriter {
|
|||||||
int combined = (((value & 4095) << 4) | (value >> 12 & 15));
|
int combined = (((value & 4095) << 4) | (value >> 12 & 15));
|
||||||
int newId = WorldPackets.toNewId(combined);
|
int newId = WorldPackets.toNewId(combined);
|
||||||
|
|
||||||
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, newId)); // BlockState VarInt The ID of the block state.
|
particle.add(Type.VAR_INT, newId); // BlockState VarInt The ID of the block state.
|
||||||
return particle;
|
return particle;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
|
@ -32,7 +32,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||||
@ -507,7 +507,7 @@ public class WorldPackets {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Handle reddust particle color
|
// Handle reddust particle color
|
||||||
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);
|
||||||
@ -516,7 +516,6 @@ public class WorldPackets {
|
|||||||
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();
|
|
||||||
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
|
||||||
float colorValue = wrapper.get(Type.FLOAT, i + 3) * speed;
|
float colorValue = wrapper.get(Type.FLOAT, i + 3) * speed;
|
||||||
@ -524,15 +523,15 @@ public class WorldPackets {
|
|||||||
// https://minecraft.gamepedia.com/User:Alphappy/reddust
|
// https://minecraft.gamepedia.com/User:Alphappy/reddust
|
||||||
colorValue = 1;
|
colorValue = 1;
|
||||||
}
|
}
|
||||||
arguments.get(i).setValue(colorValue);
|
particle.<Float>getArgument(i).setValue(colorValue);
|
||||||
wrapper.set(Type.FLOAT, i + 3, 0f);
|
wrapper.set(Type.FLOAT, i + 3, 0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.set(Type.INT, 0, particle.getId());
|
wrapper.set(Type.INT, 0, particle.getId());
|
||||||
for (Particle.ParticleData particleData : particle.getArguments())
|
for (Particle.ParticleData<?> particleData : particle.getArguments())
|
||||||
wrapper.write(particleData.getType(), particleData.getValue());
|
particleData.write(wrapper);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.minecraft.item.Item;
|
|||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||||
|
@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_15;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14_4to1_14_3.ClientboundPackets1_14_4;
|
import com.viaversion.viaversion.protocols.protocol1_14_4to1_14_3.ClientboundPackets1_14_4;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||||
|
@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||||
|
@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||||
|
@ -22,7 +22,7 @@ import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
|
|||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
||||||
@ -87,9 +87,9 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_17_1
|
|||||||
final Particle particle = (Particle) meta.getValue();
|
final Particle particle = (Particle) meta.getValue();
|
||||||
if (particle.getId() == 2) { // Barrier
|
if (particle.getId() == 2) { // Barrier
|
||||||
particle.setId(3); // Block marker
|
particle.setId(3); // Block marker
|
||||||
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, 7754)); // Barrier state
|
particle.add(Type.VAR_INT, 7754); // Barrier state
|
||||||
} else if (particle.getId() == 3) { // Light block
|
} else if (particle.getId() == 3) { // Light block
|
||||||
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, 7786)); // Light block state
|
particle.add(Type.VAR_INT, 7786); // Light block state
|
||||||
} else {
|
} else {
|
||||||
rewriteParticle(particle);
|
rewriteParticle(particle);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
|||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
import com.viaversion.viaversion.api.type.types.version.Types1_18;
|
||||||
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
import com.viaversion.viaversion.api.type.types.version.Types1_19;
|
||||||
import com.viaversion.viaversion.data.entity.DimensionDataImpl;
|
import com.viaversion.viaversion.data.entity.DimensionDataImpl;
|
||||||
@ -363,10 +363,10 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
|
|||||||
// Remove the position
|
// Remove the position
|
||||||
particle.getArguments().remove(0);
|
particle.getArguments().remove(0);
|
||||||
|
|
||||||
final String resourceLocation = Key.stripMinecraftNamespace(particle.getArguments().get(0).get());
|
final String resourceLocation = Key.stripMinecraftNamespace(particle.<String>getArgument(0).getValue());
|
||||||
if (resourceLocation.equals("entity")) {
|
if (resourceLocation.equals("entity")) {
|
||||||
// Add Y offset
|
// Add Y offset
|
||||||
particle.getArguments().add(2, new Particle.ParticleData(Type.FLOAT, 0F));
|
particle.getArguments().add(2, new Particle.ParticleData<>(Type.FLOAT, 0F));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
|||||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||||
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
import com.viaversion.viaversion.api.rewriter.RewriterBase;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.api.type.types.Particle;
|
import com.viaversion.viaversion.api.minecraft.Particle;
|
||||||
import com.viaversion.viaversion.data.entity.DimensionDataImpl;
|
import com.viaversion.viaversion.data.entity.DimensionDataImpl;
|
||||||
import com.viaversion.viaversion.rewriter.meta.MetaFilter;
|
import com.viaversion.viaversion.rewriter.meta.MetaFilter;
|
||||||
import com.viaversion.viaversion.rewriter.meta.MetaHandlerEvent;
|
import com.viaversion.viaversion.rewriter.meta.MetaHandlerEvent;
|
||||||
@ -580,11 +580,11 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
|
|||||||
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
|
ParticleMappings mappings = protocol.getMappingData().getParticleMappings();
|
||||||
int id = particle.getId();
|
int id = particle.getId();
|
||||||
if (mappings.isBlockParticle(id)) {
|
if (mappings.isBlockParticle(id)) {
|
||||||
Particle.ParticleData data = particle.getArguments().get(0);
|
Particle.ParticleData<Integer> data = particle.getArgument(0);
|
||||||
data.setValue(protocol.getMappingData().getNewBlockStateId(data.get()));
|
data.setValue(protocol.getMappingData().getNewBlockStateId(data.getValue()));
|
||||||
} else if (mappings.isItemParticle(id) && protocol.getItemRewriter() != null) {
|
} else if (mappings.isItemParticle(id) && protocol.getItemRewriter() != null) {
|
||||||
Particle.ParticleData data = particle.getArguments().get(0);
|
Particle.ParticleData<Item> data = particle.getArgument(0);
|
||||||
Item item = data.get();
|
Item item = data.getValue();
|
||||||
protocol.getItemRewriter().handleItemToClient(item);
|
protocol.getItemRewriter().handleItemToClient(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren