fixed the damage types stuff, and HexItemModels.

This commit is contained in:
Talia-12 2023-06-22 00:45:00 +10:00
parent ef12c71e92
commit 33db54e979
14 changed files with 35 additions and 60 deletions

View file

@ -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));

View file

@ -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

View file

@ -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<Iota>) {
mob.hurt(HexDamageSources.overcastDamageFrom(ctx.caster), mob.health)
mob.hurt(mob.damageSources().source(HexDamageTypes.OVERCAST, ctx.caster), mob.health)
}
override fun particleSpray(ctx: CastingEnvironment) =

View file

@ -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<Iota>) {
trulyHurt(mob, HexDamageSources.overcastDamageFrom(ctx.caster), 1f)
trulyHurt(mob, mob.damageSources().source(HexDamageTypes.OVERCAST, ctx.caster), 1f)
}
override fun particleSpray(ctx: CastingEnvironment): ParticleSpray {

View file

@ -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)
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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);
}
}

View file

@ -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<DamageType> OVERCAST = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("overcast"));
public static final ResourceKey<DamageType> SHAME_ON_YOU = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("overcast"));
public static void bootstrap(BootstapContext<DamageType> context) {
context.register(OVERCAST, new DamageType("hexcasting.overcast", 0f));
context.register(SHAME_ON_YOU, new DamageType("hexcasting.shame", 0f));
}
}

View file

@ -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 <init> (Ljava/util/stream/Stream;)V
accessible method net/minecraft/world/item/context/UseOnContext <init> (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;

View file

@ -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 <init> (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;

View file

@ -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);

View file

@ -3,3 +3,5 @@ public net.minecraft.client.renderer.RenderType$CompositeState f_110576_ # textu
public net.minecraft.world.item.crafting.Ingredient <init>(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