woot woot! fix bad maven deps and improve perf on colorizers
This commit is contained in:
parent
c6612c547a
commit
697450dd66
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.api;
|
|||
import at.petrak.hexcasting.api.addldata.ADMediaHolder;
|
||||
import at.petrak.hexcasting.api.casting.ActionRegistryEntry;
|
||||
import at.petrak.hexcasting.api.casting.castables.SpecialHandler;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.api.player.Sentinel;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import com.google.common.base.Suppliers;
|
||||
|
@ -154,8 +154,8 @@ public interface HexAPI {
|
|||
return null;
|
||||
}
|
||||
|
||||
default FrozenColorizer getColorizer(Player player) {
|
||||
return FrozenColorizer.DEFAULT.get();
|
||||
default FrozenPigment getColorizer(Player player) {
|
||||
return FrozenPigment.DEFAULT.get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package at.petrak.hexcasting.api.addldata;
|
||||
|
||||
import at.petrak.hexcasting.api.pigment.ColorProvider;
|
||||
import net.minecraft.util.FastColor;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
@ -7,7 +8,7 @@ import net.minecraft.world.phys.Vec3;
|
|||
import java.util.UUID;
|
||||
|
||||
public interface ADColorizer {
|
||||
int color(UUID owner, float time, Vec3 position);
|
||||
ColorProvider provideColor(UUID owner);
|
||||
|
||||
static int morphBetweenColors(int[] colors, Vec3 gradientDir, float time, Vec3 position) {
|
||||
float fIdx = Mth.positiveModulo(time + (float) gradientDir.dot(position), 1f) * colors.length;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.api.casting
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import at.petrak.hexcasting.common.network.MsgCastParticleAck
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||
import net.minecraft.server.level.ServerLevel
|
||||
|
@ -23,7 +23,7 @@ data class ParticleSpray(val pos: Vec3, val vel: Vec3, val fuzziness: Double, va
|
|||
}
|
||||
}
|
||||
|
||||
fun sprayParticles(world: ServerLevel, color: FrozenColorizer) {
|
||||
fun sprayParticles(world: ServerLevel, color: FrozenPigment) {
|
||||
IXplatAbstractions.INSTANCE.sendPacketNear(this.pos, 128.0, world, MsgCastParticleAck(this, color))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.api.casting.circles;
|
|||
import at.petrak.hexcasting.api.HexAPI;
|
||||
import at.petrak.hexcasting.api.casting.eval.env.CircleCastEnv;
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.CastingImage;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.api.utils.HexUtils;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
@ -50,14 +50,14 @@ public class CircleExecutionState {
|
|||
public Direction enteredFrom;
|
||||
public CastingImage currentImage;
|
||||
public @Nullable UUID caster;
|
||||
public FrozenColorizer colorizer;
|
||||
public FrozenPigment colorizer;
|
||||
|
||||
public final AABB bounds;
|
||||
|
||||
|
||||
protected CircleExecutionState(BlockPos impetusPos, Direction impetusDir, Set<BlockPos> knownPositions,
|
||||
List<BlockPos> reachedPositions, BlockPos currentPos, Direction enteredFrom,
|
||||
CastingImage currentImage, @Nullable UUID caster, FrozenColorizer colorizer) {
|
||||
CastingImage currentImage, @Nullable UUID caster, FrozenPigment colorizer) {
|
||||
this.impetusPos = impetusPos;
|
||||
this.impetusDir = impetusDir;
|
||||
this.knownPositions = knownPositions;
|
||||
|
@ -131,10 +131,10 @@ public class CircleExecutionState {
|
|||
reachedPositions.add(impetus.getBlockPos());
|
||||
var start = seenGoodPositions.get(0);
|
||||
|
||||
FrozenColorizer colorizer;
|
||||
FrozenPigment colorizer;
|
||||
UUID casterUUID;
|
||||
if (caster == null) {
|
||||
colorizer = new FrozenColorizer(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.PURPLE)),
|
||||
colorizer = new FrozenPigment(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.PURPLE)),
|
||||
Util.NIL_UUID);
|
||||
casterUUID = null;
|
||||
} else {
|
||||
|
@ -198,7 +198,7 @@ public class CircleExecutionState {
|
|||
if (nbt.hasUUID(TAG_CASTER))
|
||||
caster = nbt.getUUID(TAG_CASTER);
|
||||
|
||||
FrozenColorizer colorizer = FrozenColorizer.fromNBT(nbt.getCompound(TAG_COLORIZER));
|
||||
FrozenPigment colorizer = FrozenPigment.fromNBT(nbt.getCompound(TAG_COLORIZER));
|
||||
|
||||
return new CircleExecutionState(startPos, startDir, knownPositions, reachedPositions, currentPos,
|
||||
enteredFrom, image, caster, colorizer);
|
||||
|
|
|
@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.block.circle.BlockCircleComponent;
|
|||
import at.petrak.hexcasting.api.casting.ParticleSpray;
|
||||
import at.petrak.hexcasting.api.casting.eval.env.CircleCastEnv;
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.CastingImage;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.lib.HexSounds;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
@ -60,7 +60,7 @@ public interface ICircleComponent {
|
|||
*/
|
||||
@Contract(pure = true)
|
||||
EnumSet<Direction> possibleExitDirections(BlockPos pos, BlockState bs, Level world);
|
||||
|
||||
|
||||
/**
|
||||
* Given the current position and a direction, return a pair of the new position after a step
|
||||
* in that direction, along with the direction (this is a helper function for creating
|
||||
|
@ -70,11 +70,12 @@ public interface ICircleComponent {
|
|||
default Pair<BlockPos, Direction> exitPositionFromDirection(BlockPos pos, Direction dir) {
|
||||
return Pair.of(pos.offset(dir.getStepX(), dir.getStepY(), dir.getStepZ()), dir);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start the {@link ICircleComponent} at the given position glowing. Returns the new state
|
||||
* of the given block.
|
||||
* // TODO: determine if this should just be in {@link ICircleComponent#acceptControlFlow(CastingImage, CircleCastEnv, Direction, BlockPos, BlockState, ServerLevel)}.
|
||||
* // TODO: determine if this should just be in
|
||||
* {@link ICircleComponent#acceptControlFlow(CastingImage, CircleCastEnv, Direction, BlockPos, BlockState, ServerLevel)}.
|
||||
*/
|
||||
BlockState startEnergized(BlockPos pos, BlockState bs, Level world);
|
||||
|
||||
|
@ -82,7 +83,7 @@ public interface ICircleComponent {
|
|||
* Returns whether the {@link ICircleComponent} at the given position is energized.
|
||||
*/
|
||||
boolean isEnergized(BlockPos pos, BlockState bs, Level world);
|
||||
|
||||
|
||||
/**
|
||||
* End the {@link ICircleComponent} at the given position glowing. Returns the new state of
|
||||
* the given block.
|
||||
|
@ -92,13 +93,13 @@ public interface ICircleComponent {
|
|||
static void sfx(BlockPos pos, BlockState bs, Level world, BlockEntityAbstractImpetus impetus, boolean success) {
|
||||
Vec3 vpos;
|
||||
Vec3 vecOutDir;
|
||||
FrozenColorizer colorizer;
|
||||
FrozenPigment colorizer;
|
||||
|
||||
UUID activator = Util.NIL_UUID;
|
||||
if (impetus.getExecutionState() != null && impetus.getExecutionState().caster != null)
|
||||
activator = impetus.getExecutionState().caster;
|
||||
if (impetus.getExecutionState() == null)
|
||||
colorizer = new FrozenColorizer(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.RED)), activator);
|
||||
colorizer = new FrozenPigment(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.RED)), activator);
|
||||
else
|
||||
colorizer = impetus.getExecutionState().colorizer;
|
||||
|
||||
|
@ -115,10 +116,10 @@ public interface ICircleComponent {
|
|||
|
||||
if (world instanceof ServerLevel serverLevel) {
|
||||
var spray = new ParticleSpray(vpos, vecOutDir.scale(success ? 1.0 : 1.5), success ? 0.1 : 0.5,
|
||||
Mth.PI / (success ? 4 : 2), success ? 30 : 100);
|
||||
Mth.PI / (success ? 4 : 2), success ? 30 : 100);
|
||||
spray.sprayParticles(serverLevel,
|
||||
success ? colorizer : new FrozenColorizer(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.RED)),
|
||||
activator));
|
||||
success ? colorizer : new FrozenPigment(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.RED)),
|
||||
activator));
|
||||
}
|
||||
|
||||
var pitch = 1f;
|
||||
|
|
|
@ -6,8 +6,8 @@ import at.petrak.hexcasting.api.casting.mishaps.Mishap;
|
|||
import at.petrak.hexcasting.api.casting.mishaps.MishapBadLocation;
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapDisallowedSpell;
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapEntityTooFarAway;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.mod.HexConfig;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.api.utils.HexUtils;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -200,7 +200,7 @@ public abstract class CastingEnvironment {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static record HeldItemInfo(ItemStack stack, @Nullable InteractionHand hand) {
|
||||
public record HeldItemInfo(ItemStack stack, @Nullable InteractionHand hand) {
|
||||
public ItemStack component1() {
|
||||
return stack;
|
||||
}
|
||||
|
@ -225,12 +225,23 @@ public abstract class CastingEnvironment {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to provide infinite items.
|
||||
*/
|
||||
protected boolean isCreativeMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to withdraw some number of items from stacks available.
|
||||
* <p>
|
||||
* Return whether it was successful.
|
||||
*/
|
||||
public boolean withdrawItem(Predicate<ItemStack> stackOk, int count, boolean actuallyRemove) {
|
||||
if (this.isCreativeMode()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var stacks = this.getUsableStacks(StackDiscoveryMode.EXTRACTION);
|
||||
|
||||
var presentCount = 0;
|
||||
|
@ -277,7 +288,7 @@ public abstract class CastingEnvironment {
|
|||
EXTRACTION,
|
||||
}
|
||||
|
||||
public abstract FrozenColorizer getColorizer();
|
||||
public abstract FrozenPigment getColorizer();
|
||||
|
||||
public abstract void produceParticles(ParticleSpray particles, FrozenColorizer colorizer);
|
||||
public abstract void produceParticles(ParticleSpray particles, FrozenPigment colorizer);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import at.petrak.hexcasting.api.casting.circles.CircleExecutionState;
|
|||
import at.petrak.hexcasting.api.casting.eval.CastResult;
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment;
|
||||
import at.petrak.hexcasting.api.casting.eval.MishapEnvironment;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -130,16 +130,16 @@ public class CircleCastEnv extends CastingEnvironment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FrozenColorizer getColorizer() {
|
||||
public FrozenPigment getColorizer() {
|
||||
var out = this.getColorizerFromImpetus();
|
||||
if (out != null)
|
||||
return out;
|
||||
|
||||
// TODO: colouriser from an adjacent inventory also?
|
||||
return new FrozenColorizer(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.PURPLE)), Util.NIL_UUID);
|
||||
return new FrozenPigment(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.PURPLE)), Util.NIL_UUID);
|
||||
}
|
||||
|
||||
private @Nullable FrozenColorizer getColorizerFromImpetus() {
|
||||
private @Nullable FrozenPigment getColorizerFromImpetus() {
|
||||
var impetus = this.getImpetus();
|
||||
if (impetus == null)
|
||||
return null;
|
||||
|
@ -150,7 +150,7 @@ public class CircleCastEnv extends CastingEnvironment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void produceParticles(ParticleSpray particles, FrozenColorizer colorizer) {
|
||||
public void produceParticles(ParticleSpray particles, FrozenPigment colorizer) {
|
||||
particles.sprayParticles(this.world, colorizer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.casting.eval.env;
|
|||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastResult;
|
||||
import at.petrak.hexcasting.api.casting.eval.sideeffects.EvalSound;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.common.lib.hex.HexEvalSounds;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -53,7 +53,7 @@ public class PackagedItemCastEnv extends PlayerBasedCastEnv {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FrozenColorizer getColorizer() {
|
||||
public FrozenPigment getColorizer() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment;
|
|||
import at.petrak.hexcasting.api.casting.eval.MishapEnvironment;
|
||||
import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect;
|
||||
import at.petrak.hexcasting.api.casting.mishaps.Mishap;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.misc.HexDamageSources;
|
||||
import at.petrak.hexcasting.api.mod.HexConfig;
|
||||
import at.petrak.hexcasting.api.mod.HexStatistics;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.api.utils.HexUtils;
|
||||
import at.petrak.hexcasting.api.utils.MediaHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -91,10 +91,11 @@ public abstract class PlayerBasedCastEnv extends CastingEnvironment {
|
|||
var out = new ArrayList<ItemStack>();
|
||||
|
||||
// First, the inventory backwards
|
||||
// We use inv.items here to get the main inventory, but not offhand or armor
|
||||
Inventory inv = this.caster.getInventory();
|
||||
for (int i = inv.getContainerSize(); i >= 0; i--) {
|
||||
for (int i = inv.items.size() - 1; i >= 0; i--) {
|
||||
if (i != inv.selected) {
|
||||
out.add(inv.getItem(i));
|
||||
out.add(inv.items.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +188,7 @@ public abstract class PlayerBasedCastEnv extends CastingEnvironment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void produceParticles(ParticleSpray particles, FrozenColorizer colorizer) {
|
||||
public void produceParticles(ParticleSpray particles, FrozenPigment colorizer) {
|
||||
particles.sprayParticles(this.world, colorizer);
|
||||
}
|
||||
|
||||
|
@ -205,4 +206,10 @@ public abstract class PlayerBasedCastEnv extends CastingEnvironment {
|
|||
var msg = mishap.getMishap().errorMessageWithName(this, mishap.getErrorCtx());
|
||||
this.caster.sendSystemMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCreativeMode() {
|
||||
// not sure what the diff between this and isCreative() is
|
||||
return this.caster.getAbilities().instabuild;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package at.petrak.hexcasting.api.casting.eval.env;
|
||||
|
||||
import at.petrak.hexcasting.api.HexAPI;
|
||||
import at.petrak.hexcasting.api.casting.ParticleSpray;
|
||||
import at.petrak.hexcasting.api.casting.eval.CastResult;
|
||||
import at.petrak.hexcasting.api.casting.eval.ExecutionClientView;
|
||||
import at.petrak.hexcasting.api.casting.eval.ResolvedPattern;
|
||||
import at.petrak.hexcasting.api.casting.iota.PatternIota;
|
||||
import at.petrak.hexcasting.api.casting.math.HexCoord;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.mod.HexStatistics;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.common.network.MsgNewSpellPatternAck;
|
||||
import at.petrak.hexcasting.common.network.MsgNewSpellPatternSyn;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
|
@ -15,6 +16,7 @@ import net.minecraft.network.chat.Component;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -61,7 +63,7 @@ public class StaffCastEnv extends PlayerBasedCastEnv {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FrozenColorizer getColorizer() {
|
||||
public FrozenPigment getColorizer() {
|
||||
return HexAPI.instance().getColorizer(this.caster);
|
||||
}
|
||||
|
||||
|
@ -108,5 +110,12 @@ public class StaffCastEnv extends PlayerBasedCastEnv {
|
|||
|
||||
IXplatAbstractions.INSTANCE.sendPacketToPlayer(sender,
|
||||
new MsgNewSpellPatternAck(clientInfo, resolvedPatterns.size() - 1));
|
||||
|
||||
if (clientInfo.getResolutionType().getSuccess()) {
|
||||
// Somehow we lost spraying particles on each new pattern, so do it here
|
||||
// this also nicely prevents particle spam on trinkets
|
||||
new ParticleSpray(sender.position(), new Vec3(0.0, 1.5, 0.0), 0.4, Math.PI / 3, 30)
|
||||
.sprayParticles(sender.getLevel(), IXplatAbstractions.INSTANCE.getColorizer(sender));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import at.petrak.hexcasting.api.casting.ParticleSpray
|
|||
import at.petrak.hexcasting.api.casting.RenderedSpell
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.CastingVM
|
||||
import at.petrak.hexcasting.api.casting.mishaps.Mishap
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.mod.HexStatistics
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import at.petrak.hexcasting.common.lib.HexItems
|
||||
import net.minecraft.Util
|
||||
|
@ -57,7 +57,7 @@ sealed class OperatorSideEffect {
|
|||
data class Particles(val spray: ParticleSpray) : OperatorSideEffect() {
|
||||
override fun performEffect(harness: CastingVM): Boolean {
|
||||
harness.env.produceParticles(this.spray, harness.env.colorizer)
|
||||
this.spray.sprayParticles(harness.env.world, harness.env.colorizer)
|
||||
// this.spray.sprayParticles(harness.env.world, harness.env.colorizer)
|
||||
|
||||
return false
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ sealed class OperatorSideEffect {
|
|||
spray.sprayParticles(harness.env.world, color)
|
||||
spray.sprayParticles(
|
||||
harness.env.world,
|
||||
FrozenColorizer(
|
||||
FrozenPigment(
|
||||
ItemStack(HexItems.DYE_COLORIZERS[DyeColor.RED]!!),
|
||||
Util.NIL_UUID
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
|||
import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.math.HexPattern
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import at.petrak.hexcasting.api.utils.lightPurple
|
||||
import at.petrak.hexcasting.common.lib.HexItems
|
||||
|
@ -21,7 +21,7 @@ import net.minecraft.world.phys.Vec3
|
|||
|
||||
abstract class Mishap : Throwable() {
|
||||
/** Mishaps spray half-red, half-this-color. */
|
||||
abstract fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer
|
||||
abstract fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment
|
||||
|
||||
open fun particleSpray(ctx: CastingEnvironment): ParticleSpray {
|
||||
return ParticleSpray(
|
||||
|
@ -54,8 +54,8 @@ abstract class Mishap : Throwable() {
|
|||
|
||||
// Useful helper functions
|
||||
|
||||
protected fun dyeColor(color: DyeColor): FrozenColorizer =
|
||||
FrozenColorizer(
|
||||
protected fun dyeColor(color: DyeColor): FrozenPigment =
|
||||
FrozenPigment(
|
||||
ItemStack(HexItems.DYE_COLORIZERS[color]!!),
|
||||
Util.NIL_UUID
|
||||
)
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.misc.HexDamageSources
|
||||
import at.petrak.hexcasting.api.casting.ParticleSpray
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.HexDamageSources
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.world.entity.Mob
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapAlreadyBrainswept(val mob: Mob) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.GREEN)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.ParticleSpray
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.network.chat.Component
|
||||
|
@ -12,7 +12,7 @@ import net.minecraft.world.level.Explosion
|
|||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class MishapBadBlock(val pos: BlockPos, val expected: Component) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.LIME)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -3,15 +3,15 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
import at.petrak.hexcasting.api.casting.ParticleSpray
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.misc.HexDamageSources
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.entity.Mob
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class MishapBadBrainsweep(val mob: Mob, val pos: BlockPos) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.GREEN)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import at.petrak.hexcasting.api.utils.aqua
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import net.minecraft.network.chat.Component
|
||||
|
@ -11,7 +11,7 @@ import net.minecraft.world.entity.item.ItemEntity
|
|||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapBadEntity(val entity: Entity, val wanted: Component) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.BROWN)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.entity.item.ItemEntity
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapBadItem(val item: ItemEntity, val wanted: Component) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.BROWN)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -3,13 +3,13 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.iota.Vec3Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
class MishapBadLocation(val location: Vec3, val type: String = "too_far") : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.MAGENTA)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.InteractionHand
|
||||
|
@ -10,7 +10,7 @@ import net.minecraft.world.item.DyeColor
|
|||
import net.minecraft.world.item.ItemStack
|
||||
|
||||
class MishapBadOffhandItem(val item: ItemStack, val hand: InteractionHand?, val wanted: Component) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.BROWN)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -3,11 +3,11 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapDisallowedSpell(val type: String = "disallowed") : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun resolutionType(ctx: CastingEnvironment) = ResolvedPatternType.INVALID
|
||||
|
|
|
@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.casting.iota.DoubleIota
|
|||
import at.petrak.hexcasting.api.casting.iota.GarbageIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.iota.Vec3Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
@ -13,7 +13,7 @@ import net.minecraft.world.phys.Vec3
|
|||
|
||||
class MishapDivideByZero(val operand1: Component, val operand2: Component, val suffix: String = "divide") : Mishap() {
|
||||
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.RED)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -2,13 +2,13 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapEntityTooFarAway(val entity: Entity) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.PINK)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -2,11 +2,11 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapEvalTooMuch : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.BLUE)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -2,13 +2,13 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import at.petrak.hexcasting.api.utils.aqua
|
||||
import net.minecraft.world.entity.Entity
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapImmuneEntity(val entity: Entity) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.BLUE)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -2,11 +2,11 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapInternalException(val exception: Exception) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.GarbageIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import at.petrak.hexcasting.api.utils.asTranslatedComponent
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
@ -18,7 +18,7 @@ class MishapInvalidIota(
|
|||
val reverseIdx: Int,
|
||||
val expected: Component
|
||||
) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.GRAY)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType
|
||||
import at.petrak.hexcasting.api.casting.iota.GarbageIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapInvalidPattern : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.YELLOW)
|
||||
|
||||
override fun resolutionType(ctx: CastingEnvironment) = ResolvedPatternType.INVALID
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
/**
|
||||
* this is bad
|
||||
*/
|
||||
class MishapInvalidSpellDatumType(val perpetrator: Any) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -3,13 +3,13 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.GarbageIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapLocationInWrongDimension(val properDimension: ResourceLocation) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.MAGENTA)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -2,12 +2,12 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.core.BlockPos
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapNoAkashicRecord(val pos: BlockPos) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.PURPLE)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -2,14 +2,14 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.DyeColor
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper
|
||||
|
||||
class MishapNoSpellCircle : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.LIGHT_BLUE)
|
||||
|
||||
private inline fun dropAll(player: Player, stacks: MutableList<ItemStack>, filter: (ItemStack) -> Boolean = { true }) {
|
||||
|
|
|
@ -3,11 +3,11 @@ package at.petrak.hexcasting.api.casting.mishaps
|
|||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.GarbageIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapNotEnoughArgs(val expected: Int, val got: Int) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.LIGHT_GRAY)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
|||
import at.petrak.hexcasting.api.casting.iota.EntityIota
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.iota.ListIota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
|
@ -12,7 +12,7 @@ import net.minecraft.world.item.DyeColor
|
|||
* Also throwable for your *own* name, for cases like Chronicler's Gambit
|
||||
*/
|
||||
class MishapOthersName(val confidant: Player) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.misc.HexDamageSources
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.HexDamageSources
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapShameOnYou() : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.BLACK)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.iota.PatternIota
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
class MishapTooManyCloseParens : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.ORANGE)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package at.petrak.hexcasting.api.casting.mishaps
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import net.minecraft.world.item.DyeColor
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@ import net.minecraft.world.item.DyeColor
|
|||
class MishapUnescapedValue(
|
||||
val perpetrator: Iota
|
||||
) : Mishap() {
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenColorizer =
|
||||
override fun accentColor(ctx: CastingEnvironment, errorCtx: Context): FrozenPigment =
|
||||
dyeColor(DyeColor.GRAY)
|
||||
|
||||
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.api.item;
|
||||
|
||||
import at.petrak.hexcasting.api.pigment.ColorProvider;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -14,5 +14,5 @@ import java.util.UUID;
|
|||
*/
|
||||
@ApiStatus.OverrideOnly
|
||||
public interface ColorizerItem {
|
||||
int color(ItemStack stack, UUID owner, float time, Vec3 position);
|
||||
ColorProvider provideColor(ItemStack stack, UUID owner);
|
||||
}
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
package at.petrak.hexcasting.api.misc;
|
||||
|
||||
import at.petrak.hexcasting.api.addldata.ADColorizer;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.FastColor;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A colorizer item and the player who owned it at the time of making the color.
|
||||
*/
|
||||
public record FrozenColorizer(ItemStack item, UUID owner) {
|
||||
|
||||
private static final int[] MINIMUM_LUMINANCE_COLOR_WHEEL = {
|
||||
0xFF200000, 0xFF202000, 0xFF002000, 0xFF002020, 0xFF000020, 0xFF200020
|
||||
};
|
||||
|
||||
public static final String TAG_STACK = "stack";
|
||||
public static final String TAG_OWNER = "owner";
|
||||
|
||||
public static final Supplier<FrozenColorizer> DEFAULT =
|
||||
() -> new FrozenColorizer(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.WHITE)), Util.NIL_UUID);
|
||||
|
||||
public CompoundTag serializeToNBT() {
|
||||
var out = new CompoundTag();
|
||||
out.put(TAG_STACK, this.item.save(new CompoundTag()));
|
||||
out.putUUID(TAG_OWNER, this.owner);
|
||||
return out;
|
||||
}
|
||||
|
||||
public static FrozenColorizer fromNBT(CompoundTag tag) {
|
||||
if (tag.isEmpty()) {
|
||||
return FrozenColorizer.DEFAULT.get();
|
||||
}
|
||||
try {
|
||||
CompoundTag stackTag = tag.getCompound(TAG_STACK);
|
||||
var stack = ItemStack.of(stackTag);
|
||||
var uuid = tag.getUUID(TAG_OWNER);
|
||||
return new FrozenColorizer(stack, uuid);
|
||||
} catch (NullPointerException exn) {
|
||||
return FrozenColorizer.DEFAULT.get();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a color with a minimum luminance applied.
|
||||
*
|
||||
* @param time absolute world time in ticks
|
||||
* @param position a position for the icosahedron, a randomish number for particles.
|
||||
* @return an AARRGGBB color.
|
||||
*/
|
||||
public int getColor(float time, Vec3 position) {
|
||||
int raw = IXplatAbstractions.INSTANCE.getRawColor(this, time, position);
|
||||
|
||||
var r = FastColor.ARGB32.red(raw);
|
||||
var g = FastColor.ARGB32.green(raw);
|
||||
var b = FastColor.ARGB32.blue(raw);
|
||||
double luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 0xFF; // Standard relative luminance calculation
|
||||
|
||||
if (luminance < 0.05) {
|
||||
int rawMod = ADColorizer.morphBetweenColors(MINIMUM_LUMINANCE_COLOR_WHEEL, new Vec3(0.1, 0.1, 0.1),
|
||||
time / 20 / 20, position);
|
||||
|
||||
r += FastColor.ARGB32.red(rawMod);
|
||||
g += FastColor.ARGB32.green(rawMod);
|
||||
b += FastColor.ARGB32.blue(rawMod);
|
||||
}
|
||||
|
||||
return 0xff_000000 | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.api.mod;
|
|||
// Don't understand what this does so i commented it all out :gigachad:
|
||||
/*
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.player.Sentinel;
|
||||
import at.petrak.hexcasting.api.spell.ParticleSpray;
|
||||
import net.minecraftforge.network.simple.SimpleChannel;
|
||||
|
@ -24,7 +24,8 @@ public final class HexApiMessages {
|
|||
Function<FrozenColorizer, Object> colorizerMessage,
|
||||
BiFunction<ParticleSpray, FrozenColorizer, Object> particleSprayMessage) {
|
||||
if (HexApiMessages.channel != null)
|
||||
throw new IllegalStateException("Already set sync channel! If you're not Hex, you shouldn't be calling this.");
|
||||
throw new IllegalStateException("Already set sync channel! If you're not Hex, you shouldn't be calling
|
||||
this.");
|
||||
HexApiMessages.channel = channel;
|
||||
HexApiMessages.sentinelMessage = sentinelMessage;
|
||||
HexApiMessages.colorizerMessage = colorizerMessage;
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package at.petrak.hexcasting.api.pigment;
|
||||
|
||||
import at.petrak.hexcasting.api.addldata.ADColorizer;
|
||||
import net.minecraft.util.FastColor;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public abstract class ColorProvider {
|
||||
/**
|
||||
* Implers, impl this function
|
||||
*/
|
||||
protected abstract int getRawColor(float time, Vec3 position);
|
||||
|
||||
private static final int[] MINIMUM_LUMINANCE_COLOR_WHEEL = {
|
||||
0xFF200000, 0xFF202000, 0xFF002000, 0xFF002020, 0xFF000020, 0xFF200020
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a color with a minimum luminance applied.
|
||||
*
|
||||
* @param time absolute world time in ticks
|
||||
* @param position a position for the icosahedron, a randomish number for particles.
|
||||
* @return an AARRGGBB color.
|
||||
*/
|
||||
public final int getColor(float time, Vec3 position) {
|
||||
int raw = this.getRawColor(time, position);
|
||||
|
||||
var r = FastColor.ARGB32.red(raw);
|
||||
var g = FastColor.ARGB32.green(raw);
|
||||
var b = FastColor.ARGB32.blue(raw);
|
||||
double luminance = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 0xFF; // Standard relative luminance calculation
|
||||
|
||||
if (luminance < 0.05) {
|
||||
int rawMod = ADColorizer.morphBetweenColors(MINIMUM_LUMINANCE_COLOR_WHEEL, new Vec3(0.1, 0.1, 0.1),
|
||||
time / 20 / 20, position);
|
||||
|
||||
r += FastColor.ARGB32.red(rawMod);
|
||||
g += FastColor.ARGB32.green(rawMod);
|
||||
b += FastColor.ARGB32.blue(rawMod);
|
||||
}
|
||||
|
||||
return 0xff_000000 | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
public static final ColorProvider MISSING = new ColorProvider() {
|
||||
@Override
|
||||
protected int getRawColor(float time, Vec3 position) {
|
||||
return 0xFF_ff00dc;
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package at.petrak.hexcasting.api.pigment;
|
||||
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A snapshot of a pigment item and its owner.
|
||||
* <p>
|
||||
* Due to capabilities being really slow to query many times a tick on Forge, this returns a colorizer <i>supplier</i>.
|
||||
* Get it once, and then query it a lot.
|
||||
*/
|
||||
public record FrozenPigment(ItemStack item, UUID owner) {
|
||||
|
||||
public static final String TAG_STACK = "stack";
|
||||
public static final String TAG_OWNER = "owner";
|
||||
|
||||
public static final Supplier<FrozenPigment> DEFAULT =
|
||||
() -> new FrozenPigment(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.WHITE)), Util.NIL_UUID);
|
||||
|
||||
public CompoundTag serializeToNBT() {
|
||||
var out = new CompoundTag();
|
||||
out.put(TAG_STACK, this.item.save(new CompoundTag()));
|
||||
out.putUUID(TAG_OWNER, this.owner);
|
||||
return out;
|
||||
}
|
||||
|
||||
public static FrozenPigment fromNBT(CompoundTag tag) {
|
||||
if (tag.isEmpty()) {
|
||||
return FrozenPigment.DEFAULT.get();
|
||||
}
|
||||
try {
|
||||
CompoundTag stackTag = tag.getCompound(TAG_STACK);
|
||||
var stack = ItemStack.of(stackTag);
|
||||
var uuid = tag.getUUID(TAG_OWNER);
|
||||
return new FrozenPigment(stack, uuid);
|
||||
} catch (NullPointerException exn) {
|
||||
return FrozenPigment.DEFAULT.get();
|
||||
}
|
||||
}
|
||||
|
||||
public ColorProvider getColorProvider() {
|
||||
return IXplatAbstractions.INSTANCE.getColorProvider(this);
|
||||
}
|
||||
}
|
|
@ -84,9 +84,10 @@ public class HexAdditionalRenderers {
|
|||
RenderSystem.lineWidth(5f);
|
||||
|
||||
var colorizer = IXplatAbstractions.INSTANCE.getColorizer(owner);
|
||||
var colProvider = colorizer.getColorProvider();
|
||||
BiConsumer<float[], float[]> v = (l, r) -> {
|
||||
int lcolor = colorizer.getColor(time, new Vec3(l[0], l[1], l[2])),
|
||||
rcolor = colorizer.getColor(time, new Vec3(r[0], r[1], r[2]));
|
||||
int lcolor = colProvider.getColor(time, new Vec3(l[0], l[1], l[2])),
|
||||
rcolor = colProvider.getColor(time, new Vec3(r[0], r[1], r[2]));
|
||||
var normal = new Vector3f(r[0] - l[0], r[1] - l[1], r[2] - l[2]);
|
||||
normal.normalize();
|
||||
buf.vertex(neo, l[0], l[1], l[2])
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.blocks;
|
||||
|
||||
import at.petrak.hexcasting.annotations.SoftImplement;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.common.blocks.entity.BlockEntityConjured;
|
||||
import at.petrak.hexcasting.xplat.IForgeLikeBlock;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -70,7 +70,7 @@ public class BlockConjured extends Block implements EntityBlock, IForgeLikeBlock
|
|||
return new BlockEntityConjured(pPos, pState);
|
||||
}
|
||||
|
||||
public static void setColor(LevelAccessor pLevel, BlockPos pPos, FrozenColorizer colorizer) {
|
||||
public static void setColor(LevelAccessor pLevel, BlockPos pPos, FrozenPigment colorizer) {
|
||||
BlockEntity blockentity = pLevel.getBlockEntity(pPos);
|
||||
if (blockentity instanceof BlockEntityConjured tile) {
|
||||
tile.setColorizer(colorizer);
|
||||
|
@ -114,13 +114,13 @@ public class BlockConjured extends Block implements EntityBlock, IForgeLikeBlock
|
|||
|
||||
@SoftImplement("forge")
|
||||
public boolean addLandingEffects(BlockState state1, ServerLevel worldserver, BlockPos pos, BlockState state2,
|
||||
LivingEntity entity, int numberOfParticles) {
|
||||
LivingEntity entity, int numberOfParticles) {
|
||||
return addLandingEffects(state1, worldserver, pos, entity, numberOfParticles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addLandingEffects(BlockState state, ServerLevel worldserver, BlockPos pos,
|
||||
LivingEntity entity, int numberOfParticles) {
|
||||
LivingEntity entity, int numberOfParticles) {
|
||||
BlockEntity tile = worldserver.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityConjured bec) {
|
||||
bec.landParticle(entity, numberOfParticles);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.blocks.entity;
|
||||
|
||||
import at.petrak.hexcasting.api.block.HexBlockEntity;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.common.blocks.BlockConjured;
|
||||
import at.petrak.hexcasting.common.blocks.BlockConjuredLight;
|
||||
import at.petrak.hexcasting.common.lib.HexBlockEntities;
|
||||
|
@ -16,7 +16,7 @@ import java.util.Random;
|
|||
|
||||
public class BlockEntityConjured extends HexBlockEntity {
|
||||
private static final Random RANDOM = new Random();
|
||||
private FrozenColorizer colorizer = FrozenColorizer.DEFAULT.get();
|
||||
private FrozenPigment colorizer = FrozenPigment.DEFAULT.get();
|
||||
|
||||
public static final String TAG_COLORIZER = "tag_colorizer";
|
||||
|
||||
|
@ -26,8 +26,9 @@ public class BlockEntityConjured extends HexBlockEntity {
|
|||
|
||||
public void walkParticle(Entity pEntity) {
|
||||
if (getBlockState().getBlock() instanceof BlockConjured conjured && !(conjured instanceof BlockConjuredLight)) {
|
||||
var colProvider = this.colorizer.getColorProvider();
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
int color = this.colorizer.getColor(pEntity.tickCount, pEntity.position()
|
||||
int color = colProvider.getColor(pEntity.tickCount, pEntity.position()
|
||||
.add(new Vec3(RANDOM.nextFloat(), RANDOM.nextFloat(), RANDOM.nextFloat()).scale(
|
||||
RANDOM.nextFloat() * 3)));
|
||||
assert level != null;
|
||||
|
@ -44,7 +45,7 @@ public class BlockEntityConjured extends HexBlockEntity {
|
|||
|
||||
public void particleEffect() {
|
||||
if (getBlockState().getBlock() instanceof BlockConjured) {
|
||||
int color = this.colorizer.getColor(RANDOM.nextFloat() * 16384,
|
||||
int color = this.colorizer.getColorProvider().getColor(RANDOM.nextFloat() * 16384,
|
||||
new Vec3(RANDOM.nextFloat(), RANDOM.nextFloat(), RANDOM.nextFloat()).scale(
|
||||
RANDOM.nextFloat() * 3));
|
||||
assert level != null;
|
||||
|
@ -73,8 +74,9 @@ public class BlockEntityConjured extends HexBlockEntity {
|
|||
}
|
||||
|
||||
public void landParticle(Entity entity, int number) {
|
||||
var colProvider = this.colorizer.getColorProvider();
|
||||
for (int i = 0; i < number * 2; i++) {
|
||||
int color = this.colorizer.getColor(entity.tickCount, entity.position()
|
||||
int color = colProvider.getColor(entity.tickCount, entity.position()
|
||||
.add(new Vec3(RANDOM.nextFloat(), RANDOM.nextFloat(), RANDOM.nextFloat()).scale(
|
||||
RANDOM.nextFloat() * 3)));
|
||||
assert level != null;
|
||||
|
@ -93,14 +95,14 @@ public class BlockEntityConjured extends HexBlockEntity {
|
|||
|
||||
@Override
|
||||
protected void loadModData(CompoundTag tag) {
|
||||
this.colorizer = FrozenColorizer.fromNBT(tag.getCompound(TAG_COLORIZER));
|
||||
this.colorizer = FrozenPigment.fromNBT(tag.getCompound(TAG_COLORIZER));
|
||||
}
|
||||
|
||||
public FrozenColorizer getColorizer() {
|
||||
public FrozenPigment getColorizer() {
|
||||
return this.colorizer;
|
||||
}
|
||||
|
||||
public void setColorizer(FrozenColorizer colorizer) {
|
||||
public void setColorizer(FrozenPigment colorizer) {
|
||||
this.colorizer = colorizer;
|
||||
this.sync();
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import at.petrak.hexcasting.api.casting.castables.SpellAction
|
|||
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.casting.mishaps.MishapBadOffhandItem
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.misc.MediaConstants
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions
|
||||
import net.minecraft.world.item.ItemStack
|
||||
|
||||
|
@ -39,10 +39,10 @@ object OpColorize : SpellAction {
|
|||
override fun cast(ctx: CastingEnvironment) {
|
||||
val copy = stack.copy()
|
||||
val caster = ctx.caster
|
||||
if (caster != null && ctx.withdrawItem(copy::equals, 1, true)) {
|
||||
if (caster != null && ctx.withdrawItem(copy::sameItem, 1, true)) {
|
||||
IXplatAbstractions.INSTANCE.setColorizer(
|
||||
ctx.caster,
|
||||
FrozenColorizer(copy, caster.uuid)
|
||||
FrozenPigment(copy, caster.uuid)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
|
|||
import at.petrak.hexcasting.api.casting.getPlayer
|
||||
import at.petrak.hexcasting.api.casting.getPositiveDouble
|
||||
import at.petrak.hexcasting.api.casting.iota.Iota
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer
|
||||
import at.petrak.hexcasting.api.misc.MediaConstants
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment
|
||||
import at.petrak.hexcasting.api.player.FlightAbility
|
||||
import at.petrak.hexcasting.common.lib.HexItems
|
||||
import at.petrak.hexcasting.common.lib.HexSounds
|
||||
|
@ -110,8 +110,8 @@ class OpFlight(val type: Type) : SpellAction {
|
|||
}
|
||||
player.level.playSound(null, player.x, player.y, player.z, HexSounds.FLIGHT_FINISH, SoundSource.PLAYERS, 2f, 1f)
|
||||
val superDangerSpray = ParticleSpray(player.position(), Vec3(0.0, 1.0, 0.0), Math.PI, 0.4, count = 20)
|
||||
superDangerSpray.sprayParticles(player.getLevel(), FrozenColorizer(ItemStack(HexItems.DYE_COLORIZERS[DyeColor.RED]!!), Util.NIL_UUID))
|
||||
superDangerSpray.sprayParticles(player.getLevel(), FrozenColorizer(ItemStack(HexItems.DYE_COLORIZERS[DyeColor.BLACK]!!), Util.NIL_UUID))
|
||||
superDangerSpray.sprayParticles(player.getLevel(), FrozenPigment(ItemStack(HexItems.DYE_COLORIZERS[DyeColor.RED]!!), Util.NIL_UUID))
|
||||
superDangerSpray.sprayParticles(player.getLevel(), FrozenPigment(ItemStack(HexItems.DYE_COLORIZERS[DyeColor.BLACK]!!), Util.NIL_UUID))
|
||||
} else {
|
||||
if (!player.abilities.mayfly) {
|
||||
player.abilities.mayfly = true
|
||||
|
@ -143,9 +143,9 @@ class OpFlight(val type: Type) : SpellAction {
|
|||
.sprayParticles(player.getLevel(), color)
|
||||
val dangerSpray = ParticleSpray(player.position(), Vec3(0.0, 1.0, 0.0), 0.3, Math.PI * 0.75, count = 0)
|
||||
dangerSpray.copy(count = oneDangerParticleCount)
|
||||
.sprayParticles(player.getLevel(), FrozenColorizer(ItemStack(HexItems.DYE_COLORIZERS[DyeColor.BLACK]!!), Util.NIL_UUID))
|
||||
.sprayParticles(player.getLevel(), FrozenPigment(ItemStack(HexItems.DYE_COLORIZERS[DyeColor.BLACK]!!), Util.NIL_UUID))
|
||||
dangerSpray.copy(count = oneDangerParticleCount)
|
||||
.sprayParticles(player.getLevel(), FrozenColorizer(ItemStack(HexItems.DYE_COLORIZERS[DyeColor.RED]!!), Util.NIL_UUID))
|
||||
.sprayParticles(player.getLevel(), FrozenPigment(ItemStack(HexItems.DYE_COLORIZERS[DyeColor.RED]!!), Util.NIL_UUID))
|
||||
|
||||
if (player.level.random.nextFloat() < 0.02)
|
||||
player.level.playSound(null, player.x, player.y, player.z, HexSounds.FLIGHT_AMBIENCE, SoundSource.PLAYERS, 0.2f, 1f)
|
||||
|
|
|
@ -2,7 +2,7 @@ package at.petrak.hexcasting.common.impl;
|
|||
|
||||
import at.petrak.hexcasting.api.HexAPI;
|
||||
import at.petrak.hexcasting.api.addldata.ADMediaHolder;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.api.player.Sentinel;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -85,7 +85,7 @@ public class HexAPIImpl implements HexAPI {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FrozenColorizer getColorizer(Player player) {
|
||||
public FrozenPigment getColorizer(Player player) {
|
||||
return IXplatAbstractions.INSTANCE.getColorizer(player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package at.petrak.hexcasting.common.items.colorizer;
|
||||
|
||||
import at.petrak.hexcasting.api.item.ColorizerItem;
|
||||
import at.petrak.hexcasting.api.pigment.ColorProvider;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -21,7 +22,16 @@ public class ItemDyeColorizer extends Item implements ColorizerItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int color(ItemStack stack, UUID owner, float time, Vec3 position) {
|
||||
return dyeColor.getTextColor();
|
||||
public ColorProvider provideColor(ItemStack stack, UUID owner) {
|
||||
return colorProvider;
|
||||
}
|
||||
|
||||
protected MyColorProvider colorProvider = new MyColorProvider();
|
||||
|
||||
protected class MyColorProvider extends ColorProvider {
|
||||
@Override
|
||||
protected int getRawColor(float time, Vec3 position) {
|
||||
return dyeColor.getTextColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,33 +2,42 @@ package at.petrak.hexcasting.common.items.colorizer;
|
|||
|
||||
import at.petrak.hexcasting.api.addldata.ADColorizer;
|
||||
import at.petrak.hexcasting.api.item.ColorizerItem;
|
||||
import net.minecraft.Util;
|
||||
import at.petrak.hexcasting.api.pigment.ColorProvider;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ItemPrideColorizer extends Item implements ColorizerItem {
|
||||
public enum Type {
|
||||
AGENDER,
|
||||
AROACE,
|
||||
AROMANTIC,
|
||||
ASEXUAL,
|
||||
BISEXUAL,
|
||||
DEMIBOY,
|
||||
DEMIGIRL,
|
||||
GAY,
|
||||
GENDERFLUID,
|
||||
GENDERQUEER,
|
||||
INTERSEX,
|
||||
LESBIAN,
|
||||
NONBINARY,
|
||||
PANSEXUAL,
|
||||
PLURAL,
|
||||
TRANSGENDER;
|
||||
AGENDER(new int[]{0x16a10c, 0xffffff, 0x7a8081, 0x302f30}),
|
||||
AROACE(new int[]{0x7210bc, 0xebf367, 0xffffff, 0x82dceb, 0x2f4dd8}),
|
||||
AROMANTIC(new int[]{0x16a10c, 0x82eb8b, 0xffffff, 0x7a8081, 0x302f30}),
|
||||
ASEXUAL(new int[]{0x333233, 0x9a9fa1, 0xffffff, 0x7210bc}),
|
||||
BISEXUAL(new int[]{0xdb45ff, 0x9c2bd0, 0x6894d4}),
|
||||
DEMIBOY(new int[]{0x9a9fa1, 0xa9ffff, 0xffffff}),
|
||||
DEMIGIRL(new int[]{0x9a9fa1, 0xfcb1ff, 0xffffff}),
|
||||
GAY(new int[]{0xd82f3a, 0xe0883f, 0xebf367, 0x2db418, 0x2f4dd8}),
|
||||
GENDERFLUID(new int[]{0xfbacf9, 0xffffff, 0x9c2bd0, 0x333233, 0x2f4dd8}),
|
||||
GENDERQUEER(new int[]{0xca78ef, 0xffffff, 0x2db418}),
|
||||
// how to do an intersex gradient escapes me
|
||||
INTERSEX(new int[]{0xebf367, 0x7210bc}),
|
||||
LESBIAN(new int[]{0xd82f3a, 0xefb87d, 0xffffff, 0xfbacf9, 0xa30262}),
|
||||
NONBINARY(new int[]{0xebf367, 0xffffff, 0x7210bc, 0x333233}),
|
||||
PANSEXUAL(new int[]{0xe278ef, 0xebf367, 0x6ac2e4}),
|
||||
PLURAL(new int[]{0x30c69f, 0x347ddf, 0x6b3fbe, 0x000000}),
|
||||
TRANSGENDER(new int[]{0xeb92ea, 0xffffff, 0x6ac2e4});
|
||||
|
||||
private final int[] colors;
|
||||
|
||||
private Type(int[] colors) {
|
||||
this.colors = colors;
|
||||
for (int i = 0; i < this.colors.length; i++) {
|
||||
this.colors[i] |= 0xFF_000000;
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name().toLowerCase(Locale.ROOT);
|
||||
|
@ -43,40 +52,16 @@ public class ItemPrideColorizer extends Item implements ColorizerItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int color(ItemStack stack, UUID owner, float time, Vec3 position) {
|
||||
return ADColorizer.morphBetweenColors(getColors(), new Vec3(0.1, 0.1, 0.1), time / 20 / 20, position);
|
||||
public ColorProvider provideColor(ItemStack stack, UUID owner) {
|
||||
return colorProvider;
|
||||
}
|
||||
|
||||
public int[] getColors() {
|
||||
return COLORS.get(this.type);
|
||||
}
|
||||
protected MyColorProvider colorProvider = new MyColorProvider();
|
||||
|
||||
private static final EnumMap<Type, int[]> COLORS = Util.make(() -> {
|
||||
var out = new EnumMap<Type, int[]>(Type.class);
|
||||
|
||||
out.put(Type.AGENDER, new int[]{0x16a10c, 0xffffff, 0x7a8081, 0x302f30});
|
||||
out.put(Type.AROACE, new int[]{0x7210bc, 0xebf367, 0xffffff, 0x82dceb, 0x2f4dd8});
|
||||
out.put(Type.AROMANTIC, new int[]{0x16a10c, 0x82eb8b, 0xffffff, 0x7a8081, 0x302f30});
|
||||
out.put(Type.ASEXUAL, new int[]{0x333233, 0x9a9fa1, 0xffffff, 0x7210bc});
|
||||
out.put(Type.BISEXUAL, new int[]{0xdb45ff, 0x9c2bd0, 0x6894d4});
|
||||
out.put(Type.DEMIBOY, new int[]{0x9a9fa1, 0xa9ffff, 0xffffff});
|
||||
out.put(Type.DEMIGIRL, new int[]{0x9a9fa1, 0xfcb1ff, 0xffffff});
|
||||
out.put(Type.GAY, new int[]{0xd82f3a, 0xe0883f, 0xebf367, 0x2db418, 0x2f4dd8});
|
||||
out.put(Type.GENDERFLUID, new int[]{0xfbacf9, 0xffffff, 0x9c2bd0, 0x333233, 0x2f4dd8});
|
||||
out.put(Type.GENDERQUEER, new int[]{0xca78ef, 0xffffff, 0x2db418});
|
||||
out.put(Type.INTERSEX, new int[]{0xebf367, 0x7210bc}); // how to do an intersex gradient escapes me
|
||||
out.put(Type.LESBIAN, new int[]{0xd82f3a, 0xefb87d, 0xffffff, 0xfbacf9, 0xa30262});
|
||||
out.put(Type.NONBINARY, new int[]{0xebf367, 0xffffff, 0x7210bc, 0x333233});
|
||||
out.put(Type.PANSEXUAL, new int[]{0xe278ef, 0xebf367, 0x6ac2e4});
|
||||
out.put(Type.PLURAL, new int[]{0x30c69f, 0x347ddf, 0x6b3fbe, 0x000000});
|
||||
out.put(Type.TRANSGENDER, new int[]{0xeb92ea, 0xffffff, 0x6ac2e4});
|
||||
|
||||
for (int[] color : out.values()) {
|
||||
for (int i = 0; i < color.length; i++) {
|
||||
color[i] |= 0xff_000000;
|
||||
}
|
||||
protected class MyColorProvider extends ColorProvider {
|
||||
@Override
|
||||
protected int getRawColor(float time, Vec3 position) {
|
||||
return ADColorizer.morphBetweenColors(type.colors, new Vec3(0.1, 0.1, 0.1), time / 400, position);
|
||||
}
|
||||
|
||||
return out;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,15 @@ package at.petrak.hexcasting.common.items.colorizer;
|
|||
|
||||
import at.petrak.hexcasting.api.addldata.ADColorizer;
|
||||
import at.petrak.hexcasting.api.item.ColorizerItem;
|
||||
import at.petrak.hexcasting.api.pigment.ColorProvider;
|
||||
import at.petrak.paucal.api.PaucalAPI;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -18,34 +20,54 @@ public class ItemUUIDColorizer extends Item implements ColorizerItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int color(ItemStack stack, UUID owner, float time, Vec3 position) {
|
||||
var contributor = PaucalAPI.instance().getContributor(owner);
|
||||
if (contributor != null) {
|
||||
List<?> colorList = contributor.get("hexcasting:colorizer");
|
||||
if (colorList != null) {
|
||||
var colors = new int[colorList.size()];
|
||||
var ok = true;
|
||||
for (int i = 0; i < colorList.size(); i++) {
|
||||
Object elt = colorList.get(i);
|
||||
if (elt instanceof Number n) {
|
||||
colors[i] = n.intValue() | 0xff_000000;
|
||||
} else {
|
||||
ok = false;
|
||||
break;
|
||||
public ColorProvider provideColor(ItemStack stack, UUID owner) {
|
||||
return new MyColorProvider(owner);
|
||||
}
|
||||
|
||||
protected static class MyColorProvider extends ColorProvider {
|
||||
private final int[] colors;
|
||||
|
||||
MyColorProvider(UUID owner) {
|
||||
var contributor = PaucalAPI.instance().getContributor(owner);
|
||||
if (contributor != null) {
|
||||
var colorList = contributor.otherVals().getAsJsonArray("hexcasting:colorizer");
|
||||
if (colorList != null) {
|
||||
var colors = new int[colorList.size()];
|
||||
var ok = true;
|
||||
for (int i = 0; i < colorList.size(); i++) {
|
||||
JsonElement elt = colorList.get(i);
|
||||
if (elt instanceof JsonPrimitive n && n.isNumber()) {
|
||||
colors[i] = n.getAsNumber().intValue() | 0xff_000000;
|
||||
} else {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
this.colors = colors;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
return ADColorizer.morphBetweenColors(colors, new Vec3(0.1, 0.1, 0.1), time / 20 / 20, position);
|
||||
}
|
||||
}
|
||||
|
||||
// randomly scrungle the bits
|
||||
var rand = new Random(owner.getLeastSignificantBits() ^ owner.getMostSignificantBits());
|
||||
var hue1 = rand.nextFloat();
|
||||
var saturation1 = rand.nextFloat(0.4f, 0.8f);
|
||||
var brightness1 = rand.nextFloat(0.7f, 1.0f);
|
||||
var hue2 = rand.nextFloat();
|
||||
var saturation2 = rand.nextFloat(0.7f, 1.0f);
|
||||
var brightness2 = rand.nextFloat(0.2f, 0.7f);
|
||||
|
||||
var col1 = Color.HSBtoRGB(hue1, saturation1, brightness1);
|
||||
var col2 = Color.HSBtoRGB(hue2, saturation2, brightness2);
|
||||
this.colors = new int[]{col1, col2};
|
||||
}
|
||||
|
||||
// randomly scrungle the bits
|
||||
var rand = new Random(owner.getLeastSignificantBits() ^ owner.getMostSignificantBits());
|
||||
var hue = rand.nextFloat();
|
||||
var saturation = rand.nextFloat(0.4f, 1.0f);
|
||||
var brightness = rand.nextFloat(0.5f, 1.0f);
|
||||
|
||||
return Color.HSBtoRGB(hue, saturation, brightness);
|
||||
@Override
|
||||
protected int getRawColor(float time, Vec3 position) {
|
||||
return ADColorizer.morphBetweenColors(this.colors, new Vec3(0.1, 0.1, 0.1), time / 400, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package at.petrak.hexcasting.common.network;
|
||||
|
||||
import at.petrak.hexcasting.api.casting.ParticleSpray;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.common.particles.ConjureParticleOptions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -17,7 +17,7 @@ import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
|||
/**
|
||||
* Sent server->client to spray particles everywhere.
|
||||
*/
|
||||
public record MsgCastParticleAck(ParticleSpray spray, FrozenColorizer colorizer) implements IMessage {
|
||||
public record MsgCastParticleAck(ParticleSpray spray, FrozenPigment colorizer) implements IMessage {
|
||||
public static final ResourceLocation ID = modLoc("cprtcl");
|
||||
|
||||
@Override
|
||||
|
@ -37,7 +37,7 @@ public record MsgCastParticleAck(ParticleSpray spray, FrozenColorizer colorizer)
|
|||
var spread = buf.readDouble();
|
||||
var count = buf.readInt();
|
||||
var tag = buf.readAnySizeNbt();
|
||||
var colorizer = FrozenColorizer.fromNBT(tag);
|
||||
var colorizer = FrozenPigment.fromNBT(tag);
|
||||
return new MsgCastParticleAck(
|
||||
new ParticleSpray(new Vec3(posX, posY, posZ), new Vec3(velX, velY, velZ), fuzziness, spread, count),
|
||||
colorizer);
|
||||
|
@ -71,9 +71,10 @@ public record MsgCastParticleAck(ParticleSpray spray, FrozenColorizer colorizer)
|
|||
Minecraft.getInstance().execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
var colProvider = msg.colorizer().getColorProvider();
|
||||
for (int i = 0; i < msg.spray().getCount(); i++) {
|
||||
// For the colors, pick any random time to get a mix of colors
|
||||
var color = msg.colorizer().getColor(RANDOM.nextFloat() * 256f, Vec3.ZERO);
|
||||
var color = colProvider.getColor(RANDOM.nextFloat() * 256f, Vec3.ZERO);
|
||||
|
||||
var offset = randomInCircle(Mth.TWO_PI).normalize()
|
||||
.scale(RANDOM.nextFloat() * msg.spray().getFuzziness() / 2);
|
||||
|
|
|
@ -11,7 +11,8 @@ import at.petrak.hexcasting.api.casting.eval.sideeffects.EvalSound;
|
|||
import at.petrak.hexcasting.api.casting.eval.vm.CastingImage;
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.CastingVM;
|
||||
import at.petrak.hexcasting.api.casting.iota.IotaType;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.ColorProvider;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.api.player.AltioraAbility;
|
||||
import at.petrak.hexcasting.api.player.FlightAbility;
|
||||
import at.petrak.hexcasting.api.player.Sentinel;
|
||||
|
@ -78,7 +79,7 @@ public interface IXplatAbstractions {
|
|||
|
||||
boolean isBrainswept(Mob mob);
|
||||
|
||||
void setColorizer(Player target, FrozenColorizer colorizer);
|
||||
void setColorizer(Player target, FrozenPigment colorizer);
|
||||
|
||||
void setSentinel(Player target, @Nullable Sentinel sentinel);
|
||||
|
||||
|
@ -94,7 +95,7 @@ public interface IXplatAbstractions {
|
|||
|
||||
@Nullable AltioraAbility getAltiora(Player player);
|
||||
|
||||
FrozenColorizer getColorizer(Player player);
|
||||
FrozenPigment getColorizer(Player player);
|
||||
|
||||
@Nullable Sentinel getSentinel(Player player);
|
||||
|
||||
|
@ -123,7 +124,7 @@ public interface IXplatAbstractions {
|
|||
|
||||
boolean isColorizer(ItemStack stack);
|
||||
|
||||
int getRawColor(FrozenColorizer colorizer, float time, Vec3 position);
|
||||
ColorProvider getColorProvider(FrozenPigment colorizer);
|
||||
|
||||
// Items
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.fabric.cc;
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import dev.onyxstudios.cca.api.v3.component.Component;
|
||||
import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -18,20 +18,20 @@ public class CCFavoredColorizer implements Component, AutoSyncedComponent {
|
|||
this.owner = owner;
|
||||
}
|
||||
|
||||
private FrozenColorizer colorizer = FrozenColorizer.DEFAULT.get();
|
||||
private FrozenPigment colorizer = FrozenPigment.DEFAULT.get();
|
||||
|
||||
public FrozenColorizer getColorizer() {
|
||||
public FrozenPigment getColorizer() {
|
||||
return colorizer;
|
||||
}
|
||||
|
||||
public void setColorizer(FrozenColorizer colorizer) {
|
||||
public void setColorizer(FrozenPigment colorizer) {
|
||||
this.colorizer = colorizer;
|
||||
HexCardinalComponents.FAVORED_COLORIZER.sync(this.owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNbt(CompoundTag tag) {
|
||||
this.colorizer = FrozenColorizer.fromNBT(tag.getCompound(TAG_COLORIZER));
|
||||
this.colorizer = FrozenPigment.fromNBT(tag.getCompound(TAG_COLORIZER));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,10 +2,10 @@ package at.petrak.hexcasting.fabric.cc.adimpl;
|
|||
|
||||
import at.petrak.hexcasting.api.addldata.ADColorizer;
|
||||
import at.petrak.hexcasting.api.item.ColorizerItem;
|
||||
import at.petrak.hexcasting.api.pigment.ColorProvider;
|
||||
import at.petrak.hexcasting.fabric.cc.HexCardinalComponents;
|
||||
import dev.onyxstudios.cca.api.v3.item.ItemComponent;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -30,8 +30,8 @@ public abstract class CCColorizer extends ItemComponent implements ADColorizer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int color(UUID owner, float time, Vec3 position) {
|
||||
return item.color(this.stack, owner, time, position);
|
||||
public ColorProvider provideColor(UUID owner) {
|
||||
return item.provideColor(this.stack, owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,9 +11,10 @@ import at.petrak.hexcasting.api.casting.eval.sideeffects.EvalSound;
|
|||
import at.petrak.hexcasting.api.casting.eval.vm.CastingImage;
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.CastingVM;
|
||||
import at.petrak.hexcasting.api.casting.iota.IotaType;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.mod.HexConfig;
|
||||
import at.petrak.hexcasting.api.mod.HexTags;
|
||||
import at.petrak.hexcasting.api.pigment.ColorProvider;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.api.player.AltioraAbility;
|
||||
import at.petrak.hexcasting.api.player.FlightAbility;
|
||||
import at.petrak.hexcasting.api.player.Sentinel;
|
||||
|
@ -142,7 +143,7 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setColorizer(Player target, FrozenColorizer colorizer) {
|
||||
public void setColorizer(Player target, FrozenPigment colorizer) {
|
||||
var cc = HexCardinalComponents.FAVORED_COLORIZER.get(target);
|
||||
cc.setColorizer(colorizer);
|
||||
}
|
||||
|
@ -194,7 +195,7 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FrozenColorizer getColorizer(Player player) {
|
||||
public FrozenPigment getColorizer(Player player) {
|
||||
var cc = HexCardinalComponents.FAVORED_COLORIZER.get(player);
|
||||
return cc.getColorizer();
|
||||
}
|
||||
|
@ -263,9 +264,9 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getRawColor(FrozenColorizer colorizer, float time, Vec3 position) {
|
||||
public ColorProvider getColorProvider(FrozenPigment colorizer) {
|
||||
var cc = HexCardinalComponents.COLORIZER.maybeGet(colorizer.item());
|
||||
return cc.map(col -> col.color(colorizer.owner(), time, position)).orElse(0xff_ff00dc);
|
||||
return cc.map(col -> col.provideColor(colorizer.owner())).orElse(ColorProvider.MISSING);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
"fabric": ">=0.64",
|
||||
"fabric-language-kotlin": ">=1.7.4+kotlin.1.6.21",
|
||||
"cardinal-components": "~5.0.0",
|
||||
"paucal": "0.5.x",
|
||||
"paucal": "0.6.x",
|
||||
"cloth-config": "8.2.x",
|
||||
"patchouli": ">=1.19.2-77"
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
forgeVersion=43.1.1
|
||||
forgeVersion=43.2.8
|
||||
|
||||
kotlinForForgeVersion=3.7.1
|
||||
|
||||
|
|
|
@ -2,15 +2,15 @@ package at.petrak.hexcasting.forge.cap.adimpl;
|
|||
|
||||
import at.petrak.hexcasting.api.addldata.ADColorizer;
|
||||
import at.petrak.hexcasting.api.item.ColorizerItem;
|
||||
import at.petrak.hexcasting.api.pigment.ColorProvider;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public record CapItemColorizer(ColorizerItem holder,
|
||||
ItemStack stack) implements ADColorizer {
|
||||
@Override
|
||||
public int color(UUID owner, float time, Vec3 position) {
|
||||
return holder.color(stack, owner, time, position);
|
||||
public ColorProvider provideColor(UUID owner) {
|
||||
return holder.provideColor(this.stack, owner);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package at.petrak.hexcasting.forge.network;
|
||||
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
@ -13,7 +13,7 @@ import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
|||
/**
|
||||
* Sent server->client to synchronize the status of the sentinel.
|
||||
*/
|
||||
public record MsgColorizerUpdateAck(FrozenColorizer update) implements IMessage {
|
||||
public record MsgColorizerUpdateAck(FrozenPigment update) implements IMessage {
|
||||
public static final ResourceLocation ID = modLoc("color");
|
||||
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@ public record MsgColorizerUpdateAck(FrozenColorizer update) implements IMessage
|
|||
var buf = new FriendlyByteBuf(buffer);
|
||||
|
||||
var tag = buf.readAnySizeNbt();
|
||||
var colorizer = FrozenColorizer.fromNBT(tag);
|
||||
var colorizer = FrozenPigment.fromNBT(tag);
|
||||
return new MsgColorizerUpdateAck(colorizer);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package at.petrak.hexcasting.forge.xplat;
|
||||
|
||||
import at.petrak.hexcasting.api.HexAPI;
|
||||
import at.petrak.hexcasting.api.addldata.ADColorizer;
|
||||
import at.petrak.hexcasting.api.addldata.ADHexHolder;
|
||||
import at.petrak.hexcasting.api.addldata.ADIotaHolder;
|
||||
import at.petrak.hexcasting.api.addldata.ADMediaHolder;
|
||||
|
@ -13,8 +12,9 @@ import at.petrak.hexcasting.api.casting.eval.sideeffects.EvalSound;
|
|||
import at.petrak.hexcasting.api.casting.eval.vm.CastingImage;
|
||||
import at.petrak.hexcasting.api.casting.eval.vm.CastingVM;
|
||||
import at.petrak.hexcasting.api.casting.iota.IotaType;
|
||||
import at.petrak.hexcasting.api.misc.FrozenColorizer;
|
||||
import at.petrak.hexcasting.api.mod.HexTags;
|
||||
import at.petrak.hexcasting.api.pigment.ColorProvider;
|
||||
import at.petrak.hexcasting.api.pigment.FrozenPigment;
|
||||
import at.petrak.hexcasting.api.player.AltioraAbility;
|
||||
import at.petrak.hexcasting.api.player.FlightAbility;
|
||||
import at.petrak.hexcasting.api.player.Sentinel;
|
||||
|
@ -179,7 +179,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setColorizer(Player player, FrozenColorizer colorizer) {
|
||||
public void setColorizer(Player player, FrozenPigment colorizer) {
|
||||
CompoundTag tag = player.getPersistentData();
|
||||
tag.put(TAG_COLOR, colorizer.serializeToNBT());
|
||||
|
||||
|
@ -253,8 +253,8 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FrozenColorizer getColorizer(Player player) {
|
||||
return FrozenColorizer.fromNBT(player.getPersistentData().getCompound(TAG_COLOR));
|
||||
public FrozenPigment getColorizer(Player player) {
|
||||
return FrozenPigment.fromNBT(player.getPersistentData().getCompound(TAG_COLOR));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -276,7 +276,8 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
public CastingVM getStaffcastVM(ServerPlayer player, InteractionHand hand) {
|
||||
// This is always from a staff because we don't need to load the harness when casting from item
|
||||
var ctx = new StaffCastEnv(player, hand);
|
||||
return new CastingVM(CastingImage.loadFromNbt(player.getPersistentData().getCompound(TAG_HARNESS), player.getLevel()), ctx);
|
||||
return new CastingVM(CastingImage.loadFromNbt(player.getPersistentData().getCompound(TAG_HARNESS),
|
||||
player.getLevel()), ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -336,14 +337,12 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getRawColor(FrozenColorizer colorizer, float time, Vec3 position) {
|
||||
public ColorProvider getColorProvider(FrozenPigment colorizer) {
|
||||
var maybeColorizer = colorizer.item().getCapability(HexCapabilities.COLOR).resolve();
|
||||
if (maybeColorizer.isPresent()) {
|
||||
ADColorizer col = maybeColorizer.get();
|
||||
return col.color(colorizer.owner(), time, position);
|
||||
return maybeColorizer.get().provideColor(colorizer.owner());
|
||||
}
|
||||
|
||||
return 0xff_ff00dc; // missing color
|
||||
return ColorProvider.MISSING;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,8 +17,8 @@ plugins {
|
|||
// Also it looks like property lookups don't work this early
|
||||
id 'fabric-loom' version '1.0-SNAPSHOT' apply false
|
||||
|
||||
id("at.petra-k.PKPlugin") version "0.1.0-pre-65"
|
||||
id("at.petra-k.PKSubprojPlugin") version "0.1.0-pre-65" apply false
|
||||
id("at.petra-k.PKPlugin") version "0.1.0-pre-80"
|
||||
id("at.petra-k.PKSubprojPlugin") version "0.1.0-pre-80" apply false
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
|
|
@ -12,8 +12,8 @@ minecraftVersion=1.19.2
|
|||
kotlinVersion=1.7.20
|
||||
modVersion=0.11.0
|
||||
|
||||
paucalVersion=0.5.0
|
||||
paucalVersion=0.6.0-pre-117
|
||||
patchouliVersion=77
|
||||
|
||||
jeiVersion=11.4.0.282
|
||||
pehkuiVersion=3.6.0
|
||||
pehkuiVersion=3.7.3
|
||||
|
|
Loading…
Reference in New Issue