Skip to content

Commit

Permalink
Account for no food properties on items
Browse files Browse the repository at this point in the history
Signed-off-by: TheSilkMiner <thesilkminer@outlook.com>
  • Loading branch information
TheSilkMiner committed Jul 29, 2022
1 parent 4aa0ded commit 8824f75
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private List<IParsedType> generics() throws CompileException {
final IZenClassRegistry classes = CraftTweakerAPI.getRegistry().getZenClassRegistry();

final Class<?> objectType = this.objectType.type();
final String objectName = classes.getNameFor(loader, this.objectType.type()).orElseThrow();
final String objectName = classes.getNameFor(loader, objectType).orElseThrow();

final String referenceName = this.buildGenericReferenceName(loader, classes, objectType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraft.world.food.FoodProperties;
import org.openzen.zencode.java.ZenCodeType;

import java.util.Objects;

@ZenCodeType.Name(ContentTweakerVanillaConstants.VANILLA_OBJECT_PACKAGE + ".property.FoodItemProperties")
@ZenRegister(loaders = ContentTweakerConstants.CONTENT_LOADER_ID)
public final class FoodItemProperties extends ItemProperties {
Expand Down Expand Up @@ -37,6 +39,6 @@ public boolean fastFood() {
// TODO("Effects")

private FoodProperties resolveProperties() {
return this.resolve().getFoodProperties();
return Objects.requireNonNull(this.resolve().getFoodProperties(), () -> "The item " + this.reference().id() + " is not a food");
}
}

0 comments on commit 8824f75

Please sign in to comment.