3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-10-08 11:10:06 +02:00

Merge pull request #923 from creeper123123321/master

Named sound effect rewriting + Effect rewriting
Dieser Commit ist enthalten in:
Myles 2018-07-29 12:59:01 +01:00 committet von GitHub
Commit c9dab5402e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
6 geänderte Dateien mit 332 neuen und 74 gelöschten Zeilen

Datei anzeigen

@ -69,9 +69,13 @@ public class BungeeEncodeHandler extends MessageToMessageEncoder<ByteBuf> {
}
if (needsCompress) {
ByteBuf old = bytebuf;
bytebuf = BungeePipelineUtil.compress(ctx, bytebuf);
old.release();
out.add(bytebuf);
} else {
out.add(bytebuf.retain());
}
out.add(bytebuf.retain());
}
@Override

Datei anzeigen

@ -201,7 +201,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
registerOutgoing(State.PLAY, 0x15, 0x16);
// InventoryPackets 0x16 -> 0x17
registerOutgoing(State.PLAY, 0x17, 0x18);
// InventoryPackets 0x18 -> 0x19
// WorldPackets 0x18 -> 0x19
registerOutgoing(State.PLAY, 0x1A, 0x1B);
registerOutgoing(State.PLAY, 0x1B, 0x1C);
// New packet 0x1D - NBT Query
@ -210,7 +210,31 @@ public class Protocol1_13To1_12_2 extends Protocol {
registerOutgoing(State.PLAY, 0x1E, 0x20);
registerOutgoing(State.PLAY, 0x1F, 0x21);
// WorldPackets 0x20 -> 0x22
registerOutgoing(State.PLAY, 0x21, 0x23);
// Effect packet
registerOutgoing(State.PLAY, 0x21, 0x23, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // Effect Id
map(Type.POSITION); // Location
map(Type.INT); // Data
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int id = wrapper.get(Type.INT, 0);
int data = wrapper.get(Type.INT, 1);
if (id == 1010) { // Play record
wrapper.set(Type.INT, 1, data = MappingData.oldToNewItems.get(data << 4));
} else if (id == 2001) { // Block break + block break sound
int blockId = data & 0xFFF;
int blockData = data >> 12;
wrapper.set(Type.INT, 1, data = WorldPackets.toNewId(blockId << 4 | blockData));
}
}
});
}
});
// WorldPackets 0x22 -> 0x24
// Join (save dimension id)
registerOutgoing(State.PLAY, 0x23, 0x25, new PacketRemapper() {
@ -449,7 +473,9 @@ public class Protocol1_13To1_12_2 extends Protocol {
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.STRING); // Title
wrapper.passthrough(Type.STRING); // Description
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.ITEM)); // Translate item to flat item
Item icon = wrapper.read(Type.ITEM);
InventoryPackets.toClient(icon);
wrapper.write(Type.FLAT_ITEM, icon); // Translate item to flat item
wrapper.passthrough(Type.VAR_INT); // Frame type
int flags = wrapper.passthrough(Type.INT); // Flags
if ((flags & 1) != 0)
@ -814,7 +840,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
}
private int getNewSoundID(final int oldID) {
return MappingData.oldToNewSounds.get(oldID);
return MappingData.soundMappings.getNewSound(oldID);
}
// Based on method from https://github.com/Bukkit/Bukkit/blob/master/src/main/java/org/bukkit/ChatColor.java

Datei anzeigen

