diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2022-11-07 23:09:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-07 16:09:55 +0100 |
commit | 6c3d4537f1f98d66f09436a9fae99a7b4644ecf5 (patch) | |
tree | adf57af6bd219bd80157800a24c0758e58ab1de3 /src/main/java/gregtech/api/enums | |
parent | acfa3dfed94b0e8c69ab6439593197338701b1c4 (diff) | |
download | GT5-Unofficial-6c3d4537f1f98d66f09436a9fae99a7b4644ecf5.tar.gz GT5-Unofficial-6c3d4537f1f98d66f09436a9fae99a7b4644ecf5.tar.bz2 GT5-Unofficial-6c3d4537f1f98d66f09436a9fae99a7b4644ecf5.zip |
remove compat with IC2 fuel can (#1506)
* remove compat with IC2 fuel can
* Spotless apply for branch feature/remove-ic2-fuel-can for #1506 (#1507)
Co-authored-by: Glease <4586901+Glease@users.noreply.github.com>
Co-authored-by: GitHub GTNH Actions <>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/api/enums')
-rw-r--r-- | src/main/java/gregtech/api/enums/ItemList.java | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index 07f06b950c..f68bbb145f 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -5,6 +5,7 @@ import static gregtech.api.enums.GT_Values.W; import gregtech.api.interfaces.IItemContainer; import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; @@ -87,8 +88,10 @@ public enum ItemList implements IItemContainer { IC2_Compressed_Coal_Ball, IC2_Compressed_Coal_Chunk, IC2_Fuel_Rod_Empty, - IC2_Fuel_Can_Empty, - IC2_Fuel_Can_Filled, + @Deprecated + IC2_Fuel_Can_Empty(true), + @Deprecated + IC2_Fuel_Can_Filled(true), IC2_Food_Can_Empty, IC2_Food_Can_Filled, IC2_Food_Can_Spoiled, @@ -2111,7 +2114,20 @@ public enum ItemList implements IItemContainer { sLeadZincSolution, sHydrochloricAcid; private ItemStack mStack; - private boolean mHasNotBeenSet = true; + private boolean mHasNotBeenSet; + private boolean mDeprecated; + private boolean mWarned; + + ItemList() { + mHasNotBeenSet = true; + } + + ItemList(boolean aDeprecated) { + if (aDeprecated) { + mDeprecated = true; + mHasNotBeenSet = true; + } + } @Override public IItemContainer set(Item aItem) { @@ -2131,16 +2147,14 @@ public enum ItemList implements IItemContainer { @Override public Item getItem() { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + sanityCheck(); if (GT_Utility.isStackInvalid(mStack)) return null; return mStack.getItem(); } @Override public Block getBlock() { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + sanityCheck(); return GT_Utility.getBlockFromItem(getItem()); } @@ -2156,38 +2170,39 @@ public enum ItemList implements IItemContainer { @Override public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT) { + if (mDeprecated && !mWarned) { + new Exception(this + " is now deprecated").printStackTrace(GT_Log.err); + // warn only once + mWarned = true; + } if (GT_Utility.isStackInvalid(aStack)) return false; return GT_Utility.areUnificationsEqual((ItemStack) aStack, aWildcard ? getWildcard(1) : get(1), aIgnoreNBT); } @Override public ItemStack get(long aAmount, Object... aReplacements) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + sanityCheck(); if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(mStack)); } @Override public ItemStack getWildcard(long aAmount, Object... aReplacements) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + sanityCheck(); if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); return GT_Utility.copyAmountAndMetaData(aAmount, W, GT_OreDictUnificator.get(mStack)); } @Override public ItemStack getUndamaged(long aAmount, Object... aReplacements) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + sanityCheck(); if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); return GT_Utility.copyAmountAndMetaData(aAmount, 0, GT_OreDictUnificator.get(mStack)); } @Override public ItemStack getAlmostBroken(long aAmount, Object... aReplacements) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + sanityCheck(); if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); return GT_Utility.copyAmountAndMetaData(aAmount, mStack.getMaxDamage() - 1, GT_OreDictUnificator.get(mStack)); } @@ -2228,24 +2243,21 @@ public enum ItemList implements IItemContainer { @Override public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + sanityCheck(); if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); return GT_Utility.copyAmountAndMetaData(aAmount, aMetaValue, GT_OreDictUnificator.get(mStack)); } @Override public IItemContainer registerOre(Object... aOreNames) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + sanityCheck(); for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, get(1)); return this; } @Override public IItemContainer registerWildcardAsOre(Object... aOreNames) { - if (mHasNotBeenSet) - throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + sanityCheck(); for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, getWildcard(1)); return this; } @@ -2258,4 +2270,14 @@ public enum ItemList implements IItemContainer { public ItemStack getInternalStack_unsafe() { return mStack; } + + private void sanityCheck() { + if (mHasNotBeenSet) + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + if (mDeprecated && !mWarned) { + new Exception(this + " is now deprecated").printStackTrace(GT_Log.err); + // warn only once + mWarned = true; + } + } } |