mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Make BlockInventoryHolder block strings immutable; clean up lectern unloading
This commit is contained in:
parent
72186d91f1
commit
22c39d285e
2 changed files with 7 additions and 4 deletions
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue