mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-10 01:10:30 +00:00
Simplify the previous patch a little
We can use BlockEntityType.getKey, rather than having to extend our registry wrappers.
This commit is contained in:
parent
128ac2f109
commit
ab00580389
@ -8,9 +8,9 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
|||||||
import dan200.computercraft.api.peripheral.PeripheralType;
|
import dan200.computercraft.api.peripheral.PeripheralType;
|
||||||
import dan200.computercraft.core.methods.NamedMethod;
|
import dan200.computercraft.core.methods.NamedMethod;
|
||||||
import dan200.computercraft.core.methods.PeripheralMethod;
|
import dan200.computercraft.core.methods.PeripheralMethod;
|
||||||
import dan200.computercraft.shared.platform.RegistryWrappers;
|
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ final class GenericPeripheralBuilder {
|
|||||||
|
|
||||||
String type;
|
String type;
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
var typeId = RegistryWrappers.BLOCK_ENTITY_TYPES.tryGetKey(blockEntity.getType());
|
var typeId = BlockEntityType.getKey(blockEntity.getType());
|
||||||
if (typeId == null) {
|
if (typeId == null) {
|
||||||
LOG.error(
|
LOG.error(
|
||||||
"Block entity {} for {} was not registered. Skipping creating a generic peripheral for it.",
|
"Block entity {} for {} was not registered. Skipping creating a generic peripheral for it.",
|
||||||
|
@ -38,8 +38,6 @@ public final class RegistryWrappers {
|
|||||||
public interface RegistryWrapper<T> extends IdMap<T> {
|
public interface RegistryWrapper<T> extends IdMap<T> {
|
||||||
ResourceLocation getKey(T object);
|
ResourceLocation getKey(T object);
|
||||||
|
|
||||||
@Nullable ResourceLocation tryGetKey(T object);
|
|
||||||
|
|
||||||
T get(ResourceLocation location);
|
T get(ResourceLocation location);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -268,12 +268,6 @@ public class TestPlatformHelper extends AbstractComputerCraftAPI implements Plat
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ResourceLocation tryGetKey(T object) {
|
|
||||||
return registry.getKey(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T get(ResourceLocation location) {
|
public T get(ResourceLocation location) {
|
||||||
var object = registry.get(location);
|
var object = registry.get(location);
|
||||||
|
@ -337,12 +337,6 @@ public class PlatformHelperImpl implements PlatformHelper {
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ResourceLocation tryGetKey(T object) {
|
|
||||||
return registry.getKey(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T get(ResourceLocation location) {
|
public T get(ResourceLocation location) {
|
||||||
var object = registry.get(location);
|
var object = registry.get(location);
|
||||||
|
@ -360,12 +360,6 @@ public class PlatformHelperImpl implements PlatformHelper {
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ResourceLocation tryGetKey(T object) {
|
|
||||||
return registry.getKey(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T get(ResourceLocation location) {
|
public T get(ResourceLocation location) {
|
||||||
var object = registry.getValue(location);
|
var object = registry.getValue(location);
|
||||||
|
Loading…
Reference in New Issue
Block a user