From 33db54e979043d68e9b30838c889c92c82398dc8 Mon Sep 17 00:00:00 2001 From: Talia-12 Date: Thu, 22 Jun 2023 00:45:00 +1000 Subject: [PATCH] fixed the damage types stuff, and HexItemModels. --- .../casting/eval/env/PlayerBasedCastEnv.java | 4 ++-- .../casting/eval/env/PlayerBasedMishapEnv.java | 3 ++- .../casting/mishaps/MishapAlreadyBrainswept.kt | 4 ++-- .../api/casting/mishaps/MishapBadBrainsweep.kt | 4 ++-- .../api/casting/mishaps/MishapShameOnYou.kt | 4 ++-- .../api/misc/DamageSourceOvercast.java | 12 ------------ .../api/misc/DamageSourceShameOnYou.java | 12 ------------ .../api/misc/EntityDamageSourceOvercast.java | 13 ------------- .../hexcasting/api/misc/HexDamageSources.java | 13 ------------- .../hexcasting/common/lib/HexDamageTypes.java | 17 +++++++++++++++++ Common/src/main/resources/hexplat.accesswidener | 2 ++ .../main/resources/fabricasting.accesswidener | 2 ++ .../forge/datagen/xplat/HexItemModels.java | 3 ++- .../resources/META-INF/accesstransformer.cfg | 2 ++ 14 files changed, 35 insertions(+), 60 deletions(-) delete mode 100644 Common/src/main/java/at/petrak/hexcasting/api/misc/DamageSourceOvercast.java delete mode 100644 Common/src/main/java/at/petrak/hexcasting/api/misc/DamageSourceShameOnYou.java delete mode 100644 Common/src/main/java/at/petrak/hexcasting/api/misc/EntityDamageSourceOvercast.java delete mode 100644 Common/src/main/java/at/petrak/hexcasting/api/misc/HexDamageSources.java create mode 100644 Common/src/main/java/at/petrak/hexcasting/common/lib/HexDamageTypes.java diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/PlayerBasedCastEnv.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/PlayerBasedCastEnv.java index 25b17d8e..af828b2d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/PlayerBasedCastEnv.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/PlayerBasedCastEnv.java @@ -9,12 +9,12 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment; import at.petrak.hexcasting.api.casting.eval.MishapEnvironment; import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect; import at.petrak.hexcasting.api.casting.mishaps.Mishap; -import at.petrak.hexcasting.api.misc.HexDamageSources; import at.petrak.hexcasting.api.mod.HexConfig; import at.petrak.hexcasting.api.mod.HexStatistics; import at.petrak.hexcasting.api.pigment.FrozenPigment; import at.petrak.hexcasting.api.utils.HexUtils; import at.petrak.hexcasting.api.utils.MediaHelper; +import at.petrak.hexcasting.common.lib.HexDamageTypes; import at.petrak.hexcasting.xplat.IXplatAbstractions; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -170,7 +170,7 @@ public abstract class PlayerBasedCastEnv extends CastingEnvironment { double healthToRemove = Math.max(costLeft / mediaToHealth, 0.5); var mediaAbleToCastFromHP = this.caster.getHealth() * mediaToHealth; - Mishap.trulyHurt(this.caster, HexDamageSources.OVERCAST, (float) healthToRemove); + Mishap.trulyHurt(this.caster, this.caster.damageSources().source(HexDamageTypes.OVERCAST), (float) healthToRemove); var actuallyTaken = Mth.ceil(mediaAbleToCastFromHP - (this.caster.getHealth() * mediaToHealth)); diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/PlayerBasedMishapEnv.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/PlayerBasedMishapEnv.java index 0dc90b4b..05c9227f 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/PlayerBasedMishapEnv.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/PlayerBasedMishapEnv.java @@ -3,6 +3,7 @@ package at.petrak.hexcasting.api.casting.eval.env; import at.petrak.hexcasting.api.casting.eval.MishapEnvironment; import at.petrak.hexcasting.api.casting.mishaps.Mishap; import at.petrak.hexcasting.api.misc.HexDamageSources; +import at.petrak.hexcasting.common.lib.HexDamageTypes; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.damagesource.DamageSource; @@ -36,7 +37,7 @@ public class PlayerBasedMishapEnv extends MishapEnvironment { @Override public void damage(float healthProportion) { - Mishap.trulyHurt(this.caster, HexDamageSources.OVERCAST, this.caster.getHealth() * healthProportion); + Mishap.trulyHurt(this.caster, this.caster.damageSources().source(HexDamageTypes.OVERCAST), this.caster.getHealth() * healthProportion); } @Override diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapAlreadyBrainswept.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapAlreadyBrainswept.kt index 6e238ac6..9e5918d9 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapAlreadyBrainswept.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapAlreadyBrainswept.kt @@ -3,8 +3,8 @@ package at.petrak.hexcasting.api.casting.mishaps import at.petrak.hexcasting.api.casting.ParticleSpray import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.iota.Iota -import at.petrak.hexcasting.api.misc.HexDamageSources import at.petrak.hexcasting.api.pigment.FrozenPigment +import at.petrak.hexcasting.common.lib.HexDamageTypes import net.minecraft.world.entity.Mob import net.minecraft.world.item.DyeColor @@ -13,7 +13,7 @@ class MishapAlreadyBrainswept(val mob: Mob) : Mishap() { dyeColor(DyeColor.GREEN) override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { - mob.hurt(HexDamageSources.overcastDamageFrom(ctx.caster), mob.health) + mob.hurt(mob.damageSources().source(HexDamageTypes.OVERCAST, ctx.caster), mob.health) } override fun particleSpray(ctx: CastingEnvironment) = diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadBrainsweep.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadBrainsweep.kt index e9cc0c10..4e235350 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadBrainsweep.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapBadBrainsweep.kt @@ -3,8 +3,8 @@ package at.petrak.hexcasting.api.casting.mishaps import at.petrak.hexcasting.api.casting.ParticleSpray import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.iota.Iota -import at.petrak.hexcasting.api.misc.HexDamageSources import at.petrak.hexcasting.api.pigment.FrozenPigment +import at.petrak.hexcasting.common.lib.HexDamageTypes import net.minecraft.core.BlockPos import net.minecraft.world.entity.Mob import net.minecraft.world.item.DyeColor @@ -15,7 +15,7 @@ class MishapBadBrainsweep(val mob: Mob, val pos: BlockPos) : Mishap() { dyeColor(DyeColor.GREEN) override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList) { - trulyHurt(mob, HexDamageSources.overcastDamageFrom(ctx.caster), 1f) + trulyHurt(mob, mob.damageSources().source(HexDamageTypes.OVERCAST, ctx.caster), 1f) } override fun particleSpray(ctx: CastingEnvironment): ParticleSpray { diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapShameOnYou.kt b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapShameOnYou.kt index 52173e1d..96ca4d2a 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapShameOnYou.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/mishaps/MishapShameOnYou.kt @@ -2,8 +2,8 @@ package at.petrak.hexcasting.api.casting.mishaps import at.petrak.hexcasting.api.casting.eval.CastingEnvironment import at.petrak.hexcasting.api.casting.iota.Iota -import at.petrak.hexcasting.api.misc.HexDamageSources import at.petrak.hexcasting.api.pigment.FrozenPigment +import at.petrak.hexcasting.common.lib.HexDamageTypes import net.minecraft.world.item.DyeColor class MishapShameOnYou() : Mishap() { @@ -14,7 +14,7 @@ class MishapShameOnYou() : Mishap() { val caster = ctx.caster if (caster != null) { // FIXME: handle null caster case - Mishap.trulyHurt(caster, HexDamageSources.SHAME, 69420f) + trulyHurt(caster, caster.damageSources().source(HexDamageTypes.SHAME_ON_YOU), 69420f) } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/misc/DamageSourceOvercast.java b/Common/src/main/java/at/petrak/hexcasting/api/misc/DamageSourceOvercast.java deleted file mode 100644 index 9cd89eea..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/misc/DamageSourceOvercast.java +++ /dev/null @@ -1,12 +0,0 @@ -package at.petrak.hexcasting.api.misc; - -import net.minecraft.world.damagesource.DamageSource; - -public class DamageSourceOvercast extends DamageSource { - public DamageSourceOvercast() { - super("hexcasting.overcast"); - this.bypassArmor(); - this.bypassMagic(); - this.setMagic(); - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/misc/DamageSourceShameOnYou.java b/Common/src/main/java/at/petrak/hexcasting/api/misc/DamageSourceShameOnYou.java deleted file mode 100644 index 32595b85..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/misc/DamageSourceShameOnYou.java +++ /dev/null @@ -1,12 +0,0 @@ -package at.petrak.hexcasting.api.misc; - -import net.minecraft.world.damagesource.DamageSource; - -public class DamageSourceShameOnYou extends DamageSource { - public DamageSourceShameOnYou() { - super("hexcasting.shame"); - this.bypassArmor(); - this.bypassMagic(); - this.setMagic(); - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/misc/EntityDamageSourceOvercast.java b/Common/src/main/java/at/petrak/hexcasting/api/misc/EntityDamageSourceOvercast.java deleted file mode 100644 index b5d91c76..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/misc/EntityDamageSourceOvercast.java +++ /dev/null @@ -1,13 +0,0 @@ -package at.petrak.hexcasting.api.misc; - -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.Entity; - -public class EntityDamageSourceOvercast extends DamageSource { - public EntityDamageSourceOvercast(Entity entity) { - super("hexcasting.overcast", entity); - this.bypassArmor(); - this.bypassMagic(); - this.setMagic(); - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/api/misc/HexDamageSources.java b/Common/src/main/java/at/petrak/hexcasting/api/misc/HexDamageSources.java deleted file mode 100644 index 8dd06719..00000000 --- a/Common/src/main/java/at/petrak/hexcasting/api/misc/HexDamageSources.java +++ /dev/null @@ -1,13 +0,0 @@ -package at.petrak.hexcasting.api.misc; - -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.Entity; - -public final class HexDamageSources { - public static final DamageSourceOvercast OVERCAST = new DamageSourceOvercast(); - public static final DamageSourceShameOnYou SHAME = new DamageSourceShameOnYou(); - - public static DamageSource overcastDamageFrom(Entity cause) { - return new EntityDamageSourceOvercast(cause); - } -} diff --git a/Common/src/main/java/at/petrak/hexcasting/common/lib/HexDamageTypes.java b/Common/src/main/java/at/petrak/hexcasting/common/lib/HexDamageTypes.java new file mode 100644 index 00000000..e27ac183 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/common/lib/HexDamageTypes.java @@ -0,0 +1,17 @@ +package at.petrak.hexcasting.common.lib; + +import net.minecraft.core.registries.Registries; +import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.damagesource.DamageType; + +public class HexDamageTypes { + public static final ResourceKey OVERCAST = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("overcast")); + public static final ResourceKey SHAME_ON_YOU = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("overcast")); + + public static void bootstrap(BootstapContext context) { + context.register(OVERCAST, new DamageType("hexcasting.overcast", 0f)); + context.register(SHAME_ON_YOU, new DamageType("hexcasting.shame", 0f)); + } +} diff --git a/Common/src/main/resources/hexplat.accesswidener b/Common/src/main/resources/hexplat.accesswidener index b3bfdcfc..d8a1955d 100644 --- a/Common/src/main/resources/hexplat.accesswidener +++ b/Common/src/main/resources/hexplat.accesswidener @@ -6,3 +6,5 @@ accessible class net/minecraft/client/renderer/RenderStateShard$EmptyTextureSta accessible class net/minecraft/world/item/crafting/Ingredient$Value accessible method net/minecraft/world/item/crafting/Ingredient (Ljava/util/stream/Stream;)V accessible method net/minecraft/world/item/context/UseOnContext (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/phys/BlockHitResult;)V +accessible method net/minecraft/world/damagesource/DamageSources source (Lnet/minecraft/resources/ResourceKey;)Lnet/minecraft/world/damagesource/DamageSource; +accessible method net/minecraft/world/damagesource/DamageSources source (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/damagesource/DamageSource; \ No newline at end of file diff --git a/Fabric/src/main/resources/fabricasting.accesswidener b/Fabric/src/main/resources/fabricasting.accesswidener index bbbb5449..a1b06bb7 100644 --- a/Fabric/src/main/resources/fabricasting.accesswidener +++ b/Fabric/src/main/resources/fabricasting.accesswidener @@ -12,3 +12,5 @@ accessible class net/minecraft/client/renderer/RenderType$CompositeState accessible field net/minecraft/client/renderer/RenderType$CompositeState textureState Lnet/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard; accessible class net/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard accessible method net/minecraft/world/item/context/UseOnContext (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/phys/BlockHitResult;)V +accessible method net/minecraft/world/damagesource/DamageSources source (Lnet/minecraft/resources/ResourceKey;)Lnet/minecraft/world/damagesource/DamageSource; +accessible method net/minecraft/world/damagesource/DamageSources source (Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/damagesource/DamageSource; \ No newline at end of file diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexItemModels.java b/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexItemModels.java index 4bcc03cd..8ca595ea 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexItemModels.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexItemModels.java @@ -20,6 +20,7 @@ import net.minecraft.data.PackOutput; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.level.block.Block; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.common.data.ExistingFileHelper; @@ -72,7 +73,7 @@ public class HexItemModels extends PaucalItemModelProvider { simpleItem(HexItems.SCRYING_LENS); getBuilder(getPath(HexItems.SCRYING_LENS)) .transforms() - .transform(ItemTransforms.TransformType.HEAD) + .transform(ItemDisplayContext.HEAD) .rotation(0f, 0f, 0f) .translation(-2.5f, 0f, -8f) .scale(0.4f); diff --git a/Forge/src/main/resources/META-INF/accesstransformer.cfg b/Forge/src/main/resources/META-INF/accesstransformer.cfg index bb097c31..dacc3e1b 100644 --- a/Forge/src/main/resources/META-INF/accesstransformer.cfg +++ b/Forge/src/main/resources/META-INF/accesstransformer.cfg @@ -3,3 +3,5 @@ public net.minecraft.client.renderer.RenderType$CompositeState f_110576_ # textu public net.minecraft.world.item.crafting.Ingredient (Ljava/util/stream/Stream;)V public net.minecraft.world.item.crafting.Ingredient f_43902_ # values public net.minecraft.core.Registry$RegistryBootstrap +public net.minecraft.world.damagesource.DamageSources m_269079_(Lnet/minecraft/resources/ResourceKey;)Lnet/minecraft/world/damagesource/DamageSource; # source +public net.minecraft.world.damagesource.DamageSources m_269298_(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/damagesource/DamageSource; # source \ No newline at end of file