mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Allow custom unusable-space blocker item (#4038)
* Allow the "unusable-space-block" to be a custom item (specified by bedrock identifier) * add space for log error * don't use ugly atomic reference
This commit is contained in:
parent
176ef83ed1
commit
b1f04a9012
1 changed files with 14 additions and 5 deletions
|
@ -208,12 +208,21 @@ public class InventoryUtils {
|
||||||
|
|
||||||
private static ItemDefinition getUnusableSpaceBlockDefinition(int protocolVersion) {
|
private static ItemDefinition getUnusableSpaceBlockDefinition(int protocolVersion) {
|
||||||
String unusableSpaceBlock = GeyserImpl.getInstance().getConfig().getUnusableSpaceBlock();
|
String unusableSpaceBlock = GeyserImpl.getInstance().getConfig().getUnusableSpaceBlock();
|
||||||
ItemMapping unusableSpaceBlockID = Registries.ITEMS.forVersion(protocolVersion).getMapping(unusableSpaceBlock);
|
ItemDefinition itemDefinition = null;
|
||||||
if (unusableSpaceBlockID != null) {
|
|
||||||
return unusableSpaceBlockID.getBedrockDefinition();
|
// looping through all the items to find the one with the specified Bedrock identifier
|
||||||
} else {
|
for (ItemDefinition definition : Registries.ITEMS.forVersion(protocolVersion).getItemDefinitions().values()) {
|
||||||
GeyserImpl.getInstance().getLogger().error("Invalid value" + unusableSpaceBlock + ". Resorting to barrier block.");
|
if (definition.getIdentifier().equals(unusableSpaceBlock)) {
|
||||||
|
itemDefinition = definition;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemDefinition == null) {
|
||||||
|
GeyserImpl.getInstance().getLogger().error("Invalid value " + unusableSpaceBlock + ". Resorting to barrier block.");
|
||||||
return Registries.ITEMS.forVersion(protocolVersion).getStoredItems().barrier().getBedrockDefinition();
|
return Registries.ITEMS.forVersion(protocolVersion).getStoredItems().barrier().getBedrockDefinition();
|
||||||
|
} else {
|
||||||
|
return itemDefinition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue