Skip to content

Commit

Permalink
have option to disable empty item crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
botn365 committed Nov 25, 2024
1 parent c34e759 commit cf664dd
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/main/java/gregtech/api/enums/ItemList.java
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,7 @@ public enum ItemList implements IItemContainer {
;
private ItemStack mStack;
private boolean mHasNotBeenSet = true;
public boolean dontCrashOnEmpty = false;
public static boolean crashOnEmpty = true;

@Override
public IItemContainer set(Item aItem) {
Expand All @@ -1947,17 +1947,23 @@ public IItemContainer set(ItemStack aStack) {

@Override
public Item getItem() {
if (mHasNotBeenSet)
throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
if (mHasNotBeenSet){
if (crashOnEmpty) {
throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
}
}
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!");
if (mHasNotBeenSet){
if (crashOnEmpty) {
throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
}
}
return GT_Utility.getBlockFromItem(getItem());
}

Expand All @@ -1981,7 +1987,7 @@ public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT
@Override
public ItemStack get(long aAmount, Object... aReplacements) {
if (mHasNotBeenSet) {
if (dontCrashOnEmpty) {
if (crashOnEmpty) {
throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
}
}
Expand All @@ -1993,7 +1999,7 @@ public ItemStack get(long aAmount, Object... aReplacements) {
@Override
public ItemStack getWildcard(long aAmount, Object... aReplacements) {
if (mHasNotBeenSet) {
if (dontCrashOnEmpty) {
if (crashOnEmpty) {
throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
}
}
Expand All @@ -2005,7 +2011,7 @@ public ItemStack getWildcard(long aAmount, Object... aReplacements) {
@Override
public ItemStack getUndamaged(long aAmount, Object... aReplacements) {
if (mHasNotBeenSet) {
if (dontCrashOnEmpty) {
if (crashOnEmpty) {
throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
}
}
Expand All @@ -2017,7 +2023,7 @@ public ItemStack getUndamaged(long aAmount, Object... aReplacements) {
@Override
public ItemStack getAlmostBroken(long aAmount, Object... aReplacements) {
if (mHasNotBeenSet) {
if (dontCrashOnEmpty) {
if (crashOnEmpty) {
throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
}
}
Expand Down Expand Up @@ -2063,7 +2069,7 @@ public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacement
@Override
public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements) {
if (mHasNotBeenSet) {
if (dontCrashOnEmpty) {
if (crashOnEmpty) {
throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
}
}
Expand All @@ -2075,7 +2081,7 @@ public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplace
@Override
public IItemContainer registerOre(Object... aOreNames) {
if (mHasNotBeenSet) {
if (dontCrashOnEmpty) {
if (crashOnEmpty) {
throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
}
}
Expand All @@ -2087,7 +2093,7 @@ public IItemContainer registerOre(Object... aOreNames) {
@Override
public IItemContainer registerWildcardAsOre(Object... aOreNames) {
if (mHasNotBeenSet) {
if (dontCrashOnEmpty) {
if (crashOnEmpty) {
throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!");
}
}
Expand Down

0 comments on commit cf664dd

Please sign in to comment.