diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/AbilityInstances.java b/src/main/java/gregtech/api/metatileentity/multiblock/AbilityInstances.java index 56f2333ecd7..5f69ac57bde 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/AbilityInstances.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/AbilityInstances.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.multiblock; +import gregtech.api.util.GTLog; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -100,7 +102,8 @@ protected boolean canAdd(Object o) { public void add(int index, Object element) { if (!key.checkType(element)) throw new IllegalArgumentException( - String.format("element's class \"%s\" is not of type \"%s\"", element.getClass(), + String.format("element \"%s\" does not extend/implement \"%s\"", + element.getClass().getSimpleName(), this.key.getType())); if (!instances.contains(element)) instances.add(index, element); @@ -117,10 +120,16 @@ public void add(int index, Object element) { public Object set(int index, Object element) { if (!key.checkType(element)) throw new IllegalArgumentException( - String.format("element's class \"%s\" is not of type \"%s\"", element.getClass(), + String.format("element \"%s\" does not extend/implement \"%s\"", + element.getClass().getSimpleName(), this.key.getType())); - if (instances.contains(element)) + + int existing = instances.indexOf(element); + if (existing != -1) { + GTLog.logger.warn("attempted to set \"{}\" at index {} when we already have it at {}", + element.getClass().getSimpleName(), index, existing); return null; + } return instances.set(index, element); } diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/IMultiblockAbilityPart.java b/src/main/java/gregtech/api/metatileentity/multiblock/IMultiblockAbilityPart.java index dcaeb179d22..d66334adf4c 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/IMultiblockAbilityPart.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/IMultiblockAbilityPart.java @@ -30,7 +30,8 @@ public interface IMultiblockAbilityPart extends IMultiblockPart { /** * Register abilities to the multiblock here *
- * Check {@link AbilityInstances#isKey(MultiblockAbility) AbiliteInstances.isKey()} if you override {@link IMultiblockAbilityPart#getAbilities()} + * Check {@link AbilityInstances#isKey(MultiblockAbility) AbiliteInstances.isKey()} if you override + * {@link IMultiblockAbilityPart#getAbilities()} * * @param abilityInstances list to register abilities to */ diff --git a/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockAbility.java b/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockAbility.java index 1a9eac30790..8ce0e0d7273 100644 --- a/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockAbility.java +++ b/src/main/java/gregtech/api/metatileentity/multiblock/MultiblockAbility.java @@ -125,7 +125,7 @@ public boolean checkType(Object o) { } public String getType() { - return this.clazz.toString(); + return this.clazz.getSimpleName(); } public @Nullable T checkAndCast(Object o) {