diff options
author | SHsuperCM <shsupercm@gmail.com> | 2021-10-09 17:44:19 +0300 |
---|---|---|
committer | SHsuperCM <shsupercm@gmail.com> | 2021-10-09 17:44:19 +0300 |
commit | 3e60c7b5cf646fbda1c15b38877ba7e5022dd2e2 (patch) | |
tree | 33caefca8ec95d254070d8f8158c148b2b2a543b | |
parent | e3ddc19843e7a70a391782e835091bb0bda9e2a6 (diff) | |
download | CITResewn-3e60c7b5cf646fbda1c15b38877ba7e5022dd2e2.tar.gz CITResewn-3e60c7b5cf646fbda1c15b38877ba7e5022dd2e2.tar.bz2 CITResewn-3e60c7b5cf646fbda1c15b38877ba7e5022dd2e2.zip |
Setup for enchantment layer application
#15
6 files changed, 41 insertions, 7 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java b/src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java index f4d2b5b..9e39287 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/ActiveCITs.java @@ -69,14 +69,14 @@ public class ActiveCITs { List<CITItem> citItems = this.citItems.get(stack.getItem()); if (citItems != null) for (CITItem citItem : citItems) - if (citItem.test(stack, hand, world, entity)) + if (citItem.test(stack, hand, world, entity, true)) return citItem; return null; } public CITElytra getCITElytra(ItemStack stack, World world, LivingEntity livingEntity) { for (CITElytra citElytra : citElytra) - if (citElytra.test(stack, Hand.MAIN_HAND, world, livingEntity)) + if (citElytra.test(stack, Hand.MAIN_HAND, world, livingEntity, true)) return citElytra; return null; } @@ -87,12 +87,27 @@ public class ActiveCITs { List<CITArmor> citArmor = this.citArmor.get(item); if (citArmor != null) for (CITArmor armor : citArmor) - if (armor.test(stack, null, world, livingEntity)) + if (armor.test(stack, null, world, livingEntity, true)) return armor; } return null; } + public List<CITEnchantment> getCITEnchantment(ItemStack stack, World world, LivingEntity livingEntity) { + Hand hand = livingEntity != null && stack == livingEntity.getOffHandStack() ? Hand.OFF_HAND : Hand.MAIN_HAND; + + List<CITEnchantment> applied = new ArrayList<>(); + + for (List<CITEnchantment> layer : this.citEnchantments) + for (CITEnchantment cit : layer) + if (cit.test(stack, hand, world, livingEntity, false)) { + applied.add(cit); + break; + } + + return applied; + } + public BakedModel getItemModelCached(ItemStack stack, World world, LivingEntity entity, int seed) { BakedModel bakedModel = null; diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citenchantment/ItemRendererMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citenchantment/ItemRendererMixin.java new file mode 100644 index 0000000..b19e901 --- /dev/null +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citenchantment/ItemRendererMixin.java @@ -0,0 +1,8 @@ +package shcm.shsupercm.fabric.citresewn.mixin.citenchantment; + +import net.minecraft.client.render.item.ItemRenderer; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(ItemRenderer.class) +public class ItemRendererMixin { +}
\ No newline at end of file diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citenchantment/ItemStackMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citenchantment/ItemStackMixin.java new file mode 100644 index 0000000..07faf22 --- /dev/null +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/citenchantment/ItemStackMixin.java @@ -0,0 +1,8 @@ +package shcm.shsupercm.fabric.citresewn.mixin.citenchantment; + +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(ItemStack.class) +public class ItemStackMixin { +} diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java index ebfcaf1..db29fdd 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/pack/cits/CIT.java @@ -251,7 +251,10 @@ public abstract class CIT { } } - public boolean test(ItemStack stack, Hand hand, World world, LivingEntity entity) { + public boolean test(ItemStack stack, Hand hand, World world, LivingEntity entity, boolean ignoreItemType) { + if (!ignoreItemType && !items.contains(stack.getItem())) + return false; + if (!damageAny && stack.getItem().isDamageable()) { int damage = stack.getDamage(); if (damageMask != null) 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 b1c37db..cd0b604 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 @@ -36,8 +36,6 @@ public class CITEnchantment extends CIT { 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()); } diff --git a/src/main/resources/citresewn.mixins.json b/src/main/resources/citresewn.mixins.json index 3c6ba99..79caa97 100644 --- a/src/main/resources/citresewn.mixins.json +++ b/src/main/resources/citresewn.mixins.json @@ -14,11 +14,13 @@ "citelytra.ElytraFeatureRendererMixin", "citelytra.ItemStackMixin", "citenchantment.BufferBuilderStorageAccessor", + "citenchantment.ItemRendererMixin", + "citenchantment.ItemStackMixin", "citenchantment.RenderPhaseAccessor", "cititem.ItemRendererMixin", "cititem.ItemStackMixin", - "cititem.ModelLoaderMixin", "cititem.JsonUnbakedModelAccessor", + "cititem.ModelLoaderMixin", "core.GroupResourcePackAccessor", "core.ModelLoaderMixin", "core.NbtCompoundAccessor", |