Simplify the previous patch a little

We can use BlockEntityType.getKey, rather than having to extend our
registry wrappers.
This commit is contained in:
Jonathan Coates 2024-03-17 16:21:56 +00:00
parent 128ac2f109
commit ab00580389
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
5 changed files with 2 additions and 22 deletions

View File

@ -8,9 +8,9 @@
import dan200.computercraft.api.peripheral.PeripheralType;
import dan200.computercraft.core.methods.NamedMethod;
import dan200.computercraft.core.methods.PeripheralMethod;
import dan200.computercraft.shared.platform.RegistryWrappers;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -40,7 +40,7 @@ IPeripheral toPeripheral(BlockEntity blockEntity, Direction side) {
String type;
if (name == null) {
var typeId = RegistryWrappers.BLOCK_ENTITY_TYPES.tryGetKey(blockEntity.getType());
var typeId = BlockEntityType.getKey(blockEntity.getType());
if (typeId == null) {
LOG.error(
"Block entity {} for {} was not registered. Skipping creating a generic peripheral for it.",

View File

@ -38,8 +38,6 @@ public final class RegistryWrappers {
public interface RegistryWrapper<T> extends IdMap<T> {
ResourceLocation getKey(T object);
@Nullable ResourceLocation tryGetKey(T object);
T get(ResourceLocation location);
@Nullable

View File

@ -268,12 +268,6 @@ public ResourceLocation getKey(T object) {
return key;
}
@Nullable
@Override
public ResourceLocation tryGetKey(T object) {
return registry.getKey(object);
}
@Override
public T get(ResourceLocation location) {
var object = registry.get(location);

View File

@ -337,12 +337,6 @@ public ResourceLocation getKey(T object) {
return key;
}
@Nullable
@Override
public ResourceLocation tryGetKey(T object) {
return registry.getKey(object);
}
@Override
public T get(ResourceLocation location) {
var object = registry.get(location);

View File

@ -360,12 +360,6 @@ public ResourceLocation getKey(T object) {
return key;
}
@Nullable
@Override
public ResourceLocation tryGetKey(T object) {
return registry.getKey(object);
}
@Override
public T get(ResourceLocation location) {
var object = registry.getValue(location);