1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-24 01:09:30 +00:00

Fix non-vanilla block breaking (#5575)

* Keep track of non-vanilla block break.

* Just use simple BitSet registry.
This commit is contained in:
oryxel
2025-06-05 01:34:41 +07:00
committed by GitHub
parent f3656f7dac
commit f104a3d4ca
3 changed files with 8 additions and 1 deletions

View File

@@ -82,6 +82,11 @@ public class BlockRegistries {
*/
public static final MappedRegistry<String, Integer, Object2IntMap<String>> JAVA_IDENTIFIER_TO_ID = MappedRegistry.create(RegistryLoaders.empty(Object2IntOpenHashMap::new));
/**
* A registry containing non-vanilla block IDS.
*/
public static final SimpleRegistry<BitSet> NON_VANILLA_BLOCK_IDS = SimpleRegistry.create(RegistryLoaders.empty(BitSet::new));
/**
* A registry containing all the waterlogged blockstates.
* Properties.WATERLOGGED should not be relied on for two reasons:

View File

@@ -303,6 +303,7 @@ public class CustomBlockRegistryPopulator {
BlockRegistries.JAVA_BLOCKS.registerWithAnyIndex(javaBlockState.stateGroupId(), block, Blocks.AIR);
BlockRegistries.JAVA_IDENTIFIER_TO_ID.register(javaId, stateRuntimeId);
BlockRegistries.NON_VANILLA_BLOCK_IDS.register(set -> set.set(stateRuntimeId));
// TODO register different collision types?
BoundingBox[] geyserCollisions = Arrays.stream(javaBlockState.collision())

View File

@@ -33,6 +33,7 @@ import org.cloudburstmc.protocol.bedrock.data.PlayerBlockActionData;
import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition;
import org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket;
import org.geysermc.geyser.api.block.custom.CustomBlockState;
import org.geysermc.geyser.api.block.custom.nonvanilla.JavaBlockState;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.type.ItemFrameEntity;
import org.geysermc.geyser.inventory.GeyserItemStack;
@@ -101,7 +102,7 @@ final class BedrockBlockActions {
SkullCache.Skull skull = session.getSkullCache().getSkulls().get(vector);
session.setBlockBreakStartTime(0);
if (blockStateOverride != null || customItem != null || (skull != null && skull.getBlockDefinition() != null)) {
if (BlockRegistries.NON_VANILLA_BLOCK_IDS.get().get(blockState) || blockStateOverride != null || customItem != null || (skull != null && skull.getBlockDefinition() != null)) {
session.setBlockBreakStartTime(System.currentTimeMillis());
}
startBreak.setData((int) (65535 / breakTime));