@ -5,14 +5,13 @@ import com.google.common.collect.HashBiMap;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.netty.util.collection.IntObjectHashMap;
import io.netty.util.collection.IntObjectMap;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.util.GsonUtil;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@ -22,7 +21,7 @@ public class MappingData {
public static Map<String, Integer[]> itemTags = new HashMap<>();
public static Map<String, Integer[]> fluidTags = new HashMap<>();
public static BiMap<Short, String> oldEnchantmentsIds = HashBiMap.create();
public static Map<Integer, Integer> oldToNewSounds = new HashMap<>();
public static SoundMappings soundMappings;
public static BlockMappings blockMappings;
public static void init() {
@ -30,13 +29,7 @@ public class MappingData {
JsonObject mapping1_13 = loadData("mapping-1.13.json");
Via.getPlatform().getLogger().info("Loading block mapping...");
try {
Class.forName("io.netty.util.collection.IntObjectMap");
blockMappings = new BMNettyCollections();
} catch (ClassNotFoundException e) {
blockMappings = new BMJDKCollections();
}
blockMappings.init(mapping1_12, mapping1_13);
blockMappings = new BlockMappingsShortArray(mapping1_12.getAsJsonObject("blocks"), mapping1_13.getAsJsonObject("blocks"));
Via.getPlatform().getLogger().info("Loading item mapping...");
mapIdentifiers(oldToNewItems, mapping1_12.getAsJsonObject("items"), mapping1_13.getAsJsonObject("items"));
Via.getPlatform().getLogger().info("Loading new tags...");
@ -46,7 +39,7 @@ public class MappingData {
Via.getPlatform().getLogger().info("Loading enchantments...");
loadEnchantments(oldEnchantmentsIds, mapping1_12.getAsJsonObject("enchantments"));
Via.getPlatform().getLogger().info("Loading sound mapping...");
mapIdentifiers(oldToNewSounds, mapping1_12.getAsJsonArray("sounds"), mapping1_13.getAsJsonArray("sounds"));
soundMappings = new SoundMappingShortArray(mapping1_12.getAsJsonArray("sounds"), mapping1_13.getAsJsonArray("sounds"));
}
public static JsonObject loadData(String name) {
@ -125,47 +118,61 @@ public class MappingData {
}
public interface BlockMappings {
void init(JsonObject mapping1_12, JsonObject mapping1_13);
Integer getNewBlock(int old);
int getNewBlock(int old);
}
private static class BMJDKCollections implements BlockMappings {
private Map<Integer, Integer> oldToNew = new HashMap<>();
@Override
public void init(JsonObject mapping1_12, JsonObject mapping1_13) {
mapIdentifiers(oldToNew, mapping1_12.getAsJsonObject("blocks"), mapping1_13.getAsJsonObject("blocks"));
}
@Override
public Integer getNewBlock(int old) {
return oldToNew.get(old);
}
}
private static class BMNettyCollections implements BlockMappings {
private IntObjectMap<Integer> oldToNew = new IntObjectHashMap<>();
@Override
public void init(JsonObject mapping1_12, JsonObject mapping1_13) {
mapIdentifiers(oldToNew, mapping1_12.getAsJsonObject("blocks"), mapping1_13.getAsJsonObject("blocks"));
}
@Override
public Integer getNewBlock(int old) {
return oldToNew.get(old);
}
private static void mapIdentifiers(IntObjectMap<Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
continue;
}
output.put(Integer.parseInt(entry.getKey()), Integer.parseInt(value.getKey()));
private static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
continue;
}
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
}
}
private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) {
for (int i = 0; i < oldIdentifiers.size(); i++) {
JsonElement v = oldIdentifiers.get(i);
Integer index = findIndex(newIdentifiers, v.getAsString());
if (index == null) {
Via.getPlatform().getLogger().warning("No key for " + v + " :( ");
continue;
}
output[i] = index.shortValue();
}
}
private static class BlockMappingsShortArray implements BlockMappings {
private short[] oldToNew = new short[4084];
private BlockMappingsShortArray(JsonObject mapping1_12, JsonObject mapping1_13) {
Arrays.fill(oldToNew, (short) -1);
mapIdentifiers(oldToNew, mapping1_12, mapping1_13);
}
@Override
public int getNewBlock(int old) {
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
}
}
public interface SoundMappings {
int getNewSound(int old);
}
private static class SoundMappingShortArray implements SoundMappings {
private short[] oldToNew = new short[662];
private SoundMappingShortArray(JsonArray mapping1_12, JsonArray mapping1_13) {
Arrays.fill(oldToNew, (short) -1);
mapIdentifiers(oldToNew, mapping1_12, mapping1_13);
}
@Override
public int getNewSound(int old) {
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
}
}
}

