refactor limit access to built-in registries
This commit is contained in:
1 parent
8dd08d5cb1
commit
bd5dfdbf9f
25 files changed
+243
-176
No files matched your search
@@ -4,7 +4,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@@ -227,6 +229,7 @@ public class BlockInfo
|
||||
Material material = state.getMaterial();
|
||||
Block block = state.getBlock();
|
||||
String metastring = "";
|
||||
final Registry<Block> blocks = world.registryAccess().registryOrThrow(Registries.BLOCK);
|
||||
for (net.minecraft.world.level.block.state.properties.Property<?> iproperty : state.getProperties())
|
||||
{
|
||||
metastring += ", "+iproperty.getName() + '='+state.getValue(iproperty);
|
||||
@@ -234,7 +237,7 @@ public class BlockInfo
|
||||
List<Component> lst = new ArrayList<>();
|
||||
lst.add(Messenger.s(""));
|
||||
lst.add(Messenger.s("====================================="));
|
||||
lst.add(Messenger.s(String.format("Block info for %s%s (id %d%s):", BuiltInRegistries.BLOCK.getKey(block),metastring, BuiltInRegistries.BLOCK.getId(block), metastring )));
|
||||
lst.add(Messenger.s(String.format("Block info for %s%s (id %d%s):", blocks.getKey(block),metastring, blocks.getId(block), metastring )));
|
||||
lst.add(Messenger.s(String.format(" - Material: %s", materialName.get(material))));
|
||||
lst.add(Messenger.s(String.format(" - Map colour: %s", mapColourName.get(state.getMapColor(world, pos)))));
|
||||
lst.add(Messenger.s(String.format(" - Sound type: %s", soundName.get(block.getSoundType(state)))));
|
||||
|
||||
Reference in new issue
Block a user