Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aade94a48f | ||
|
|
edebe64cf8 | ||
|
|
ae4f837091 | ||
|
|
5e6d87c8fd | ||
|
|
20e9723d21 | ||
|
|
54724ac540 | ||
|
|
a9c848e32e | ||
|
|
02f9e87233 | ||
|
|
22d546edc0 |
No files matched your search
@@ -78,7 +78,7 @@ public class MappingDataBase implements MappingData {
|
||||
|
||||
Mappings particles = loadFromArray(oldMappings, newMappings, diffmapping, "particles");
|
||||
if (particles != null) {
|
||||
particleMappings = new ParticleMappings(oldMappings.getAsJsonArray("particles"), particles);
|
||||
particleMappings = new ParticleMappings(oldMappings.getAsJsonArray("particles"), newMappings.getAsJsonArray("particles"), particles);
|
||||
}
|
||||
|
||||
if (loadItems && newMappings.has("items")) {
|
||||
|
||||
@@ -29,15 +29,17 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
|
||||
public class ParticleMappings {
|
||||
private final Object2IntMap<String> stringToId;
|
||||
private final Object2IntMap<String> mappedStringToId;
|
||||
private final Mappings mappings;
|
||||
private final IntList itemParticleIds = new IntArrayList(2);
|
||||
private final IntList blockParticleIds = new IntArrayList(4);
|
||||
|
||||
public ParticleMappings(JsonArray oldMappings, Mappings mappings) {
|
||||
public ParticleMappings(JsonArray oldMappings, JsonArray newMappings, Mappings mappings) {
|
||||
this.mappings = mappings;
|
||||
|
||||
stringToId = MappingDataLoader.arrayToMap(oldMappings);
|
||||
mappedStringToId = MappingDataLoader.arrayToMap(newMappings);
|
||||
stringToId.defaultReturnValue(-1);
|
||||
mappedStringToId.defaultReturnValue(-1);
|
||||
addBlockParticle("block");
|
||||
addBlockParticle("falling_dust");
|
||||
addBlockParticle("block_marker");
|
||||
@@ -54,6 +56,16 @@ public class ParticleMappings {
|
||||
return stringToId.getInt(identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mapped integer id for the given mapped identifier, or -1 if not found.
|
||||
*
|
||||
* @param mappedIdentifier mapped string identifier
|
||||
* @return mapped int id, or -1 if not found
|
||||
*/
|
||||
public int mappedId(String mappedIdentifier) {
|
||||
return mappedStringToId.getInt(mappedIdentifier);
|
||||
}
|
||||
|
||||
public Mappings getMappings() {
|
||||
return mappings;
|
||||
}
|
||||
|
||||
+16
-4
@@ -46,7 +46,11 @@ public class ParticleType extends Type<Particle> {
|
||||
}
|
||||
|
||||
public ParticleTypeFiller filler(final Protocol<?, ?, ?, ?> protocol) {
|
||||
return this.new ParticleTypeFiller(protocol);
|
||||
return filler(protocol, true);
|
||||
}
|
||||
|
||||
public ParticleTypeFiller filler(final Protocol<?, ?, ?, ?> protocol, final boolean useMappedNames) {
|
||||
return this.new ParticleTypeFiller(protocol, useMappedNames);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,7 +101,13 @@ public class ParticleType extends Type<Particle> {
|
||||
};
|
||||
public static final ParticleReader VIBRATION = (buf, particle) -> {
|
||||
particle.add(Type.POSITION1_14, Type.POSITION1_14.read(buf)); // From block pos
|
||||
final String resourceLocation = Type.STRING.read(buf);
|
||||
|
||||
String resourceLocation = Type.STRING.read(buf);
|
||||
particle.add(Type.STRING, resourceLocation);
|
||||
if (resourceLocation.startsWith("minecraft:")) {
|
||||
resourceLocation = resourceLocation.substring(10);
|
||||
}
|
||||
|
||||
if (resourceLocation.equals("block")) {
|
||||
particle.add(Type.POSITION1_14, Type.POSITION1_14.read(buf)); // Target block pos
|
||||
} else if (resourceLocation.equals("entity")) {
|
||||
@@ -112,13 +122,15 @@ public class ParticleType extends Type<Particle> {
|
||||
public final class ParticleTypeFiller {
|
||||
|
||||
private final ParticleMappings mappings;
|
||||
private final boolean useMappedNames;
|
||||
|
||||
private ParticleTypeFiller(final Protocol<?, ?, ?, ?> protocol) {
|
||||
private ParticleTypeFiller(final Protocol<?, ?, ?, ?> protocol, final boolean useMappedNames) {
|
||||
this.mappings = protocol.getMappingData().getParticleMappings();
|
||||
this.useMappedNames = useMappedNames;
|
||||
}
|
||||
|
||||
public ParticleTypeFiller reader(final String identifier, final ParticleReader reader) {
|
||||
readers.put(mappings.id(identifier), reader);
|
||||
readers.put(useMappedNames ? mappings.mappedId(identifier) : mappings.id(identifier), reader);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+13
-20
@@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPaletteImpl;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.util.CompactArrayUtil;
|
||||
import com.viaversion.viaversion.util.MathUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public final class PaletteType1_18 extends Type<DataPalette> {
|
||||
@@ -88,29 +89,21 @@ public final class PaletteType1_18 extends Type<DataPalette> {
|
||||
|
||||
@Override
|
||||
public void write(final ByteBuf buffer, final DataPalette palette) throws Exception {
|
||||
int bitsPerValue;
|
||||
if (palette.size() > 1) {
|
||||
// 1, 2, and 3 bit linear palettes can't be read by the client
|
||||
bitsPerValue = type == PaletteType.BLOCKS ? 4 : 1;
|
||||
while (palette.size() > 1 << bitsPerValue) {
|
||||
bitsPerValue += 1;
|
||||
}
|
||||
|
||||
if (bitsPerValue > type.highestBitsPerValue()) {
|
||||
bitsPerValue = globalPaletteBits;
|
||||
}
|
||||
} else {
|
||||
bitsPerValue = 0;
|
||||
}
|
||||
|
||||
buffer.writeByte(bitsPerValue);
|
||||
|
||||
if (bitsPerValue == 0) {
|
||||
// Write single value
|
||||
final int bitsPerValue;
|
||||
if (palette.size() == 1) {
|
||||
// Single value palette
|
||||
buffer.writeByte(0); // 0 bit storage
|
||||
Type.VAR_INT.writePrimitive(buffer, palette.idByIndex(0));
|
||||
Type.VAR_INT.writePrimitive(buffer, 0); // Empty values length
|
||||
return;
|
||||
}
|
||||
}/* else if (palette.size() == 0) {
|
||||
Via.getPlatform().getLogger().warning("Palette size is 0!");
|
||||
}*/
|
||||
|
||||
// 1, 2, and 3 bit linear block palettes can't be read by the client
|
||||
final int min = type == PaletteType.BLOCKS ? 4 : 1;
|
||||
bitsPerValue = MathUtil.clamp(MathUtil.ceilLog2(palette.size()), min, type.highestBitsPerValue());
|
||||
buffer.writeByte(bitsPerValue);
|
||||
|
||||
if (bitsPerValue != globalPaletteBits) {
|
||||
// Write pallete
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.viaversion.viaversion.util;
|
||||
|
||||
public final class MathUtil {
|
||||
|
||||
/**
|
||||
* Returns the ceiled log to the base of 2 for the given number.
|
||||
*
|
||||
* @param i positive number to ceillog
|
||||
* @return ceiled log2 of the given number
|
||||
*/
|
||||
public static int ceilLog2(final int i) {
|
||||
return i > 0 ? 32 - Integer.numberOfLeadingZeros(i - 1) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the clamped number within the given range.
|
||||
*
|
||||
* @param i number to clamp
|
||||
* @param min minimum value
|
||||
* @param max maximum value
|
||||
* @return clamped number
|
||||
*/
|
||||
public static int clamp(final int i, final int min, final int max) {
|
||||
if (i < min) {
|
||||
return min;
|
||||
}
|
||||
return i > max ? max : i;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_13_1to1_13;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.MappingData;
|
||||
import com.viaversion.viaversion.api.data.MappingDataBase;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_13Types;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
@@ -38,7 +39,6 @@ import com.viaversion.viaversion.protocols.protocol1_13_1to1_13.packets.WorldPac
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
|
||||
|
||||
+40
-1
@@ -57,7 +57,46 @@ public class WorldPackets {
|
||||
blockRewriter.registerBlockAction(ClientboundPackets1_13.BLOCK_ACTION);
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_13.BLOCK_CHANGE);
|
||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_13.MULTI_BLOCK_CHANGE);
|
||||
blockRewriter.registerEffect(ClientboundPackets1_13.EFFECT, 1010, 2001);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.EFFECT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Effect Id
|
||||
map(Type.POSITION); // Location
|
||||
map(Type.INT); // Data
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
if (id == 2000) { // Smoke
|
||||
int data = wrapper.get(Type.INT, 1);
|
||||
switch (data) {
|
||||
case 1: // North
|
||||
wrapper.set(Type.INT, 1, 2); // North
|
||||
break;
|
||||
case 0: // North-West
|
||||
case 3: // West
|
||||
case 6: // South-West
|
||||
wrapper.set(Type.INT, 1, 4); // West
|
||||
break;
|
||||
case 2: // North-East
|
||||
case 5: // East
|
||||
case 8: // South-East
|
||||
wrapper.set(Type.INT, 1, 5); // East
|
||||
break;
|
||||
case 7: // South
|
||||
wrapper.set(Type.INT, 1, 3); // South
|
||||
break;
|
||||
default: // Self and other directions
|
||||
wrapper.set(Type.INT, 1, 0); // Down
|
||||
break;
|
||||
}
|
||||
} else if (id == 1010) { // Play record
|
||||
wrapper.set(Type.INT, 1, protocol.getMappingData().getNewItemId(wrapper.get(Type.INT, 1)));
|
||||
} else if (id == 2001) { // Block break + block break sound
|
||||
wrapper.set(Type.INT, 1, protocol.getMappingData().getNewBlockStateId(wrapper.get(Type.INT, 1)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
|
||||
+17
-2
@@ -19,6 +19,8 @@ package com.viaversion.viaversion.protocols.protocol1_13to1_12_2.packets;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
@@ -46,6 +48,7 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.Client
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -122,8 +125,9 @@ public class WorldPackets {
|
||||
}
|
||||
}
|
||||
|
||||
if (action == 5) // Set type of flower in flower pot
|
||||
if (action == 5) { // Set type of flower in flower pot
|
||||
wrapper.cancel(); // Removed
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -442,7 +446,9 @@ public class WorldPackets {
|
||||
|
||||
// Rewrite BlockEntities to normal blocks
|
||||
BlockEntityProvider provider = Via.getManager().getProviders().get(BlockEntityProvider.class);
|
||||
for (CompoundTag tag : chunk.getBlockEntities()) {
|
||||
final Iterator<CompoundTag> iterator = chunk.getBlockEntities().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
CompoundTag tag = iterator.next();
|
||||
int newId = provider.transform(wrapper.user(), null, tag, false);
|
||||
if (newId != -1) {
|
||||
int x = ((NumberTag) tag.get("x")).asInt();
|
||||
@@ -458,6 +464,15 @@ public class WorldPackets {
|
||||
|
||||
chunk.getSections()[y >> 4].setFlatBlock(x & 0xF, y & 0xF, z & 0xF, newId);
|
||||
}
|
||||
|
||||
final Tag idTag = tag.get("id");
|
||||
if (idTag instanceof StringTag) {
|
||||
// No longer block entities
|
||||
final String id = ((StringTag) idTag).getValue();
|
||||
if (id.equals("minecraft:noteblock") || id.equals("minecraft:flower_pot")) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Via.getConfig().isServersideBlockConnections()) {
|
||||
|
||||
+3
-3
@@ -149,15 +149,15 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
WorldPackets.voidAir = getMappingData().getBlockStateMappings().getNewId(8591);
|
||||
WorldPackets.caveAir = getMappingData().getBlockStateMappings().getNewId(8592);
|
||||
|
||||
Types1_13_2.PARTICLE.filler(this)
|
||||
Types1_13_2.PARTICLE.filler(this, false)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("item", ParticleType.Readers.VAR_INT_ITEM);
|
||||
Types1_14.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("item", ParticleType.Readers.VAR_INT_ITEM);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -277,7 +277,7 @@ public class Protocol1_16To1_15_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
Types1_16.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("item", ParticleType.Readers.VAR_INT_ITEM);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -228,7 +228,7 @@ public final class Protocol1_17To1_16_4 extends AbstractProtocol<ClientboundPack
|
||||
Types1_17.PARTICLE.filler(this)
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION)
|
||||
.reader("item", ParticleType.Readers.VAR_INT_ITEM)
|
||||
.reader("vibration", ParticleType.Readers.VIBRATION);
|
||||
|
||||
+1
@@ -37,6 +37,7 @@ public final class BlockEntityIds {
|
||||
IDS[7] = 19; // Structure block
|
||||
IDS[8] = 20; // End gateway
|
||||
IDS[9] = 7; // Sign
|
||||
IDS[10] = 22; // Shulker box
|
||||
IDS[11] = 23; // Bed
|
||||
IDS[12] = 30; // Jigsaw
|
||||
IDS[13] = 31; // Campfire
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ public final class Protocol1_18To1_17_1 extends AbstractProtocol<ClientboundPack
|
||||
.reader("block", ParticleType.Readers.BLOCK)
|
||||
.reader("block_marker", ParticleType.Readers.BLOCK)
|
||||
.reader("dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.DUST)
|
||||
.reader("falling_dust", ParticleType.Readers.BLOCK)
|
||||
.reader("dust_color_transition", ParticleType.Readers.DUST_TRANSITION)
|
||||
.reader("item", ParticleType.Readers.VAR_INT_ITEM)
|
||||
.reader("vibration", ParticleType.Readers.VIBRATION);
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ public final class EntityPackets extends EntityRewriter<Protocol1_18To1_17_1> {
|
||||
filter().handler((event, meta) -> {
|
||||
meta.setMetaType(Types1_18.META_TYPES.byId(meta.metaType().typeId()));
|
||||
if (meta.metaType() == Types1_18.META_TYPES.particleType) {
|
||||
Particle particle = (Particle) meta.getValue();
|
||||
final Particle particle = (Particle) meta.getValue();
|
||||
if (particle.getId() == 2) { // Barrier
|
||||
particle.setId(3); // Block marker
|
||||
particle.getArguments().add(new Particle.ParticleData(Type.VAR_INT, 7754)); // Barrier state
|
||||
|
||||
+19
-4
@@ -118,11 +118,24 @@ public final class WorldPackets {
|
||||
final NumberTag yTag = tag.get("y");
|
||||
final NumberTag zTag = tag.get("z");
|
||||
final StringTag idTag = tag.get("id");
|
||||
if (xTag == null || yTag == null || zTag == null || idTag == null) {
|
||||
if (xTag == null || yTag == null || zTag == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String id = idTag.getValue();
|
||||
final String id;
|
||||
if (idTag == null) {
|
||||
// Thank you 1.8, very cool (might have to be moved somewhere else)
|
||||
if (tag.get("Chest") instanceof StringTag) {
|
||||
id = "minecraft:chest";
|
||||
} else if (tag.get("EnderChest") instanceof StringTag) {
|
||||
id = "minecraft:ender_chest";
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
id = idTag.getValue();
|
||||
}
|
||||
|
||||
final int typeId = protocol.getMappingData().blockEntityIds().getInt(id.replace("minecraft:", ""));
|
||||
if (typeId == -1) {
|
||||
Via.getPlatform().getLogger().warning("Unknown block entity: " + id);
|
||||
@@ -155,11 +168,13 @@ public final class WorldPackets {
|
||||
|
||||
final int offset = i * ChunkSection.BIOME_SIZE;
|
||||
for (int biomeIndex = 0, biomeArrayIndex = offset; biomeIndex < ChunkSection.BIOME_SIZE; biomeIndex++, biomeArrayIndex++) {
|
||||
biomePalette.setIdAt(biomeIndex, biomeData[biomeArrayIndex]);
|
||||
// Also catch invalid biomes with id -1
|
||||
final int biome = biomeData[biomeArrayIndex];
|
||||
biomePalette.setIdAt(biomeIndex, biome != -1 ? biome : 0);
|
||||
}
|
||||
}
|
||||
|
||||
final Chunk chunk = new Chunk1_18(oldChunk.getX(), oldChunk.getZ(), oldChunk.getSections(), oldChunk.getHeightMap(), blockEntities);
|
||||
final Chunk chunk = new Chunk1_18(oldChunk.getX(), oldChunk.getZ(), sections, oldChunk.getHeightMap(), blockEntities);
|
||||
wrapper.write(new Chunk1_18Type(tracker.currentWorldSectionHeight(),
|
||||
MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().mappedSize()),
|
||||
MathUtil.ceilLog2(tracker.biomesSent())), chunk);
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.ParticleMappings;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
@@ -482,9 +483,10 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
if (mappings.isBlockParticle(id)) {
|
||||
Particle.ParticleData data = particle.getArguments().get(0);
|
||||
data.setValue(protocol.getMappingData().getNewBlockStateId(data.get()));
|
||||
} else if (mappings.isItemParticle(id)) {
|
||||
} else if (mappings.isItemParticle(id) && protocol.getItemRewriter() != null) {
|
||||
Particle.ParticleData data = particle.getArguments().get(0);
|
||||
data.setValue(protocol.getMappingData().getNewItemId(data.get()));
|
||||
Item item = data.get();
|
||||
protocol.getItemRewriter().handleItemToClient(item);
|
||||
}
|
||||
|
||||
particle.setId(protocol.getMappingData().getNewParticleId(id));
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viaversion.util;
|
||||
|
||||
public final class MathUtil {
|
||||
|
||||
/**
|
||||
* Returns the ceiled log to the base of 2 for the given number.
|
||||
*
|
||||
* @param i positive number to ceillog
|
||||
* @return ceiled log2 of the given number
|
||||
*/
|
||||
public static int ceilLog2(final int i) {
|
||||
return i > 0 ? 32 - Integer.numberOfLeadingZeros(i - 1) : 0;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
|
||||
projectVersion=4.1.0
|
||||
projectVersion=4.1.1
|
||||
|
||||
# Gradle properties
|
||||
org.gradle.daemon=true
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
Reference in new issue
Block a user