Merge branch 'main' of https://github.com/gamma-delta/HexMod into akashic

This commit is contained in:
yrsegal@gmail.com 2022-04-09 13:28:18 -04:00
commit 4cf8233d21
6 changed files with 22 additions and 12 deletions

View file

@ -18,5 +18,5 @@ class MishapLocationInWrongDimension(val properDimension: ResourceLocation) : Mi
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Component =
error("wrong_dimension", actionName(errorCtx.action!!), properDimension.toString(),
ctx.world.dimension().registryName.toString())
ctx.world.dimension().location().toString())
}

View file

@ -21,7 +21,7 @@ object OpDestroySentinel : SpellOperator {
val maybeCap = ctx.caster.getCapability(HexCapabilities.SENTINEL).resolve()
maybeCap.ifPresent {
if (it.dimension != ctx.world.dimension())
throw MishapLocationInWrongDimension(it.dimension.registryName)
throw MishapLocationInWrongDimension(it.dimension.location())
particles.add(ParticleSpray.Cloud(it.position, 2.0))
}

View file

@ -18,7 +18,7 @@ object OpGetSentinelPos : ConstManaOperator {
val cap = maybeCap.get()
if (cap.dimension != ctx.world.dimension())
throw MishapLocationInWrongDimension(cap.dimension.registryName)
throw MishapLocationInWrongDimension(cap.dimension.location())
return spellListOf(
if (cap.hasSentinel)
cap.position

View file

@ -22,7 +22,7 @@ object OpGetSentinelWayfind : ConstManaOperator {
val cap = maybeCap.get()
if (cap.dimension != ctx.world.dimension())
throw MishapLocationInWrongDimension(cap.dimension.registryName)
throw MishapLocationInWrongDimension(cap.dimension.location())
val sentinelPos = if (!cap.hasSentinel)
return spellListOf(Widget.NULL)

View file

@ -0,0 +1,14 @@
package at.petrak.hexcasting.common.network;
import at.petrak.hexcasting.client.gui.GuiSpellcasting;
import net.minecraft.client.Minecraft;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public record GuiOpener(MsgOpenSpellGuiAck msg) {
@OnlyIn(Dist.CLIENT)
public void openGui() {
var mc = Minecraft.getInstance();
mc.setScreen(new GuiSpellcasting(msg.hand(), msg.patterns(), msg.components()));
}
}

View file

@ -1,9 +1,7 @@
package at.petrak.hexcasting.common.network;
import at.petrak.hexcasting.client.gui.GuiSpellcasting;
import at.petrak.hexcasting.common.casting.ResolvedPattern;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
@ -57,12 +55,10 @@ public record MsgOpenSpellGuiAck(InteractionHand hand, List<ResolvedPattern> pat
}
public void handle(Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() ->
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
var mc = Minecraft.getInstance();
mc.setScreen(new GuiSpellcasting(hand, patterns, components));
})
);
ctx.get().enqueueWork(() -> {
GuiOpener opener = new GuiOpener(this);
DistExecutor.safeRunWhenOn(Dist.CLIENT, () -> opener::openGui);
});
ctx.get().setPacketHandled(true);
}