Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 00:00:41 +01:00
Make BlockInventoryHolder block strings immutable; clean up lectern unloading
Dieser Commit ist enthalten in:
Ursprung
72186d91f1
Commit
22c39d285e
@ -26,7 +26,7 @@
|
|||||||
package org.geysermc.connector.network.translators.inventory.holder;
|
package org.geysermc.connector.network.translators.inventory.holder;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
import com.nukkitx.nbt.NbtMap;
|
import com.nukkitx.nbt.NbtMap;
|
||||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
||||||
@ -40,6 +40,7 @@ import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
|
|||||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,8 +59,10 @@ public class BlockInventoryHolder extends InventoryHolder {
|
|||||||
this.defaultJavaBlockState = BlockTranslator.getJavaBlockState(javaBlockIdentifier);
|
this.defaultJavaBlockState = BlockTranslator.getJavaBlockState(javaBlockIdentifier);
|
||||||
this.containerType = containerType;
|
this.containerType = containerType;
|
||||||
if (validBlocks != null) {
|
if (validBlocks != null) {
|
||||||
this.validBlocks = Sets.newHashSet(validBlocks);
|
Set<String> validBlocksTemp = new HashSet<>(validBlocks.length + 1);
|
||||||
this.validBlocks.add(javaBlockIdentifier.split("\\[")[0]);
|
Collections.addAll(validBlocksTemp, validBlocks);
|
||||||
|
validBlocksTemp.add(javaBlockIdentifier.split("\\[")[0]);
|
||||||
|
this.validBlocks = ImmutableSet.copyOf(validBlocksTemp);
|
||||||
} else {
|
} else {
|
||||||
this.validBlocks = Collections.singleton(javaBlockIdentifier.split("\\[")[0]);
|
this.validBlocks = Collections.singleton(javaBlockIdentifier.split("\\[")[0]);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public class JavaUnloadChunkTranslator extends PacketTranslator<ServerUnloadChun
|
|||||||
iterator = session.getLecternCache().iterator();
|
iterator = session.getLecternCache().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Vector3i position = iterator.next();
|
Vector3i position = iterator.next();
|
||||||
if (Math.floor((double) position.getX() / 16) == packet.getX() && Math.floor((double) position.getZ() / 16) == packet.getZ()) {
|
if ((position.getX() >> 4) == packet.getX() && (position.getZ() >> 4) == packet.getZ()) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren