Skip to content

Commit

Permalink
Renamed some files and cleaned up code
Browse files Browse the repository at this point in the history
  • Loading branch information
miyucomics committed Mar 1, 2024
1 parent 436cde1 commit 529f5bc
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import net.minecraft.text.Text
import net.minecraft.util.DyeColor
import net.minecraft.util.Hand

class NeedActiveArchLampMishap : Mishap() {
class NeedsActiveArchLampMishap : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.RED)
override fun particleSpray(ctx: CastingContext) = ParticleSpray.burst(ctx.caster.pos, 1.0)
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Text = error(Hexical.MOD_ID + ":needs_active_arch_lamp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import net.minecraft.text.Text
import net.minecraft.util.DyeColor
import net.minecraft.util.Hand

class NeedLampMishap : Mishap() {
class NeedsLampMishap : Mishap() {
override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.RED)
override fun particleSpray(ctx: CastingContext) = ParticleSpray.burst(ctx.caster.pos, 1.0)
override fun errorMessage(ctx: CastingContext, errorCtx: Context): Text = error(Hexical.MOD_ID + ":needs_lamp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.iota.NullIota
import at.petrak.hexcasting.api.spell.iota.Vec3Iota
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes
import miyucomics.hexical.casting.mishaps.NeedActiveArchLampMishap
import miyucomics.hexical.casting.mishaps.NeedsActiveArchLampMishap
import miyucomics.hexical.persistent_state.PersistentStateHandler
import miyucomics.hexical.utils.CastingUtils

Expand All @@ -16,7 +16,7 @@ class OpGetArchLampData(private val mode: Int) : ConstMediaAction {

override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
if (!CastingUtils.doesPlayerHaveActiveArchLamp(ctx.caster))
throw NeedActiveArchLampMishap()
throw NeedsActiveArchLampMishap()
val state = PersistentStateHandler.getPlayerState(ctx.caster)
when (mode) {
0 -> return listOf(Vec3Iota(state.position))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.iota.NullIota
import at.petrak.hexcasting.api.spell.iota.Vec3Iota
import at.petrak.hexcasting.api.utils.vecFromNBT
import miyucomics.hexical.casting.mishaps.NeedLampMishap
import miyucomics.hexical.casting.mishaps.NeedsLampMishap
import miyucomics.hexical.registry.HexicalItems

class OpGetLampData(private val mode: Int) : ConstMediaAction {
override val argc = 0

override fun execute(args: List<Iota>, ctx: CastingContext): List<Iota> {
if (!(ctx.caster.activeItem.item == HexicalItems.LAMP_ITEM && ctx.source == CastingContext.CastSource.PACKAGED_HEX))
throw NeedLampMishap()
throw NeedsLampMishap()
val nbt = ctx.caster.activeItem.nbt ?: return listOf(NullIota())
when (mode) {
0 -> return listOf(Vec3Iota(vecFromNBT(nbt.getLongArray("position"))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import miyucomics.hexical.blocks.AdvancedConjuredBlock
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Vec3d

class OpConfigureBlock(private val property: String, arguments: Int = 0) : SpellAction {
class OpConfigureAdvancedBlock(private val property: String, arguments: Int = 0) : SpellAction {
override val argc = arguments + 1

override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
import at.petrak.hexcasting.api.spell.mishaps.MishapOthersName
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes
import miyucomics.hexical.casting.mishaps.NeedActiveArchLampMishap
import miyucomics.hexical.casting.mishaps.NeedsActiveArchLampMishap
import miyucomics.hexical.persistent_state.PersistentStateHandler
import miyucomics.hexical.utils.CastingUtils

Expand All @@ -16,7 +16,7 @@ class OpSetArchLampStorage : SpellAction {

override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>>? {
if (!CastingUtils.doesPlayerHaveActiveArchLamp(ctx.caster))
throw NeedActiveArchLampMishap()
throw NeedsActiveArchLampMishap()
val iota = args[0]
val trueName = MishapOthersName.getTrueNameFromDatum(iota, ctx.caster)
if (trueName != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import at.petrak.hexcasting.api.spell.RenderedSpell
import at.petrak.hexcasting.api.spell.SpellAction
import at.petrak.hexcasting.api.spell.casting.CastingContext
import at.petrak.hexcasting.api.spell.iota.Iota
import miyucomics.hexical.casting.mishaps.NeedActiveArchLampMishap
import miyucomics.hexical.casting.mishaps.NeedsActiveArchLampMishap
import miyucomics.hexical.registry.HexicalItems
import miyucomics.hexical.utils.CastingUtils

class OpTerminateLamp : SpellAction {
class OpTerminateArchLamp : SpellAction {
override val argc = 0

override fun execute(args: List<Iota>, ctx: CastingContext): Triple<RenderedSpell, Int, List<ParticleSpray>> {
if (!CastingUtils.doesPlayerHaveActiveArchLamp(ctx.caster))
throw NeedActiveArchLampMishap()
throw NeedsActiveArchLampMishap()
return Triple(Spell(), 0, listOf())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package miyucomics.hexical.interfaces
interface CastingContextMixinInterface {
fun getCastByLamp(): Boolean
fun setCastByLamp(castByLamp: Boolean)
fun getArchlamp(): Boolean
fun setArchlamp(castByLamp: Boolean)
fun getArchLamp(): Boolean
fun setArchLamp(castByLamp: Boolean)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public abstract class CastingContextMixin implements CastingContextMixinInterfac
@Unique private boolean hexical$archlamp = false;
@Override public boolean getCastByLamp() {return hexical$isCastByLamp;}
@Override public void setCastByLamp(boolean value) {hexical$isCastByLamp = value;}
@Override public boolean getArchlamp() {return hexical$archlamp;}
@Override public void setArchlamp(boolean value) {hexical$archlamp = value;}
@Override public boolean getArchLamp() {return hexical$archlamp;}
@Override public void setArchLamp(boolean value) {hexical$archlamp = value;}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private boolean silenceLamp (ServerWorld world, PlayerEntity player, double x, d
@Inject(method = "withdrawMedia", at = @At("HEAD"), cancellable = true, remap = false)
private void withdrawMediaWisp(int mediaCost, boolean allowOvercast, CallbackInfoReturnable<Integer> cir) {
CastingContext ctx = hexical$harness.getCtx();
if (((CastingContextMixinInterface) (Object) ctx).getArchlamp()) {
if (((CastingContextMixinInterface) (Object) ctx).getArchLamp()) {
if (ctx.getCaster().isCreative()) {
cir.setReturnValue(0);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ object HexicalPatterns {
var NEPHTHYS_GAMBIT = register(HexPattern.fromAngles("deaqqdq", HexDir.SOUTH_EAST), "nephthys", OpNephthys);

var CONJURE_ADVANCED_BLOCK: HexPattern = register(HexPattern.fromAngles("dee", HexDir.NORTH_WEST), "conjure_advanced_block", OpConjureAdvancedBlock())
var CONFIGURE_BLOCK_BOUNCY: HexPattern = register(HexPattern.fromAngles("deeqa", HexDir.NORTH_WEST), "modify_block_bouncy", OpConfigureBlock("bouncy"))
var CONFIGURE_BLOCK_EPHEMERAL: HexPattern = register(HexPattern.fromAngles("deewwaawd", HexDir.NORTH_WEST), "modify_block_ephemeral", OpConfigureBlock("ephemeral", 1))
var CONFIGURE_BLOCK_INVISIBLE: HexPattern = register(HexPattern.fromAngles("deeqedeaqqqwqqq", HexDir.NORTH_WEST), "modify_block_invisible", OpConfigureBlock("invisible"))
var CONFIGURE_BLOCK_REPLACEABLE: HexPattern = register(HexPattern.fromAngles("deewqaqqqqq", HexDir.NORTH_WEST), "modify_block_replaceable", OpConfigureBlock("replaceable"))
var CONFIGURE_BLOCK_VOLATILE: HexPattern = register(HexPattern.fromAngles("deewedeeeee", HexDir.NORTH_WEST), "modify_block_volatile", OpConfigureBlock("volatile"))
var CONFIGURE_BLOCK_BOUNCY: HexPattern = register(HexPattern.fromAngles("deeqa", HexDir.NORTH_WEST), "modify_block_bouncy", OpConfigureAdvancedBlock("bouncy"))
var CONFIGURE_BLOCK_EPHEMERAL: HexPattern = register(HexPattern.fromAngles("deewwaawd", HexDir.NORTH_WEST), "modify_block_ephemeral", OpConfigureAdvancedBlock("ephemeral", 1))
var CONFIGURE_BLOCK_INVISIBLE: HexPattern = register(HexPattern.fromAngles("deeqedeaqqqwqqq", HexDir.NORTH_WEST), "modify_block_invisible", OpConfigureAdvancedBlock("invisible"))
var CONFIGURE_BLOCK_REPLACEABLE: HexPattern = register(HexPattern.fromAngles("deewqaqqqqq", HexDir.NORTH_WEST), "modify_block_replaceable", OpConfigureAdvancedBlock("replaceable"))
var CONFIGURE_BLOCK_VOLATILE: HexPattern = register(HexPattern.fromAngles("deewedeeeee", HexDir.NORTH_WEST), "modify_block_volatile", OpConfigureAdvancedBlock("volatile"))

var CHORUS_BLINK: HexPattern = register(HexPattern.fromAngles("aawqqqq", HexDir.SOUTH_EAST), "chorus_blink", OpChorusBlink())
var PROGRAM_LAMP: HexPattern = register(HexPattern.fromAngles("wwqqqqq", HexDir.EAST), "program_lamp", OpProgramLamp())
Expand All @@ -40,7 +40,7 @@ object HexicalPatterns {
var ARCH_LAMP_USE_TIME: HexPattern = register(HexPattern.fromAngles("qaqwddedqwddwa", HexDir.NORTH_EAST), "get_arch_lamp_use_time", OpGetArchLampData(3))
var ARCH_LAMP_STORAGE: HexPattern = register(HexPattern.fromAngles("qaqwddedqwaqqqqq", HexDir.NORTH_EAST), "get_arch_lamp_storage", OpGetArchLampData(4))
var IS_USING_LAMP: HexPattern = register(HexPattern.fromAngles("qaqwddedqeed", HexDir.NORTH_EAST), "is_using_lamp", OpIsUsingArchLamp())
var TERMINATE_LAMP: HexPattern = register(HexPattern.fromAngles("qaqwddedwaqdee", HexDir.NORTH_EAST), "terminate_arch_lamp", OpTerminateLamp())
var TERMINATE_LAMP: HexPattern = register(HexPattern.fromAngles("qaqwddedwaqdee", HexDir.NORTH_EAST), "terminate_arch_lamp", OpTerminateArchLamp())
var SET_LAMP_STORAGE: HexPattern = register(HexPattern.fromAngles("qaqwddedqedeeeee", HexDir.NORTH_EAST), "set_arch_lamp_storage", OpSetArchLampStorage())

@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CastingUtils {
val context = CastingContext(user, user.activeHand, CastingContext.CastSource.PACKAGED_HEX)
(context as CastingContextMixinInterface).setCastByLamp(true)
if (archlamp)
(context as CastingContextMixinInterface).setArchlamp(true)
(context as CastingContextMixinInterface).setArchLamp(true)
CastingHarness(context).executeIotas(hex, world)
}

Expand Down

0 comments on commit 529f5bc

Please sign in to comment.