Search in sources :

Example 1 with InvalidRecipeConfigException

use of crazypants.enderio.base.config.recipes.InvalidRecipeConfigException in project EnderIO by SleepyTrousers.

the class ConditionDependency method readResolve.

@Override
public Object readResolve() throws InvalidRecipeConfigException {
    try {
        if (itemString == null || itemString.trim().isEmpty()) {
            throw new InvalidRecipeConfigException("Missing item");
        }
        item = new ItemOptional().setAllowDelaying(false);
        item.setName(itemString);
        item.readResolve();
    } catch (InvalidRecipeConfigException e) {
        throw new InvalidRecipeConfigException(e, "in <dependency>");
    }
    return this;
}
Also used : InvalidRecipeConfigException(crazypants.enderio.base.config.recipes.InvalidRecipeConfigException)

Example 2 with InvalidRecipeConfigException

use of crazypants.enderio.base.config.recipes.InvalidRecipeConfigException in project EnderIO by SleepyTrousers.

the class Entity method enforceValidity.

@Override
public void enforceValidity() throws InvalidRecipeConfigException {
    if (!isValid()) {
        Log.warn("Could not find an entity for '" + name + "'");
        Log.warn("Available entities are:");
        for (CapturedMob possible : CapturedMob.getAllSouls()) {
            Log.warn(" -> " + possible.getEntityName() + " (" + possible.getDisplayName() + ")");
        // Log.warn(" <entity name=\"" + possible.getEntityName() + "\" costMultiplier=\"1\" disabled=\"false\"/> <!-- " + possible.getDisplayName() + " -->");
        }
        throw new InvalidRecipeConfigException("Could not find an entity for '" + name + "'");
    }
}
Also used : CapturedMob(crazypants.enderio.util.CapturedMob) InvalidRecipeConfigException(crazypants.enderio.base.config.recipes.InvalidRecipeConfigException)

Example 3 with InvalidRecipeConfigException

use of crazypants.enderio.base.config.recipes.InvalidRecipeConfigException in project EnderIO by SleepyTrousers.

the class Fluid method readResolve.

@Override
public Object readResolve() throws InvalidRecipeConfigException {
    if (name == null || name.trim().isEmpty()) {
        throw new InvalidRecipeConfigException("Missing fluid name");
    }
    fluid = FluidRegistry.getFluid(name);
    final String nbt_nullchecked = nbt;
    if (nbt_nullchecked != null) {
        if (!nbt_nullchecked.trim().isEmpty()) {
            try {
                tag = JsonToNBT.getTagFromJson(nbt_nullchecked);
            } catch (NBTException e) {
                throw new InvalidRecipeConfigException(nbt_nullchecked + " is not valid NBT json.");
            }
        }
    }
    return this;
}
Also used : InvalidRecipeConfigException(crazypants.enderio.base.config.recipes.InvalidRecipeConfigException) NBTException(net.minecraft.nbt.NBTException)

Example 4 with InvalidRecipeConfigException

use of crazypants.enderio.base.config.recipes.InvalidRecipeConfigException in project EnderIO by SleepyTrousers.

the class Grid method readResolve.

@Override
public Object readResolve() throws InvalidRecipeConfigException {
    try {
        if (size != null && !size.trim().isEmpty() && !"3x3".equals(size.trim())) {
            if (size.trim().length() != 3 || size.charAt(1) != 'x') {
                throw new InvalidRecipeConfigException("Invalid size attribute '" + size.trim());
            }
            String widthString = size.substring(0, 1);
            String heightString = size.substring(2, 3);
            try {
                width = Integer.parseInt(widthString);
                height = Integer.parseInt(heightString);
            } catch (NumberFormatException e) {
                throw new InvalidRecipeConfigException("Invalid size attribute '" + size.trim());
            }
            if (width < 1 || width > 3 || height < 1 || height > 3) {
                throw new InvalidRecipeConfigException("Invalid size attribute '" + size.trim());
            }
        } else {
            width = height = 3;
        }
        if (items == null) {
            throw new InvalidRecipeConfigException("No items");
        }
        if (items.isEmpty() || items.size() < width * height) {
            throw new InvalidRecipeConfigException("Not enough items (required=" + (width * height) + ", provided=" + items.size() + ")");
        }
        if (items.size() > width * height) {
            throw new InvalidRecipeConfigException("Too many items (required=" + (width * height) + ", provided=" + items.size() + ")");
        }
        valid = true;
        for (ItemOptional item : items) {
            valid = valid && item.isValid();
        }
    } catch (InvalidRecipeConfigException e) {
        throw new InvalidRecipeConfigException(e, "in <grid>");
    }
    return this;
}
Also used : InvalidRecipeConfigException(crazypants.enderio.base.config.recipes.InvalidRecipeConfigException)

Example 5 with InvalidRecipeConfigException

use of crazypants.enderio.base.config.recipes.InvalidRecipeConfigException in project EnderIO by SleepyTrousers.

the class Grindingball method readResolve.

@Override
public Object readResolve() throws InvalidRecipeConfigException {
    if (disabled) {
        return this;
    }
    try {
        super.readResolve();
        if (item == null) {
            throw new InvalidRecipeConfigException("Missing <item>");
        }
        if (durability <= 0) {
            throw new InvalidRecipeConfigException("'durability' is invalid'");
        }
        if (grinding <= 0 || grinding > 5f) {
            throw new InvalidRecipeConfigException("'grinding' is invalid'");
        }
        if (chance <= 0 || chance > 5f) {
            throw new InvalidRecipeConfigException("'chance' is invalid'");
        }
        if (power <= 0 || power > 5f) {
            throw new InvalidRecipeConfigException("'power' is invalid'");
        }
        valid = item.isValid();
        if (required && !valid && active) {
            throw new InvalidRecipeConfigException("No valid <item>");
        }
    } catch (InvalidRecipeConfigException e) {
        throw new InvalidRecipeConfigException(e, "in <grindingball>");
    }
    return this;
}
Also used : InvalidRecipeConfigException(crazypants.enderio.base.config.recipes.InvalidRecipeConfigException)

Aggregations

InvalidRecipeConfigException (crazypants.enderio.base.config.recipes.InvalidRecipeConfigException)13 NBTException (net.minecraft.nbt.NBTException)3 CapturedMob (crazypants.enderio.util.CapturedMob)1