diff options
author | SHsuperCM <shsupercm@gmail.com> | 2021-10-09 10:06:14 +0300 |
---|---|---|
committer | SHsuperCM <shsupercm@gmail.com> | 2021-10-09 10:06:14 +0300 |
commit | d7f842a6dd474d69709a6c47296e4873ead74a50 (patch) | |
tree | 5694a3073d49ed9bc3f90c116dab70a2a100cfb9 /src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits | |
parent | 9d84d9e53c59390d6d350efe1bee30dc35b2b5a2 (diff) | |
download | CITResewn-d7f842a6dd474d69709a6c47296e4873ead74a50.tar.gz CITResewn-d7f842a6dd474d69709a6c47296e4873ead74a50.tar.bz2 CITResewn-d7f842a6dd474d69709a6c47296e4873ead74a50.zip |
CIT Enchantment parsing and active storage
#15
Diffstat (limited to 'src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits')
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java index 6f8cc76..16222a7 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CITEnchantment.java @@ -1,13 +1,49 @@ package shcm.shsupercm.fabric.citresewn.pack.cits; +import net.minecraft.resource.ResourceType; import net.minecraft.util.Identifier; import shcm.shsupercm.fabric.citresewn.ex.CITParseException; import shcm.shsupercm.fabric.citresewn.pack.CITPack; +import java.util.Locale; import java.util.Properties; public class CITEnchantment extends CIT { + public final Identifier textureIdentifier; + public final float speed, rotation, duration; + public final int layer; + public final Blend blend; + public CITEnchantment(CITPack pack, Identifier identifier, Properties properties) throws CITParseException { super(pack, identifier, properties); + try { + textureIdentifier = resolvePath(identifier, properties.getProperty("texture"), ".png", id -> pack.resourcePack.contains(ResourceType.CLIENT_RESOURCES, id)); + if (textureIdentifier == null) + throw new Exception("Cannot resolve texture"); + + layer = Integer.parseInt(properties.getProperty("layer", "0")); + + blend = Blend.valueOf(properties.getProperty("blend", "add").toUpperCase(Locale.ENGLISH)); + + speed = Float.parseFloat(properties.getProperty("speed", "0")); + + rotation = Float.parseFloat(properties.getProperty("rotation", "0")); + + duration = Float.max(0f, Float.parseFloat(properties.getProperty("duration", "0"))); + } catch (Exception e) { + throw new CITParseException(pack.resourcePack, identifier, (e.getClass() == Exception.class ? "" : e.getClass().getSimpleName() + ": ") + e.getMessage()); + } + } + + public enum Blend { + ADD, + SUBTRACT, + MULTIPLY, + DODGE, + BURN, + SCREEN, + REPLACE, + OVERLAY, + ALPHA; } -} +}
\ No newline at end of file |