Datei anzeigen

@ -0,0 +1,152 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data;
import java.util.HashMap;
import java.util.Map;
public class NamedSoundRewriter {
private static Map<String, String> oldToNew = new HashMap<>();
static {
// Extracted from Minecraft Wiki
oldToNew.put("block.cloth.break", "block.wool.break");
oldToNew.put("block.cloth.fall", "block.wool.fall");
oldToNew.put("block.cloth.hit", "block.wool.hit");
oldToNew.put("block.cloth.place", "block.wool.place");
oldToNew.put("block.cloth.step", "block.wool.step");
oldToNew.put("block.enderchest.close", "block.ender_chest.close");
oldToNew.put("block.enderchest.open", "block.ender_chest.open");
oldToNew.put("block.metal_pressureplate.click_off", "block.metal_pressure_plate.click_off");
oldToNew.put("block.metal_pressureplate.click_on", "block.metal_pressure_plate.click_on");
oldToNew.put("block.note.basedrum", "block.note_block.basedrum");
oldToNew.put("block.note.bass", "block.note_block.bass");
oldToNew.put("block.note.bell", "block.note_block.bell");
oldToNew.put("block.note.chime", "block.note_block.chime");
oldToNew.put("block.note.flute", "block.note_block.flute");
oldToNew.put("block.note.guitar", "block.note_block.guitar");
oldToNew.put("block.note.harp", "block.note_block.harp");
oldToNew.put("block.note.hat", "block.note_block.hat");
oldToNew.put("block.note.pling", "block.note_block.pling");
oldToNew.put("block.note.snare", "block.note_block.snare");
oldToNew.put("block.note.xylophone", "block.note_block.xylophone");
oldToNew.put("block.slime.break", "block.slime_block.break");
oldToNew.put("block.slime.fall", "block.slime_block.fall");
oldToNew.put("block.slime.hit", "block.slime_block.hit");
oldToNew.put("block.slime.place", "block.slime_block.place");
oldToNew.put("block.slime.step", "block.slime_block.step");
oldToNew.put("block.stone_pressureplate.click_off", "block.stone_pressure_plate.click_off");
oldToNew.put("block.stone_pressureplate.click_on", "block.stone_pressure_plate.click_on");
oldToNew.put("block.waterlily.place", "block.lily_pad.place");
oldToNew.put("block.wood_pressureplate.click_off", "block.wooden_pressure_plate.click_off");
oldToNew.put("block.wood_button.click_on", "block.wooden_button.click_on");
oldToNew.put("block.wood_button.click_off", "block.wooden_button.click_off");
oldToNew.put("block.wood_pressureplate.click_on", "block.wooden_pressure_plate.click_on");
oldToNew.put("entity.armorstand.break", "entity.armor_stand.break");
oldToNew.put("entity.armorstand.fall", "entity.armor_stand.fall");
oldToNew.put("entity.armorstand.hit", "entity.armor_stand.hit");
oldToNew.put("entity.armorstand.place", "entity.armor_stand.place");
oldToNew.put("entity.bobber.retrieve", "entity.fishing_bobber.retrieve");
oldToNew.put("entity.bobber.splash", "entity.fishing_bobber.splash");
oldToNew.put("entity.bobber.throw", "entity.fishing_bobber.throw");
oldToNew.put("entity.enderdragon.ambient", "entity.ender_dragon.ambient");
oldToNew.put("entity.enderdragon.death", "entity.ender_dragon.death");
oldToNew.put("entity.enderdragon.flap", "entity.ender_dragon.flap");
oldToNew.put("entity.enderdragon.growl", "entity.ender_dragon.growl");
oldToNew.put("entity.enderdragon.hurt", "entity.ender_dragon.hurt");
oldToNew.put("entity.enderdragon.shoot", "entity.ender_dragon.shoot");
oldToNew.put("entity.enderdragon_fireball.explode", "entity.dragon_fireball.explode");
oldToNew.put("entity.endereye.death", "entity.ender_eye.death");
oldToNew.put("entity.endereye.launch", "entity.ender_eye.launch");
oldToNew.put("entity.endermen.ambient", "entity.enderman.ambient");
oldToNew.put("entity.endermen.death", "entity.enderman.death");
oldToNew.put("entity.endermen.hurt", "entity.enderman.hurt");
oldToNew.put("entity.endermen.scream", "entity.enderman.scream");
oldToNew.put("entity.endermen.stare", "entity.enderman.stare");
oldToNew.put("entity.endermen.teleport", "entity.enderman.teleport");
oldToNew.put("entity.enderpearl.throw", "entity.ender_pearl.throw");
oldToNew.put("entity.evocation_illager.ambient", "entity.evoker.ambient");
oldToNew.put("entity.evocation_illager.cast_spell", "entity.evoker.cast_spell");
oldToNew.put("entity.evocation_illager.death", "entity.evoker.death");
oldToNew.put("entity.evocation_illager.hurt", "entity.evoker.hurt");
oldToNew.put("entity.evocation_illager.prepare_attack", "entity.evoker.prepare_attack");
oldToNew.put("entity.evocation_illager.prepare_summon", "entity.evoker.prepare_summon");
oldToNew.put("entity.evocation_illager.prepare_wololo", "entity.evoker.prepare_wololo");
oldToNew.put("entity.firework.blast", "entity.firework_rocket.blast");
oldToNew.put("entity.firework.blast_far", "entity.firework_rocket.blast_far");
oldToNew.put("entity.firework.large_blast", "entity.firework_rocket.large_blast");
oldToNew.put("entity.firework.large_blast_far", "entity.firework_rocket.large_blast_far");
oldToNew.put("entity.firework.launch", "entity.firework_rocket.launch");
oldToNew.put("entity.firework.shoot", "entity.firework_rocket.shoot");
oldToNew.put("entity.firework.twinkle", "entity.firework_rocket.twinkle");
oldToNew.put("entity.firework.twinkle_far", "entity.firework_rocket.twinkle_far");
oldToNew.put("entity.illusion_illager.ambient", "entity.illusioner.ambient");
oldToNew.put("entity.illusion_illager.cast_spell", "entity.illusioner.cast_spell");
oldToNew.put("entity.illusion_illager.death", "entity.illusioner.death");
oldToNew.put("entity.illusion_illager.hurt", "entity.illusioner.hurt");
oldToNew.put("entity.illusion_illager.mirror_move", "entity.illusioner.mirror_move");
oldToNew.put("entity.illusion_illager.prepare_blindness", "entity.illusioner.prepare_blindness");
oldToNew.put("entity.illusion_illager.prepare_mirror", "entity.illusioner.prepare_mirror");
oldToNew.put("entity.irongolem.attack", "entity.iron_golem.attack");
oldToNew.put("entity.irongolem.death", "entity.iron_golem.death");
oldToNew.put("entity.irongolem.hurt", "entity.iron_golem.hurt");
oldToNew.put("entity.irongolem.step", "entity.iron_golem.step");
oldToNew.put("entity.itemframe.add_item", "entity.item_frame.add_item");
oldToNew.put("entity.itemframe.break", "entity.item_frame.break");
oldToNew.put("entity.itemframe.place", "entity.item_frame.place");
oldToNew.put("entity.itemframe.remove_item", "entity.item_frame.remove_item");
oldToNew.put("entity.itemframe.rotate_item", "entity.item_frame.rotate_item");
oldToNew.put("entity.leashknot.break", "entity.leash_knot.break");
oldToNew.put("entity.leashknot.place", "entity.leash_knot.place");
oldToNew.put("entity.lightning.impact", "entity.lightning_bolt.impact");
oldToNew.put("entity.lightning.thunder", "entity.lightning_bolt.thunder");
oldToNew.put("entity.lingeringpotion.throw", "entity.lingering_potion.throw");
oldToNew.put("entity.magmacube.death", "entity.magma_cube.death");
oldToNew.put("entity.magmacube.hurt", "entity.magma_cube.hurt");
oldToNew.put("entity.magmacube.jump", "entity.magma_cube.jump");
oldToNew.put("entity.magmacube.squish", "entity.magma_cube.squish");
oldToNew.put("entity.parrot.imitate.enderdragon", "entity.parrot.imitate.ender_dragon");
oldToNew.put("entity.parrot.imitate.evocation_illager", "entity.parrot.imitate.evoker");
oldToNew.put("entity.parrot.imitate.illusion_illager", "entity.parrot.imitate.illusioner");
oldToNew.put("entity.parrot.imitate.magmacube", "entity.parrot.imitate.magma_cube");
oldToNew.put("entity.parrot.imitate.vindication_illager", "entity.parrot.imitate.vindicator");
oldToNew.put("entity.player.splash.highspeed", "entity.player.splash.high_speed");
oldToNew.put("entity.polar_bear.baby_ambient", "entity.polar_bear.ambient_baby");
oldToNew.put("entity.small_magmacube.death", "entity.magma_cube.death_small");
oldToNew.put("entity.small_magmacube.hurt", "entity.magma_cube.hurt_small");
oldToNew.put("entity.small_magmacube.squish", "entity.magma_cube.squish_small");
oldToNew.put("entity.small_slime.death", "entity.slime.death_small");
oldToNew.put("entity.small_slime.hurt", "entity.slime.hurt_small");
oldToNew.put("entity.small_slime.jump", "entity.slime.jump_small");
oldToNew.put("entity.small_slime.squish", "entity.slime.squish_small");
oldToNew.put("entity.snowman.ambient", "entity.snow_golem.ambient");
oldToNew.put("entity.snowman.death", "entity.snow_golem.death");
oldToNew.put("entity.snowman.hurt", "entity.snow_golem.hurt");
oldToNew.put("entity.snowman.shoot", "entity.snow_golem.shoot");
oldToNew.put("entity.vindication_illager.ambient", "entity.vindicator.ambient");
oldToNew.put("entity.vindication_illager.death", "entity.vindicator.death");
oldToNew.put("entity.vindication_illager.hurt", "entity.vindicator.hurt");
oldToNew.put("entity.zombie.attack_door_wood", "entity.zombie.attack_wooden_door");
oldToNew.put("entity.zombie.break_door_wood", "entity.zombie.break_wooden_door");
oldToNew.put("entity.zombie_pig.ambient", "entity.zombie_pigman.ambient");
oldToNew.put("entity.zombie_pig.angry", "entity.zombie_pigman.angry");
oldToNew.put("entity.zombie_pig.death", "entity.zombie_pigman.death");
oldToNew.put("entity.zombie_pig.hurt", "entity.zombie_pigman.hurt");
oldToNew.put("record.11", "music_disc.11");
oldToNew.put("record.13", "music_disc.13");
oldToNew.put("record.blocks", "music_disc.blocks");
oldToNew.put("record.cat", "music_disc.cat");
oldToNew.put("record.chirp", "music_disc.chirp");
oldToNew.put("record.far", "music_disc.far");
oldToNew.put("record.mall", "music_disc.mall");
oldToNew.put("record.mellohi", "music_disc.mellohi");
oldToNew.put("record.stal", "music_disc.stal");
oldToNew.put("record.strad", "music_disc.strad");
oldToNew.put("record.wait", "music_disc.wait");
oldToNew.put("record.ward", "music_disc.ward");
}
public static String getNewId(String old) {
String newId = oldToNew.get(old);
return newId != null ? newId : old.toLowerCase();
}
}

