Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 22:40:18 +01:00
Merge pull request #1 from davchoo/feature/blocky
Fix light components and overriding inventory blocks
Dieser Commit ist enthalten in:
Commit
1e75b88215
@ -76,7 +76,9 @@ public class BlockInventoryHolder extends InventoryHolder {
|
|||||||
// (This could be a virtual inventory that the player is opening)
|
// (This could be a virtual inventory that the player is opening)
|
||||||
if (checkInteractionPosition(session)) {
|
if (checkInteractionPosition(session)) {
|
||||||
// Then, check to see if the interacted block is valid for this inventory by ensuring the block state identifier is valid
|
// Then, check to see if the interacted block is valid for this inventory by ensuring the block state identifier is valid
|
||||||
|
// and the bedrock block is vanilla
|
||||||
int javaBlockId = session.getGeyser().getWorldManager().getBlockAt(session, session.getLastInteractionBlockPosition());
|
int javaBlockId = session.getGeyser().getWorldManager().getBlockAt(session, session.getLastInteractionBlockPosition());
|
||||||
|
if (!BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.get().containsKey(javaBlockId)) {
|
||||||
String[] javaBlockString = BlockRegistries.JAVA_IDENTIFIERS.get().getOrDefault(javaBlockId, "minecraft:air").split("\\[");
|
String[] javaBlockString = BlockRegistries.JAVA_IDENTIFIERS.get().getOrDefault(javaBlockId, "minecraft:air").split("\\[");
|
||||||
if (isValidBlock(javaBlockString)) {
|
if (isValidBlock(javaBlockString)) {
|
||||||
// We can safely use this block
|
// We can safely use this block
|
||||||
@ -87,6 +89,7 @@ public class BlockInventoryHolder extends InventoryHolder {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Vector3i position = InventoryUtils.findAvailableWorldSpace(session);
|
Vector3i position = InventoryUtils.findAvailableWorldSpace(session);
|
||||||
if (position == null) {
|
if (position == null) {
|
||||||
@ -96,7 +99,7 @@ public class BlockInventoryHolder extends InventoryHolder {
|
|||||||
UpdateBlockPacket blockPacket = new UpdateBlockPacket();
|
UpdateBlockPacket blockPacket = new UpdateBlockPacket();
|
||||||
blockPacket.setDataLayer(0);
|
blockPacket.setDataLayer(0);
|
||||||
blockPacket.setBlockPosition(position);
|
blockPacket.setBlockPosition(position);
|
||||||
blockPacket.setRuntimeId(session.getBlockMappings().getBedrockBlockId(defaultJavaBlockState));
|
blockPacket.setRuntimeId(session.getBlockMappings().getVanillaBedrockBlockId(defaultJavaBlockState));
|
||||||
blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY);
|
blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY);
|
||||||
session.sendUpstreamPacket(blockPacket);
|
session.sendUpstreamPacket(blockPacket);
|
||||||
inventory.setHolderPosition(position);
|
inventory.setHolderPosition(position);
|
||||||
|
@ -118,7 +118,7 @@ public class BlockRegistries {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
CustomSkullRegistryPopulator.populate();
|
CustomSkullRegistryPopulator.populate();
|
||||||
BlockRegistryPopulator.populate();
|
BlockRegistryPopulator.registerJavaBlocks();
|
||||||
COLLISIONS = IntMappedRegistry.create(Pair.of("org.geysermc.geyser.translator.collision.CollisionRemapper", "mappings/collision.json"), CollisionRegistryLoader::new);
|
COLLISIONS = IntMappedRegistry.create(Pair.of("org.geysermc.geyser.translator.collision.CollisionRemapper", "mappings/collision.json"), CollisionRegistryLoader::new);
|
||||||
CustomBlockRegistryPopulator.registerCustomBedrockBlocks();
|
CustomBlockRegistryPopulator.registerCustomBedrockBlocks();
|
||||||
BlockRegistryPopulator.registerBedrockBlocks();
|
BlockRegistryPopulator.registerBedrockBlocks();
|
||||||
|
@ -74,14 +74,6 @@ public final class BlockRegistryPopulator {
|
|||||||
*/
|
*/
|
||||||
private static JsonNode BLOCKS_JSON;
|
private static JsonNode BLOCKS_JSON;
|
||||||
|
|
||||||
public static void populate() {
|
|
||||||
registerJavaBlocks();
|
|
||||||
// CustomBlockRegistryPopulator.registerCustomBedrockBlocks() and registerBedrockBlocks() moved to BlockRegistries to ensure correct load order
|
|
||||||
|
|
||||||
// Needs to be placed somewhere at some point
|
|
||||||
//BLOCKS_JSON = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void registerBedrockBlocks() {
|
public static void registerBedrockBlocks() {
|
||||||
BiFunction<String, NbtMapBuilder, String> emptyMapper = (bedrockIdentifier, statesBuilder) -> null;
|
BiFunction<String, NbtMapBuilder, String> emptyMapper = (bedrockIdentifier, statesBuilder) -> null;
|
||||||
ImmutableMap<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> blockMappers = ImmutableMap.<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>>builder()
|
ImmutableMap<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>> blockMappers = ImmutableMap.<ObjectIntPair<String>, BiFunction<String, NbtMapBuilder, String>>builder()
|
||||||
@ -262,9 +254,11 @@ public final class BlockRegistryPopulator {
|
|||||||
.customBlockStateIds(customBlockStateIds)
|
.customBlockStateIds(customBlockStateIds)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BLOCKS_JSON = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerJavaBlocks() {
|
public static void registerJavaBlocks() {
|
||||||
JsonNode blocksJson;
|
JsonNode blocksJson;
|
||||||
try (InputStream stream = GeyserImpl.getInstance().getBootstrap().getResource("mappings/blocks.json")) {
|
try (InputStream stream = GeyserImpl.getInstance().getBootstrap().getResource("mappings/blocks.json")) {
|
||||||
blocksJson = GeyserImpl.JSON_MAPPER.readTree(stream);
|
blocksJson = GeyserImpl.JSON_MAPPER.readTree(stream);
|
||||||
|
@ -254,15 +254,12 @@ public class CustomBlockRegistryPopulator {
|
|||||||
}
|
}
|
||||||
if (components.lightEmission() != null) {
|
if (components.lightEmission() != null) {
|
||||||
builder.putCompound("minecraft:light_emission", NbtMap.builder()
|
builder.putCompound("minecraft:light_emission", NbtMap.builder()
|
||||||
.putInt("value", components.lightEmission())
|
.putByte("emission", components.lightEmission().byteValue())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
// This is supposed to be sent as "light_dampening" since "block_light_filter" is the old value
|
|
||||||
// However, it seems they forgot to actually update it on the network despite all the documentation changing
|
|
||||||
// So we'll send this for now
|
|
||||||
if (components.lightDampening() != null) {
|
if (components.lightDampening() != null) {
|
||||||
builder.putCompound("minecraft:block_light_filter", NbtMap.builder()
|
builder.putCompound("minecraft:light_dampening", NbtMap.builder()
|
||||||
.putByte("value", components.lightDampening().byteValue())
|
.putByte("lightLevel", components.lightDampening().byteValue())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
if (components.rotation() != null) {
|
if (components.rotation() != null) {
|
||||||
|
@ -55,6 +55,7 @@ public class DoubleChestInventoryTranslator extends ChestInventoryTranslator {
|
|||||||
// See BlockInventoryHolder - same concept there except we're also dealing with a specific block state
|
// See BlockInventoryHolder - same concept there except we're also dealing with a specific block state
|
||||||
if (session.getLastInteractionPlayerPosition().equals(session.getPlayerEntity().getPosition())) {
|
if (session.getLastInteractionPlayerPosition().equals(session.getPlayerEntity().getPosition())) {
|
||||||
int javaBlockId = session.getGeyser().getWorldManager().getBlockAt(session, session.getLastInteractionBlockPosition());
|
int javaBlockId = session.getGeyser().getWorldManager().getBlockAt(session, session.getLastInteractionBlockPosition());
|
||||||
|
if (!BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.get().containsKey(javaBlockId)) {
|
||||||
String[] javaBlockString = BlockRegistries.JAVA_IDENTIFIERS.get().getOrDefault(javaBlockId, "minecraft:air").split("\\[");
|
String[] javaBlockString = BlockRegistries.JAVA_IDENTIFIERS.get().getOrDefault(javaBlockId, "minecraft:air").split("\\[");
|
||||||
if (javaBlockString.length > 1 && (javaBlockString[0].equals("minecraft:chest") || javaBlockString[0].equals("minecraft:trapped_chest"))
|
if (javaBlockString.length > 1 && (javaBlockString[0].equals("minecraft:chest") || javaBlockString[0].equals("minecraft:trapped_chest"))
|
||||||
&& !javaBlockString[1].contains("type=single")) {
|
&& !javaBlockString[1].contains("type=single")) {
|
||||||
@ -81,6 +82,7 @@ public class DoubleChestInventoryTranslator extends ChestInventoryTranslator {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Vector3i position = InventoryUtils.findAvailableWorldSpace(session);
|
Vector3i position = InventoryUtils.findAvailableWorldSpace(session);
|
||||||
if (position == null) {
|
if (position == null) {
|
||||||
@ -88,7 +90,7 @@ public class DoubleChestInventoryTranslator extends ChestInventoryTranslator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector3i pairPosition = position.add(Vector3i.UNIT_X);
|
Vector3i pairPosition = position.add(Vector3i.UNIT_X);
|
||||||
int bedrockBlockId = session.getBlockMappings().getBedrockBlockId(defaultJavaBlockState);
|
int bedrockBlockId = session.getBlockMappings().getVanillaBedrockBlockId(defaultJavaBlockState);
|
||||||
|
|
||||||
UpdateBlockPacket blockPacket = new UpdateBlockPacket();
|
UpdateBlockPacket blockPacket = new UpdateBlockPacket();
|
||||||
blockPacket.setDataLayer(0);
|
blockPacket.setDataLayer(0);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren