From 9ce42f85ca6c1f29d93ec011e0d47ee48238f5a4 Mon Sep 17 00:00:00 2001 From: IchHabeHunger54 Date: Sat, 1 Jun 2024 17:42:14 +0200 Subject: [PATCH 01/11] port #447 --- settings.gradle.kts | 4 +- .../arsmagicalegacy/ArsMagicaLegacy.java | 4 +- .../arsmagicalegacy/client/AMRenderTypes.java | 76 +++++++++++++++---- .../arsmagicalegacy/client/DistProxy.java | 17 ----- .../InscriptionTableScreen.java | 2 +- .../colorpicker}/ColorPickerScreen.java | 3 +- .../colorpicker/ColorPickerState.java | 35 +++++++++ .../colorpicker}/ColorPickerWidget.java | 5 +- .../colorpicker/package-info.java | 7 ++ .../client/renderer/spell/BeamRenderer.java | 53 ++----------- .../client/renderer/spell/package-info.java | 7 ++ .../InscriptionTableMenu.java | 5 +- .../resources/META-INF/accesstransformer.cfg | 8 +- 13 files changed, 136 insertions(+), 90 deletions(-) delete mode 100644 src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/DistProxy.java rename src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/{ => inscriptiontable/colorpicker}/ColorPickerScreen.java (98%) create mode 100644 src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/ColorPickerState.java rename src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/{ => inscriptiontable/colorpicker}/ColorPickerWidget.java (98%) create mode 100644 src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/package-info.java create mode 100644 src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/renderer/spell/package-info.java diff --git a/settings.gradle.kts b/settings.gradle.kts index 3caf8c794..e4421eebc 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,7 +1,7 @@ pluginManagement { plugins { - id("net.neoforged.gradle.userdev") version "7.0.106" - id("com.github.minecraftschurlimods.helperplugin") version "1.11" + id("net.neoforged.gradle.userdev") version "7.0.137" + id("com.github.minecraftschurlimods.helperplugin") version "1.13" } repositories { mavenLocal() diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/ArsMagicaLegacy.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/ArsMagicaLegacy.java index 037047857..82b4f842f 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/ArsMagicaLegacy.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/ArsMagicaLegacy.java @@ -1,7 +1,7 @@ package com.github.minecraftschurlimods.arsmagicalegacy; import com.github.minecraftschurlimods.arsmagicalegacy.api.ArsMagicaAPI; -import com.github.minecraftschurlimods.arsmagicalegacy.client.DistProxy; +import com.github.minecraftschurlimods.arsmagicalegacy.client.ClientInit; import com.github.minecraftschurlimods.arsmagicalegacy.common.affinity.AffinityHelper; import com.github.minecraftschurlimods.arsmagicalegacy.common.etherium.EtheriumHelper; import com.github.minecraftschurlimods.arsmagicalegacy.common.handler.EventHandler; @@ -50,7 +50,7 @@ public ArsMagicaLegacy(ModContainer container, IEventBus bus) { EventHandler.register(bus); ServerInit.init(); if (FMLEnvironment.dist == Dist.CLIENT) { - DistProxy.init(bus); + ClientInit.init(bus); } Config.init(); NetworkInit.init(bus); diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/AMRenderTypes.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/AMRenderTypes.java index 69d994219..38436973f 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/AMRenderTypes.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/AMRenderTypes.java @@ -1,20 +1,18 @@ package com.github.minecraftschurlimods.arsmagicalegacy.client; +import com.github.minecraftschurlimods.arsmagicalegacy.api.ArsMagicaAPI; +import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.inscriptiontable.colorpicker.ColorPickerState; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.VertexFormat; import net.minecraft.client.renderer.RenderStateShard; import net.minecraft.client.renderer.RenderType; +import net.minecraft.resources.ResourceLocation; public class AMRenderTypes { - public static final RenderStateShard.ShaderStateShard COLOR_WHEEL_SHADER = new RenderStateShard.ShaderStateShard(AMShaders::getColorWheelShader); - public static float colorWheelCenterX, colorWheelCenterY, colorWheelRadius, colorWheelBrightness; // TODO: This is incredibly hacky, find a better way - - public static void setColorWheel(float cX, float cY, float radius, float brightness) { - colorWheelCenterX = cX; - colorWheelCenterY = cY; - colorWheelRadius = radius; - colorWheelBrightness = brightness; - } + private static final RenderStateShard.ShaderStateShard COLOR_WHEEL_SHADER = new RenderStateShard.ShaderStateShard(AMShaders::getColorWheelShader); + private static final RenderStateShard.TextureStateShard BEAM_CORE_TEXTURE = new RenderStateShard.TextureStateShard(new ResourceLocation(ArsMagicaAPI.MOD_ID, "textures/misc/beam_core.png"), false, false); + private static final RenderStateShard.TextureStateShard BEAM_MAIN_TEXTURE = new RenderStateShard.TextureStateShard(new ResourceLocation(ArsMagicaAPI.MOD_ID, "textures/misc/beam_main.png"), false, false); + private static final RenderStateShard.TextureStateShard BEAM_GLOW_TEXTURE = new RenderStateShard.TextureStateShard(new ResourceLocation(ArsMagicaAPI.MOD_ID, "textures/misc/beam_glow.png"), false, false); public static final RenderType COLOR_WHEEL = RenderType.create( "color_wheel", @@ -23,16 +21,66 @@ public static void setColorWheel(float cX, float cY, float radius, float brightn 256, false, false, - RenderType.CompositeState - .builder() + RenderType.CompositeState.builder() .setShaderState(COLOR_WHEEL_SHADER) .setTransparencyState(RenderStateShard.TRANSLUCENT_TRANSPARENCY) .setDepthTestState(RenderStateShard.LEQUAL_DEPTH_TEST) .setLayeringState(new RenderStateShard.LayeringStateShard("set_uniforms", () -> { - AMShaders.setUniform("center", colorWheelCenterX, colorWheelCenterY); - AMShaders.setUniform("radius", colorWheelRadius); - AMShaders.setUniform("brightness", colorWheelBrightness); + ColorPickerState state = ColorPickerState.get(); + AMShaders.setUniform("center", state.getCenterX(), state.getCenterY()); + AMShaders.setUniform("radius", state.getRadius()); + AMShaders.setUniform("brightness", state.getBrightness()); }, () -> {})) .createCompositeState(false) ); + public static final RenderType BEAM_CORE = RenderType.create( + "beam_core", + DefaultVertexFormat.POSITION_COLOR_TEX, + VertexFormat.Mode.QUADS, + 256, + false, + false, + RenderType.CompositeState.builder() + .setTextureState(BEAM_CORE_TEXTURE) + .setShaderState(RenderStateShard.POSITION_COLOR_TEX_SHADER) + .setLayeringState(RenderStateShard.VIEW_OFFSET_Z_LAYERING) + .setTransparencyState(RenderStateShard.TRANSLUCENT_TRANSPARENCY) + .setDepthTestState(RenderStateShard.NO_DEPTH_TEST) + .setCullState(RenderStateShard.NO_CULL) + .setLightmapState(RenderStateShard.NO_LIGHTMAP) + .setWriteMaskState(RenderStateShard.COLOR_WRITE) + .createCompositeState(false)); + public static final RenderType BEAM_MAIN = RenderType.create( + "beam_main", + DefaultVertexFormat.POSITION_COLOR_TEX, + VertexFormat.Mode.QUADS, + 256, + false, + false, + RenderType.CompositeState.builder() + .setTextureState(BEAM_MAIN_TEXTURE) + .setShaderState(RenderStateShard.POSITION_COLOR_TEX_SHADER) + .setLayeringState(RenderStateShard.VIEW_OFFSET_Z_LAYERING) + .setTransparencyState(RenderStateShard.TRANSLUCENT_TRANSPARENCY) + .setDepthTestState(RenderStateShard.NO_DEPTH_TEST) + .setCullState(RenderStateShard.NO_CULL) + .setLightmapState(RenderStateShard.NO_LIGHTMAP) + .setWriteMaskState(RenderStateShard.COLOR_WRITE) + .createCompositeState(false)); + public static final RenderType BEAM_GLOW = RenderType.create("beam_glow", + DefaultVertexFormat.POSITION_COLOR_TEX, + VertexFormat.Mode.QUADS, + 256, + false, + false, + RenderType.CompositeState.builder() + .setTextureState(BEAM_GLOW_TEXTURE) + .setShaderState(RenderStateShard.POSITION_COLOR_TEX_SHADER) + .setLayeringState(RenderStateShard.VIEW_OFFSET_Z_LAYERING) + .setTransparencyState(RenderStateShard.TRANSLUCENT_TRANSPARENCY) + .setDepthTestState(RenderStateShard.NO_DEPTH_TEST) + .setCullState(RenderStateShard.NO_CULL) + .setLightmapState(RenderStateShard.NO_LIGHTMAP) + .setWriteMaskState(RenderStateShard.COLOR_WRITE) + .createCompositeState(false)); } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/DistProxy.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/DistProxy.java deleted file mode 100644 index d77f45084..000000000 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/DistProxy.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.minecraftschurlimods.arsmagicalegacy.client; - -import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.inscriptiontable.InscriptionTableScreen; -import net.neoforged.bus.api.IEventBus; - -public final class DistProxy { - /** - * Runs client initialization. Needs a separate class to prevent unwanted classloading. - */ - public static void init(IEventBus modEventBus) { - ClientInit.init(modEventBus); - } - - public static void onInscriptionTableSlotChanged() { - InscriptionTableScreen.onSlotChanged(); - } -} diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/InscriptionTableScreen.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/InscriptionTableScreen.java index 3a7ef9ce8..8836886ea 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/InscriptionTableScreen.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/InscriptionTableScreen.java @@ -5,9 +5,9 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellItem; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellPart; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ShapeGroup; -import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.ColorPickerScreen; import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.SelfClearingEditBox; import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.dragndrop.DragArea; +import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.inscriptiontable.colorpicker.ColorPickerScreen; import com.github.minecraftschurlimods.arsmagicalegacy.common.block.inscriptiontable.InscriptionTableMenu; import com.github.minecraftschurlimods.arsmagicalegacy.common.init.AMSpellParts; import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.modifier.Color; diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/ColorPickerScreen.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/ColorPickerScreen.java similarity index 98% rename from src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/ColorPickerScreen.java rename to src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/ColorPickerScreen.java index 2ff35cadb..b3533c12c 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/ColorPickerScreen.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/ColorPickerScreen.java @@ -1,6 +1,7 @@ -package com.github.minecraftschurlimods.arsmagicalegacy.client.gui; +package com.github.minecraftschurlimods.arsmagicalegacy.client.gui.inscriptiontable.colorpicker; import com.github.minecraftschurlimods.arsmagicalegacy.api.ArsMagicaAPI; +import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.ColorUtil; import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.databinding.Listenable; import com.github.minecraftschurlimods.arsmagicalegacy.common.util.TranslationConstants; import com.google.common.collect.ImmutableList; diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/ColorPickerState.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/ColorPickerState.java new file mode 100644 index 000000000..96c8ddcc4 --- /dev/null +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/ColorPickerState.java @@ -0,0 +1,35 @@ +package com.github.minecraftschurlimods.arsmagicalegacy.client.gui.inscriptiontable.colorpicker; + +public class ColorPickerState { + private static final ColorPickerState INSTANCE = new ColorPickerState(); + private float centerX, centerY, radius, brightness; + + private ColorPickerState() {} + + public float getCenterX() { + return centerX; + } + + public float getCenterY() { + return centerY; + } + + public float getRadius() { + return radius; + } + + public float getBrightness() { + return brightness; + } + + public static ColorPickerState get() { + return INSTANCE; + } + + public void setColorWheel(float centerX, float centerY, float radius, float brightness) { + this.centerX = centerX; + this.centerY = centerY; + this.radius = radius; + this.brightness = brightness; + } +} diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/ColorPickerWidget.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/ColorPickerWidget.java similarity index 98% rename from src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/ColorPickerWidget.java rename to src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/ColorPickerWidget.java index caa37d614..5b2de7c89 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/ColorPickerWidget.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/ColorPickerWidget.java @@ -1,6 +1,7 @@ -package com.github.minecraftschurlimods.arsmagicalegacy.client.gui; +package com.github.minecraftschurlimods.arsmagicalegacy.client.gui.inscriptiontable.colorpicker; import com.github.minecraftschurlimods.arsmagicalegacy.client.AMRenderTypes; +import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.ColorUtil; import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.databinding.Listenable; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.BufferBuilder; @@ -88,7 +89,7 @@ private void renderColorWheel(GuiGraphics graphics) { float cX = getX() + radius; float cY = getY() + radius; graphics.pose().pushPose(); - AMRenderTypes.setColorWheel(cX, cY, radius, _brightness); + ColorPickerState.get().setColorWheel(cX, cY, radius, _brightness); graphics.fillGradient(AMRenderTypes.COLOR_WHEEL, getX(), getY(), getX() + width, getY() + height, 0xFFFFFFFF, 0xFFFFFFFF, 0); graphics.pose().popPose(); } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/package-info.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/package-info.java new file mode 100644 index 000000000..5576f6e3a --- /dev/null +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/colorpicker/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.github.minecraftschurlimods.arsmagicalegacy.client.gui.inscriptiontable.colorpicker; + +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/renderer/spell/BeamRenderer.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/renderer/spell/BeamRenderer.java index eb93eb199..a02be304b 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/renderer/spell/BeamRenderer.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/renderer/spell/BeamRenderer.java @@ -1,20 +1,15 @@ package com.github.minecraftschurlimods.arsmagicalegacy.client.renderer.spell; -import com.github.minecraftschurlimods.arsmagicalegacy.api.ArsMagicaAPI; +import com.github.minecraftschurlimods.arsmagicalegacy.client.AMRenderTypes; import com.github.minecraftschurlimods.arsmagicalegacy.client.ClientHelper; import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.ColorUtil; import com.github.minecraftschurlimods.arsmagicalegacy.common.util.AMUtil; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.math.Axis; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.RenderStateShard; -import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.Entity; @@ -30,44 +25,8 @@ /** * Taken and adapted from Direwolf20's Mining Gadgets mod. */ -public class BeamRenderer extends RenderType { - private static final ResourceLocation CORE_TEXTURE = new ResourceLocation(ArsMagicaAPI.MOD_ID, "textures/misc/beam_core.png"); - private static final RenderType CORE = create("beam_core", DefaultVertexFormat.POSITION_COLOR_TEX, VertexFormat.Mode.QUADS, 256, false, false, - RenderType.CompositeState.builder().setTextureState(new RenderStateShard.TextureStateShard(CORE_TEXTURE, false, false)) - .setShaderState(RenderStateShard.ShaderStateShard.POSITION_COLOR_TEX_SHADER) - .setLayeringState(VIEW_OFFSET_Z_LAYERING) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setDepthTestState(NO_DEPTH_TEST) - .setCullState(NO_CULL) - .setLightmapState(NO_LIGHTMAP) - .setWriteMaskState(COLOR_WRITE) - .createCompositeState(false)); - private static final ResourceLocation MAIN_TEXTURE = new ResourceLocation(ArsMagicaAPI.MOD_ID, "textures/misc/beam_main.png"); - private static final RenderType MAIN = create("beam_main", DefaultVertexFormat.POSITION_COLOR_TEX, VertexFormat.Mode.QUADS, 256, false, false, - RenderType.CompositeState.builder().setTextureState(new RenderStateShard.TextureStateShard(MAIN_TEXTURE, false, false)) - .setShaderState(RenderStateShard.ShaderStateShard.POSITION_COLOR_TEX_SHADER) - .setLayeringState(VIEW_OFFSET_Z_LAYERING) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setDepthTestState(NO_DEPTH_TEST) - .setCullState(NO_CULL) - .setLightmapState(NO_LIGHTMAP) - .setWriteMaskState(COLOR_WRITE) - .createCompositeState(false)); - private static final ResourceLocation GLOW_TEXTURE = new ResourceLocation(ArsMagicaAPI.MOD_ID, "textures/misc/beam_glow.png"); - private static final RenderType GLOW = create("beam_glow", DefaultVertexFormat.POSITION_COLOR_TEX, VertexFormat.Mode.QUADS, 256, false, false, - RenderType.CompositeState.builder().setTextureState(new RenderStateShard.TextureStateShard(GLOW_TEXTURE, false, false)) - .setShaderState(RenderStateShard.ShaderStateShard.POSITION_COLOR_TEX_SHADER) - .setLayeringState(VIEW_OFFSET_Z_LAYERING) - .setTransparencyState(TRANSLUCENT_TRANSPARENCY) - .setDepthTestState(NO_DEPTH_TEST) - .setCullState(NO_CULL) - .setLightmapState(NO_LIGHTMAP) - .setWriteMaskState(COLOR_WRITE) - .createCompositeState(false)); - - public BeamRenderer(String pName, VertexFormat pFormat, VertexFormat.Mode pMode, int pBufferSize, boolean pAffectsCrumbling, boolean pSortOnUpload, Runnable pSetupState, Runnable pClearState) { - super(pName, pFormat, pMode, pBufferSize, pAffectsCrumbling, pSortOnUpload, pSetupState, pClearState); - } +public class BeamRenderer { + private BeamRenderer() {} public static void drawBeam(PoseStack stack, Entity entity, Vec3 target, InteractionHand hand, int color, float ticks) { Minecraft mc = Minecraft.getInstance(); @@ -114,9 +73,9 @@ public static void drawBeam(PoseStack stack, Entity entity, Vec3 target, Interac PoseStack.Pose pose = stack.last(); Matrix3f normal = pose.normal(); Matrix4f matrix = pose.pose(); - drawPart(buffer.getBuffer(GLOW), matrix, normal, 0.07f * (0.9f + 0.1f * Mth.sin(time * 0.99f) * Mth.sin(time * 0.3f) * Mth.sin(time * 0.1f)), distance, 0.5f, 1, x, y, z, hand, r, g, b, 0.7f); - drawPart(buffer.getBuffer(MAIN), matrix, normal, 0.02f, distance, v, v + distance * 1.5f, x, y, z, hand, r, g, b, 1); - drawPart(buffer.getBuffer(CORE), matrix, normal, 0.01f, distance, v, v + distance * 1.5f, x, y, z, hand, r, g, b, 1); + drawPart(buffer.getBuffer(AMRenderTypes.BEAM_GLOW), matrix, normal, 0.07f * (0.9f + 0.1f * Mth.sin(time * 0.99f) * Mth.sin(time * 0.3f) * Mth.sin(time * 0.1f)), distance, 0.5f, 1, x, y, z, hand, r, g, b, 0.7f); + drawPart(buffer.getBuffer(AMRenderTypes.BEAM_MAIN), matrix, normal, 0.02f, distance, v, v + distance * 1.5f, x, y, z, hand, r, g, b, 1); + drawPart(buffer.getBuffer(AMRenderTypes.BEAM_CORE), matrix, normal, 0.01f, distance, v, v + distance * 1.5f, x, y, z, hand, r, g, b, 1); stack.popPose(); buffer.endBatch(); } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/renderer/spell/package-info.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/renderer/spell/package-info.java new file mode 100644 index 000000000..147759268 --- /dev/null +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/renderer/spell/package-info.java @@ -0,0 +1,7 @@ +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +package com.github.minecraftschurlimods.arsmagicalegacy.client.renderer.spell; + +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/block/inscriptiontable/InscriptionTableMenu.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/block/inscriptiontable/InscriptionTableMenu.java index e224b4126..98561c816 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/block/inscriptiontable/InscriptionTableMenu.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/block/inscriptiontable/InscriptionTableMenu.java @@ -7,12 +7,11 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellPart; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ShapeGroup; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellStack; -import com.github.minecraftschurlimods.arsmagicalegacy.client.DistProxy; +import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.inscriptiontable.InscriptionTableScreen; import com.github.minecraftschurlimods.arsmagicalegacy.common.init.AMMenuTypes; import com.github.minecraftschurlimods.arsmagicalegacy.common.init.AMSounds; import com.github.minecraftschurlimods.arsmagicalegacy.network.InscriptionTableCreateSpellPacket; import com.github.minecraftschurlimods.arsmagicalegacy.network.InscriptionTableSyncPacket; -import net.minecraft.SharedConstants; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; @@ -164,7 +163,7 @@ public Optional tryRemove(int p_150642_, int p_150643_, Player player public void setChanged() { super.setChanged(); if (table.getLevel().isClientSide()) { - DistProxy.onInscriptionTableSlotChanged(); + InscriptionTableScreen.onSlotChanged(); } } diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 72bcf1f64..083d532cc 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -6,6 +6,12 @@ public net.minecraft.world.level.block.entity.LecternBlockEntity setPage(I)V protected net.minecraft.client.resources.TextureAtlasHolder textureAtlas public net.minecraft.client.renderer.texture.TextureAtlas texturesByName public net.minecraft.gametest.framework.GameTestHelper testInfo -public net.minecraft.client.renderer.RenderStateShard TRANSLUCENT_TRANSPARENCY +public net.minecraft.client.renderer.RenderStateShard COLOR_WRITE public net.minecraft.client.renderer.RenderStateShard LEQUAL_DEPTH_TEST +public net.minecraft.client.renderer.RenderStateShard NO_CULL +public net.minecraft.client.renderer.RenderStateShard NO_DEPTH_TEST +public net.minecraft.client.renderer.RenderStateShard NO_LIGHTMAP +public net.minecraft.client.renderer.RenderStateShard POSITION_COLOR_TEX_SHADER +public net.minecraft.client.renderer.RenderStateShard TRANSLUCENT_TRANSPARENCY +public net.minecraft.client.renderer.RenderStateShard VIEW_OFFSET_Z_LAYERING public net.minecraft.world.level.block.TransparentBlock (Lnet/minecraft/world/level/block/state/BlockBehaviour$Properties;)V From 94e3bd7a5c3242f12050e8a158cc5f96bc3a3fff Mon Sep 17 00:00:00 2001 From: IchHabeHunger54 Date: Sat, 1 Jun 2024 17:49:59 +0200 Subject: [PATCH 02/11] port #450 --- .../data/AMEnglishLanguageProvider.java | 20 +++++ .../arsmagicalegacy/Config.java | 22 +++++ .../gui/inscriptiontable/ShapeGroupArea.java | 15 ++-- .../client/hud/ShapeGroupHUD.java | 85 ++++++++++++++++++- 4 files changed, 132 insertions(+), 10 deletions(-) diff --git a/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMEnglishLanguageProvider.java b/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMEnglishLanguageProvider.java index ca3e80ccb..fa7f312ca 100644 --- a/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMEnglishLanguageProvider.java +++ b/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMEnglishLanguageProvider.java @@ -373,6 +373,26 @@ protected void addTranslations() { skillTranslation(AMTalents.MANA_REGEN_BOOST_3, "Mana Regeneration III", "...just to get back every single mana point I have consumed before.", "talents", "Your mana regeneration is boosted by 15%%. This replaces the boosts of $(l:talents/mana_regen_1)Mana Regen I$() and $(l:talents/mana_regen_2)Mana Regen II$()."); skillTranslation(AMTalents.SHIELD_OVERLOAD, "Shield Overload", "No more wasting excess mana.", "talents", "When your mana bar is full, excess mana regenerated turns into a shield that protects you from 5%% of all incoming damage."); skillTranslation(AMTalents.SPELL_MOTION, "Spell Motion", "I like to move it, move it.", "talents", "Manipulating the winds around you, you have found a way to move at normal speed while using spells."); + configTranslation("mana_x", "Horizontal position of the mana bar."); + configTranslation("mana_y", "Vertical position of the mana bar."); + configTranslation("mana_anchor_x", "Horizontal anchor of the mana bar."); + configTranslation("mana_anchor_y", "Vertical anchor of the mana bar."); + configTranslation("burnout_x", "Horizontal position of the burnout bar."); + configTranslation("burnout_y", "Vertical position of the burnout bar."); + configTranslation("burnout_anchor_x", "Horizontal anchor of the burnout bar."); + configTranslation("burnout_anchor_y", "Vertical anchor of the burnout bar."); + configTranslation("xp_x", "Horizontal position of the magic xp bar."); + configTranslation("xp_y", "Vertical position of the magic xp bar."); + configTranslation("xp_anchor_x", "Horizontal anchor of the magic xp bar."); + configTranslation("xp_anchor_y", "Vertical anchor of the magic xp bar."); + configTranslation("spell_book_x", "Horizontal position of the spell book hud."); + configTranslation("spell_book_y", "Vertical position of the spell book hud."); + configTranslation("spell_book_anchor_x", "Horizontal anchor of the spell book hud."); + configTranslation("spell_book_anchor_y", "Vertical anchor of the spell book hud."); + configTranslation("shape_group_x", "Horizontal position of the shape group hud."); + configTranslation("shape_group_y", "Vertical position of the shape group hud."); + configTranslation("shape_group_anchor_x", "Horizontal anchor of the shape group hud."); + configTranslation("shape_group_anchor_y", "Vertical anchor of the shape group hud."); configTranslation("require_compendium_crafting", "Whether the player needs to craft the compendium before being able to use magic. If disabled, the player can use magic from the beginning."); configTranslation("burnout_ratio", "The default mana to burnout ratio, used in calculating spell costs."); configTranslation("crafting_altar_check_time", "The time in ticks between multiblock validation checks for the crafting altar."); diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/Config.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/Config.java index 419660922..facd4a3fe 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/Config.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/Config.java @@ -56,6 +56,10 @@ public static final class Client { public final ModConfigSpec.IntValue SPELL_BOOK_Y; public final ModConfigSpec.EnumValue SPELL_BOOK_ANCHOR_X; public final ModConfigSpec.EnumValue SPELL_BOOK_ANCHOR_Y; + public final ModConfigSpec.IntValue SHAPE_GROUP_X; + public final ModConfigSpec.IntValue SHAPE_GROUP_Y; + public final ModConfigSpec.EnumValue SHAPE_GROUP_ANCHOR_X; + public final ModConfigSpec.EnumValue SHAPE_GROUP_ANCHOR_Y; private Client(ModConfigSpec.Builder builder) { builder.comment("HUD Elements").push("hud_elements"); @@ -131,6 +135,24 @@ private Client(ModConfigSpec.Builder builder) { .translation(TranslationConstants.CONFIG + "spell_book_anchor_y") .defineEnum("spell_book_anchor_y", HUDElement.AnchorY.BOTTOM); builder.pop(); + builder.push("shape_group"); + SHAPE_GROUP_X = builder + .comment("Horizontal position of the shape group hud.") + .translation(TranslationConstants.CONFIG + "shape_group_x") + .defineInRange("shape_group_x", 0, Short.MIN_VALUE, Short.MAX_VALUE); + SHAPE_GROUP_Y = builder + .comment("Vertical position of the shape group hud.") + .translation(TranslationConstants.CONFIG + "shape_group_y") + .defineInRange("shape_group_y", 0, Short.MIN_VALUE, Short.MAX_VALUE); + SHAPE_GROUP_ANCHOR_X = builder + .comment("Horizontal anchor of the shape group hud.") + .translation(TranslationConstants.CONFIG + "shape_group_anchor_x") + .defineEnum("shape_group_anchor_x", HUDElement.AnchorX.LEFT); + SHAPE_GROUP_ANCHOR_Y = builder + .comment("Horizontal anchor of the shape group hud.") + .translation(TranslationConstants.CONFIG + "shape_group_anchor_y") + .defineEnum("shape_group_anchor_y", HUDElement.AnchorY.TOP); + builder.pop(); builder.pop(); } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/ShapeGroupArea.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/ShapeGroupArea.java index e7251ada2..2d40d3215 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/ShapeGroupArea.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/gui/inscriptiontable/ShapeGroupArea.java @@ -16,12 +16,13 @@ public class ShapeGroupArea extends DragTargetArea { private static final ResourceLocation GUI = new ResourceLocation(ArsMagicaAPI.MOD_ID, "textures/gui/inscription_table.png"); - private static final int ROWS = 2; - private static final int COLUMNS = 2; - private static final int X_PADDING = 2; - private static final int Y_PADDING = 1; - static final int WIDTH = 36; - static final int HEIGHT = 34; + public static final int ROWS = 2; + public static final int COLUMNS = 2; + public static final int X_PADDING = 2; + public static final int Y_PADDING = 1; + public static final int WIDTH = 36; + public static final int HEIGHT = 34; + public static final int DISABLED_OVERLAY_COLOR = 0x7f000000; private final BiConsumer onDrop; private LockState lockState = LockState.NONE; @@ -72,7 +73,7 @@ public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPar if (lockState == LockState.ALL) { guiGraphics.pose().pushPose(); guiGraphics.pose().translate(0, 0, 10); - guiGraphics.fill(x, y, x + WIDTH, y + HEIGHT, 0x7f000000); + guiGraphics.fill(x, y, x + WIDTH, y + HEIGHT, DISABLED_OVERLAY_COLOR); guiGraphics.pose().popPose(); } for (int i = 0; i < ROWS; i++) { diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/hud/ShapeGroupHUD.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/hud/ShapeGroupHUD.java index fd7a0067e..73694b3c9 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/hud/ShapeGroupHUD.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/client/hud/ShapeGroupHUD.java @@ -1,16 +1,95 @@ package com.github.minecraftschurlimods.arsmagicalegacy.client.hud; +import com.github.minecraftschurlimods.arsmagicalegacy.Config; +import com.github.minecraftschurlimods.arsmagicalegacy.api.ArsMagicaAPI; +import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpell; +import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellItem; +import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellPart; +import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ShapeGroup; +import com.github.minecraftschurlimods.arsmagicalegacy.client.ClientHelper; +import com.github.minecraftschurlimods.arsmagicalegacy.client.SkillIconAtlas; +import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.inscriptiontable.ShapeGroupArea; +import com.github.minecraftschurlimods.arsmagicalegacy.client.gui.inscriptiontable.SpellPartDraggable; +import com.github.minecraftschurlimods.arsmagicalegacy.common.item.spellbook.SpellBookItem; import com.github.minecraftschurlimods.betterhudlib.HUDElement; +import com.mojang.blaze3d.platform.Window; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.neoforged.neoforge.client.gui.overlay.ExtendedGui; +import java.util.List; + public final class ShapeGroupHUD extends HUDElement { + private static final ResourceLocation GUI = new ResourceLocation(ArsMagicaAPI.MOD_ID, "textures/gui/inscription_table.png"); + public ShapeGroupHUD() { - super(AnchorX.CENTER, AnchorY.CENTER, 0, 0, 0, 0); + super(Config.CLIENT.SHAPE_GROUP_ANCHOR_X, Config.CLIENT.SHAPE_GROUP_ANCHOR_Y, Config.CLIENT.SHAPE_GROUP_X::get, Config.CLIENT.SHAPE_GROUP_Y::get, () -> ShapeGroupArea.WIDTH * 5, () -> ShapeGroupArea.HEIGHT); + } + + @Override + public void draw(ExtendedGui gui, GuiGraphics graphics, float partialTicks) { + Player player = ClientHelper.getLocalPlayer(); + if (player == null || Minecraft.getInstance().options.hideGui) return; + ItemStack mainHand = player.getItemInHand(InteractionHand.MAIN_HAND); + ItemStack offHand = player.getItemInHand(InteractionHand.OFF_HAND); + if (mainHand.getItem() instanceof SpellBookItem) { + mainHand = SpellBookItem.getSelectedSpell(mainHand); + } else if (offHand.getItem() instanceof SpellBookItem) { + offHand = SpellBookItem.getSelectedSpell(offHand); + } + if (mainHand.getItem() instanceof ISpellItem) { + renderShapeGroupHUD(graphics, mainHand); + } else if (offHand.getItem() instanceof ISpellItem) { + renderShapeGroupHUD(graphics, offHand); + } } @Override - public void draw(ExtendedGui forgeGui, GuiGraphics graphics, float partialTicks) { - // TODO + protected void onPositionUpdate(AnchorX anchorX, AnchorY anchorY, int x, int y) { + Config.CLIENT.SHAPE_GROUP_ANCHOR_X.set(anchorX); + Config.CLIENT.SHAPE_GROUP_ANCHOR_Y.set(anchorY); + Config.CLIENT.SHAPE_GROUP_X.set(x); + Config.CLIENT.SHAPE_GROUP_Y.set(y); + } + + @Override + protected void save() { + Config.CLIENT.save(); + } + + private void renderShapeGroupHUD(GuiGraphics graphics, ItemStack itemStack) { + ISpell spell = ArsMagicaAPI.get().getSpellHelper().getSpell(itemStack); + List shapeGroups = spell.shapeGroups(); + if (shapeGroups.isEmpty()) return; + int activeShapeGroup = spell.currentShapeGroupIndex(); + Window window = Minecraft.getInstance().getWindow(); + int x = getX(window.getScreenWidth()); + int y = getY(window.getScreenHeight()); + for (int i = 0; i < shapeGroups.size(); i++) { + ShapeGroup shapeGroup = shapeGroups.get(i); + if (shapeGroup.isEmpty()) continue; + graphics.blit(GUI, x + i * ShapeGroupArea.WIDTH, y, 5, 220, 18, ShapeGroupArea.WIDTH, ShapeGroupArea.HEIGHT, 256, 256); + if (i != activeShapeGroup) { + graphics.pose().pushPose(); + graphics.pose().translate(0, 0, 10); + graphics.fill(x + i * ShapeGroupArea.WIDTH, y, x + ShapeGroupArea.WIDTH + i * ShapeGroupArea.WIDTH, y + ShapeGroupArea.HEIGHT, ShapeGroupArea.DISABLED_OVERLAY_COLOR); + graphics.pose().popPose(); + } + List parts = shapeGroup.parts(); + for (int j = 0; j < ShapeGroupArea.ROWS; j++) { + for (int k = 0; k < ShapeGroupArea.COLUMNS; k++) { + int index = j * ShapeGroupArea.COLUMNS + k; + if (index >= parts.size()) continue; + ISpellPart part = parts.get(index); + graphics.pose().pushPose(); + graphics.blit(x + i * ShapeGroupArea.WIDTH + k * SpellPartDraggable.SIZE + ShapeGroupArea.X_PADDING, y + j * SpellPartDraggable.SIZE + ShapeGroupArea.Y_PADDING, 10, SpellPartDraggable.SIZE, SpellPartDraggable.SIZE, SkillIconAtlas.instance().getSprite(part.getId())); + graphics.pose().popPose(); + } + } + } } } From b4defe5a30b7aa014269052c3e5083ada6a02910 Mon Sep 17 00:00:00 2001 From: IchHabeHunger54 Date: Sat, 1 Jun 2024 17:51:16 +0200 Subject: [PATCH 03/11] port #451 --- .../arsmagicalegacy/common/spell/Spell.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/Spell.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/Spell.java index 98346ef8f..6887d0d2d 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/Spell.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/Spell.java @@ -178,9 +178,8 @@ public SpellCastResult cast(LivingEntity caster, Level level, int castingTicks, NeoForge.EVENT_BUS.post(new AffinityChangingEvent.Post(player, event.affinity, (float) helper.getAffinityDepth(player, event.affinity), false)); } } - float xp = 0.05f * affinityShifts.size(); + float xp = (float) affinityShifts().values().stream().mapToDouble(e -> e).sum() * affinityShifts.size() * 100; if (continuous) xp /= 4; - if (affinityGains) xp *= 0.9f; api.getMagicHelper().awardXp(player, xp); } return result; From 7b8aae0d52dd29bb34543c05d48af2c96b2e86c6 Mon Sep 17 00:00:00 2001 From: IchHabeHunger54 Date: Sat, 1 Jun 2024 18:14:09 +0200 Subject: [PATCH 04/11] port #452 --- .../arsmagicalegacy/api/AMTags.java | 16 +++++ .../api/spell/ISpellComponent.java | 48 +++++++++++-- .../api/spell/ISpellHelper.java | 19 ++++- .../data/AMDamageTypeProvider.java | 32 ++++----- .../arsmagicalegacy/data/AMTagsProvider.java | 12 ++++ .../block/spellrune/SpellRuneBlockEntity.java | 4 +- .../common/entity/NatureScythe.java | 2 +- .../common/entity/Projectile.java | 4 +- .../common/entity/ThrownRock.java | 2 +- .../arsmagicalegacy/common/entity/Wall.java | 2 +- .../arsmagicalegacy/common/entity/Wave.java | 4 +- .../arsmagicalegacy/common/entity/Zone.java | 4 +- .../common/entity/ai/EnderTorrentGoal.java | 2 +- .../common/init/AMDamageSources.java | 69 +++++++++++++++---- .../common/init/AMSpellParts.java | 13 ++-- .../common/magic/ContingencyHelper.java | 2 +- .../arsmagicalegacy/common/spell/Spell.java | 2 +- .../common/spell/SpellHelper.java | 8 +-- .../common/spell/component/Attract.java | 7 +- .../common/spell/component/BanishRain.java | 6 +- .../common/spell/component/Blink.java | 5 +- .../common/spell/component/Blizzard.java | 6 +- .../common/spell/component/Charm.java | 6 +- .../common/spell/component/CreateWater.java | 6 +- .../common/spell/component/Damage.java | 39 +++++------ .../common/spell/component/Daylight.java | 6 +- .../common/spell/component/Dig.java | 6 +- .../common/spell/component/Disarm.java | 5 +- .../common/spell/component/Dispel.java | 6 +- .../spell/component/DivineIntervention.java | 6 +- .../common/spell/component/Drought.java | 6 +- .../common/spell/component/Effect.java | 6 +- .../spell/component/EnderIntervention.java | 6 +- .../common/spell/component/Explosion.java | 6 +- .../common/spell/component/FallingStar.java | 6 +- .../common/spell/component/FireRain.java | 6 +- .../common/spell/component/Fling.java | 5 +- .../common/spell/component/Forge.java | 6 +- .../common/spell/component/Grow.java | 6 +- .../common/spell/component/Harvest.java | 6 +- .../common/spell/component/Heal.java | 6 +- .../common/spell/component/Ignition.java | 6 +- .../common/spell/component/Knockback.java | 5 +- .../common/spell/component/LifeDrain.java | 6 +- .../common/spell/component/LifeTap.java | 6 +- .../common/spell/component/Light.java | 4 +- .../common/spell/component/ManaBlast.java | 6 +- .../common/spell/component/ManaDrain.java | 6 +- .../common/spell/component/MeltArmor.java | 6 +- .../common/spell/component/Moonrise.java | 6 +- .../common/spell/component/PlaceBlock.java | 6 +- .../common/spell/component/Plant.java | 6 +- .../common/spell/component/Plow.java | 6 +- .../spell/component/RandomTeleport.java | 5 +- .../common/spell/component/Recall.java | 5 +- .../common/spell/component/Repel.java | 7 +- .../common/spell/component/Rift.java | 6 +- .../common/spell/component/Storm.java | 5 +- .../common/spell/component/Summon.java | 7 +- .../common/spell/component/Telekinesis.java | 7 +- .../common/spell/component/Transplace.java | 6 +- .../common/spell/component/WizardsAutumn.java | 6 +- .../common/spell/shape/AoE.java | 4 +- .../common/spell/shape/Beam.java | 2 +- .../common/spell/shape/Chain.java | 6 +- .../common/spell/shape/Channel.java | 2 +- .../common/spell/shape/Self.java | 2 +- .../common/spell/shape/Touch.java | 2 +- 68 files changed, 376 insertions(+), 179 deletions(-) diff --git a/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/AMTags.java b/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/AMTags.java index e800aaec2..ce0630aec 100644 --- a/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/AMTags.java +++ b/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/AMTags.java @@ -3,6 +3,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; +import net.minecraft.world.damagesource.DamageType; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.Item; import net.minecraft.world.level.biome.Biome; @@ -137,4 +138,19 @@ private static TagKey tag(String name) { return TagKey.create(Registries.BIOME, new ResourceLocation(ArsMagicaAPI.MOD_ID, name)); } } + + /** + * Holds the mod's damage type tags. + */ + public static final class DamageTypes { + public static final TagKey SPELL = tag("spell"); + + private static TagKey forgeTag(String name) { + return TagKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(FORGE, name)); + } + + private static TagKey tag(String name) { + return TagKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, name)); + } + } } diff --git a/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/spell/ISpellComponent.java b/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/spell/ISpellComponent.java index b8ef3f6c1..8384f9733 100644 --- a/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/spell/ISpellComponent.java +++ b/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/spell/ISpellComponent.java @@ -1,10 +1,12 @@ package com.github.minecraftschurlimods.arsmagicalegacy.api.spell; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import org.jetbrains.annotations.ApiStatus.OverrideOnly; +import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.Set; @@ -14,7 +16,7 @@ */ public interface ISpellComponent extends ISpellPart { /** - * Invoke this spell component for an entity. Called only on the server. + * Invoke this spell component for an entity. Called only on the server. Deprecated, use variant with directEntity parameter below instead. * * @param spell The spell being cast. * @param caster The caster of the spell. @@ -25,11 +27,14 @@ public interface ISpellComponent extends ISpellPart { * @param ticksUsed The amount of ticks the spell is being cast for. * @return The spell cast result (success if anything was affected). */ + @Deprecated(forRemoval = true) @OverrideOnly - SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed); + default SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + return invoke(spell, caster, null, level, modifiers, target, index, ticksUsed); + } /** - * Invoke this spell component for a block. Called only on the server. + * Invoke this spell component for a block. Called only on the server. Deprecated, use variant with directEntity parameter below instead. * * @param spell The spell being cast. * @param caster The caster of the spell. @@ -40,8 +45,11 @@ public interface ISpellComponent extends ISpellPart { * @param ticksUsed The amount of ticks the spell is being cast for. * @return The spell cast result (success if anything was affected). */ + @Deprecated(forRemoval = true) @OverrideOnly - SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed); + default SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + return invoke(spell, caster, null, level, modifiers, target, index, ticksUsed); + } /** * @return The stats used by this spell part. @@ -52,4 +60,36 @@ public interface ISpellComponent extends ISpellPart { default SpellPartType getType() { return SpellPartType.COMPONENT; } + + /** + * Invoke this spell component for an entity. Called only on the server. + * + * @param spell The spell being cast. + * @param caster The caster of the spell. + * @param directEntity The direct entity casting the spell, e.g. a projectile. + * @param level The level the spell is being cast in. + * @param modifiers The modifiers modifying this component. + * @param target The target. + * @param index The index of this spell component in the spell execution stack. + * @param ticksUsed The amount of ticks the spell is being cast for. + * @return The spell cast result (success if anything was affected). + */ + @OverrideOnly + SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed); + + /** + * Invoke this spell component for a block. Called only on the server. + * + * @param spell The spell being cast. + * @param caster The caster of the spell. + * @param directEntity The direct entity casting the spell, e.g. a projectile. + * @param level The level the spell is being cast in. + * @param modifiers The modifiers modifying this component. + * @param target The target. + * @param index The index of this spell component in the spell execution stack. + * @param ticksUsed The amount of ticks the spell is being cast for. + * @return The spell cast result (success if anything was affected). + */ + @OverrideOnly + SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed); } diff --git a/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/spell/ISpellHelper.java b/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/spell/ISpellHelper.java index e4f70753a..a87ad3b4e 100644 --- a/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/spell/ISpellHelper.java +++ b/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/spell/ISpellHelper.java @@ -156,6 +156,23 @@ public interface ISpellHelper { */ float getModifiedStat(float baseValue, ISpellPartStat stat, List modifiers, ISpell spell, LivingEntity caster, @Nullable HitResult target, int componentIndex); + /** + * Casts the spell. Deprecated, use variant with directEntity parameter below. + * + * @param spell The spell to cast. + * @param caster The entity casting the spell. + * @param level The level the spell is cast in. + * @param target The target of the spell cast. + * @param castingTicks How long the spell has already been cast. + * @param index The 1 based index of the currently invoked part. + * @param awardXp The magic xp awarded for casting this spell. + * @return A SpellCastResult that represents the spell casting outcome. + */ + @Deprecated(forRemoval = true) + default SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, @Nullable HitResult target, int castingTicks, int index, boolean awardXp) { + return invoke(spell, caster, null, level, target, castingTicks, index, awardXp); + } + /** * Casts the spell. * @@ -168,7 +185,7 @@ public interface ISpellHelper { * @param awardXp The magic xp awarded for casting this spell. * @return A SpellCastResult that represents the spell casting outcome. */ - SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, @Nullable HitResult target, int castingTicks, int index, boolean awardXp); + SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, @Nullable HitResult target, int castingTicks, int index, boolean awardXp); /** * Selects the next shape group of the given spell item stack, wrapping around. diff --git a/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMDamageTypeProvider.java b/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMDamageTypeProvider.java index c08858af4..5fe1620d0 100644 --- a/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMDamageTypeProvider.java +++ b/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMDamageTypeProvider.java @@ -17,27 +17,27 @@ public AMDamageTypeProvider() { @Override public void generate() { - register(AMDamageSources.NATURE_SCYTHE, 0.1F); - register(AMDamageSources.SHOCKWAVE, 0.1F); - register(AMDamageSources.THROWN_ROCK, 0.1F); - register(AMDamageSources.WIND, 0.0F); - register(AMDamageSources.FALLING_STAR, 0.1F); + register(AMDamageSources.SPELL_DROWNING, 0.0f, "drown", DamageEffects.DROWNING); + register(AMDamageSources.SPELL_FIRE, 0.1f, "inFire", DamageEffects.BURNING); + register(AMDamageSources.SPELL_FROST, 0.1f, "freeze", DamageEffects.FREEZING); + register(AMDamageSources.SPELL_LIGHTNING, 0.1f, "lightningBolt"); + register(AMDamageSources.SPELL_MAGIC, 0.0f, "magic"); + register(AMDamageSources.SPELL_PHYSICAL, 0.1f, "mob"); + register(AMDamageSources.SPELL_PHYSICAL_PLAYER, 0.1f, "player"); + register(AMDamageSources.NATURE_SCYTHE, 0.1f); + register(AMDamageSources.SHOCKWAVE, 0.1f); + register(AMDamageSources.THROWN_ROCK, 0.1f); + register(AMDamageSources.WIND, 0.0f); + register(AMDamageSources.FALLING_STAR, 0.1f); } - protected void register(ResourceKey key, DamageScaling scaling, float exhaustion, DamageEffects effects, DeathMessageType deathMessageType) { - super.add(key.location(), new DamageType(key.location().getPath(), scaling, exhaustion, effects, deathMessageType)); - } - - protected void register(ResourceKey key, DamageScaling scaling, float exhaustion) { - super.add(key.location(), new DamageType(key.location().getPath(), scaling, exhaustion)); - } - protected void register(ResourceKey key, DamageScaling scaling, float exhaustion, DamageEffects effects) { - super.add(key.location(), new DamageType(key.location().getPath(), scaling, exhaustion, effects)); + protected void register(ResourceKey key, float exhaustion, String messageId, DamageEffects effects) { + super.add(key.location(), new DamageType(messageId, exhaustion, effects)); } - protected void register(ResourceKey key, float exhaustion, DamageEffects effects) { - super.add(key.location(), new DamageType(key.location().getPath(), exhaustion, effects)); + protected void register(ResourceKey key, float exhaustion, String messageId) { + super.add(key.location(), new DamageType(messageId, exhaustion)); } protected void register(ResourceKey key, float exhaustion) { diff --git a/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMTagsProvider.java b/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMTagsProvider.java index 29a8f8a48..422d6e093 100644 --- a/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMTagsProvider.java +++ b/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMTagsProvider.java @@ -188,7 +188,19 @@ static class DamageTypes extends TagsProvider { @Override protected void addTags(HolderLookup.Provider lookup) { + tag(AMTags.DamageTypes.SPELL).add(AMDamageSources.SPELL_DROWNING, AMDamageSources.SPELL_FIRE, AMDamageSources.SPELL_FROST, AMDamageSources.SPELL_LIGHTNING, AMDamageSources.SPELL_MAGIC, AMDamageSources.SPELL_PHYSICAL, AMDamageSources.SPELL_PHYSICAL_PLAYER); + tag(DamageTypeTags.ALWAYS_TRIGGERS_SILVERFISH).add(AMDamageSources.SPELL_MAGIC); + tag(DamageTypeTags.AVOIDS_GUARDIAN_THORNS).add(AMDamageSources.SPELL_MAGIC); + tag(DamageTypeTags.BYPASSES_ARMOR).add(AMDamageSources.SPELL_DROWNING, AMDamageSources.SPELL_FROST, AMDamageSources.SPELL_MAGIC); + tag(DamageTypeTags.BYPASSES_INVULNERABILITY).addTag(AMTags.DamageTypes.SPELL); + tag(DamageTypeTags.IGNITES_ARMOR_STANDS).add(AMDamageSources.SPELL_FIRE); + tag(DamageTypeTags.IS_DROWNING).add(AMDamageSources.SPELL_DROWNING); + tag(DamageTypeTags.IS_FIRE).add(AMDamageSources.SPELL_FIRE); + tag(DamageTypeTags.IS_FREEZING).add(AMDamageSources.SPELL_FROST); + tag(DamageTypeTags.IS_LIGHTNING).add(AMDamageSources.SPELL_LIGHTNING); tag(DamageTypeTags.IS_PROJECTILE).add(AMDamageSources.NATURE_SCYTHE, AMDamageSources.THROWN_ROCK); + tag(DamageTypeTags.WITHER_IMMUNE_TO).add(AMDamageSources.SPELL_DROWNING); + tag(DamageTypeTags.WITCH_RESISTANT_TO).add(AMDamageSources.SPELL_MAGIC); } } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/block/spellrune/SpellRuneBlockEntity.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/block/spellrune/SpellRuneBlockEntity.java index 5d728bc0d..b1bcea618 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/block/spellrune/SpellRuneBlockEntity.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/block/spellrune/SpellRuneBlockEntity.java @@ -84,8 +84,8 @@ public void collide(Level level, BlockPos pos, Entity entity, Direction directio caster = living; } if (spell == null || caster == null) return; - SpellCastResult r1 = helper.invoke(spell, caster, level, new EntityHitResult(entity), 0, index, awardXp); - SpellCastResult r2 = helper.invoke(spell, caster, level, new BlockHitResult(entity.position(), direction, pos, false), 0, index, awardXp); + SpellCastResult r1 = helper.invoke(spell, caster, null, level, new EntityHitResult(entity), 0, index, awardXp); + SpellCastResult r2 = helper.invoke(spell, caster, null, level, new BlockHitResult(entity.position(), direction, pos, false), 0, index, awardXp); if (r1.isSuccess() || r2.isSuccess()) { level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL); } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/NatureScythe.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/NatureScythe.java index 37857b2da..d60756702 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/NatureScythe.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/NatureScythe.java @@ -84,7 +84,7 @@ public void tick() { entity = ((PartEntity) entity).getParent(); } if (entity instanceof LivingEntity living && entity != getOwner()) { - living.hurt(AMDamageSources.natureScythe(this, getOwner()), 12); + living.hurt(AMDamageSources.natureScythe(this), 12); setHasHit(); } if (hasHit && distanceTo(getOwner()) < 4) { diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Projectile.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Projectile.java index 4a131a979..085f80020 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Projectile.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Projectile.java @@ -110,7 +110,7 @@ public void tick() { setDeltaMovement(newX * speed, newY * speed, newZ * speed); setBounces(getBounces() - 1); } else if (!level.isClientSide()) { - ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, level, result, tickCount, index, true); + ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, this, level, result, tickCount, index, true); decreaseBounces(); } } else if (result.getType().equals(HitResult.Type.ENTITY) && !level.isClientSide()) { @@ -119,7 +119,7 @@ public void tick() { e = part.getParent(); } if (e != owner && tryReflect(e)) { - ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, level, result, tickCount, index, true); + ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, this, level, result, tickCount, index, true); decreaseBounces(); } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/ThrownRock.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/ThrownRock.java index 40949099d..3a23cd51f 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/ThrownRock.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/ThrownRock.java @@ -74,7 +74,7 @@ public void tick() { Entity entity = ((EntityHitResult) hit).getEntity(); if (entity instanceof LivingEntity living && entity != getOwner()) { if (!living.isBlocking()) { - entity.hurt(AMDamageSources.thrownRock(this, getOwner()), 6); + entity.hurt(AMDamageSources.thrownRock(this), 6); } else if (living instanceof Player player) { player.stopUsingItem(); if (random.nextFloat() < 0.25f) { diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Wall.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Wall.java index f0b844583..6a039d837 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Wall.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Wall.java @@ -93,7 +93,7 @@ public void tick() { Vec3 closest = AMUtil.closestPointOnLine(e.position(), a, b); closest = new Vec3(closest.x, getY(), closest.z); if (tryReflect(e) && closest.distanceTo(e.position()) < 0.75 && Math.abs(getY() - e.getY()) < 2) { - ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, level, new EntityHitResult(e), tickCount, index, true); + ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, this, level, new EntityHitResult(e), tickCount, index, true); } } if (tickCount > 0) { diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Wave.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Wave.java index ac3bee0ce..a618443f2 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Wave.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Wave.java @@ -92,7 +92,7 @@ public void tick() { int index = getIndex(); float radius = getRadius(); ISpell spell = getSpell(); - forAllInRange(radius, false, e -> ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, level, new EntityHitResult(e), tickCount, index, true)); + forAllInRange(radius, false, e -> ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, this, level, new EntityHitResult(e), tickCount, index, true)); List list = new ArrayList<>(); for (int x = (int) Math.rint(-radius); x <= (int) Math.rint(radius); x++) { for (int y = (int) Math.rint(-radius); y <= (int) Math.rint(radius); y++) { @@ -103,7 +103,7 @@ public void tick() { } for (Vec3 vec : list) { HitResult result = AMUtil.getHitResult(vec, vec.add(getDeltaMovement()), this, getTargetNonSolid() ? ClipContext.Block.OUTLINE : ClipContext.Block.COLLIDER, getTargetNonSolid() ? ClipContext.Fluid.ANY : ClipContext.Fluid.NONE); - ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, level, result, tickCount, index, true); + ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, this, level, result, tickCount, index, true); } if (tickCount > 0) { PacketDistributor.NEAR.with(new PacketDistributor.TargetPoint(getX(), getY(), getZ(), 128, level.dimension())).send(new SpawnAMParticlesPacket(this)); diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Zone.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Zone.java index 3128c74ca..347aa691c 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Zone.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/Zone.java @@ -89,7 +89,7 @@ public void tick() { int index = getIndex(); float radius = getRadius(); ISpell spell = getSpell(); - forAllInRange(radius, false, e -> ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, level, new EntityHitResult(e), tickCount, index, true)); + forAllInRange(radius, false, e -> ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, this, level, new EntityHitResult(e), tickCount, index, true)); List list = new ArrayList<>(); for (int x = (int) Math.rint(-radius); x <= (int) Math.rint(radius); x++) { for (int y = (int) Math.rint(-getBbHeight()); y <= (int) Math.rint(getBbHeight()); y++) { @@ -100,7 +100,7 @@ public void tick() { } for (Vec3 vec : list) { HitResult result = AMUtil.getHitResult(vec, vec.add(getDeltaMovement()), this, getTargetNonSolid() ? ClipContext.Block.OUTLINE : ClipContext.Block.COLLIDER, getTargetNonSolid() ? ClipContext.Fluid.ANY : ClipContext.Fluid.NONE); - ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, level, result, tickCount, index, true); + ArsMagicaAPI.get().getSpellHelper().invoke(spell, owner, this, level, result, tickCount, index, true); } if (tickCount > 0) { PacketDistributor.NEAR.with(new PacketDistributor.TargetPoint(getX(), getY(), getZ(), 128, level.dimension())).send(new SpawnAMParticlesPacket(this)); diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/ai/EnderTorrentGoal.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/ai/EnderTorrentGoal.java index f957c62c7..175612f48 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/ai/EnderTorrentGoal.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/entity/ai/EnderTorrentGoal.java @@ -19,7 +19,7 @@ public void tick() { if (caster.getTarget() != null) { caster.getLookControl().setLookAt(caster.getTarget(), 30, 30); if (caster.getTicksInAction() % 2 == 0) { - ArsMagicaAPI.get().getSpellHelper().invoke(spell, caster, caster.level(), new EntityHitResult(caster), caster.getTicksInAction(), 0, false); + ArsMagicaAPI.get().getSpellHelper().invoke(spell, caster, null, caster.level(), new EntityHitResult(caster), caster.getTicksInAction(), 0, false); } else if (caster.getTicksInAction() == 10) { caster.level().playSound(null, caster, AMSounds.ENDER_GUARDIAN_ATTACK.value(), SoundSource.HOSTILE, 1.0f, (float) (0.5 + caster.getRandom().nextDouble() * 0.5f)); } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/init/AMDamageSources.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/init/AMDamageSources.java index ce8e51001..1423a9cba 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/init/AMDamageSources.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/init/AMDamageSources.java @@ -1,6 +1,10 @@ package com.github.minecraftschurlimods.arsmagicalegacy.common.init; import com.github.minecraftschurlimods.arsmagicalegacy.api.ArsMagicaAPI; +import com.github.minecraftschurlimods.arsmagicalegacy.common.entity.FallingStar; +import com.github.minecraftschurlimods.arsmagicalegacy.common.entity.NatureScythe; +import com.github.minecraftschurlimods.arsmagicalegacy.common.entity.Shockwave; +import com.github.minecraftschurlimods.arsmagicalegacy.common.entity.ThrownRock; import net.minecraft.core.Holder; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.Registries; @@ -9,36 +13,73 @@ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageType; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.Nullable; public interface AMDamageSources { - ResourceKey NATURE_SCYTHE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "nature_scythe")); - ResourceKey SHOCKWAVE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "shockwave")); - ResourceKey THROWN_ROCK = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "thrown_rock")); - ResourceKey WIND = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "wind")); - ResourceKey FALLING_STAR = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "falling_star")); + ResourceKey SPELL_DROWNING = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "spell_drowning")); + ResourceKey SPELL_FIRE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "spell_fire")); + ResourceKey SPELL_FROST = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "spell_frost")); + ResourceKey SPELL_LIGHTNING = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "spell_lightning")); + ResourceKey SPELL_MAGIC = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "spell_magic")); + ResourceKey SPELL_PHYSICAL = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "spell_physical")); + ResourceKey SPELL_PHYSICAL_PLAYER = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "spell_physical_player")); + ResourceKey NATURE_SCYTHE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "nature_scythe")); + ResourceKey SHOCKWAVE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "shockwave")); + ResourceKey THROWN_ROCK = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "thrown_rock")); + ResourceKey WIND = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "wind")); + ResourceKey FALLING_STAR = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ArsMagicaAPI.MOD_ID, "falling_star")); private static Holder type(RegistryAccess access, ResourceKey type) { return access.registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(type); } - static DamageSource natureScythe(Entity directSource, @Nullable Entity indirectSource) { - return new DamageSource(type(directSource.level().registryAccess(), NATURE_SCYTHE), directSource, indirectSource); + static DamageSource spellDrowning(LivingEntity source, @Nullable Entity directSource) { + return new DamageSource(type(source.level().registryAccess(), SPELL_DROWNING), source, directSource); } - static DamageSource shockwave(Entity source) { + static DamageSource spellFire(LivingEntity source, @Nullable Entity directSource) { + return new DamageSource(type(source.level().registryAccess(), SPELL_FIRE), source, directSource); + } + + static DamageSource spellFrost(LivingEntity source, @Nullable Entity directSource) { + return new DamageSource(type(source.level().registryAccess(), SPELL_FROST), source, directSource); + } + + static DamageSource spellLightning(LivingEntity source, @Nullable Entity directSource) { + return new DamageSource(type(source.level().registryAccess(), SPELL_LIGHTNING), source, directSource); + } + + static DamageSource spellMagic(LivingEntity source, @Nullable Entity directSource) { + return new DamageSource(type(source.level().registryAccess(), SPELL_MAGIC), source, directSource); + } + + static DamageSource spellPhysical(LivingEntity source, @Nullable Entity directSource) { + return new DamageSource(type(source.level().registryAccess(), SPELL_PHYSICAL), source, directSource); + } + + static DamageSource spellPhysicalPlayer(Player source, @Nullable Entity directSource) { + return new DamageSource(type(source.level().registryAccess(), SPELL_PHYSICAL_PLAYER), source, directSource); + } + + static DamageSource natureScythe(NatureScythe source) { + return new DamageSource(type(source.level().registryAccess(), NATURE_SCYTHE), source.getOwner(), source); + } + + static DamageSource shockwave(Shockwave source) { return new DamageSource(type(source.level().registryAccess(), SHOCKWAVE), source); } - static DamageSource fallingStar(Entity source) { - return new DamageSource(type(source.level().registryAccess(), FALLING_STAR), source); + static DamageSource fallingStar(FallingStar source) { + return new DamageSource(type(source.level().registryAccess(), FALLING_STAR), source.getOwner(), source); } - static DamageSource thrownRock(Entity directSource, @Nullable Entity indirectSource) { - return new DamageSource(type(directSource.level().registryAccess(), THROWN_ROCK), directSource, indirectSource); + static DamageSource thrownRock(ThrownRock source) { + return new DamageSource(type(source.level().registryAccess(), THROWN_ROCK), source.getOwner(), source); } - static DamageSource wind(Entity directSource) { - return new DamageSource(type(directSource.level().registryAccess(), WIND), directSource); + static DamageSource wind(Entity source) { + return new DamageSource(type(source.level().registryAccess(), WIND), source); } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/init/AMSpellParts.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/init/AMSpellParts.java index ba4f341b2..da60dffb1 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/init/AMSpellParts.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/init/AMSpellParts.java @@ -95,13 +95,12 @@ public interface AMSpellParts { DeferredHolder CONTINGENCY_FIRE = SPELL_PARTS.register("contingency_fire", () -> new Contingency(ContingencyType.FIRE)); DeferredHolder CONTINGENCY_FALL = SPELL_PARTS.register("contingency_fall", () -> new Contingency(ContingencyType.FALL)); - DeferredHolder DROWNING_DAMAGE = SPELL_PARTS.register("drowning_damage", () -> new Damage(e -> e.damageSources().drown(), Config.SERVER.DAMAGE, e -> !e.canDrownInFluidType(NeoForgeMod.WATER_TYPE.value()))); - DeferredHolder FIRE_DAMAGE = SPELL_PARTS.register("fire_damage", () -> new Damage(e -> e.damageSources().inFire(), Config.SERVER.DAMAGE, Entity::fireImmune)); - DeferredHolder FROST_DAMAGE = SPELL_PARTS.register("frost_damage", () -> new Damage(e -> e.damageSources().freeze(), Config.SERVER.DAMAGE, e -> !e.canFreeze())); - DeferredHolder LIGHTNING_DAMAGE = SPELL_PARTS.register("lightning_damage", () -> new Damage(e -> e.damageSources().lightningBolt(), Config.SERVER.DAMAGE)); - DeferredHolder MAGIC_DAMAGE = SPELL_PARTS.register("magic_damage", () -> new Damage(e -> e.damageSources().indirectMagic(e, null), Config.SERVER.DAMAGE)); - DeferredHolder PHYSICAL_DAMAGE = SPELL_PARTS.register("physical_damage", () -> new Damage(e -> e instanceof Player p ? p.damageSources().playerAttack(p) : e.damageSources().mobAttack(e), Config.SERVER.DAMAGE)); - DeferredHolder ABSORPTION = SPELL_PARTS.register("absorption", () -> new Effect(MobEffects.ABSORPTION)); + DeferredHolder DROWNING_DAMAGE = SPELL_PARTS.register("drowning_damage", () -> new Damage(AMDamageSources::spellDrowning, Config.SERVER.DAMAGE)); + DeferredHolder FIRE_DAMAGE = SPELL_PARTS.register("fire_damage", () -> new Damage(AMDamageSources::spellFire, Config.SERVER.DAMAGE)); + DeferredHolder FROST_DAMAGE = SPELL_PARTS.register("frost_damage", () -> new Damage(AMDamageSources::spellFrost, Config.SERVER.DAMAGE)); + DeferredHolder LIGHTNING_DAMAGE = SPELL_PARTS.register("lightning_damage", () -> new Damage(AMDamageSources::spellLightning, Config.SERVER.DAMAGE)); + DeferredHolder MAGIC_DAMAGE = SPELL_PARTS.register("magic_damage", () -> new Damage(AMDamageSources::spellMagic, Config.SERVER.DAMAGE)); + DeferredHolder PHYSICAL_DAMAGE = SPELL_PARTS.register("physical_damage", () -> new Damage((e, d) -> e instanceof Player p ? AMDamageSources.spellPhysicalPlayer(p, d) : AMDamageSources.spellPhysical(e, d), Config.SERVER.DAMAGE)); DeferredHolder ABSORPTION = SPELL_PARTS.register("absorption", () -> new Effect(MobEffects.ABSORPTION)); DeferredHolder BLINDNESS = SPELL_PARTS.register("blindness", () -> new Effect(MobEffects.BLINDNESS)); DeferredHolder HASTE = SPELL_PARTS.register("haste", () -> new Effect(MobEffects.DIG_SPEED)); DeferredHolder HEALTH_BOOST = SPELL_PARTS.register("health_boost", () -> new Effect(MobEffects.HEALTH_BOOST)); diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/magic/ContingencyHelper.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/magic/ContingencyHelper.java index 7150d6195..28307ee96 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/magic/ContingencyHelper.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/magic/ContingencyHelper.java @@ -78,7 +78,7 @@ public Contingency() { } private void execute(Level level, LivingEntity target) { - ArsMagicaAPI.get().getSpellHelper().invoke(spell, target, level, new EntityHitResult(target), 0, index, true); + ArsMagicaAPI.get().getSpellHelper().invoke(spell, target, null, level, new EntityHitResult(target), 0, index, true); } } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/Spell.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/Spell.java index 6887d0d2d..daf21a472 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/Spell.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/Spell.java @@ -145,7 +145,7 @@ public SpellCastResult cast(LivingEntity caster, Level level, int castingTicks, return SpellCastResult.BURNED_OUT; if (!spellHelper.hasReagents(caster, reagents)) return SpellCastResult.MISSING_REAGENTS; } - SpellCastResult result = spellHelper.invoke(this, caster, level, null, castingTicks, 0, awardXp); + SpellCastResult result = spellHelper.invoke(this, caster, null, level, null, castingTicks, 0, awardXp); if (level.isClientSide()) { NeoForge.EVENT_BUS.post(new SpellEvent.Cast.Post(caster, this)); return result; diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/SpellHelper.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/SpellHelper.java index 476c719cc..d0a91e1c1 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/SpellHelper.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/SpellHelper.java @@ -191,7 +191,7 @@ public float getModifiedStat(float baseValue, ISpellPartStat stat, List>> pwm = spell.partsWithModifiers(); Pair> pair = pwm.get(index); ISpellPart part = pair.getFirst(); @@ -204,7 +204,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, @N if (NeoForge.EVENT_BUS.post(new SpellEvent.Cast.Component(caster, spell, component, modifiers, target)).isCanceled()) return SpellCastResult.CANCELLED; if (target instanceof EntityHitResult entityHitResult) { - result = component.invoke(spell, caster, level, modifiers, entityHitResult, index + 1, castingTicks); + result = component.invoke(spell, caster, directEntity, level, modifiers, entityHitResult, index + 1, castingTicks); if (result.isSuccess()) { Vec3 location = target.getLocation(); PacketDistributor.TargetPoint targetPoint = new PacketDistributor.TargetPoint(location.x, location.y, location.z, 64, level.dimension()); @@ -212,14 +212,14 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, @N } } if (target instanceof BlockHitResult blockHitResult) { - result = component.invoke(spell, caster, level, modifiers, blockHitResult, index + 1, castingTicks); + result = component.invoke(spell, caster, directEntity, level, modifiers, blockHitResult, index + 1, castingTicks); if (result.isSuccess()) { Vec3 location = target.getLocation(); PacketDistributor.TargetPoint targetPoint = new PacketDistributor.TargetPoint(location.x, location.y, location.z, 64, level.dimension()); PacketDistributor.NEAR.with(targetPoint).send(new SpawnComponentParticlesPacket(component, caster, Either.left(blockHitResult), getColor(modifiers, spell, caster, index + 1, -1))); } } - return result.isFail() || index + 1 == pwm.size() ? result : invoke(spell, caster, level, target, castingTicks, index + 1, awardXp); + return result.isFail() || index + 1 == pwm.size() ? result : invoke(spell, caster, directEntity, level, target, castingTicks, index + 1, awardXp); } case SHAPE -> { ISpellShape shape = (ISpellShape) part; diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Attract.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Attract.java index 84a9cf221..acdd08501 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Attract.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Attract.java @@ -27,7 +27,8 @@ private static SpellCastResult performAttract(@Nullable Entity targetEntity, AAB boolean success = false; for (Entity e : caster.level().getEntities(targetEntity, aabb)) { if (e == caster) continue; - if (e instanceof AbstractSpellEntity effect && effect.getOwner() != null && effect.getOwner().is(e)) continue; + if (e instanceof AbstractSpellEntity effect && effect.getOwner() != null && effect.getOwner().is(e)) + continue; success = true; Vec3 vec = e.position(); double distance = targetPos.distanceTo(vec) + 0.1; @@ -39,14 +40,14 @@ private static SpellCastResult performAttract(@Nullable Entity targetEntity, AAB } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { float range = ArsMagicaAPI.get().getSpellHelper().getModifiedStat(2, SpellPartStats.RANGE, modifiers, spell, caster, target, index) * 2; Entity entity = target.getEntity(); return performAttract(entity, entity.getBoundingBox().inflate(range, range, range), caster, target.getLocation(), modifiers, spell, target, index); } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { float range = ArsMagicaAPI.get().getSpellHelper().getModifiedStat(2, SpellPartStats.RANGE, modifiers, spell, caster, target, index) * 2; return performAttract(null, AABB.ofSize(target.getLocation(), range, range, range), caster, target.getLocation(), modifiers, spell, target, index); } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/BanishRain.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/BanishRain.java index 1ee939a64..5ca61a792 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/BanishRain.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/BanishRain.java @@ -4,16 +4,18 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class BanishRain extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (!level.isClientSide() && level.getLevelData().isRaining()) { ((ServerLevel) level).setWeatherParameters(24000, 0, false, false); return SpellCastResult.SUCCESS; @@ -22,7 +24,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { if (!level.isClientSide() && level.getLevelData().isRaining()) { ((ServerLevel) level).setWeatherParameters(24000, 0, false, false); return SpellCastResult.SUCCESS; diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Blink.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Blink.java index bb42b7a56..073aeef8a 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Blink.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Blink.java @@ -12,6 +12,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -21,7 +22,7 @@ public Blink() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (caster.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value()) || target.getEntity() instanceof LivingEntity living && living.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value())) return SpellCastResult.EFFECT_FAILED; Entity entity = target.getEntity(); @@ -39,7 +40,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Blizzard.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Blizzard.java index fd54ff441..742d86b8b 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Blizzard.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Blizzard.java @@ -6,11 +6,13 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import com.github.minecraftschurlimods.arsmagicalegacy.common.init.AMEntities; import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.SpellPartStats; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.Objects; @@ -21,13 +23,13 @@ public Blizzard() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { spawn(spell, caster, level, modifiers, target, index); return SpellCastResult.SUCCESS; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { spawn(spell, caster, level, modifiers, target, index); return SpellCastResult.SUCCESS; } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Charm.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Charm.java index 87e3fb010..562504828 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Charm.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Charm.java @@ -3,18 +3,20 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpell; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class Charm extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (target.getEntity() instanceof Animal animal) { animal.setInLove(caster instanceof Player player ? player : null); return SpellCastResult.SUCCESS; @@ -23,7 +25,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/CreateWater.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/CreateWater.java index fd5629b75..166f750b0 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/CreateWater.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/CreateWater.java @@ -4,6 +4,7 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.AbstractCauldronBlock; @@ -13,17 +14,18 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class CreateWater extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { BlockPos pos = target.getBlockPos(); BlockState state = level.getBlockState(pos); Block block = state.getBlock(); diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Damage.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Damage.java index 74d384076..fa89d5bb9 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Damage.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Damage.java @@ -7,59 +7,56 @@ import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.SpellPartStats; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.function.Function; -import java.util.function.Predicate; import java.util.function.Supplier; public class Damage extends AbstractComponent { - private final Function damageSourceFunction; + private final DamageSourceFunction damageSourceFunction; private final Function damage; - private final Predicate failIf; - public Damage(Function damageSourceFunction, Function damage, Predicate failIf) { + public Damage(DamageSourceFunction damageSourceFunction, Function damage) { super(SpellPartStats.DAMAGE, SpellPartStats.HEALING); this.damageSourceFunction = damageSourceFunction; this.damage = damage; - this.failIf = failIf; } - public Damage(Function damageSourceFunction, Supplier damage, Predicate failIf) { - this(damageSourceFunction, e -> damage.get(), failIf); - } - - public Damage(Function damageSourceFunction, Function damage) { - this(damageSourceFunction, damage, e -> false); - } - - public Damage(Function damageSourceFunction, Supplier damage) { - this(damageSourceFunction, e -> damage.get(), e -> false); + public Damage(DamageSourceFunction damageSourceFunction, Supplier damage) { + this(damageSourceFunction, e -> damage.get()); } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (!(target.getEntity() instanceof LivingEntity living)) return SpellCastResult.EFFECT_FAILED; - if (failIf.test(living)) return SpellCastResult.EFFECT_FAILED; + DamageSource damageSource = damageSourceFunction.getDamageSource(caster, directEntity); + if (target.getEntity().isInvulnerableTo(damageSource)) return SpellCastResult.EFFECT_FAILED; float damage = this.damage.apply(living).floatValue(); if (living instanceof Player && living != caster && !((ServerLevel) level).getServer().isPvpAllowed() && damage > 0) return SpellCastResult.EFFECT_FAILED; if (damage < 0) { - damage = ArsMagicaAPI.get().getSpellHelper().getModifiedStat(damage, SpellPartStats.HEALING, modifiers, spell, caster, target, index); - living.heal(-damage); + damage = ArsMagicaAPI.get().getSpellHelper().getModifiedStat(-damage, SpellPartStats.HEALING, modifiers, spell, caster, target, index); + living.heal(damage); return SpellCastResult.SUCCESS; } damage = ArsMagicaAPI.get().getSpellHelper().getModifiedStat(damage, SpellPartStats.DAMAGE, modifiers, spell, caster, target, index); - return living.hurt(damageSourceFunction.apply(caster), damage) ? SpellCastResult.SUCCESS : SpellCastResult.EFFECT_FAILED; + return living.hurt(damageSource, damage) ? SpellCastResult.SUCCESS : SpellCastResult.EFFECT_FAILED; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } + + @FunctionalInterface + public interface DamageSourceFunction { + DamageSource getDamageSource(LivingEntity entity, @Nullable Entity directEntity); + } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Daylight.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Daylight.java index a572ca7d7..15da8f0e2 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Daylight.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Daylight.java @@ -4,16 +4,18 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class Daylight extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (level.getDayTime() % 24000 >= 12000 && level instanceof ServerLevel server) { server.setDayTime(level.getDayTime() + 12000); return SpellCastResult.SUCCESS; @@ -22,7 +24,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { if (level.getDayTime() % 24000 >= 12000 && level instanceof ServerLevel server) { server.setDayTime(level.getDayTime() + 12000); return SpellCastResult.SUCCESS; diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Dig.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Dig.java index 37adb1103..af8a0213a 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Dig.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Dig.java @@ -8,6 +8,7 @@ import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.TierMapping; import com.github.minecraftschurlimods.arsmagicalegacy.common.util.AMUtil; import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -17,6 +18,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.neoforged.neoforge.common.TierSortingRegistry; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -26,12 +28,12 @@ public Dig() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { BlockPos blockPos = target.getBlockPos(); BlockState state = level.getBlockState(blockPos); float hardness = state.getDestroySpeed(level, blockPos); diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Disarm.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Disarm.java index 2a5dea49e..e7c957548 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Disarm.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Disarm.java @@ -13,12 +13,13 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class Disarm extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { Entity entity = target.getEntity(); if (entity instanceof LivingEntity living) { ItemStack main = living.getMainHandItem().copy(); @@ -53,7 +54,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Dispel.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Dispel.java index e03f537bb..e2063ee06 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Dispel.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Dispel.java @@ -5,17 +5,19 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; public class Dispel extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (target.getEntity() instanceof LivingEntity living) { List effects = new ArrayList<>(); int left = 6; @@ -35,7 +37,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/DivineIntervention.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/DivineIntervention.java index e1b38cf2d..8a65a43a6 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/DivineIntervention.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/DivineIntervention.java @@ -7,17 +7,19 @@ import com.github.minecraftschurlimods.arsmagicalegacy.common.util.TranslationConstants; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class DivineIntervention extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (caster.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value())) return SpellCastResult.EFFECT_FAILED; if (target.getEntity() instanceof LivingEntity living && !living.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value())) { if (living.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value())) { @@ -40,7 +42,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Drought.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Drought.java index 33f306535..8170747c0 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Drought.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Drought.java @@ -5,6 +5,7 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -12,18 +13,19 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.Optional; public class Drought extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { BlockPos pos = target.getBlockPos(); BlockState state = level.getBlockState(pos); if (level.getBlockState(pos.offset(target.getDirection().getNormal())).getBlock() == Blocks.WATER) { diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Effect.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Effect.java index 306c0ab9a..1191cfef2 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Effect.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Effect.java @@ -9,10 +9,12 @@ import net.minecraft.core.Holder; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -29,7 +31,7 @@ public Effect(MobEffect effect) { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (!(target.getEntity() instanceof LivingEntity living)) return SpellCastResult.EFFECT_FAILED; var helper = ArsMagicaAPI.get().getSpellHelper(); int amplifier = (int) helper.getModifiedStat(0, SpellPartStats.POWER, modifiers, spell, caster, target, index); @@ -42,7 +44,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/EnderIntervention.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/EnderIntervention.java index 0feba1bb8..228e077eb 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/EnderIntervention.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/EnderIntervention.java @@ -7,17 +7,19 @@ import com.github.minecraftschurlimods.arsmagicalegacy.common.util.TranslationConstants; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class EnderIntervention extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (caster.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value())) return SpellCastResult.EFFECT_FAILED; if (target.getEntity() instanceof LivingEntity living && !living.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value())) { if (living.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value())) { @@ -40,7 +42,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Explosion.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Explosion.java index 59e065abf..1da8ece7d 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Explosion.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Explosion.java @@ -5,11 +5,13 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.SpellPartStats; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -19,13 +21,13 @@ public Explosion() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { level.explode(caster, target.getLocation().x(), target.getLocation().y(), target.getLocation().z(), ArsMagicaAPI.get().getSpellHelper().getModifiedStat(2, SpellPartStats.RANGE, modifiers, spell, caster, target, index), caster instanceof Player ? Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.MOB); return SpellCastResult.SUCCESS; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { level.explode(caster, target.getLocation().x(), target.getLocation().y(), target.getLocation().z(), ArsMagicaAPI.get().getSpellHelper().getModifiedStat(2, SpellPartStats.RANGE, modifiers, spell, caster, target, index), caster instanceof Player ? Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.MOB); return SpellCastResult.SUCCESS; } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/FallingStar.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/FallingStar.java index fe0b3dae6..2de818fe9 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/FallingStar.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/FallingStar.java @@ -6,12 +6,14 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import com.github.minecraftschurlimods.arsmagicalegacy.common.init.AMEntities; import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.SpellPartStats; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.Objects; @@ -22,13 +24,13 @@ public FallingStar() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { spawn(spell, caster, level, modifiers, target, index); return SpellCastResult.SUCCESS; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { spawn(spell, caster, level, modifiers, target, index); return SpellCastResult.SUCCESS; } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/FireRain.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/FireRain.java index ca9ca92c5..a9cbb3372 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/FireRain.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/FireRain.java @@ -6,11 +6,13 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import com.github.minecraftschurlimods.arsmagicalegacy.common.init.AMEntities; import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.SpellPartStats; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.Objects; @@ -21,13 +23,13 @@ public FireRain() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { spawn(spell, caster, level, modifiers, target, index); return SpellCastResult.SUCCESS; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { spawn(spell, caster, level, modifiers, target, index); return SpellCastResult.SUCCESS; } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Fling.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Fling.java index bf593cf5a..52d38add3 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Fling.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Fling.java @@ -11,6 +11,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -20,7 +21,7 @@ public Fling() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { Entity entity = target.getEntity(); Vec3 delta = entity.getDeltaMovement(); entity.setDeltaMovement(delta.x(), delta.y() + ArsMagicaAPI.get().getSpellHelper().getModifiedStat(1, SpellPartStats.SPEED, modifiers, spell, caster, target, index) * 1.05f, delta.z()); @@ -28,7 +29,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Forge.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Forge.java index 2d0911a94..5f6eca36a 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Forge.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Forge.java @@ -5,6 +5,7 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import net.minecraft.core.BlockPos; import net.minecraft.world.SimpleContainer; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.npc.Villager; @@ -20,13 +21,14 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; import java.util.Optional; public class Forge extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (target.getEntity() instanceof Villager villager) { if (!level.isClientSide()) { level.addFreshEntity(new ItemEntity(level, villager.position().x(), villager.position().y(), villager.position().z(), new ItemStack(Items.EMERALD))); @@ -38,7 +40,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { if (!(caster instanceof Player)) return SpellCastResult.EFFECT_FAILED; BlockPos pos = target.getBlockPos(); Block block = level.getBlockState(pos).getBlock(); diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Grow.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Grow.java index 8fa641295..b455ea066 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Grow.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Grow.java @@ -6,23 +6,25 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.BonemealableBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class Grow extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { BlockPos pos = target.getBlockPos(); BlockState state = level.getBlockState(pos); if (!(state.getBlock() instanceof BonemealableBlock) && target.getDirection() == Direction.UP) { diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Harvest.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Harvest.java index fe9e6adf6..c2fba1a71 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Harvest.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Harvest.java @@ -6,6 +6,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.ItemStack; @@ -15,17 +16,18 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class Harvest extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { BlockPos pos = target.getBlockPos(); BlockState state = level.getBlockState(pos); if (!(state.getBlock() instanceof CropBlock) && target.getDirection() == Direction.UP) { diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Heal.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Heal.java index 5ffea6d98..6ae3417ff 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Heal.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Heal.java @@ -5,10 +5,12 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.SpellPartStats; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -18,7 +20,7 @@ public Heal() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (target.getEntity() instanceof LivingEntity living) { float healing = ArsMagicaAPI.get().getSpellHelper().getModifiedStat(2, SpellPartStats.HEALING, modifiers, spell, caster, target, index); if (living.isInvertedHealAndHarm()) { @@ -32,7 +34,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Ignition.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Ignition.java index 4bb297a0f..9d6f61bd1 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Ignition.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Ignition.java @@ -7,6 +7,7 @@ import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.SpellPartStats; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.monster.Creeper; import net.minecraft.world.level.Level; @@ -18,6 +19,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -27,7 +29,7 @@ public Ignition() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (target.getEntity() instanceof Creeper creeper && !creeper.isIgnited()) { creeper.ignite(); return SpellCastResult.SUCCESS; @@ -38,7 +40,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { BlockPos pos = target.getBlockPos(); BlockState state = level.getBlockState(pos); if (state.getBlock() instanceof CampfireBlock && !state.getValue(CampfireBlock.LIT)) { diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Knockback.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Knockback.java index 57d0caea2..8947afd6b 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Knockback.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Knockback.java @@ -11,6 +11,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -20,7 +21,7 @@ public Knockback() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { Entity entity = target.getEntity(); float velocity = ArsMagicaAPI.get().getSpellHelper().getModifiedStat(1, SpellPartStats.SPEED, modifiers, spell, caster, target, index); Vec3 delta = entity.getDeltaMovement(); @@ -29,7 +30,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/LifeDrain.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/LifeDrain.java index 7b1124943..09b5c3d6d 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/LifeDrain.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/LifeDrain.java @@ -5,10 +5,12 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.SpellPartStats; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -18,7 +20,7 @@ public LifeDrain() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (target.getEntity() instanceof LivingEntity living) { float damage = ArsMagicaAPI.get().getSpellHelper().getModifiedStat(2, living.isInvertedHealAndHarm() ? SpellPartStats.HEALING : SpellPartStats.DAMAGE, modifiers, spell, caster, target, index) * 2; if (living.hurt(level.damageSources().fellOutOfWorld(), damage)) { @@ -30,7 +32,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/LifeTap.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/LifeTap.java index f7c06f7c8..56800fbcd 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/LifeTap.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/LifeTap.java @@ -5,10 +5,12 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.SpellPartStats; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -18,7 +20,7 @@ public LifeTap() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (target.getEntity() instanceof LivingEntity living) { var api = ArsMagicaAPI.get(); float damage = api.getSpellHelper().getModifiedStat(2, living.isInvertedHealAndHarm() ? SpellPartStats.HEALING : SpellPartStats.DAMAGE, modifiers, spell, caster, target, index) * 2; @@ -31,7 +33,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Light.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Light.java index 7ed8dc9a6..e100b6da5 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Light.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Light.java @@ -6,11 +6,13 @@ import com.github.minecraftschurlimods.arsmagicalegacy.common.init.AMMobEffects; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.phys.BlockHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -20,7 +22,7 @@ public Light() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { Direction direction = target.getDirection(); BlockPos pos = target.getBlockPos().offset(direction.getStepX(), direction.getStepY(), direction.getStepZ()); if (level.getBlockState(pos).isAir()) { diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/ManaBlast.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/ManaBlast.java index f7bb54bbd..b5b40aecc 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/ManaBlast.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/ManaBlast.java @@ -6,10 +6,12 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.SpellPartStats; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -19,7 +21,7 @@ public ManaBlast() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (!(target.getEntity() instanceof LivingEntity living)) return SpellCastResult.EFFECT_FAILED; var api = ArsMagicaAPI.get(); var helper = api.getManaHelper(); @@ -30,7 +32,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/ManaDrain.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/ManaDrain.java index 02e4bc32f..09c742cc1 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/ManaDrain.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/ManaDrain.java @@ -4,16 +4,18 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpell; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class ManaDrain extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (target.getEntity() instanceof LivingEntity living) { var helper = ArsMagicaAPI.get().getManaHelper(); float mana = Math.min(250, helper.getMana(living)); @@ -25,7 +27,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/MeltArmor.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/MeltArmor.java index ec635c8e8..e3bab10ea 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/MeltArmor.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/MeltArmor.java @@ -3,17 +3,19 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpell; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class MeltArmor extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { boolean success = false; for (ItemStack stack : target.getEntity().getArmorSlots()) { if (stack != null && stack.isDamageableItem()) { @@ -26,7 +28,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Moonrise.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Moonrise.java index f40354804..fd33a3f11 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Moonrise.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Moonrise.java @@ -4,16 +4,18 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class Moonrise extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (level.getDayTime() % 24000 < 12000 && level instanceof ServerLevel server) { server.setDayTime(level.getDayTime() + 12000); return SpellCastResult.SUCCESS; @@ -22,7 +24,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { if (level.getDayTime() % 24000 < 12000 && level instanceof ServerLevel server) { server.setDayTime(level.getDayTime() + 12000); return SpellCastResult.SUCCESS; diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/PlaceBlock.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/PlaceBlock.java index 6a95beb5e..5c633843e 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/PlaceBlock.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/PlaceBlock.java @@ -8,6 +8,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -19,6 +20,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -26,12 +28,12 @@ public class PlaceBlock extends AbstractComponent { private static final String KEY = ArsMagicaAPI.MOD_ID + ":place_block_id"; @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { if (!(caster instanceof Player player)) return SpellCastResult.EFFECT_FAILED; ItemStack stack = ArsMagicaAPI.get().getSpellHelper().getSpellItemStackFromEntity(player); if (player.isShiftKeyDown()) { diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Plant.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Plant.java index 3936d0c50..9aa0f15b6 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Plant.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Plant.java @@ -5,6 +5,7 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; @@ -16,6 +17,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.neoforged.neoforge.common.IPlantable; +import org.jetbrains.annotations.Nullable; import java.util.HashMap; import java.util.List; @@ -23,12 +25,12 @@ public class Plant extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { if (!(caster instanceof Player player)) return SpellCastResult.EFFECT_FAILED; BlockPos pos = target.getBlockPos(); BlockState state = level.getBlockState(pos); diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Plow.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Plow.java index 4d345552c..bea79f063 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Plow.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Plow.java @@ -5,6 +5,7 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -13,17 +14,18 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; public class Plow extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { ItemStack hoe = new ItemStack(Items.WOODEN_HOE); InteractionResult result = hoe.useOn(new UseOnContext(level, caster instanceof Player player ? player : null, InteractionHand.MAIN_HAND, hoe, target)); return result.consumesAction() ? SpellCastResult.SUCCESS : SpellCastResult.EFFECT_FAILED; diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/RandomTeleport.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/RandomTeleport.java index 580e48621..28d0dd3d8 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/RandomTeleport.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/RandomTeleport.java @@ -13,6 +13,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -22,7 +23,7 @@ public RandomTeleport() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (caster.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value()) || target.getEntity() instanceof LivingEntity living && living.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value())) return SpellCastResult.EFFECT_FAILED; float range = ArsMagicaAPI.get().getSpellHelper().getModifiedStat(5, SpellPartStats.RANGE, modifiers, spell, caster, target, index) * 4; @@ -42,7 +43,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Recall.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Recall.java index 2013e1a9c..3692a86c8 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Recall.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Recall.java @@ -14,6 +14,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -32,14 +33,14 @@ private static boolean performRecall(Entity target, Level level, CompoundTag tag } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (caster.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value()) || target.getEntity() instanceof LivingEntity living && living.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value())) return SpellCastResult.EFFECT_FAILED; return performRecall(target.getEntity(), level, ArsMagicaAPI.get().getSpellHelper().getSpellItemStackFromEntity(caster).getOrCreateTag()) ? SpellCastResult.SUCCESS : SpellCastResult.EFFECT_FAILED; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { if (!caster.isShiftKeyDown()) return SpellCastResult.EFFECT_FAILED; ItemStack stack = ArsMagicaAPI.get().getSpellHelper().getSpellItemStackFromEntity(caster); CompoundTag tag = stack.getOrCreateTag(); diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Repel.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Repel.java index dc6d99eaa..f1e594d83 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Repel.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Repel.java @@ -27,7 +27,8 @@ private static SpellCastResult performRepel(@Nullable Entity targetEntity, AABB boolean success = false; for (Entity e : caster.level().getEntities(targetEntity, aabb)) { if (e == caster) continue; - if (e instanceof AbstractSpellEntity effect && effect.getOwner() != null && effect.getOwner().is(e)) continue; + if (e instanceof AbstractSpellEntity effect && effect.getOwner() != null && effect.getOwner().is(e)) + continue; success = true; Vec3 vec = e.position(); double distance = targetPos.distanceTo(vec) + 0.1; @@ -39,14 +40,14 @@ private static SpellCastResult performRepel(@Nullable Entity targetEntity, AABB } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { float range = ArsMagicaAPI.get().getSpellHelper().getModifiedStat(2, SpellPartStats.RANGE, modifiers, spell, caster, target, index) * 2; Entity entity = target.getEntity(); return performRepel(entity, entity.getBoundingBox().inflate(range, range, range), caster, target.getLocation(), modifiers, spell, target, index); } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { float range = ArsMagicaAPI.get().getSpellHelper().getModifiedStat(2, SpellPartStats.RANGE, modifiers, spell, caster, target, index) * 2; return performRepel(null, AABB.ofSize(target.getLocation(), range, range, range), caster, target.getLocation(), modifiers, spell, target, index); } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Rift.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Rift.java index 902f415eb..c19c1d323 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Rift.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Rift.java @@ -11,11 +11,13 @@ import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.SimpleMenuProvider; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.neoforged.neoforge.server.permission.PermissionAPI; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -25,7 +27,7 @@ public Rift() { } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (target.getEntity() instanceof ServerPlayer sp && ArsMagicaAPI.get().getRiftHelper().getRift(sp) != null) { int size = Math.min(Math.round(Math.max(1, ArsMagicaAPI.get().getSpellHelper().getModifiedStat(1, SpellPartStats.POWER, modifiers, spell, caster, target, index))), PermissionAPI.getPermission(sp, AMPermissions.MAX_RIFT_SIZE)); sp.openMenu(new SimpleMenuProvider((id, inv, player) -> RiftMenu.rift(id, inv, sp, size), Component.translatable(TranslationConstants.RIFT_TITLE)), buf -> { @@ -38,7 +40,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Storm.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Storm.java index e0a893554..37145f57d 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Storm.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Storm.java @@ -17,6 +17,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -66,12 +67,12 @@ private static SpellCastResult performStorm(LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { return performStorm(caster, level, modifiers, spell, target, index); } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return performStorm(caster, level, modifiers, spell, target, index); } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Summon.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Summon.java index 964e3afcb..013186739 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Summon.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Summon.java @@ -3,22 +3,23 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpell; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; -//TODO public class Summon extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Telekinesis.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Telekinesis.java index 57b288f94..78d53876f 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Telekinesis.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Telekinesis.java @@ -3,22 +3,23 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpell; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; -//TODO public class Telekinesis extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Transplace.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Transplace.java index ab1a0b8c8..2b60739ef 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Transplace.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Transplace.java @@ -4,17 +4,19 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; import com.github.minecraftschurlimods.arsmagicalegacy.common.init.AMMobEffects; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.Nullable; import java.util.List; public class Transplace extends AbstractComponent { @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { if (caster.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value()) || target.getEntity() instanceof LivingEntity living && living.hasEffect(AMMobEffects.ASTRAL_DISTORTION.value())) return SpellCastResult.EFFECT_FAILED; Vec3 targetPos = target.getEntity().position(); @@ -25,7 +27,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return SpellCastResult.EFFECT_FAILED; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/WizardsAutumn.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/WizardsAutumn.java index e5943a8c7..85589ac8a 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/WizardsAutumn.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/WizardsAutumn.java @@ -7,12 +7,14 @@ import com.github.minecraftschurlimods.arsmagicalegacy.common.spell.SpellPartStats; import net.minecraft.core.BlockPos; import net.minecraft.tags.BlockTags; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -38,12 +40,12 @@ private static SpellCastResult performWizardsAutumn(BlockPos origin, ISpell spel } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, EntityHitResult target, int index, int ticksUsed) { return performWizardsAutumn(target.getEntity().blockPosition(), spell, caster, level, modifiers, target, index); } @Override - public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { + public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entity directEntity, Level level, List modifiers, BlockHitResult target, int index, int ticksUsed) { return performWizardsAutumn(target.getBlockPos(), spell, caster, level, modifiers, target, index); } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/AoE.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/AoE.java index 9f76f9cb3..a0f759d35 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/AoE.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/AoE.java @@ -37,7 +37,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li if (e instanceof PartEntity && ((PartEntity) e).getParent() != null) { e = ((PartEntity) e).getParent(); } - if (helper.invoke(spell, caster, level, new EntityHitResult(e), ticksUsed, index, awardXp) == SpellCastResult.SUCCESS) { + if (helper.invoke(spell, caster, null, level, new EntityHitResult(e), ticksUsed, index, awardXp) == SpellCastResult.SUCCESS) { appliedToAtLeastOneEntity = true; } } @@ -55,7 +55,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li case Z -> pos.offset(x, y, offset); }; if (!level.getBlockState(lookPos).isAir()) { - helper.invoke(spell, caster, level, new BlockHitResult(hit.getLocation(), ((BlockHitResult) hit).getDirection(), lookPos, ((BlockHitResult) hit).isInside()), ticksUsed, index, awardXp); + helper.invoke(spell, caster, null, level, new BlockHitResult(hit.getLocation(), ((BlockHitResult) hit).getDirection(), lookPos, ((BlockHitResult) hit).isInside()), ticksUsed, index, awardXp); } } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Beam.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Beam.java index 60e58aa85..08d282fd1 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Beam.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Beam.java @@ -20,7 +20,7 @@ public Beam() { @Override public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, @Nullable HitResult hit, int ticksUsed, int index, boolean awardXp) { var helper = ArsMagicaAPI.get().getSpellHelper(); - return helper.invoke(spell, caster, level, helper.trace(caster, level, 64, true, helper.getModifiedStat(0, SpellPartStats.TARGET_NON_SOLID, modifiers, spell, caster, hit, index) > 0), ticksUsed, index, awardXp); + return helper.invoke(spell, caster, null, level, helper.trace(caster, level, 64, true, helper.getModifiedStat(0, SpellPartStats.TARGET_NON_SOLID, modifiers, spell, caster, hit, index) > 0), ticksUsed, index, awardXp); } @Override diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Chain.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Chain.java index 477fb175b..63bca23f0 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Chain.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Chain.java @@ -28,12 +28,12 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, Li var helper = ArsMagicaAPI.get().getSpellHelper(); HitResult hitResult = helper.trace(caster, level, 16, true, helper.getModifiedStat(0, SpellPartStats.TARGET_NON_SOLID, modifiers, spell, caster, hit, index) > 0); if (hitResult instanceof BlockHitResult bhr) - return helper.invoke(spell, caster, level, bhr, ticksUsed, index, awardXp); + return helper.invoke(spell, caster, null, level, bhr, ticksUsed, index, awardXp); SpellCastResult result = SpellCastResult.EFFECT_FAILED; if (hitResult instanceof EntityHitResult ehr) { - result = helper.invoke(spell, caster, level, ehr, ticksUsed, index, awardXp); + result = helper.invoke(spell, caster, null, level, ehr, ticksUsed, index, awardXp); for (Entity e : getEntities(ehr.getEntity(), helper.getModifiedStat(4, SpellPartStats.RANGE, modifiers, spell, caster, hit, index), caster)) { - SpellCastResult currentResult = helper.invoke(spell, caster, level, new EntityHitResult(e), ticksUsed, index, awardXp); + SpellCastResult currentResult = helper.invoke(spell, caster, null, level, new EntityHitResult(e), ticksUsed, index, awardXp); result = result == SpellCastResult.SUCCESS ? SpellCastResult.SUCCESS : currentResult; } } diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Channel.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Channel.java index a0ae347f6..005555f49 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Channel.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Channel.java @@ -15,7 +15,7 @@ public class Channel extends AbstractShape { @Override public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, @Nullable HitResult hit, int ticksUsed, int index, boolean awardXp) { - return ArsMagicaAPI.get().getSpellHelper().invoke(spell, caster, level, new EntityHitResult(caster), ticksUsed, index, awardXp); + return ArsMagicaAPI.get().getSpellHelper().invoke(spell, caster, null, level, new EntityHitResult(caster), ticksUsed, index, awardXp); } @Override diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Self.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Self.java index e98699b77..b3ef934f7 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Self.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Self.java @@ -15,7 +15,7 @@ public class Self extends AbstractShape { @Override public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, @Nullable HitResult target, int ticksUsed, int index, boolean awardXp) { - return ArsMagicaAPI.get().getSpellHelper().invoke(spell, caster, level, new EntityHitResult(caster), ticksUsed, index, awardXp); + return ArsMagicaAPI.get().getSpellHelper().invoke(spell, caster, null, level, new EntityHitResult(caster), ticksUsed, index, awardXp); } @Override diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Touch.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Touch.java index 36c4a6762..70b2e3375 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Touch.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/shape/Touch.java @@ -20,7 +20,7 @@ public Touch() { @Override public SpellCastResult invoke(ISpell spell, LivingEntity caster, Level level, List modifiers, @Nullable HitResult hit, int ticksUsed, int index, boolean awardXp) { var helper = ArsMagicaAPI.get().getSpellHelper(); - return helper.invoke(spell, caster, level, helper.trace(caster, level, helper.getModifiedStat(2.5f, SpellPartStats.RANGE, modifiers, spell, caster, hit, index), true, helper.getModifiedStat(0, SpellPartStats.TARGET_NON_SOLID, modifiers, spell, caster, hit, index) > 0), ticksUsed, index, awardXp); + return helper.invoke(spell, caster, null, level, helper.trace(caster, level, helper.getModifiedStat(2.5f, SpellPartStats.RANGE, modifiers, spell, caster, hit, index), true, helper.getModifiedStat(0, SpellPartStats.TARGET_NON_SOLID, modifiers, spell, caster, hit, index) > 0), ticksUsed, index, awardXp); } @Override From afd29a1fc408a2f0d6298e882e4d96188ded1743 Mon Sep 17 00:00:00 2001 From: IchHabeHunger54 Date: Sat, 1 Jun 2024 18:19:44 +0200 Subject: [PATCH 05/11] port #453 --- .../arsmagicalegacy/data/AMPatchouliBookProvider.java | 4 ++-- .../arsmagicalegacy/data/AMRitualProvider.java | 6 +++--- .../arsmagicalegacy/common/init/AMBlocks.java | 2 ++ .../arsmagicalegacy/common/spell/component/Light.java | 3 ++- .../arsmagicalegacy/test/SkillLearnRitualTest.java | 6 +++--- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMPatchouliBookProvider.java b/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMPatchouliBookProvider.java index 2e0b7bba3..6d5c63877 100644 --- a/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMPatchouliBookProvider.java +++ b/src/data/java/com/github/minecraftschurlimods/arsmagicalegacy/data/AMPatchouliBookProvider.java @@ -105,7 +105,7 @@ protected void addBooks(HolderLookup.Provider provider, Consumer BLACK_AUREM = BLOCKS.register("black_aurem", BlackAuremBlock::new); DeferredBlock WIZARDS_CHALK = BLOCKS.register("wizards_chalk", WizardsChalkBlock::new); DeferredBlock SPELL_RUNE = BLOCKS.register("spell_rune", SpellRuneBlock::new); + DeferredBlock SPELL_LIGHT = BLOCKS.register("spell_light", () -> new AirBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.AIR).lightLevel($ -> 15))); DeferredBlock CHIMERITE_ORE = BLOCKS.registerSimpleBlock("chimerite_ore", BlockBehaviour.Properties.of().requiresCorrectToolForDrops().strength(3F, 3F)); DeferredBlock DEEPSLATE_CHIMERITE_ORE = BLOCKS.registerSimpleBlock("deepslate_chimerite_ore", BlockBehaviour.Properties.of().mapColor(MapColor.DEEPSLATE).requiresCorrectToolForDrops().strength(4.5F, 3F).sound(SoundType.DEEPSLATE)); DeferredBlock CHIMERITE_BLOCK = BLOCKS.registerSimpleBlock("chimerite_block", BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_PINK).requiresCorrectToolForDrops().strength(3F, 3F)); diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Light.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Light.java index e100b6da5..7dcda344b 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Light.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/spell/component/Light.java @@ -3,6 +3,7 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpell; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.ISpellModifier; import com.github.minecraftschurlimods.arsmagicalegacy.api.spell.SpellCastResult; +import com.github.minecraftschurlimods.arsmagicalegacy.common.init.AMBlocks; import com.github.minecraftschurlimods.arsmagicalegacy.common.init.AMMobEffects; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -26,7 +27,7 @@ public SpellCastResult invoke(ISpell spell, LivingEntity caster, @Nullable Entit Direction direction = target.getDirection(); BlockPos pos = target.getBlockPos().offset(direction.getStepX(), direction.getStepY(), direction.getStepZ()); if (level.getBlockState(pos).isAir()) { - level.setBlock(pos, Blocks.LIGHT.defaultBlockState(), Block.UPDATE_ALL); + level.setBlock(pos, AMBlocks.SPELL_LIGHT.get().defaultBlockState(), Block.UPDATE_ALL); return SpellCastResult.SUCCESS; } return SpellCastResult.EFFECT_FAILED; diff --git a/src/test/java/com/github/minecraftschurlimods/arsmagicalegacy/test/SkillLearnRitualTest.java b/src/test/java/com/github/minecraftschurlimods/arsmagicalegacy/test/SkillLearnRitualTest.java index 4bfcfc62c..8d0bd16b7 100644 --- a/src/test/java/com/github/minecraftschurlimods/arsmagicalegacy/test/SkillLearnRitualTest.java +++ b/src/test/java/com/github/minecraftschurlimods/arsmagicalegacy/test/SkillLearnRitualTest.java @@ -30,7 +30,7 @@ private static void test(ExtendedGameTestHelper helper, ResourceLocation skill, @EmptyTemplate @TestHolder(description = "Test that blizzard unlocks when casting the required unlock spell") public static void testUnlockBlizzard(ExtendedGameTestHelper helper) { - test(helper, AMSpellParts.BLIZZARD.getId(), AMSpellParts.SELF.get(), AMSpellParts.FROST_DAMAGE.get(), AMSpellParts.DAMAGE.get(), AMSpellParts.FROST.get(), AMSpellParts.STORM.get()); + test(helper, AMSpellParts.BLIZZARD.getId(), AMSpellParts.SELF.get(), AMSpellParts.FROST_DAMAGE.get(), AMSpellParts.FROST.get(), AMSpellParts.STORM.get()); } @GameTest @@ -44,7 +44,7 @@ public static void testUnlockDaylight(ExtendedGameTestHelper helper) { @EmptyTemplate @TestHolder(description = "Test that dismembering unlocks when casting the required unlock spell") public static void testUnlockDismembering(ExtendedGameTestHelper helper) { - test(helper, AMSpellParts.DISMEMBERING.getId(), AMSpellParts.SELF.get(), AMSpellParts.PHYSICAL_DAMAGE.get(), AMSpellParts.DAMAGE.get(), AMSpellParts.PIERCING.get()); + test(helper, AMSpellParts.DISMEMBERING.getId(), AMSpellParts.SELF.get(), AMSpellParts.PHYSICAL_DAMAGE.get(), AMSpellParts.DAMAGE.get(), AMSpellParts.HEALING.get(), AMSpellParts.PIERCING.get()); } @GameTest @@ -58,7 +58,7 @@ public static void testUnlockEffectPower(ExtendedGameTestHelper helper) { @EmptyTemplate @TestHolder(description = "Test that falling star unlocks when casting the required unlock spell") public static void testUnlockFallingStar(ExtendedGameTestHelper helper) { - test(helper, AMSpellParts.FALLING_STAR.getId(), AMSpellParts.SELF.get(), AMSpellParts.ASTRAL_DISTORTION.get(), AMSpellParts.MAGIC_DAMAGE.get(), AMSpellParts.SOLAR.get()); + test(helper, AMSpellParts.FALLING_STAR.getId(), AMSpellParts.SELF.get(), AMSpellParts.ASTRAL_DISTORTION.get(), AMSpellParts.MAGIC_DAMAGE.get(), AMSpellParts.GRAVITY.get()); } @GameTest From 546790a44dd25c63ce716f64744b6de4450f2f39 Mon Sep 17 00:00:00 2001 From: IchHabeHunger54 Date: Sat, 1 Jun 2024 18:23:59 +0200 Subject: [PATCH 06/11] port #454 --- .../common/handler/EventHandler.java | 96 ++++++++++++------- 1 file changed, 60 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/handler/EventHandler.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/handler/EventHandler.java index 91141c0f1..96cebb473 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/handler/EventHandler.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/handler/EventHandler.java @@ -171,33 +171,36 @@ private static CreativeModeTab buildMainCreativeTab() { .withTabsAfter(ArsMagicaAPI.PREFAB_SPELLS_CREATIVE_TAB) .icon(() -> ArsMagicaAPI.get().getBookStack()) .title(Component.translatable(TranslationConstants.MAIN_CREATIVE_TAB)) - .displayItems((params, output) -> { - List list = new ArrayList<>(); - var api = ArsMagicaAPI.get(); - for (DeferredHolder o : AMRegistries.ITEMS.getEntries()) { - if (!o.isBound()) continue; - Item item = o.get(); - if (item instanceof ISkillPointItem skillPointItem) { - for (SkillPoint point : api.getSkillPointRegistry()) { - if (point != AMSkillPoints.NONE.value()) { - list.add(skillPointItem.setSkillPoint(new ItemStack(item), point)); - } - } - continue; - } - if (item instanceof IAffinityItem affinityItem) { - for (Affinity affinity : api.getAffinityRegistry()) { - if (Affinity.NONE.equals(affinity.getId())) continue; - list.add(affinityItem.setAffinity(new ItemStack(item), affinity)); - } - continue; - } - if (!AMItems.HIDDEN_ITEMS.contains(o)) { - list.add(new ItemStack(item)); - } + .displayItems(EventHandler::fillMainCreativeTab) + .build(); + } + + private static void fillMainCreativeTab(CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) { + List list = new ArrayList<>(); + var api = ArsMagicaAPI.get(); + for (DeferredHolder o : AMRegistries.ITEMS.getEntries()) { + if (!o.isBound()) continue; + Item item = o.get(); + if (item instanceof ISkillPointItem skillPointItem) { + for (SkillPoint point : api.getSkillPointRegistry()) { + if (point != AMSkillPoints.NONE.value()) { + list.add(skillPointItem.setSkillPoint(new ItemStack(item), point)); } - output.acceptAll(list); - }).build(); + } + continue; + } + if (item instanceof IAffinityItem affinityItem) { + for (Affinity affinity : api.getAffinityRegistry()) { + if (Affinity.NONE.equals(affinity.getId())) continue; + list.add(affinityItem.setAffinity(new ItemStack(item), affinity)); + } + continue; + } + if (!AMItems.HIDDEN_ITEMS.contains(o)) { + list.add(new ItemStack(item)); + } + } + output.acceptAll(list); } private static CreativeModeTab buildPrefabSpellsCreativeTab() { @@ -206,10 +209,14 @@ private static CreativeModeTab buildPrefabSpellsCreativeTab() { .withTabsBefore(ArsMagicaAPI.MAIN_CREATIVE_TAB) .icon(() -> AMItems.SPELL_PARCHMENT.asOptional().map(ItemStack::new).orElse(ItemStack.EMPTY)) .title(Component.translatable(TranslationConstants.PREFAB_SPELL_CREATIVE_TAB)) - .displayItems((params, output) -> AMUtil.getRegistry(PrefabSpell.REGISTRY_KEY).stream().map(PrefabSpell::makeSpell).forEach(output::accept)) + .displayItems(EventHandler::fillPrefabSpellsCreativeTab) .build(); } + private static void fillPrefabSpellsCreativeTab(CreativeModeTab.ItemDisplayParameters params, CreativeModeTab.Output output) { + AMUtil.getRegistry(PrefabSpell.REGISTRY_KEY).stream().map(PrefabSpell::makeSpell).forEach(output::accept); + } + private static void registerSpawnPlacements(SpawnPlacementRegisterEvent evt) { evt.register(AMEntities.DRYAD.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Dryad::checkDryadSpawnRules, SpawnPlacementRegisterEvent.Operation.AND); evt.register(AMEntities.MANA_CREEPER.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, Monster::checkMonsterSpawnRules, SpawnPlacementRegisterEvent.Operation.AND); @@ -308,9 +315,26 @@ private static void playerItemCrafted(PlayerEvent.ItemCraftedEvent event) { } private static void playerRespawn(PlayerEvent.PlayerRespawnEvent event) { - AttributeInstance maxManaAttr = event.getEntity().getAttribute(AMAttributes.MAX_MANA.value()); + var api = ArsMagicaAPI.get(); + Player player = event.getEntity(); + int magicLevel = api.getMagicHelper().getLevel(player); + float newMaxMana = Config.SERVER.MANA_BASE.get().floatValue() + Config.SERVER.MANA_MULTIPLIER.get().floatValue() * (magicLevel - 1); + AttributeInstance maxManaAttr = player.getAttribute(AMAttributes.MAX_MANA.value()); if (maxManaAttr != null) { - ArsMagicaAPI.get().getManaHelper().increaseMana(event.getEntity(), (float) (maxManaAttr.getBaseValue() / 2)); + maxManaAttr.setBaseValue(newMaxMana); + api.getManaHelper().increaseMana(player, (float) (maxManaAttr.getBaseValue() / 2)); + } + AttributeInstance manaRegenAttr = player.getAttribute(AMAttributes.MANA_REGEN.value()); + if (manaRegenAttr != null) { + manaRegenAttr.setBaseValue(newMaxMana * Config.SERVER.MANA_REGEN_MULTIPLIER.get()); + } + AttributeInstance maxBurnoutAttr = player.getAttribute(AMAttributes.MAX_BURNOUT.value()); + if (maxBurnoutAttr != null) { + maxBurnoutAttr.setBaseValue(Config.SERVER.BURNOUT_BASE.get().floatValue() + Config.SERVER.BURNOUT_MULTIPLIER.get().floatValue() * (magicLevel - 1)); + } + AttributeInstance burnoutRegenAttr = player.getAttribute(AMAttributes.BURNOUT_REGEN.value()); + if (burnoutRegenAttr != null) { + burnoutRegenAttr.setBaseValue(newMaxMana * Config.SERVER.BURNOUT_REGEN_MULTIPLIER.get()); } } @@ -339,14 +363,14 @@ private static void rightClickBlock(PlayerInteractEvent.RightClickBlock event) { if (!(stack.getItem() instanceof SpellRecipeItem)) return; if (player.isSecondaryUseActive()) { SpellRecipeItem.takeFromLectern(player, level, pos, state); - } else { - lectern.pageCount = SpellRecipeItem.getPageCount(stack); - if (player instanceof ServerPlayer sp) { - PacketDistributor.PLAYER.with(sp).send(new OpenSpellRecipeGuiInLecternPacket(stack, pos, lectern.getPage())); - } - player.awardStat(Stats.INTERACT_WITH_LECTERN); - event.setCanceled(true); + return; + } + lectern.pageCount = SpellRecipeItem.getPageCount(stack); + if (player instanceof ServerPlayer sp) { + PacketDistributor.PLAYER.with(sp).send(new OpenSpellRecipeGuiInLecternPacket(stack, pos, lectern.getPage())); } + player.awardStat(Stats.INTERACT_WITH_LECTERN); + event.setCanceled(true); } private static void affinityChangingPre(AffinityChangingEvent.Pre event) { From a7e06f2f864336d3c615730846a48b5a3c2e4a7e Mon Sep 17 00:00:00 2001 From: Minecraftschurli Date: Sat, 1 Jun 2024 12:53:36 +0200 Subject: [PATCH 07/11] bump gradle stuff --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 510e4efae..d951fac2b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From d7e4132377a33c58320e8961887ebfa266bd4756 Mon Sep 17 00:00:00 2001 From: Minecraftschurli Date: Mon, 8 Jul 2024 22:28:32 +0200 Subject: [PATCH 08/11] fix gradle setup --- build.gradle.kts | 5 +++++ settings.gradle.kts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5bcd239f6..6f108f8df 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -150,15 +150,20 @@ dependencies { jarJar(codeclib) "apiCompileOnly"(codeclib) implementation(codeclib) + "dataImplementation"(codeclib) testImplementation(codeclib) val betterkeybindlib = project.localGradleProperty("dependency.betterkeybindlib.version").map { "com.github.minecraftschurlimods:betterkeybindlib:$it" } jarJar(betterkeybindlib) implementation(betterkeybindlib) + "dataImplementation"(betterkeybindlib) + testImplementation(betterkeybindlib) val betterhudlib = project.localGradleProperty("dependency.betterhudlib.version").map { "com.github.minecraftschurlimods:betterhudlib:$it" } jarJar(betterhudlib) implementation(betterhudlib) + "dataImplementation"(betterhudlib) + testImplementation(betterhudlib) val easyDatagenLibVersion = project.localGradleProperty("dependency.easydatagenlib.version") val easyDatagenLibApiDep = easyDatagenLibVersion.map { "com.github.minecraftschurlimods:easydatagenlib:${it}:api" } diff --git a/settings.gradle.kts b/settings.gradle.kts index e4421eebc..b756075fc 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,7 +1,7 @@ pluginManagement { plugins { - id("net.neoforged.gradle.userdev") version "7.0.137" - id("com.github.minecraftschurlimods.helperplugin") version "1.13" + id("net.neoforged.gradle.userdev") version "7.0.142" + id("com.github.minecraftschurlimods.helperplugin") version "1.14" } repositories { mavenLocal() From d612ca5473ebb12faa558c2d296ab7ef060d0409 Mon Sep 17 00:00:00 2001 From: Minecraftschurli Date: Mon, 8 Jul 2024 22:29:35 +0200 Subject: [PATCH 09/11] run datagen --- .../83c470eb0163363e09250d5117f0d60a576c4c0f | 14 ++++++++++- .../ff85aeffff7b400453d938ac4326ddfe68257a73 | 15 ++++++++---- .../assets/arsmagicalegacy/lang/en_us.json | 24 +++++++++++++++++-- .../ritual/unlock_blizzard.json | 4 +--- .../ritual/unlock_dismembering.json | 1 + .../ritual/unlock_falling_star.json | 2 +- .../damage_type/spell_drowning.json | 6 +++++ .../damage_type/spell_fire.json | 6 +++++ .../damage_type/spell_frost.json | 6 +++++ .../damage_type/spell_lightning.json | 5 ++++ .../damage_type/spell_magic.json | 5 ++++ .../damage_type/spell_physical.json | 5 ++++ .../damage_type/spell_physical_player.json | 5 ++++ .../tags/damage_type/spell.json | 11 +++++++++ .../always_triggers_silverfish.json | 5 ++++ .../damage_type/avoids_guardian_thorns.json | 5 ++++ .../tags/damage_type/bypasses_armor.json | 7 ++++++ .../damage_type/bypasses_invulnerability.json | 5 ++++ .../damage_type/ignites_armor_stands.json | 5 ++++ .../tags/damage_type/is_drowning.json | 5 ++++ .../minecraft/tags/damage_type/is_fire.json | 5 ++++ .../tags/damage_type/is_freezing.json | 5 ++++ .../tags/damage_type/is_lightning.json | 5 ++++ .../tags/damage_type/witch_resistant_to.json | 5 ++++ .../tags/damage_type/wither_immune_to.json | 5 ++++ 25 files changed, 155 insertions(+), 11 deletions(-) create mode 100644 src/main/generated/data/arsmagicalegacy/damage_type/spell_drowning.json create mode 100644 src/main/generated/data/arsmagicalegacy/damage_type/spell_fire.json create mode 100644 src/main/generated/data/arsmagicalegacy/damage_type/spell_frost.json create mode 100644 src/main/generated/data/arsmagicalegacy/damage_type/spell_lightning.json create mode 100644 src/main/generated/data/arsmagicalegacy/damage_type/spell_magic.json create mode 100644 src/main/generated/data/arsmagicalegacy/damage_type/spell_physical.json create mode 100644 src/main/generated/data/arsmagicalegacy/damage_type/spell_physical_player.json create mode 100644 src/main/generated/data/arsmagicalegacy/tags/damage_type/spell.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/always_triggers_silverfish.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/avoids_guardian_thorns.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/bypasses_armor.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/bypasses_invulnerability.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/ignites_armor_stands.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/is_drowning.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/is_fire.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/is_freezing.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/is_lightning.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/witch_resistant_to.json create mode 100644 src/main/generated/data/minecraft/tags/damage_type/wither_immune_to.json diff --git a/src/main/generated/.cache/83c470eb0163363e09250d5117f0d60a576c4c0f b/src/main/generated/.cache/83c470eb0163363e09250d5117f0d60a576c4c0f index eb67068c9..eed89b307 100644 --- a/src/main/generated/.cache/83c470eb0163363e09250d5117f0d60a576c4c0f +++ b/src/main/generated/.cache/83c470eb0163363e09250d5117f0d60a576c4c0f @@ -1,2 +1,14 @@ -// 1.20.4 2024-03-07T11:37:55.0448681 vanilla/Tags for minecraft:damage_type mod id arsmagicalegacy +// 1.20.4 2024-07-08T21:48:24.0933596 vanilla/Tags for minecraft:damage_type mod id arsmagicalegacy +07f784f7ed5b3ad0ddec7569015692dfd549d762 data/arsmagicalegacy/tags/damage_type/spell.json +240062c9a629d99c93ed89e53ddc1f0cb649805a data/minecraft/tags/damage_type/always_triggers_silverfish.json +240062c9a629d99c93ed89e53ddc1f0cb649805a data/minecraft/tags/damage_type/avoids_guardian_thorns.json +ea013487020b7d759a4366c808bd3b59b68b2764 data/minecraft/tags/damage_type/bypasses_armor.json +d49cb911fbcd1e5c6723ebf4997c48387dde9c7e data/minecraft/tags/damage_type/bypasses_invulnerability.json +e1c6c75429e4c46d7a5a9cc1d1df45f7418a5ed6 data/minecraft/tags/damage_type/ignites_armor_stands.json +5a75079830398a48509c802d48817593eefb09b5 data/minecraft/tags/damage_type/is_drowning.json +e1c6c75429e4c46d7a5a9cc1d1df45f7418a5ed6 data/minecraft/tags/damage_type/is_fire.json +ab5b80074e5908727f795fb164cc46b6a034d929 data/minecraft/tags/damage_type/is_freezing.json +4768e884132e773068f6c84945efc08f32a71bc6 data/minecraft/tags/damage_type/is_lightning.json 187ec63cb4213044f3e304b75a6c55f7ed5d2968 data/minecraft/tags/damage_type/is_projectile.json +240062c9a629d99c93ed89e53ddc1f0cb649805a data/minecraft/tags/damage_type/witch_resistant_to.json +5a75079830398a48509c802d48817593eefb09b5 data/minecraft/tags/damage_type/wither_immune_to.json diff --git a/src/main/generated/.cache/ff85aeffff7b400453d938ac4326ddfe68257a73 b/src/main/generated/.cache/ff85aeffff7b400453d938ac4326ddfe68257a73 index 687bdac05..82c44ea73 100644 --- a/src/main/generated/.cache/ff85aeffff7b400453d938ac4326ddfe68257a73 +++ b/src/main/generated/.cache/ff85aeffff7b400453d938ac4326ddfe68257a73 @@ -1,4 +1,4 @@ -// 1.20.4 2024-03-07T12:00:28.6713589 vanilla/Registries +// 1.20.4 2024-07-08T21:48:24.0770467 vanilla/Registries 0095c886f52658495198001f9b2f2d21f136e31f data/arsmagicalegacy/arsmagicalegacy/ability/clarity.json bee1556fd07899fd3833f2c63bef87a6e5154952 data/arsmagicalegacy/arsmagicalegacy/ability/enderman_pumpkin.json 8ee324f913eb2d6d7ec07a77c88c1dbb4a272eee data/arsmagicalegacy/arsmagicalegacy/ability/enderman_thorns.json @@ -149,11 +149,11 @@ d5d016553f87404b0595ccb6d060a289039866c6 data/arsmagicalegacy/arsmagicalegacy/ri b9303f24d0f09c8aa1c4456a6b3a79af5aa03361 data/arsmagicalegacy/arsmagicalegacy/ritual/spawn_life_guardian.json 3e7b92796a67e17086ec8bf5da6f6bb0b4b7913d data/arsmagicalegacy/arsmagicalegacy/ritual/spawn_lightning_guardian.json e407d88f882d2b2859d95e3951e1e1073e4af148 data/arsmagicalegacy/arsmagicalegacy/ritual/spawn_water_guardian.json -e2562c91e54515ac19c4e552d50b0a10bca9ea04 data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_blizzard.json +f178a48c72dee27abf6e2f032580ac316547fb57 data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_blizzard.json 736522e9c463f8854c74f5f64d433107bf505cad data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_daylight.json -12cf7ea08b21964c22c4033ea020203755573c24 data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_dismembering.json +2ac7ba4d65cdf38b3d1cef446a42017404c67d49 data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_dismembering.json 6a5a620bfeb6de02024e9911b3c3aa0fa70c30b8 data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_effect_power.json -85dc9fb66ddd43dc9aaf5503e0d536044614bc86 data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_falling_star.json +28acdd52eafbbca390bf18b999b871f9f45841f8 data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_falling_star.json a301a518a3224b20b9d2a1b39d92ef7e21fea58c data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_fire_rain.json fb75ecee90337e1ee9bc84f0106c47a15124759a data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_health_boost.json 7f9d3e55b46c0ec413541d1583a29d89e98040fa data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_mana_blast.json @@ -293,6 +293,13 @@ aa993fa48a16571e85f04bee7f314c03328b0e50 data/arsmagicalegacy/arsmagicalegacy/sp 60914d37b9f545120c6d8d74876c540ba543c424 data/arsmagicalegacy/damage_type/falling_star.json 7677bb8d9ae68cd7763fbbc4fde8a9313ded2b25 data/arsmagicalegacy/damage_type/nature_scythe.json 6e4af12b960c6dba10f30174c33635391bf97841 data/arsmagicalegacy/damage_type/shockwave.json +4c7f16d77ddf9ff466785fff80264b0fe7be17fb data/arsmagicalegacy/damage_type/spell_drowning.json +a130a3a2bf518d4166380a6ef919014ff05d4795 data/arsmagicalegacy/damage_type/spell_fire.json +00dcb67b5cd8ccb3f0bf5eb3f1cceba728fb631e data/arsmagicalegacy/damage_type/spell_frost.json +aa20b85097749b4cbf28ebfade04c28a3edc6f5e data/arsmagicalegacy/damage_type/spell_lightning.json +f5fcdab1a21b2f34da2fd2653821587061f9f8e9 data/arsmagicalegacy/damage_type/spell_magic.json +25d924fdac4392adb88fe3b6aa2c23420f6fb4f9 data/arsmagicalegacy/damage_type/spell_physical.json +4b4b2ff422d23e4cb6282f664d89dad7ac8ff8e6 data/arsmagicalegacy/damage_type/spell_physical_player.json 1e71e7d6c3b4bf6cf12bcd570d4e2fa0e8f86c2a data/arsmagicalegacy/damage_type/thrown_rock.json 77244346686aae80786e8b128144b3a80c3f889d data/arsmagicalegacy/damage_type/wind.json 18732db843a4e47cde2219521eb81c0e558695f4 data/arsmagicalegacy/neoforge/biome_modifier/aum.json diff --git a/src/main/generated/assets/arsmagicalegacy/lang/en_us.json b/src/main/generated/assets/arsmagicalegacy/lang/en_us.json index b7b325c77..1985edae0 100644 --- a/src/main/generated/assets/arsmagicalegacy/lang/en_us.json +++ b/src/main/generated/assets/arsmagicalegacy/lang/en_us.json @@ -173,7 +173,11 @@ "config.arsmagicalegacy.burnout.base": "The base value for burnout calculation. Burnout is calculated as base + multiplier * (level - 1).", "config.arsmagicalegacy.burnout.multiplier": "The multiplier for burnout calculation. Burnout is calculated as base + multiplier * (level - 1).", "config.arsmagicalegacy.burnout.regen_multiplier": "The multiplier for burnout regeneration. Burnout regen is calculated as (base + multiplier * (level - 1)) * regen_multiplier.", + "config.arsmagicalegacy.burnout_anchor_x": "Horizontal anchor of the burnout bar.", + "config.arsmagicalegacy.burnout_anchor_y": "Vertical anchor of the burnout bar.", "config.arsmagicalegacy.burnout_ratio": "The default mana to burnout ratio, used in calculating spell costs.", + "config.arsmagicalegacy.burnout_x": "Horizontal position of the burnout bar.", + "config.arsmagicalegacy.burnout_y": "Vertical position of the burnout bar.", "config.arsmagicalegacy.crafting_altar_check_time": "The time in ticks between multiblock validation checks for the crafting altar.", "config.arsmagicalegacy.enable_inscription_table_in_world_upgrading": "Whether inscription table upgrading is allowed in-world. If disabled, the upgrades must be applied through crafting.", "config.arsmagicalegacy.entities.dryad.bonemeal_chance": "The chance of bonemeal being applied.", @@ -187,10 +191,26 @@ "config.arsmagicalegacy.mana.base": "The base value for mana calculation. Mana is calculated as base + multiplier * (level - 1).", "config.arsmagicalegacy.mana.multiplier": "The multiplier for mana calculation. Mana is calculated as base + multiplier * (level - 1).", "config.arsmagicalegacy.mana.regen_multiplier": "The multiplier for mana regeneration. Mana regen is calculated as (base + multiplier * (level - 1)) * regen_multiplier.", + "config.arsmagicalegacy.mana_anchor_x": "Horizontal anchor of the mana bar.", + "config.arsmagicalegacy.mana_anchor_y": "Vertical anchor of the mana bar.", + "config.arsmagicalegacy.mana_x": "Horizontal position of the mana bar.", + "config.arsmagicalegacy.mana_y": "Vertical position of the mana bar.", "config.arsmagicalegacy.max_etherium_storage": "The maximum amount of etherium that can be stored in an obelisk / celestial prism / black aurem.", "config.arsmagicalegacy.require_compendium_crafting": "Whether the player needs to craft the compendium before being able to use magic. If disabled, the player can use magic from the beginning.", + "config.arsmagicalegacy.shape_group_anchor_x": "Horizontal anchor of the shape group hud.", + "config.arsmagicalegacy.shape_group_anchor_y": "Vertical anchor of the shape group hud.", + "config.arsmagicalegacy.shape_group_x": "Horizontal position of the shape group hud.", + "config.arsmagicalegacy.shape_group_y": "Vertical position of the shape group hud.", + "config.arsmagicalegacy.spell_book_anchor_x": "Horizontal anchor of the spell book hud.", + "config.arsmagicalegacy.spell_book_anchor_y": "Vertical anchor of the spell book hud.", + "config.arsmagicalegacy.spell_book_x": "Horizontal position of the spell book hud.", + "config.arsmagicalegacy.spell_book_y": "Vertical position of the spell book hud.", "config.arsmagicalegacy.spell_parts.damage": "Damage of damage-based components, in half hearts.", "config.arsmagicalegacy.spell_parts.duration": "Duration of effect-based components, in ticks.", + "config.arsmagicalegacy.xp_anchor_x": "Horizontal anchor of the magic xp bar.", + "config.arsmagicalegacy.xp_anchor_y": "Vertical anchor of the magic xp bar.", + "config.arsmagicalegacy.xp_x": "Horizontal position of the magic xp bar.", + "config.arsmagicalegacy.xp_y": "Vertical position of the magic xp bar.", "config.jade.plugin_arsmagicalegacy.altar": "Altar", "config.jade.plugin_arsmagicalegacy.etherium": "Etherium", "death.attack.falling_star": "%1$s was obliterated by a falling star", @@ -296,7 +316,7 @@ "item.arsmagicalegacy.arcane_compendium.blocks.black_aurem.name": "Black Aurem", "item.arsmagicalegacy.arcane_compendium.blocks.black_aurem.page0.text": "The Black Aurem is the $(l:blocks/obelisk)Obelisk's$() dark counterpart, used to generate dark $(l:mechanics/etherium)Etherium$(). Instead of $(l:blocks/ores#vinteum)vinteum$(), it consumes the lifes of animals.$(br2)Similarly, it can be supported by a multiblock structure, which builds up in levels. The structure's different levels are shown on the later pages.", "item.arsmagicalegacy.arcane_compendium.blocks.black_aurem.page1.text": "The Black Aurem cannot be obtained through crafting. Instead, it must be created through a special corruption ritual. This ritual requires a multiblock structure, seen on the next page. Once built, throw a piece of $(l:blocks/ores#sunstone)Sunstone$() somewhere into the structure.", - "item.arsmagicalegacy.arcane_compendium.blocks.black_aurem.page2.text": "Finally, to initiate the ritual, you must $(l:components/fire_damage)severely burn$() the Obelisk.", + "item.arsmagicalegacy.arcane_compendium.blocks.black_aurem.page2.text": "Finally, to initiate the ritual, you must $(l:components/fire_damage)severely burn$() the bottom of the Obelisk.", "item.arsmagicalegacy.arcane_compendium.blocks.black_aurem.page2.title": "Corruption Ritual", "item.arsmagicalegacy.arcane_compendium.blocks.black_aurem.page3.title": "Black Aurem Chalk", "item.arsmagicalegacy.arcane_compendium.blocks.black_aurem.page4.title": "Black Aurem Level 1", @@ -306,7 +326,7 @@ "item.arsmagicalegacy.arcane_compendium.blocks.celestial_prism.name": "Celestial Prism", "item.arsmagicalegacy.arcane_compendium.blocks.celestial_prism.page0.text": "The Celestial Prism is the $(l:blocks/obelisk)Obelisk's$() light counterpart, used to generate light $(l:mechanics/etherium)Etherium$(). Instead of $(l:blocks/ores#vinteum)vinteum$(), it utilizes the sun's power.$(br2)Similarly, it can be supported by a multiblock structure, which builds up in levels. The structure's different levels are shown on the later pages.", "item.arsmagicalegacy.arcane_compendium.blocks.celestial_prism.page1.text": "The Celestial Prism cannot be obtained through crafting. Instead, it must be created through a special purification ritual. This ritual requires a multiblock structure, seen on the next page. Once built, throw a piece of $(l:blocks/ores#moonstone)Moonstone$() somewhere into the structure.", - "item.arsmagicalegacy.arcane_compendium.blocks.celestial_prism.page2.text": "Finally, to initiate the ritual, simply place some $(l:components/light)light$() on the Obelisk.", + "item.arsmagicalegacy.arcane_compendium.blocks.celestial_prism.page2.text": "Finally, to initiate the ritual, simply place some $(l:components/light)light$() on the bottom of the Obelisk.", "item.arsmagicalegacy.arcane_compendium.blocks.celestial_prism.page2.title": "Purification Ritual", "item.arsmagicalegacy.arcane_compendium.blocks.celestial_prism.page3.title": "Celestial Prism Chalk", "item.arsmagicalegacy.arcane_compendium.blocks.celestial_prism.page4.title": "Celestial Prism Level 1", diff --git a/src/main/generated/data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_blizzard.json b/src/main/generated/data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_blizzard.json index 7cae902e3..d9b90a01e 100644 --- a/src/main/generated/data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_blizzard.json +++ b/src/main/generated/data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_blizzard.json @@ -11,8 +11,6 @@ "arsmagicalegacy:frost", "arsmagicalegacy:storm" ], - "modifiers": [ - "arsmagicalegacy:damage" - ] + "modifiers": [] } } \ No newline at end of file diff --git a/src/main/generated/data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_dismembering.json b/src/main/generated/data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_dismembering.json index b313ce3e2..5f8faf36e 100644 --- a/src/main/generated/data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_dismembering.json +++ b/src/main/generated/data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_dismembering.json @@ -11,6 +11,7 @@ ], "modifiers": [ "arsmagicalegacy:damage", + "arsmagicalegacy:healing", "arsmagicalegacy:piercing" ] } diff --git a/src/main/generated/data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_falling_star.json b/src/main/generated/data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_falling_star.json index 9d38726b9..66a600ad9 100644 --- a/src/main/generated/data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_falling_star.json +++ b/src/main/generated/data/arsmagicalegacy/arsmagicalegacy/ritual/unlock_falling_star.json @@ -11,7 +11,7 @@ "arsmagicalegacy:magic_damage" ], "modifiers": [ - "arsmagicalegacy:solar" + "arsmagicalegacy:gravity" ] } } \ No newline at end of file diff --git a/src/main/generated/data/arsmagicalegacy/damage_type/spell_drowning.json b/src/main/generated/data/arsmagicalegacy/damage_type/spell_drowning.json new file mode 100644 index 000000000..5d1d3ef64 --- /dev/null +++ b/src/main/generated/data/arsmagicalegacy/damage_type/spell_drowning.json @@ -0,0 +1,6 @@ +{ + "effects": "drowning", + "exhaustion": 0.0, + "message_id": "drown", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/src/main/generated/data/arsmagicalegacy/damage_type/spell_fire.json b/src/main/generated/data/arsmagicalegacy/damage_type/spell_fire.json new file mode 100644 index 000000000..53255eed1 --- /dev/null +++ b/src/main/generated/data/arsmagicalegacy/damage_type/spell_fire.json @@ -0,0 +1,6 @@ +{ + "effects": "burning", + "exhaustion": 0.1, + "message_id": "inFire", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/src/main/generated/data/arsmagicalegacy/damage_type/spell_frost.json b/src/main/generated/data/arsmagicalegacy/damage_type/spell_frost.json new file mode 100644 index 000000000..3d82b2584 --- /dev/null +++ b/src/main/generated/data/arsmagicalegacy/damage_type/spell_frost.json @@ -0,0 +1,6 @@ +{ + "effects": "freezing", + "exhaustion": 0.1, + "message_id": "freeze", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/src/main/generated/data/arsmagicalegacy/damage_type/spell_lightning.json b/src/main/generated/data/arsmagicalegacy/damage_type/spell_lightning.json new file mode 100644 index 000000000..6d302c833 --- /dev/null +++ b/src/main/generated/data/arsmagicalegacy/damage_type/spell_lightning.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0.1, + "message_id": "lightningBolt", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/src/main/generated/data/arsmagicalegacy/damage_type/spell_magic.json b/src/main/generated/data/arsmagicalegacy/damage_type/spell_magic.json new file mode 100644 index 000000000..ef634d5d9 --- /dev/null +++ b/src/main/generated/data/arsmagicalegacy/damage_type/spell_magic.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0.0, + "message_id": "magic", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/src/main/generated/data/arsmagicalegacy/damage_type/spell_physical.json b/src/main/generated/data/arsmagicalegacy/damage_type/spell_physical.json new file mode 100644 index 000000000..e77a1af08 --- /dev/null +++ b/src/main/generated/data/arsmagicalegacy/damage_type/spell_physical.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0.1, + "message_id": "mob", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/src/main/generated/data/arsmagicalegacy/damage_type/spell_physical_player.json b/src/main/generated/data/arsmagicalegacy/damage_type/spell_physical_player.json new file mode 100644 index 000000000..674995e14 --- /dev/null +++ b/src/main/generated/data/arsmagicalegacy/damage_type/spell_physical_player.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0.1, + "message_id": "player", + "scaling": "when_caused_by_living_non_player" +} \ No newline at end of file diff --git a/src/main/generated/data/arsmagicalegacy/tags/damage_type/spell.json b/src/main/generated/data/arsmagicalegacy/tags/damage_type/spell.json new file mode 100644 index 000000000..5cc589532 --- /dev/null +++ b/src/main/generated/data/arsmagicalegacy/tags/damage_type/spell.json @@ -0,0 +1,11 @@ +{ + "values": [ + "arsmagicalegacy:spell_drowning", + "arsmagicalegacy:spell_fire", + "arsmagicalegacy:spell_frost", + "arsmagicalegacy:spell_lightning", + "arsmagicalegacy:spell_magic", + "arsmagicalegacy:spell_physical", + "arsmagicalegacy:spell_physical_player" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/always_triggers_silverfish.json b/src/main/generated/data/minecraft/tags/damage_type/always_triggers_silverfish.json new file mode 100644 index 000000000..a73f55a6c --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/always_triggers_silverfish.json @@ -0,0 +1,5 @@ +{ + "values": [ + "arsmagicalegacy:spell_magic" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/avoids_guardian_thorns.json b/src/main/generated/data/minecraft/tags/damage_type/avoids_guardian_thorns.json new file mode 100644 index 000000000..a73f55a6c --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/avoids_guardian_thorns.json @@ -0,0 +1,5 @@ +{ + "values": [ + "arsmagicalegacy:spell_magic" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/bypasses_armor.json b/src/main/generated/data/minecraft/tags/damage_type/bypasses_armor.json new file mode 100644 index 000000000..6bc6317e0 --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/bypasses_armor.json @@ -0,0 +1,7 @@ +{ + "values": [ + "arsmagicalegacy:spell_drowning", + "arsmagicalegacy:spell_frost", + "arsmagicalegacy:spell_magic" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/bypasses_invulnerability.json b/src/main/generated/data/minecraft/tags/damage_type/bypasses_invulnerability.json new file mode 100644 index 000000000..df720cb60 --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/bypasses_invulnerability.json @@ -0,0 +1,5 @@ +{ + "values": [ + "#arsmagicalegacy:spell" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/ignites_armor_stands.json b/src/main/generated/data/minecraft/tags/damage_type/ignites_armor_stands.json new file mode 100644 index 000000000..107a10ddf --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/ignites_armor_stands.json @@ -0,0 +1,5 @@ +{ + "values": [ + "arsmagicalegacy:spell_fire" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/is_drowning.json b/src/main/generated/data/minecraft/tags/damage_type/is_drowning.json new file mode 100644 index 000000000..3cf3fe6d3 --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/is_drowning.json @@ -0,0 +1,5 @@ +{ + "values": [ + "arsmagicalegacy:spell_drowning" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/is_fire.json b/src/main/generated/data/minecraft/tags/damage_type/is_fire.json new file mode 100644 index 000000000..107a10ddf --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/is_fire.json @@ -0,0 +1,5 @@ +{ + "values": [ + "arsmagicalegacy:spell_fire" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/is_freezing.json b/src/main/generated/data/minecraft/tags/damage_type/is_freezing.json new file mode 100644 index 000000000..3d98e3313 --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/is_freezing.json @@ -0,0 +1,5 @@ +{ + "values": [ + "arsmagicalegacy:spell_frost" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/is_lightning.json b/src/main/generated/data/minecraft/tags/damage_type/is_lightning.json new file mode 100644 index 000000000..8b04b61c2 --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/is_lightning.json @@ -0,0 +1,5 @@ +{ + "values": [ + "arsmagicalegacy:spell_lightning" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/witch_resistant_to.json b/src/main/generated/data/minecraft/tags/damage_type/witch_resistant_to.json new file mode 100644 index 000000000..a73f55a6c --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/witch_resistant_to.json @@ -0,0 +1,5 @@ +{ + "values": [ + "arsmagicalegacy:spell_magic" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/damage_type/wither_immune_to.json b/src/main/generated/data/minecraft/tags/damage_type/wither_immune_to.json new file mode 100644 index 000000000..3cf3fe6d3 --- /dev/null +++ b/src/main/generated/data/minecraft/tags/damage_type/wither_immune_to.json @@ -0,0 +1,5 @@ +{ + "values": [ + "arsmagicalegacy:spell_drowning" + ] +} \ No newline at end of file From 7d008fd877fd4c709cb06b5bca2c96f234e1e46b Mon Sep 17 00:00:00 2001 From: Minecraftschurli Date: Sun, 28 Jul 2024 19:16:22 +0200 Subject: [PATCH 10/11] fix leveling not properly initiating --- .../api/event/PlayerLevelChangeEvent.java | 32 +++++++++++++++++++ .../api/event/PlayerLevelUpEvent.java | 23 ------------- .../api/magic/IMagicHelper.java | 7 ++++ .../common/handler/EventHandler.java | 28 ++++++++-------- .../common/magic/MagicHelper.java | 26 +++++++++------ 5 files changed, 71 insertions(+), 45 deletions(-) create mode 100644 src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/event/PlayerLevelChangeEvent.java delete mode 100644 src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/event/PlayerLevelUpEvent.java diff --git a/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/event/PlayerLevelChangeEvent.java b/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/event/PlayerLevelChangeEvent.java new file mode 100644 index 000000000..9b802a517 --- /dev/null +++ b/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/event/PlayerLevelChangeEvent.java @@ -0,0 +1,32 @@ +package com.github.minecraftschurlimods.arsmagicalegacy.api.event; + +import net.minecraft.world.entity.player.Player; +import net.neoforged.neoforge.event.entity.player.PlayerEvent; + +/** + * Event that fires when the player's magic level changes. + */ +public final class PlayerLevelChangeEvent extends PlayerEvent { + private final int level; + private final int oldLevel; + + public PlayerLevelChangeEvent(Player player, int level, int oldLevel) { + super(player); + this.level = level; + this.oldLevel = oldLevel; + } + + /** + * @return The new level of the player. + */ + public int getLevel() { + return level; + } + + /** + * @return The old level of the player. + */ + public int getOldLevel() { + return oldLevel; + } +} diff --git a/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/event/PlayerLevelUpEvent.java b/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/event/PlayerLevelUpEvent.java deleted file mode 100644 index acb8e5a31..000000000 --- a/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/event/PlayerLevelUpEvent.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.github.minecraftschurlimods.arsmagicalegacy.api.event; - -import net.minecraft.world.entity.player.Player; -import net.neoforged.neoforge.event.entity.player.PlayerEvent; - -/** - * Event that fires when the player levels up its magic. - */ -public final class PlayerLevelUpEvent extends PlayerEvent { - private final int level; - - public PlayerLevelUpEvent(Player player, int level) { - super(player); - this.level = level; - } - - /** - * @return The level the player leveled up to. - */ - public int getLevel() { - return level; - } -} diff --git a/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/magic/IMagicHelper.java b/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/magic/IMagicHelper.java index d2d08e98a..9af314c7a 100644 --- a/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/magic/IMagicHelper.java +++ b/src/api/java/com/github/minecraftschurlimods/arsmagicalegacy/api/magic/IMagicHelper.java @@ -62,6 +62,13 @@ public interface IMagicHelper { */ boolean knowsMagic(Player player); + /** + * Initiate leveling (set level 1) for the given player. + * + * @param player The player to initiate leveling for. + */ + void initiateLeveling(Player player); + /** * @param player The player to check. * @return True if the player has magic vision, false otherwise. diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/handler/EventHandler.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/handler/EventHandler.java index 96cebb473..3ad835273 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/handler/EventHandler.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/handler/EventHandler.java @@ -5,7 +5,7 @@ import com.github.minecraftschurlimods.arsmagicalegacy.api.affinity.Affinity; import com.github.minecraftschurlimods.arsmagicalegacy.api.affinity.IAffinityItem; import com.github.minecraftschurlimods.arsmagicalegacy.api.event.AffinityChangingEvent; -import com.github.minecraftschurlimods.arsmagicalegacy.api.event.PlayerLevelUpEvent; +import com.github.minecraftschurlimods.arsmagicalegacy.api.event.PlayerLevelChangeEvent; import com.github.minecraftschurlimods.arsmagicalegacy.api.event.SpellEvent; import com.github.minecraftschurlimods.arsmagicalegacy.api.magic.ContingencyType; import com.github.minecraftschurlimods.arsmagicalegacy.api.magic.IBurnoutHelper; @@ -307,11 +307,11 @@ private static void entityJoinWorld(EntityJoinLevelEvent event) { } private static void playerItemCrafted(PlayerEvent.ItemCraftedEvent event) { + Player player = event.getEntity(); + if (player.level().isClientSide()) return; var api = ArsMagicaAPI.get(); - var helper = api.getMagicHelper(); - if (helper.knowsMagic(event.getEntity())) return; if (!ItemStack.isSameItemSameTags(api.getBookStack(), event.getCrafting())) return; - helper.awardXp(event.getEntity(), 0); + api.getMagicHelper().initiateLeveling(player); } private static void playerRespawn(PlayerEvent.PlayerRespawnEvent event) { @@ -410,7 +410,7 @@ private static void modifyStats(SpellEvent.ModifyStats event) { } } - private static void playerLevelUp(PlayerLevelUpEvent event) { + private static void playerLevelUp(PlayerLevelChangeEvent event) { Player player = event.getEntity(); Level level = player.level(); int magicLevel = event.getLevel(); @@ -418,13 +418,15 @@ private static void playerLevelUp(PlayerLevelUpEvent event) { if (magicLevel == 1) { api.getSkillHelper().addSkillPoint(player, AMSkillPoints.BLUE, Config.SERVER.EXTRA_BLUE_SKILL_POINTS.get()); } - for (SkillPoint skillPoint : api.getSkillPointRegistry()) { - int minEarnLevel = skillPoint.minEarnLevel(); - int levelsForPoint = skillPoint.levelsForPoint(); - if (minEarnLevel < 0 || levelsForPoint < 0) continue; - if (magicLevel >= minEarnLevel && (magicLevel - minEarnLevel) % levelsForPoint == 0) { - api.getSkillHelper().addSkillPoint(player, skillPoint); - level.playSound(null, player.getX(), player.getY(), player.getZ(), AMSounds.GET_KNOWLEDGE_POINT.value(), SoundSource.PLAYERS, 1f, 1f); + for (int i = event.getOldLevel() + 1; i <= magicLevel; i++) { + for (SkillPoint skillPoint : api.getSkillPointRegistry()) { + int minEarnLevel = skillPoint.minEarnLevel(); + int levelsForPoint = skillPoint.levelsForPoint(); + if (minEarnLevel < 0 || levelsForPoint < 0) continue; + if (i >= minEarnLevel && (i - minEarnLevel) % levelsForPoint == 0) { + api.getSkillHelper().addSkillPoint(player, skillPoint); + level.playSound(null, player.getX(), player.getY(), player.getZ(), AMSounds.GET_KNOWLEDGE_POINT.value(), SoundSource.PLAYERS, 1f, 1f); + } } } float newMaxMana = Config.SERVER.MANA_BASE.get().floatValue() + Config.SERVER.MANA_MULTIPLIER.get().floatValue() * (magicLevel - 1); @@ -436,7 +438,7 @@ private static void playerLevelUp(PlayerLevelUpEvent event) { } AttributeInstance manaRegenAttr = player.getAttribute(AMAttributes.MANA_REGEN.value()); if (manaRegenAttr != null) { - manaRegenAttr.setBaseValue(newMaxMana * Config.SERVER.MANA_REGEN_MULTIPLIER.get() ); + manaRegenAttr.setBaseValue(newMaxMana * Config.SERVER.MANA_REGEN_MULTIPLIER.get()); } float newMaxBurnout = Config.SERVER.BURNOUT_BASE.get().floatValue() + Config.SERVER.BURNOUT_MULTIPLIER.get().floatValue() * (magicLevel - 1); AttributeInstance maxBurnoutAttr = player.getAttribute(AMAttributes.MAX_BURNOUT.value()); diff --git a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/magic/MagicHelper.java b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/magic/MagicHelper.java index 39af48ae0..441b33d59 100644 --- a/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/magic/MagicHelper.java +++ b/src/main/java/com/github/minecraftschurlimods/arsmagicalegacy/common/magic/MagicHelper.java @@ -2,7 +2,7 @@ import com.github.minecraftschurlimods.arsmagicalegacy.Config; import com.github.minecraftschurlimods.arsmagicalegacy.api.ArsMagicaAPI; -import com.github.minecraftschurlimods.arsmagicalegacy.api.event.PlayerLevelUpEvent; +import com.github.minecraftschurlimods.arsmagicalegacy.api.event.PlayerLevelChangeEvent; import com.github.minecraftschurlimods.arsmagicalegacy.api.magic.IMagicHelper; import com.github.minecraftschurlimods.arsmagicalegacy.client.ClientHelper; import com.github.minecraftschurlimods.arsmagicalegacy.common.init.AMCriteriaTriggers; @@ -68,15 +68,16 @@ public void setXp(Player player, float amount) { while (xp >= xpForNextLevel) { xp -= xpForNextLevel; level++; - NeoForge.EVENT_BUS.post(new PlayerLevelUpEvent(player, level)); - if (player instanceof ServerPlayer serverPlayer) { - AMCriteriaTriggers.PLAYER_LEVEL_UP.get().trigger(serverPlayer, level); - } xpForNextLevel = getXpForNextLevel(level); } holder.setXp(xp); - holder.setLevel(level); - syncToPlayer(player); + if (level != holder.getLevel()) { + // fire events and other extra functionality + setLevel(player, level); + } else { + // basic syncing + syncToPlayer(player); + } } @Override @@ -89,11 +90,11 @@ public void setLevel(Player player, int level) { MagicHolder holder = player.getData(MAGIC); int oldLevel = holder.getLevel(); holder.setLevel(level); + NeoForge.EVENT_BUS.post(new PlayerLevelChangeEvent(player, level, oldLevel)); if (level > oldLevel && level > 0) { for (int i = oldLevel + 1; i <= level; i++) { - NeoForge.EVENT_BUS.post(new PlayerLevelUpEvent(player, i)); if (player instanceof ServerPlayer serverPlayer) { - AMCriteriaTriggers.PLAYER_LEVEL_UP.get().trigger(serverPlayer, level); + AMCriteriaTriggers.PLAYER_LEVEL_UP.get().trigger(serverPlayer, i); } } } @@ -105,6 +106,13 @@ public boolean knowsMagic(Player player) { return !Config.SERVER.REQUIRE_COMPENDIUM_CRAFTING.get() || player.isCreative() || player.isSpectator() || getLevel(player) > 0; } + @Override + public void initiateLeveling(Player player) { + if (getLevel(player) <= 0) { + setLevel(player, 1); + } + } + /** * Syncs the attachment to the client. * From 67e09ec511c5a5f91aff13fb423681896f0e77bd Mon Sep 17 00:00:00 2001 From: Minecraftschurli Date: Sun, 28 Jul 2024 19:06:31 +0200 Subject: [PATCH 11/11] Fix gradle issues --- build.gradle.kts | 1 + settings.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6f108f8df..f2565b509 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,7 @@ import com.github.minecraftschurlimods.helperplugin.sourceSets plugins { idea + id("net.neoforged.gradle.userdev") id ("com.github.minecraftschurlimods.helperplugin") } diff --git a/settings.gradle.kts b/settings.gradle.kts index b756075fc..111140114 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,6 @@ pluginManagement { plugins { - id("net.neoforged.gradle.userdev") version "7.0.142" + id("net.neoforged.gradle.userdev") version "7.0.154" id("com.github.minecraftschurlimods.helperplugin") version "1.14" } repositories {