Datei anzeigen

@ -14,7 +14,9 @@ import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.ParticleRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.providers.BlockEntityProvider;
@ -85,6 +87,55 @@ public class WorldPackets {
}
});
// Block action
protocol.registerOutgoing(State.PLAY, 0xA, 0xA, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.POSITION); // Location
map(Type.UNSIGNED_BYTE); // Action Id
map(Type.UNSIGNED_BYTE); // Action param
map(Type.VAR_INT); // Block Id - /!\ NOT BLOCK STATE ID
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
Position pos = wrapper.get(Type.POSITION, 0);
short action = wrapper.get(Type.UNSIGNED_BYTE, 0);
short param = wrapper.get(Type.UNSIGNED_BYTE, 1);
int blockId = wrapper.get(Type.VAR_INT, 0);
if (blockId == 25)
blockId = 73;
else if (blockId == 33)
blockId = 99;
else if (blockId == 29)
blockId = 92;
else if (blockId == 54)
blockId = 142;
else if (blockId == 146)
blockId = 305;
else if (blockId == 130)
blockId = 249;
else if (blockId == 138)
blockId = 257;
else if (blockId == 52)
blockId = 140;
else if (blockId == 209)
blockId = 472;
else if (blockId >= 219 && blockId <= 234)
blockId = blockId - 219 + 483;
if (blockId == 73) { // Note block
PacketWrapper blockChange = wrapper.create(0x0B); // block change
blockChange.write(Type.POSITION, new Position(pos.getX(), pos.getY(), pos.getZ())); // Clone because position is mutable
blockChange.write(Type.VAR_INT, 248 + (action * 24 * 2) + (param * 2));
blockChange.send(Protocol1_13To1_12_2.class, true, true);
}
wrapper.set(Type.VAR_INT, 0, blockId);
}
});
}
});
// Block Change
protocol.registerOutgoing(State.PLAY, 0xB, 0xB, new PacketRemapper() {
@Override
@ -130,7 +181,19 @@ public class WorldPackets {
});
// Named Sound Effect TODO String -> Identifier? Check if identifier is present?
protocol.registerOutgoing(State.PLAY, 0x19, 0x1A);
protocol.registerOutgoing(State.PLAY, 0x19, 0x1A, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.STRING);
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
String newSoundId = NamedSoundRewriter.getNewId(wrapper.get(Type.STRING, 0));
wrapper.set(Type.STRING, 0, newSoundId);
}
});
}
});
// Chunk Data
protocol.registerOutgoing(State.PLAY, 0x20, 0x22, new PacketRemapper() {
@ -152,21 +215,29 @@ public class WorldPackets {
if (section == null)
continue;
// TODO improve performance
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
int block = section.getBlock(x, y, z);
boolean willStoreAnyBlock = false;
int newId = toNewId(block);
section.setFlatBlock(x, y, z, newId);
for (int p = 0; p < section.getPalette().size(); p++) {
int old = section.getPalette().get(p);
int newId = toNewId(old);
if (storage.isWelcome(newId)) {
willStoreAnyBlock = true;
}
section.getPalette().set(p, newId);
}
if (storage.isWelcome(newId)) {
storage.store(new Position(
(long) (x + (chunk.getX() << 4)),
(long) (y + (i << 4)),
(long) (z + (chunk.getZ() << 4))
), newId);
if (willStoreAnyBlock) {
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
int block = section.getBlock(x, y, z);
if (storage.isWelcome(block)) {
storage.store(new Position(
(long) (x + (chunk.getX() << 4)),
(long) (y + (i << 4)),
(long) (z + (chunk.getZ() << 4))
), block);
}
}
}
}
@ -276,12 +347,12 @@ public class WorldPackets {
if (oldId < 0) {
oldId = 0; // Some plugins use negative numbers to clear blocks, remap them to air.
}
Integer newId = MappingData.blockMappings.getNewBlock(oldId);
if (newId != null) {
int newId = MappingData.blockMappings.getNewBlock(oldId);
if (newId != -1) {
return newId;
}
newId = MappingData.blockMappings.getNewBlock(oldId & ~0xF); // Remove data
if (newId != null) {
if (newId != -1) {
Via.getPlatform().getLogger().warning("Missing block " + oldId);
return newId;
}

Datei anzeigen

@ -95,12 +95,10 @@
</dependency>
<!-- Netty (Network Library) -->
<!-- You should make this work with 4.0.20.Final -->
<!-- Using 4.0.23.Final to use Netty Collections -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.23.Final</version>
<version>4.0.20.Final</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>