Merge pull request #479 from Talia-12/main

Circles can store Pigments, some bugfixes
This commit is contained in:
petrak@ 2023-06-19 12:22:32 -04:00 committed by GitHub
commit 776b21cbc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 305 additions and 265 deletions

View file

@ -7,7 +7,7 @@ import net.minecraft.world.phys.Vec3;
import java.util.UUID;
public interface ADColorizer {
public interface ADPigment {
ColorProvider provideColor(UUID owner);
static int morphBetweenColors(int[] colors, Vec3 gradientDir, float time, Vec3 position) {

View file

@ -3,6 +3,7 @@ package at.petrak.hexcasting.api.casting.circles;
import at.petrak.hexcasting.api.block.HexBlockEntity;
import at.petrak.hexcasting.api.block.circle.BlockCircleComponent;
import at.petrak.hexcasting.api.misc.MediaConstants;
import at.petrak.hexcasting.api.pigment.FrozenPigment;
import at.petrak.hexcasting.api.utils.MediaHelper;
import at.petrak.hexcasting.common.items.magic.ItemCreativeUnlocker;
import at.petrak.hexcasting.common.lib.HexItems;
@ -47,7 +48,8 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
TAG_EXECUTION_STATE = "executor",
TAG_MEDIA = "media",
TAG_ERROR_MSG = "errorMsg",
TAG_ERROR_DISPLAY = "errorDisplay";
TAG_ERROR_DISPLAY = "errorDisplay",
TAG_PIGMENT = "pigment";
// We might try to load the executor in loadModData when the level doesn't exist yet,
// so save the tag and load it lazy
@ -62,6 +64,8 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
protected Component displayMsg = null;
@Nullable
protected ItemStack displayItem = null;
@Nullable
protected FrozenPigment pigment = null;
public BlockEntityAbstractImpetus(BlockEntityType<?> pType, BlockPos pWorldPosition, BlockState pBlockState) {
@ -228,6 +232,7 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
public void setMedia(long media) {
this.media = media;
sync();
}
public long extractMediaFromInsertedItem(ItemStack stack, boolean simulate) {
@ -264,6 +269,20 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
//endregion
public FrozenPigment getPigment() {
if (pigment != null)
return pigment;
if (executionState != null && executionState.casterPigment != null)
return executionState.casterPigment;
return FrozenPigment.DEFAULT.get();
}
public @Nullable FrozenPigment setPigment(@Nullable FrozenPigment pigment) {
this.pigment = pigment;
return this.pigment;
}
@Override
protected void saveModData(CompoundTag tag) {
if (this.executionState != null) {
@ -278,6 +297,8 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
this.displayItem.save(itemTag);
tag.put(TAG_ERROR_DISPLAY, itemTag);
}
if (this.pigment != null)
tag.put(TAG_PIGMENT, this.pigment.serializeToNBT());
}
@Override
@ -302,6 +323,8 @@ public abstract class BlockEntityAbstractImpetus extends HexBlockEntity implemen
this.displayMsg = null;
this.displayItem = null;
}
if (tag.contains(TAG_PIGMENT, Tag.TAG_COMPOUND))
this.pigment = FrozenPigment.fromNBT(tag.getCompound(TAG_PIGMENT));
}
public void applyScryingLensOverlay(List<Pair<ItemStack, Component>> lines,

View file

@ -37,7 +37,7 @@ public class CircleExecutionState {
TAG_ENTERED_FROM = "entered_from",
TAG_IMAGE = "image",
TAG_CASTER = "caster",
TAG_COLORIZER = "colorizer";
TAG_PIGMENT = "pigment";
public final BlockPos impetusPos;
public final Direction impetusDir;
@ -48,14 +48,14 @@ public class CircleExecutionState {
public Direction enteredFrom;
public CastingImage currentImage;
public @Nullable UUID caster;
public FrozenPigment colorizer;
public @Nullable FrozenPigment casterPigment;
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, FrozenPigment colorizer) {
CastingImage currentImage, @Nullable UUID caster, @Nullable FrozenPigment casterPigment) {
this.impetusPos = impetusPos;
this.impetusDir = impetusDir;
this.knownPositions = knownPositions;
@ -64,7 +64,7 @@ public class CircleExecutionState {
this.enteredFrom = enteredFrom;
this.currentImage = currentImage;
this.caster = caster;
this.colorizer = colorizer;
this.casterPigment = casterPigment;
this.bounds = BlockEntityAbstractImpetus.getBounds(new ArrayList<>(this.knownPositions));
}
@ -133,10 +133,9 @@ public class CircleExecutionState {
reachedPositions.add(impetus.getBlockPos());
var start = seenGoodPositions.get(0);
FrozenPigment colorizer;
FrozenPigment colorizer = null;
UUID casterUUID;
if (caster == null) {
colorizer = FrozenPigment.DEFAULT.get();
casterUUID = null;
} else {
colorizer = HexAPI.instance().getColorizer(caster);
@ -172,7 +171,8 @@ public class CircleExecutionState {
if (this.caster != null)
out.putUUID(TAG_CASTER, this.caster);
out.put(TAG_COLORIZER, this.colorizer.serializeToNBT());
if (this.casterPigment != null)
out.put(TAG_PIGMENT, this.casterPigment.serializeToNBT());
return out;
}
@ -200,10 +200,12 @@ public class CircleExecutionState {
if (nbt.hasUUID(TAG_CASTER))
caster = nbt.getUUID(TAG_CASTER);
FrozenPigment colorizer = FrozenPigment.fromNBT(nbt.getCompound(TAG_COLORIZER));
FrozenPigment pigment = null;
if (nbt.contains(TAG_PIGMENT, Tag.TAG_COMPOUND))
pigment = FrozenPigment.fromNBT(nbt.getCompound(TAG_PIGMENT));
return new CircleExecutionState(startPos, startDir, knownPositions, reachedPositions, currentPos,
enteredFrom, image, caster, colorizer);
enteredFrom, image, caster, pigment);
}
/**

View file

@ -104,9 +104,9 @@ public interface ICircleComponent {
activator = impetus.getExecutionState().caster;
if (impetus == null || impetus.getExecutionState() == null)
colorizer = new FrozenPigment(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.RED)), activator);
colorizer = new FrozenPigment(new ItemStack(HexItems.DYE_PIGMENTS.get(DyeColor.RED)), activator);
else
colorizer = impetus.getExecutionState().colorizer;
colorizer = impetus.getPigment();
if (bs.getBlock() instanceof BlockCircleComponent bcc) {
var outDir = bcc.normalDir(pos, bs, world);
@ -123,7 +123,7 @@ public interface ICircleComponent {
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);
spray.sprayParticles(serverLevel,
success ? colorizer : new FrozenPigment(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.RED)),
success ? colorizer : new FrozenPigment(new ItemStack(HexItems.DYE_PIGMENTS.get(DyeColor.RED)),
activator));
}

View file

@ -289,7 +289,9 @@ public abstract class CastingEnvironment {
EXTRACTION,
}
public abstract FrozenPigment getColorizer();
public abstract FrozenPigment getPigment();
public abstract @Nullable FrozenPigment setPigment(@Nullable FrozenPigment pigment);
public abstract void produceParticles(ParticleSpray particles, FrozenPigment colorizer);

View file

@ -9,8 +9,6 @@ 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.pigment.FrozenPigment;
import at.petrak.hexcasting.common.lib.HexItems;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
@ -146,28 +144,24 @@ public class CircleCastEnv extends CastingEnvironment {
}
@Override
public FrozenPigment getColorizer() {
var out = this.getColorizerFromImpetus();
if (out != null)
return out;
// TODO: colouriser from an adjacent inventory also?
return new FrozenPigment(new ItemStack(HexItems.DYE_COLORIZERS.get(DyeColor.PURPLE)), Util.NIL_UUID);
}
private @Nullable FrozenPigment getColorizerFromImpetus() {
public FrozenPigment getPigment() {
var impetus = this.getImpetus();
if (impetus == null)
return null;
var state = impetus.getExecutionState();
if (state == null)
return null;
return state.colorizer;
return FrozenPigment.DEFAULT.get();
return impetus.getPigment();
}
@Override
public void produceParticles(ParticleSpray particles, FrozenPigment colorizer) {
particles.sprayParticles(this.world, colorizer);
public @Nullable FrozenPigment setPigment(@Nullable FrozenPigment pigment) {
var impetus = this.getImpetus();
if (impetus == null)
return null;
return impetus.setPigment(pigment);
}
@Override
public void produceParticles(ParticleSpray particles, FrozenPigment pigment) {
particles.sprayParticles(this.world, pigment);
}
@Override

View file

@ -53,7 +53,7 @@ public class PackagedItemCastEnv extends PlayerBasedCastEnv {
}
@Override
public FrozenPigment getColorizer() {
public FrozenPigment getPigment() {
var casterStack = this.caster.getItemInHand(this.castingHand);
var casterHexHolder = IXplatAbstractions.INSTANCE.findHexHolder(casterStack);
return casterHexHolder.getPigment();

View file

@ -15,6 +15,7 @@ import at.petrak.hexcasting.api.mod.HexStatistics;
import at.petrak.hexcasting.api.pigment.FrozenPigment;
import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.api.utils.MediaHelper;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
@ -188,6 +189,11 @@ public abstract class PlayerBasedCastEnv extends CastingEnvironment {
return advs.getOrStartProgress(adv).isDone();
}
@Override
public @Nullable FrozenPigment setPigment(@Nullable FrozenPigment pigment) {
return IXplatAbstractions.INSTANCE.setPigment(caster, pigment);
}
@Override
public void produceParticles(ParticleSpray particles, FrozenPigment colorizer) {
particles.sprayParticles(this.world, colorizer);

View file

@ -63,7 +63,7 @@ public class StaffCastEnv extends PlayerBasedCastEnv {
}
@Override
public FrozenPigment getColorizer() {
public FrozenPigment getPigment() {
return HexAPI.instance().getColorizer(this.caster);
}
@ -115,7 +115,7 @@ public class StaffCastEnv extends PlayerBasedCastEnv {
// 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));
.sprayParticles(sender.getLevel(), IXplatAbstractions.INSTANCE.getPigment(sender));
}
}
}

View file

@ -56,7 +56,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)
harness.env.produceParticles(this.spray, harness.env.pigment)
// this.spray.sprayParticles(harness.env.world, harness.env.colorizer)
return false
@ -71,7 +71,7 @@ sealed class OperatorSideEffect {
spray.sprayParticles(
harness.env.world,
FrozenPigment(
ItemStack(HexItems.DYE_COLORIZERS[DyeColor.RED]!!),
ItemStack(HexItems.DYE_PIGMENTS[DyeColor.RED]!!),
Util.NIL_UUID
)
)

View file

@ -61,7 +61,7 @@ abstract class Mishap : Throwable() {
protected fun dyeColor(color: DyeColor): FrozenPigment =
FrozenPigment(
ItemStack(HexItems.DYE_COLORIZERS[color]!!),
ItemStack(HexItems.DYE_PIGMENTS[color]!!),
Util.NIL_UUID
)

View file

@ -16,7 +16,7 @@ class MishapOthersName(val confidant: Player) : Mishap() {
dyeColor(DyeColor.BLACK)
override fun execute(ctx: CastingEnvironment, errorCtx: Context, stack: MutableList<Iota>) {
val seconds = if (this.confidant == ctx.caster) 5 else 60;
val seconds = if (this.confidant == ctx.caster) 5 else 60
ctx.mishapEnvironment.blind(seconds * 20)
}
@ -49,7 +49,7 @@ class MishapOthersName(val confidant: Player) : Mishap() {
}
@JvmStatic
fun getTrueNameFromArgs(datums: List<Iota>, caster: Player): Player? {
fun getTrueNameFromArgs(datums: List<Iota>, caster: Player?): Player? {
return datums.firstNotNullOfOrNull { getTrueNameFromDatum(it, caster) }
}
}

View file

@ -13,6 +13,6 @@ import java.util.UUID;
* and the appropriate cap/CC will be attached.
*/
@ApiStatus.OverrideOnly
public interface ColorizerItem {
public interface PigmentItem {
ColorProvider provideColor(ItemStack stack, UUID owner);
}

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.api.pigment;
import at.petrak.hexcasting.api.addldata.ADColorizer;
import at.petrak.hexcasting.api.addldata.ADPigment;
import net.minecraft.util.FastColor;
import net.minecraft.world.phys.Vec3;
@ -30,7 +30,7 @@ public abstract class ColorProvider {
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),
int rawMod = ADPigment.morphBetweenColors(MINIMUM_LUMINANCE_COLOR_WHEEL, new Vec3(0.1, 0.1, 0.1),
time / 20 / 20, position);
r += FastColor.ARGB32.red(rawMod);

View file

@ -21,7 +21,7 @@ public record FrozenPigment(ItemStack item, UUID owner) {
public static final String TAG_OWNER = "owner";
public static final Supplier<FrozenPigment> DEFAULT =
() -> new FrozenPigment(new ItemStack(HexItems.DEFAULT_COLORIZER), Util.NIL_UUID);
() -> new FrozenPigment(new ItemStack(HexItems.DEFAULT_PIGMENT), Util.NIL_UUID);
public CompoundTag serializeToNBT() {
var out = new CompoundTag();

View file

@ -83,7 +83,7 @@ public class HexAdditionalRenderers {
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.lineWidth(5f);
var colorizer = IXplatAbstractions.INSTANCE.getColorizer(owner);
var colorizer = IXplatAbstractions.INSTANCE.getPigment(owner);
var colProvider = colorizer.getColorProvider();
BiConsumer<float[], float[]> v = (l, r) -> {
int lcolor = colProvider.getColor(time, new Vec3(l[0], l[1], l[2])),

View file

@ -8,6 +8,7 @@ import at.petrak.hexcasting.api.casting.mishaps.MishapBadOffhandItem
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.pigment.FrozenPigment
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.Util
import net.minecraft.world.item.ItemStack
object OpColorize : SpellAction {
@ -17,10 +18,10 @@ object OpColorize : SpellAction {
args: List<Iota>,
ctx: CastingEnvironment
): SpellAction.Result {
val (handStack, hand) = ctx.getHeldItemToOperateOn(IXplatAbstractions.INSTANCE::isColorizer)
val (handStack, hand) = ctx.getHeldItemToOperateOn(IXplatAbstractions.INSTANCE::isPigment)
?: throw MishapBadOffhandItem.of(ItemStack.EMPTY, null, "colorizer") // TODO: hack
if (!IXplatAbstractions.INSTANCE.isColorizer(handStack)) {
if (!IXplatAbstractions.INSTANCE.isPigment(handStack)) {
throw MishapBadOffhandItem.of(
handStack,
hand,
@ -38,13 +39,8 @@ object OpColorize : SpellAction {
private data class Spell(val stack: ItemStack) : RenderedSpell {
override fun cast(ctx: CastingEnvironment) {
val copy = stack.copy()
val caster = ctx.caster
if (caster != null && ctx.withdrawItem(copy::sameItem, 1, true)) {
IXplatAbstractions.INSTANCE.setColorizer(
ctx.caster,
FrozenPigment(copy, caster.uuid)
)
}
if (ctx.withdrawItem(copy::sameItem, 1, true))
ctx.setPigment(FrozenPigment(copy, ctx.caster?.uuid ?: Util.NIL_UUID))
}
}
}

View file

@ -51,17 +51,17 @@ class OpConjureBlock(val light: Boolean) : SpellAction {
if (worldState.canBeReplaced(placeContext)) {
val block = if (this.light) HexBlocks.CONJURED_LIGHT else HexBlocks.CONJURED_BLOCK
if (ctx.caster != null && !IXplatAbstractions.INSTANCE.isPlacingAllowed(ctx.world, pos, ItemStack(block), ctx.caster))
if (!IXplatAbstractions.INSTANCE.isPlacingAllowed(ctx.world, pos, ItemStack(block), ctx.caster))
return
val state = block.getStateForPlacement(placeContext)
if (state != null) {
ctx.world.setBlock(pos, state, 5)
val colorizer = ctx.colorizer
val pigment = ctx.pigment
if (ctx.world.getBlockState(pos).block is BlockConjured) {
BlockConjured.setColor(ctx.world, pos, colorizer)
BlockConjured.setColor(ctx.world, pos, pigment)
}
}
}

View file

@ -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(), FrozenPigment(ItemStack(HexItems.DYE_COLORIZERS[DyeColor.RED]!!), Util.NIL_UUID))
superDangerSpray.sprayParticles(player.getLevel(), FrozenPigment(ItemStack(HexItems.DYE_COLORIZERS[DyeColor.BLACK]!!), Util.NIL_UUID))
superDangerSpray.sprayParticles(player.getLevel(), FrozenPigment(ItemStack(HexItems.DYE_PIGMENTS[DyeColor.RED]!!), Util.NIL_UUID))
superDangerSpray.sprayParticles(player.getLevel(), FrozenPigment(ItemStack(HexItems.DYE_PIGMENTS[DyeColor.BLACK]!!), Util.NIL_UUID))
} else {
if (!player.abilities.mayfly) {
player.abilities.mayfly = true
@ -136,16 +136,16 @@ class OpFlight(val type: Type) : SpellAction {
val dangerParticleCount = (particleCount * danger).roundToInt()
val okParticleCount = particleCount - dangerParticleCount
val oneDangerParticleCount = Mth.ceil(dangerParticleCount / 2.0)
val color = IXplatAbstractions.INSTANCE.getColorizer(player)
val color = IXplatAbstractions.INSTANCE.getPigment(player)
// TODO: have the particles go in the opposite direction of the velocity?
ParticleSpray(player.position(), Vec3(0.0, -0.6, 0.0), 0.6, Math.PI * 0.3, count = okParticleCount)
.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(), FrozenPigment(ItemStack(HexItems.DYE_COLORIZERS[DyeColor.BLACK]!!), Util.NIL_UUID))
.sprayParticles(player.getLevel(), FrozenPigment(ItemStack(HexItems.DYE_PIGMENTS[DyeColor.BLACK]!!), Util.NIL_UUID))
dangerSpray.copy(count = oneDangerParticleCount)
.sprayParticles(player.getLevel(), FrozenPigment(ItemStack(HexItems.DYE_COLORIZERS[DyeColor.RED]!!), Util.NIL_UUID))
.sprayParticles(player.getLevel(), FrozenPigment(ItemStack(HexItems.DYE_PIGMENTS[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)

View file

@ -53,7 +53,7 @@ class OpMakePackagedSpell<T : ItemPackagedHex>(val itemType: T, val cost: Int) :
)
}
val trueName = ctx.caster?.let { MishapOthersName.getTrueNameFromArgs(patterns, it) }
val trueName = MishapOthersName.getTrueNameFromArgs(patterns, ctx.caster)
if (trueName != null)
throw MishapOthersName(trueName)
@ -74,7 +74,7 @@ class OpMakePackagedSpell<T : ItemPackagedHex>(val itemType: T, val cost: Int) :
val entityStack = itemEntity.item.copy()
val mediamount = extractMedia(entityStack, drainForBatteries = true)
if (mediamount > 0) {
hexHolder.writeHex(patterns, ctx.colorizer, mediamount)
hexHolder.writeHex(patterns, ctx.pigment, mediamount)
}
itemEntity.item = entityStack

View file

@ -35,14 +35,9 @@ object OpTheOnlyReasonAnyoneDownloadedPsi : SpellAction {
private data class Spell(val pos: BlockPos) : RenderedSpell {
override fun cast(ctx: CastingEnvironment) {
val caster = ctx.caster ?: return // TODO: fix!
// https://github.com/VazkiiMods/Psi/blob/master/src/main/java/vazkii/psi/common/spell/trick/PieceTrickOvergrow.java
val hit = BlockHitResult(Vec3.ZERO, Direction.UP, pos, false)
val save: ItemStack = caster.getItemInHand(InteractionHand.MAIN_HAND)
caster.setItemInHand(InteractionHand.MAIN_HAND, ItemStack(Items.BONE_MEAL))
val fakeContext = UseOnContext(caster, InteractionHand.MAIN_HAND, hit)
caster.setItemInHand(InteractionHand.MAIN_HAND, save)
val fakeContext = UseOnContext(ctx.world, ctx.caster, InteractionHand.MAIN_HAND, ItemStack(Items.BONE_MEAL), hit)
Items.BONE_MEAL.useOn(fakeContext)
}
}

View file

@ -58,7 +58,7 @@ object OpAltiora : SpellAction {
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)
val color = IXplatAbstractions.INSTANCE.getColorizer(player)
val color = IXplatAbstractions.INSTANCE.getPigment(player)
ParticleSpray(player.position(), Vec3(0.0, -0.2, 0.0), 0.4, Math.PI * 0.5, count = 3)
.sprayParticles(player.getLevel(), color)
}

View file

@ -92,7 +92,7 @@ public class HexAPIImpl implements HexAPI {
@Override
public FrozenPigment getColorizer(Player player) {
return IXplatAbstractions.INSTANCE.getColorizer(player);
return IXplatAbstractions.INSTANCE.getPigment(player);
}
ArmorMaterial ARMOR_MATERIAL = new ArmorMaterial() {

View file

@ -144,7 +144,7 @@ public abstract class ItemPackagedHex extends ItemMediaHolder implements HexHold
// Somehow we lost spraying particles on each new pattern, so do it here
// this also nicely prevents particle spam on trinkets
new ParticleSpray(player.position(), new Vec3(0.0, 1.5, 0.0), 0.4, Math.PI / 3, 30)
.sprayParticles(sPlayer.getLevel(), ctx.getColorizer());
.sprayParticles(sPlayer.getLevel(), ctx.getPigment());
}
var sound = ctx.getSound().sound();

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.items.colorizer;
package at.petrak.hexcasting.common.items.pigment;
import at.petrak.hexcasting.api.addldata.ADColorizer;
import at.petrak.hexcasting.api.item.ColorizerItem;
import at.petrak.hexcasting.api.addldata.ADPigment;
import at.petrak.hexcasting.api.item.PigmentItem;
import at.petrak.hexcasting.api.pigment.ColorProvider;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@ -9,8 +9,8 @@ import net.minecraft.world.phys.Vec3;
import java.util.UUID;
public class ItemAmethystAndCopperColorizer extends Item implements ColorizerItem {
public ItemAmethystAndCopperColorizer(Properties pProperties) {
public class ItemAmethystAndCopperPigment extends Item implements PigmentItem {
public ItemAmethystAndCopperPigment(Properties pProperties) {
super(pProperties);
}
@ -32,7 +32,7 @@ public class ItemAmethystAndCopperColorizer extends Item implements ColorizerIte
@Override
protected int getRawColor(float time, Vec3 position) {
return ADColorizer.morphBetweenColors(COLORS, new Vec3(0.1, 0.1, 0.1), time / 600, position);
return ADPigment.morphBetweenColors(COLORS, new Vec3(0.1, 0.1, 0.1), time / 600, position);
}
}
}

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.common.items.colorizer;
package at.petrak.hexcasting.common.items.pigment;
import at.petrak.hexcasting.api.item.ColorizerItem;
import at.petrak.hexcasting.api.item.PigmentItem;
import at.petrak.hexcasting.api.pigment.ColorProvider;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
@ -9,10 +9,10 @@ import net.minecraft.world.phys.Vec3;
import java.util.UUID;
public class ItemDyeColorizer extends Item implements ColorizerItem {
public class ItemDyePigment extends Item implements PigmentItem {
private final DyeColor dyeColor;
public ItemDyeColorizer(DyeColor dyeColor, Properties pProperties) {
public ItemDyePigment(DyeColor dyeColor, Properties pProperties) {
super(pProperties);
this.dyeColor = dyeColor;
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.items.colorizer;
package at.petrak.hexcasting.common.items.pigment;
import at.petrak.hexcasting.api.addldata.ADColorizer;
import at.petrak.hexcasting.api.item.ColorizerItem;
import at.petrak.hexcasting.api.addldata.ADPigment;
import at.petrak.hexcasting.api.item.PigmentItem;
import at.petrak.hexcasting.api.pigment.ColorProvider;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3;
import java.util.Locale;
import java.util.UUID;
public class ItemPrideColorizer extends Item implements ColorizerItem {
public class ItemPridePigment extends Item implements PigmentItem {
public enum Type {
AGENDER(new int[]{0x16a10c, 0xffffff, 0x7a8081, 0x302f30}),
AROACE(new int[]{0x7210bc, 0xebf367, 0xffffff, 0x82dceb, 0x2f4dd8}),
@ -20,6 +20,7 @@ public class ItemPrideColorizer extends Item implements ColorizerItem {
DEMIBOY(new int[]{0x9a9fa1, 0xa9ffff, 0xffffff}),
DEMIGIRL(new int[]{0x9a9fa1, 0xfcb1ff, 0xffffff}),
GAY(new int[]{0xd82f3a, 0xe0883f, 0xebf367, 0x2db418, 0x2f4dd8}),
// ACHILLEAN(new int[]{0x028d6e, 0x22cdad, 0xffffff, 0xe49c7, 0x4f4aca}),
GENDERFLUID(new int[]{0xfbacf9, 0xffffff, 0x9c2bd0, 0x333233, 0x2f4dd8}),
GENDERQUEER(new int[]{0xca78ef, 0xffffff, 0x2db418}),
// how to do an intersex gradient escapes me
@ -32,7 +33,7 @@ public class ItemPrideColorizer extends Item implements ColorizerItem {
private final int[] colors;
private Type(int[] colors) {
Type(int[] colors) {
this.colors = colors;
for (int i = 0; i < this.colors.length; i++) {
this.colors[i] |= 0xFF_000000;
@ -46,7 +47,7 @@ public class ItemPrideColorizer extends Item implements ColorizerItem {
public final Type type;
public ItemPrideColorizer(Type type, Properties pProperties) {
public ItemPridePigment(Type type, Properties pProperties) {
super(pProperties);
this.type = type;
}
@ -61,7 +62,7 @@ public class ItemPrideColorizer extends Item implements ColorizerItem {
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 ADPigment.morphBetweenColors(type.colors, new Vec3(0.1, 0.1, 0.1), time / 400, position);
}
}
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.items.colorizer;
package at.petrak.hexcasting.common.items.pigment;
import at.petrak.hexcasting.api.addldata.ADColorizer;
import at.petrak.hexcasting.api.item.ColorizerItem;
import at.petrak.hexcasting.api.addldata.ADPigment;
import at.petrak.hexcasting.api.item.PigmentItem;
import at.petrak.hexcasting.api.pigment.ColorProvider;
import at.petrak.paucal.api.PaucalAPI;
import com.google.gson.JsonElement;
@ -14,8 +14,8 @@ import java.awt.*;
import java.util.Random;
import java.util.UUID;
public class ItemUUIDColorizer extends Item implements ColorizerItem {
public ItemUUIDColorizer(Properties pProperties) {
public class ItemUUIDPigment extends Item implements PigmentItem {
public ItemUUIDPigment(Properties pProperties) {
super(pProperties);
}
@ -67,7 +67,7 @@ public class ItemUUIDColorizer extends Item implements ColorizerItem {
@Override
protected int getRawColor(float time, Vec3 position) {
return ADColorizer.morphBetweenColors(this.colors, new Vec3(0.1, 0.1, 0.1), time / 400, position);
return ADPigment.morphBetweenColors(this.colors, new Vec3(0.1, 0.1, 0.1), time / 400, position);
}
}
}

View file

@ -4,10 +4,10 @@ import at.petrak.hexcasting.common.items.ItemJewelerHammer;
import at.petrak.hexcasting.common.items.ItemLens;
import at.petrak.hexcasting.common.items.ItemLoreFragment;
import at.petrak.hexcasting.common.items.ItemStaff;
import at.petrak.hexcasting.common.items.colorizer.ItemAmethystAndCopperColorizer;
import at.petrak.hexcasting.common.items.colorizer.ItemDyeColorizer;
import at.petrak.hexcasting.common.items.colorizer.ItemPrideColorizer;
import at.petrak.hexcasting.common.items.colorizer.ItemUUIDColorizer;
import at.petrak.hexcasting.common.items.pigment.ItemAmethystAndCopperPigment;
import at.petrak.hexcasting.common.items.pigment.ItemDyePigment;
import at.petrak.hexcasting.common.items.pigment.ItemPridePigment;
import at.petrak.hexcasting.common.items.pigment.ItemUUIDPigment;
import at.petrak.hexcasting.common.items.magic.*;
import at.petrak.hexcasting.common.items.storage.*;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
@ -79,25 +79,25 @@ public class HexItems {
public static final ItemMediaBattery BATTERY = make("battery",
new ItemMediaBattery(unstackable()));
public static final EnumMap<DyeColor, ItemDyeColorizer> DYE_COLORIZERS = Util.make(() -> {
var out = new EnumMap<DyeColor, ItemDyeColorizer>(DyeColor.class);
public static final EnumMap<DyeColor, ItemDyePigment> DYE_PIGMENTS = Util.make(() -> {
var out = new EnumMap<DyeColor, ItemDyePigment>(DyeColor.class);
for (var dye : DyeColor.values()) {
out.put(dye, make("dye_colorizer_" + dye.getName(), new ItemDyeColorizer(dye, unstackable())));
out.put(dye, make("dye_colorizer_" + dye.getName(), new ItemDyePigment(dye, unstackable())));
}
return out;
});
public static final EnumMap<ItemPrideColorizer.Type, ItemPrideColorizer> PRIDE_COLORIZERS = Util.make(() -> {
var out = new EnumMap<ItemPrideColorizer.Type, ItemPrideColorizer>(ItemPrideColorizer.Type.class);
for (var politicsInMyVidya : ItemPrideColorizer.Type.values()) {
public static final EnumMap<ItemPridePigment.Type, ItemPridePigment> PRIDE_PIGMENTS = Util.make(() -> {
var out = new EnumMap<ItemPridePigment.Type, ItemPridePigment>(ItemPridePigment.Type.class);
for (var politicsInMyVidya : ItemPridePigment.Type.values()) {
out.put(politicsInMyVidya, make("pride_colorizer_" + politicsInMyVidya.getName(),
new ItemPrideColorizer(politicsInMyVidya, unstackable())));
new ItemPridePigment(politicsInMyVidya, unstackable())));
}
return out;
});
public static final Item UUID_COLORIZER = make("uuid_colorizer", new ItemUUIDColorizer(unstackable()));
public static final Item DEFAULT_COLORIZER = make("default_colorizer",
new ItemAmethystAndCopperColorizer(unstackable()));
public static final Item UUID_PIGMENT = make("uuid_colorizer", new ItemUUIDPigment(unstackable()));
public static final Item DEFAULT_PIGMENT = make("default_colorizer",
new ItemAmethystAndCopperPigment(unstackable()));
// BUFF SANDVICH
public static final Item SUBMARINE_SANDWICH = make("sub_sandwich",

View file

@ -95,7 +95,7 @@ public record BrainsweepRecipe(
@Override
public void toNetwork(FriendlyByteBuf buf, BrainsweepRecipe recipe) {
recipe.blockIn.write(buf);
recipe.entityIn.write(buf);
recipe.entityIn.wrapWrite(buf);
buf.writeVarInt(recipe.mediaCost);
buf.writeVarInt(Block.getId(recipe.result));
}
@ -103,10 +103,10 @@ public record BrainsweepRecipe(
@Override
public @NotNull BrainsweepRecipe fromNetwork(ResourceLocation recipeID, FriendlyByteBuf buf) {
var blockIn = StateIngredientHelper.read(buf);
var villagerIn = BrainsweepeeIngredient.read(buf);
var brainsweepeeIn = BrainsweepeeIngredient.read(buf);
var cost = buf.readVarInt();
var result = Block.stateById(buf.readVarInt());
return new BrainsweepRecipe(recipeID, blockIn, villagerIn, cost, result);
return new BrainsweepRecipe(recipeID, blockIn, brainsweepeeIn, cost, result);
}
}
}

View file

@ -29,6 +29,11 @@ public abstract class BrainsweepeeIngredient {
public abstract JsonObject serialize();
public void wrapWrite(FriendlyByteBuf buf) {
buf.writeEnum(this.ingrType());
this.write(buf);
}
public abstract void write(FriendlyByteBuf buf);
/**
@ -44,8 +49,8 @@ public abstract class BrainsweepeeIngredient {
public abstract String getSomeKindOfReasonableIDForEmi();
public static BrainsweepeeIngredient read(FriendlyByteBuf buf) {
var type = buf.readVarInt();
return switch (Type.values()[type]) {
var type = buf.readEnum(Type.class);
return switch (type) {
case VILLAGER -> VillagerIngredient.read(buf);
case ENTITY_TYPE -> EntityTypeIngredient.read(buf);
case ENTITY_TAG -> EntityTagIngredient.read(buf);

View file

@ -89,8 +89,6 @@ public class EntityTagIngredient extends BrainsweepeeIngredient {
@Override
public void write(FriendlyByteBuf buf) {
buf.writeVarInt(Type.ENTITY_TAG.ordinal());
buf.writeResourceLocation(this.entityTypeTag.location());
}

View file

@ -56,8 +56,6 @@ public class EntityTypeIngredient extends BrainsweepeeIngredient {
@Override
public void write(FriendlyByteBuf buf) {
buf.writeVarInt(Type.ENTITY_TYPE.ordinal());
buf.writeVarInt(Registry.ENTITY_TYPE.getId(this.entityType));
}

View file

@ -5,7 +5,7 @@ import at.petrak.hexcasting.api.misc.MediaConstants;
import at.petrak.hexcasting.api.mod.HexTags;
import at.petrak.hexcasting.common.blocks.decoration.BlockAkashicLog;
import at.petrak.hexcasting.common.items.ItemStaff;
import at.petrak.hexcasting.common.items.colorizer.ItemPrideColorizer;
import at.petrak.hexcasting.common.items.pigment.ItemPridePigment;
import at.petrak.hexcasting.common.lib.HexBlocks;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.recipe.SealThingsRecipe;
@ -161,7 +161,7 @@ public class HexplatRecipes extends PaucalRecipeProvider {
.unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes);
for (var dye : DyeColor.values()) {
var item = HexItems.DYE_COLORIZERS.get(dye);
var item = HexItems.DYE_PIGMENTS.get(dye);
ShapedRecipeBuilder.shaped(item)
.define('D', HexItems.AMETHYST_DUST)
.define('C', DyeItem.byColor(dye))
@ -171,30 +171,30 @@ public class HexplatRecipes extends PaucalRecipeProvider {
.unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes);
}
gayRecipe(recipes, ItemPrideColorizer.Type.AGENDER, Ingredient.of(Items.GLASS));
gayRecipe(recipes, ItemPrideColorizer.Type.AROACE, Ingredient.of(Items.WHEAT_SEEDS));
gayRecipe(recipes, ItemPrideColorizer.Type.AROMANTIC, Ingredient.of(Items.ARROW));
gayRecipe(recipes, ItemPrideColorizer.Type.ASEXUAL, Ingredient.of(Items.BREAD));
gayRecipe(recipes, ItemPrideColorizer.Type.BISEXUAL, Ingredient.of(Items.WHEAT));
gayRecipe(recipes, ItemPrideColorizer.Type.DEMIBOY, Ingredient.of(Items.RAW_IRON));
gayRecipe(recipes, ItemPrideColorizer.Type.DEMIGIRL, Ingredient.of(Items.RAW_COPPER));
gayRecipe(recipes, ItemPrideColorizer.Type.GAY, Ingredient.of(Items.STONE_BRICK_WALL));
gayRecipe(recipes, ItemPrideColorizer.Type.GENDERFLUID, Ingredient.of(Items.WATER_BUCKET));
gayRecipe(recipes, ItemPrideColorizer.Type.GENDERQUEER, Ingredient.of(Items.GLASS_BOTTLE));
gayRecipe(recipes, ItemPrideColorizer.Type.INTERSEX, Ingredient.of(Items.AZALEA));
gayRecipe(recipes, ItemPrideColorizer.Type.LESBIAN, Ingredient.of(Items.HONEYCOMB));
gayRecipe(recipes, ItemPrideColorizer.Type.NONBINARY, Ingredient.of(Items.MOSS_BLOCK));
gayRecipe(recipes, ItemPrideColorizer.Type.PANSEXUAL, ingredients.whenModIngredient(
gayRecipe(recipes, ItemPridePigment.Type.AGENDER, Ingredient.of(Items.GLASS));
gayRecipe(recipes, ItemPridePigment.Type.AROACE, Ingredient.of(Items.WHEAT_SEEDS));
gayRecipe(recipes, ItemPridePigment.Type.AROMANTIC, Ingredient.of(Items.ARROW));
gayRecipe(recipes, ItemPridePigment.Type.ASEXUAL, Ingredient.of(Items.BREAD));
gayRecipe(recipes, ItemPridePigment.Type.BISEXUAL, Ingredient.of(Items.WHEAT));
gayRecipe(recipes, ItemPridePigment.Type.DEMIBOY, Ingredient.of(Items.RAW_IRON));
gayRecipe(recipes, ItemPridePigment.Type.DEMIGIRL, Ingredient.of(Items.RAW_COPPER));
gayRecipe(recipes, ItemPridePigment.Type.GAY, Ingredient.of(Items.STONE_BRICK_WALL));
gayRecipe(recipes, ItemPridePigment.Type.GENDERFLUID, Ingredient.of(Items.WATER_BUCKET));
gayRecipe(recipes, ItemPridePigment.Type.GENDERQUEER, Ingredient.of(Items.GLASS_BOTTLE));
gayRecipe(recipes, ItemPridePigment.Type.INTERSEX, Ingredient.of(Items.AZALEA));
gayRecipe(recipes, ItemPridePigment.Type.LESBIAN, Ingredient.of(Items.HONEYCOMB));
gayRecipe(recipes, ItemPridePigment.Type.NONBINARY, Ingredient.of(Items.MOSS_BLOCK));
gayRecipe(recipes, ItemPridePigment.Type.PANSEXUAL, ingredients.whenModIngredient(
Ingredient.of(Items.CARROT),
"farmersdelight",
CompatIngredientValue.of("farmersdelight:skillet")
));
gayRecipe(recipes, ItemPrideColorizer.Type.PLURAL, Ingredient.of(Items.REPEATER));
gayRecipe(recipes, ItemPrideColorizer.Type.TRANSGENDER, Ingredient.of(Items.EGG));
gayRecipe(recipes, ItemPridePigment.Type.PLURAL, Ingredient.of(Items.REPEATER));
gayRecipe(recipes, ItemPridePigment.Type.TRANSGENDER, Ingredient.of(Items.EGG));
ring(HexItems.UUID_COLORIZER, 1, HexItems.AMETHYST_DUST, Items.AMETHYST_SHARD)
ring(HexItems.UUID_PIGMENT, 1, HexItems.AMETHYST_DUST, Items.AMETHYST_SHARD)
.unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes);
ring(HexItems.DEFAULT_COLORIZER, 1, HexItems.AMETHYST_DUST, Items.COPPER_INGOT)
ring(HexItems.DEFAULT_PIGMENT, 1, HexItems.AMETHYST_DUST, Items.COPPER_INGOT)
.unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes);
ShapedRecipeBuilder.shaped(HexItems.SCROLL_SMOL)
@ -306,7 +306,7 @@ public class HexplatRecipes extends PaucalRecipeProvider {
.unlockedBy("has_item", hasItem(HexTags.Items.EDIFIED_LOGS)).save(recipes);
for (var log : EDIFIED_LOGS) {
ShapedRecipeBuilder.shaped(HexBlocks.EDIFIED_WOOD, 3)
ShapedRecipeBuilder.shaped(log, 3)
.define('W', log)
.pattern("WW")
.pattern("WW")
@ -526,8 +526,8 @@ public class HexplatRecipes extends PaucalRecipeProvider {
.save(recipes);
}
private void gayRecipe(Consumer<FinishedRecipe> recipes, ItemPrideColorizer.Type type, Ingredient material) {
var colorizer = HexItems.PRIDE_COLORIZERS.get(type);
private void gayRecipe(Consumer<FinishedRecipe> recipes, ItemPridePigment.Type type, Ingredient material) {
var colorizer = HexItems.PRIDE_PIGMENTS.get(type);
ShapedRecipeBuilder.shaped(colorizer)
.define('D', HexItems.AMETHYST_DUST)
.define('C', material)

View file

@ -81,7 +81,7 @@ public interface IXplatAbstractions {
boolean isBrainswept(Mob mob);
void setColorizer(Player target, FrozenPigment colorizer);
@Nullable FrozenPigment setPigment(Player target, @Nullable FrozenPigment colorizer);
void setSentinel(Player target, @Nullable Sentinel sentinel);
@ -97,7 +97,7 @@ public interface IXplatAbstractions {
@Nullable AltioraAbility getAltiora(Player player);
FrozenPigment getColorizer(Player player);
FrozenPigment getPigment(Player player);
@Nullable Sentinel getSentinel(Player player);
@ -126,9 +126,9 @@ public interface IXplatAbstractions {
// coooollooorrrs
boolean isColorizer(ItemStack stack);
boolean isPigment(ItemStack stack);
ColorProvider getColorProvider(FrozenPigment colorizer);
ColorProvider getColorProvider(FrozenPigment pigment);
// Items

View file

@ -1,7 +1,7 @@
{
"name": "hexcasting.entry.great_spells",
"name": "hexcasting.category.great_spells",
"icon": "minecraft:textures/mob_effect/conduit_power.png",
"description": "hexcasting.entry.great_spells.desc",
"description": "hexcasting.category.great_spells.desc",
"parent": "hexcasting:patterns",
"sortnum": 1
}

View file

@ -1,7 +1,7 @@
{
"name": "hexcasting.entry.spells",
"name": "hexcasting.category.spells",
"icon": "minecraft:textures/item/enchanted_book.png",
"description": "hexcasting.entry.spells.desc",
"description": "hexcasting.category.spells.desc",
"parent": "hexcasting:patterns",
"sortnum": 0
}

View file

@ -1,7 +1,7 @@
{
"name": "hexcasting.entry.circle_patterns",
"category": "hexcasting:patterns",
"icon": "hexcasting:empty_impetus",
"icon": "hexcasting:impetus/empty",
"sortnum": 13,
"advancement": "hexcasting:enlightenment",
"entry_color": "54398a",

View file

@ -40,8 +40,9 @@
},
{
"type": "hexcasting:pattern",
"header": "hexcasting.action.hexcasting:concat",
"op_id": "hexcasting:add",
"anchor": "hexcasting:add",
"anchor": "hexcasting:concat",
"input": "list, list",
"output": "list",
"text": "hexcasting.page.lists.concat"
@ -64,6 +65,7 @@
},
{
"type": "hexcasting:pattern",
"header": "hexcasting.action.hexcasting:list_size",
"op_id": "hexcasting:abs",
"anchor": "hexcasting:abs",
"input": "list",

View file

@ -5,3 +5,4 @@ accessible field net/minecraft/client/renderer/RenderType$CompositeState textur
accessible class net/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard
accessible class net/minecraft/world/item/crafting/Ingredient$Value
accessible method net/minecraft/world/item/crafting/Ingredient <init> (Ljava/util/stream/Stream;)V
accessible method net/minecraft/world/item/context/UseOnContext <init> (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/phys/BlockHitResult;)V

View file

@ -1,41 +0,0 @@
package at.petrak.hexcasting.fabric.cc;
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;
import net.minecraft.world.entity.player.Player;
/**
* Holds the colorizer item favored by the player
*/
public class CCFavoredColorizer implements Component, AutoSyncedComponent {
public static final String TAG_COLORIZER = "colorizer";
private final Player owner;
public CCFavoredColorizer(Player owner) {
this.owner = owner;
}
private FrozenPigment colorizer = FrozenPigment.DEFAULT.get();
public FrozenPigment getColorizer() {
return colorizer;
}
public void setColorizer(FrozenPigment colorizer) {
this.colorizer = colorizer;
HexCardinalComponents.FAVORED_COLORIZER.sync(this.owner);
}
@Override
public void readFromNbt(CompoundTag tag) {
this.colorizer = FrozenPigment.fromNBT(tag.getCompound(TAG_COLORIZER));
}
@Override
public void writeToNbt(CompoundTag tag) {
tag.put(TAG_COLORIZER, this.colorizer.serializeToNBT());
}
}

View file

@ -0,0 +1,44 @@
package at.petrak.hexcasting.fabric.cc;
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;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.Nullable;
/**
* Holds the pigment item favored by the player
*/
public class CCFavoredPigment implements Component, AutoSyncedComponent {
public static final String TAG_PIGMENT = "pigment";
private final Player owner;
public CCFavoredPigment(Player owner) {
this.owner = owner;
}
private FrozenPigment pigment = FrozenPigment.DEFAULT.get();
public FrozenPigment getPigment() {
return pigment;
}
public FrozenPigment setPigment(@Nullable FrozenPigment pigment) {
var old = this.pigment;
this.pigment = pigment != null ? pigment : FrozenPigment.DEFAULT.get();
HexCardinalComponents.FAVORED_PIGMENT.sync(this.owner);
return old;
}
@Override
public void readFromNbt(CompoundTag tag) {
this.pigment = FrozenPigment.fromNBT(tag.getCompound(TAG_PIGMENT));
}
@Override
public void writeToNbt(CompoundTag tag) {
tag.put(TAG_PIGMENT, this.pigment.serializeToNBT());
}
}

View file

@ -33,8 +33,8 @@ public class HexCardinalComponents implements EntityComponentInitializer, ItemCo
// entities
public static final ComponentKey<CCBrainswept> BRAINSWEPT = ComponentRegistry.getOrCreate(modLoc("brainswept"),
CCBrainswept.class);
public static final ComponentKey<CCFavoredColorizer> FAVORED_COLORIZER = ComponentRegistry.getOrCreate(
modLoc("favored_colorizer"), CCFavoredColorizer.class);
public static final ComponentKey<CCFavoredPigment> FAVORED_PIGMENT = ComponentRegistry.getOrCreate(
modLoc("favored_pigment"), CCFavoredPigment.class);
public static final ComponentKey<CCSentinel> SENTINEL = ComponentRegistry.getOrCreate(modLoc("sentinel"),
CCSentinel.class);
public static final ComponentKey<CCFlight> FLIGHT = ComponentRegistry.getOrCreate(modLoc("flight"),
@ -48,8 +48,8 @@ public class HexCardinalComponents implements EntityComponentInitializer, ItemCo
public static final ComponentKey<CCPatterns> PATTERNS = ComponentRegistry.getOrCreate(modLoc("patterns"),
CCPatterns.class);
public static final ComponentKey<CCColorizer> COLORIZER = ComponentRegistry.getOrCreate(modLoc("colorizer"),
CCColorizer.class);
public static final ComponentKey<CCPigment> PIGMENT = ComponentRegistry.getOrCreate(modLoc("pigment"),
CCPigment.class);
public static final ComponentKey<CCIotaHolder> IOTA_HOLDER = ComponentRegistry.getOrCreate(modLoc("iota_holder"),
CCIotaHolder.class);
public static final ComponentKey<CCMediaHolder> MEDIA_HOLDER = ComponentRegistry.getOrCreate(modLoc("media_holder"),
@ -63,7 +63,7 @@ public class HexCardinalComponents implements EntityComponentInitializer, ItemCo
@Override
public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) {
registry.registerFor(Mob.class, BRAINSWEPT, CCBrainswept::new);
registry.registerForPlayers(FAVORED_COLORIZER, CCFavoredColorizer::new, RespawnCopyStrategy.ALWAYS_COPY);
registry.registerForPlayers(FAVORED_PIGMENT, CCFavoredPigment::new, RespawnCopyStrategy.ALWAYS_COPY);
registry.registerForPlayers(SENTINEL, CCSentinel::new, RespawnCopyStrategy.ALWAYS_COPY);
registry.registerForPlayers(ALTIORA, CCAltiora::new, RespawnCopyStrategy.LOSSLESS_ONLY);
// Fortunately these are all both only needed on the server and don't want to be copied across death
@ -82,7 +82,7 @@ public class HexCardinalComponents implements EntityComponentInitializer, ItemCo
@Override
public void registerItemComponentFactories(ItemComponentFactoryRegistry registry) {
registry.register(i -> i instanceof ColorizerItem, COLORIZER, CCColorizer.ItemBased::new);
registry.register(i -> i instanceof PigmentItem, PIGMENT, CCPigment.ItemBased::new);
registry.register(i -> i instanceof IotaHolderItem, IOTA_HOLDER, CCItemIotaHolder.ItemBased::new);
// oh havoc, you think you're so funny

View file

@ -24,7 +24,7 @@ public abstract class CCHexHolder extends ItemComponent implements ADHexHolder {
super(owner);
var item = owner.getItem();
if (!(item instanceof HexHolderItem hexHolderItem)) {
throw new IllegalStateException("item is not a colorizer: " + owner);
throw new IllegalStateException("item is not a pigment: " + owner);
}
this.hexHolder = hexHolderItem;
}

View file

@ -1,7 +1,7 @@
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.addldata.ADPigment;
import at.petrak.hexcasting.api.item.PigmentItem;
import at.petrak.hexcasting.api.pigment.ColorProvider;
import at.petrak.hexcasting.fabric.cc.HexCardinalComponents;
import dev.onyxstudios.cca.api.v3.item.ItemComponent;
@ -10,21 +10,21 @@ import net.minecraft.world.item.ItemStack;
import java.util.UUID;
/**
* The colorizer itself
* The pigment itself
*/
public abstract class CCColorizer extends ItemComponent implements ADColorizer {
public CCColorizer(ItemStack stack) {
super(stack, HexCardinalComponents.COLORIZER);
public abstract class CCPigment extends ItemComponent implements ADPigment {
public CCPigment(ItemStack stack) {
super(stack, HexCardinalComponents.PIGMENT);
}
public static class ItemBased extends CCColorizer {
private final ColorizerItem item;
public static class ItemBased extends CCPigment {
private final PigmentItem item;
public ItemBased(ItemStack owner) {
super(owner);
var item = owner.getItem();
if (!(item instanceof ColorizerItem col)) {
throw new IllegalStateException("item is not a colorizer: " + owner);
if (!(item instanceof PigmentItem col)) {
throw new IllegalStateException("item is not a pigment: " + owner);
}
this.item = col;
}

View file

@ -145,9 +145,11 @@ public class FabricXplatImpl implements IXplatAbstractions {
}
@Override
public void setColorizer(Player target, FrozenPigment colorizer) {
var cc = HexCardinalComponents.FAVORED_COLORIZER.get(target);
cc.setColorizer(colorizer);
public @Nullable FrozenPigment setPigment(Player target, @Nullable FrozenPigment pigment) {
var cc = HexCardinalComponents.FAVORED_PIGMENT.get(target);
var old = cc.getPigment();
cc.setPigment(pigment);
return old;
}
@Override
@ -197,9 +199,9 @@ public class FabricXplatImpl implements IXplatAbstractions {
}
@Override
public FrozenPigment getColorizer(Player player) {
var cc = HexCardinalComponents.FAVORED_COLORIZER.get(player);
return cc.getColorizer();
public FrozenPigment getPigment(Player player) {
var cc = HexCardinalComponents.FAVORED_PIGMENT.get(player);
return cc.getPigment();
}
@Override
@ -267,14 +269,14 @@ public class FabricXplatImpl implements IXplatAbstractions {
}
@Override
public boolean isColorizer(ItemStack stack) {
return HexCardinalComponents.COLORIZER.isProvidedBy(stack);
public boolean isPigment(ItemStack stack) {
return HexCardinalComponents.PIGMENT.isProvidedBy(stack);
}
@Override
public ColorProvider getColorProvider(FrozenPigment colorizer) {
var cc = HexCardinalComponents.COLORIZER.maybeGet(colorizer.item());
return cc.map(col -> col.provideColor(colorizer.owner())).orElse(ColorProvider.MISSING);
public ColorProvider getColorProvider(FrozenPigment pigment) {
var cc = HexCardinalComponents.PIGMENT.maybeGet(pigment.item());
return cc.map(col -> col.provideColor(pigment.owner())).orElse(ColorProvider.MISSING);
}
@Override

View file

@ -11,3 +11,4 @@ accessible class net/minecraft/client/renderer/RenderType$CompositeRenderType
accessible class net/minecraft/client/renderer/RenderType$CompositeState
accessible field net/minecraft/client/renderer/RenderType$CompositeState textureState Lnet/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard;
accessible class net/minecraft/client/renderer/RenderStateShard$EmptyTextureStateShard
accessible method net/minecraft/world/item/context/UseOnContext <init> (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/phys/BlockHitResult;)V

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.forge.cap;
import at.petrak.hexcasting.forge.network.MsgAltioraUpdateAck;
import at.petrak.hexcasting.forge.network.MsgColorizerUpdateAck;
import at.petrak.hexcasting.forge.network.MsgPigmentUpdateAck;
import at.petrak.hexcasting.forge.network.MsgSentinelStatusUpdateAck;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.server.level.ServerPlayer;
@ -28,7 +28,7 @@ public class CapSyncers {
x.setFlight(player, x.getFlight(proto));
x.setAltiora(player, x.getAltiora(proto));
x.setSentinel(player, x.getSentinel(proto));
x.setColorizer(player, x.getColorizer(proto));
x.setPigment(player, x.getPigment(proto));
x.setStaffcastImage(player, x.getStaffcastVM(proto, InteractionHand.MAIN_HAND).getImage());
x.setPatterns(player, x.getPatternsSavedInUi(proto));
}
@ -40,7 +40,7 @@ public class CapSyncers {
}
syncSentinel(player);
syncColorizer(player);
syncPigment(player);
syncAltiora(player);
}
@ -51,7 +51,7 @@ public class CapSyncers {
}
syncSentinel(player);
syncColorizer(player);
syncPigment(player);
syncAltiora(player);
}
@ -60,9 +60,9 @@ public class CapSyncers {
new MsgSentinelStatusUpdateAck(IXplatAbstractions.INSTANCE.getSentinel(player)));
}
public static void syncColorizer(ServerPlayer player) {
public static void syncPigment(ServerPlayer player) {
IXplatAbstractions.INSTANCE.sendPacketToPlayer(player,
new MsgColorizerUpdateAck(IXplatAbstractions.INSTANCE.getColorizer(player)));
new MsgPigmentUpdateAck(IXplatAbstractions.INSTANCE.getPigment(player)));
}
public static void syncAltiora(ServerPlayer player) {

View file

@ -74,7 +74,7 @@ public class ForgeCapabilityHandler {
evt.register(ADMediaHolder.class);
evt.register(ADIotaHolder.class);
evt.register(ADHexHolder.class);
evt.register(ADColorizer.class);
evt.register(ADPigment.class);
}
public static void attachItemCaps(AttachCapabilitiesEvent<ItemStack> evt) {
@ -124,9 +124,9 @@ public class ForgeCapabilityHandler {
provide(stack, HexCapabilities.VARIANT_ITEM, () -> new CapItemVariantItem(variantItem, stack)));
}
if (stack.getItem() instanceof ColorizerItem colorizer) {
if (stack.getItem() instanceof PigmentItem pigment) {
evt.addCapability(PIGMENT_CAP,
provide(stack, HexCapabilities.COLOR, () -> new CapItemColorizer(colorizer, stack)));
provide(stack, HexCapabilities.COLOR, () -> new CapItemPigment(pigment, stack)));
}
if (IXplatAbstractions.INSTANCE.isModPresent(HexInterop.Forge.CURIOS_API_ID)

View file

@ -15,6 +15,6 @@ public final class HexCapabilities {
});
public static final Capability<ADVariantItem> VARIANT_ITEM = CapabilityManager.get(new CapabilityToken<>() {
});
public static final Capability<ADColorizer> COLOR = CapabilityManager.get(new CapabilityToken<>() {
public static final Capability<ADPigment> COLOR = CapabilityManager.get(new CapabilityToken<>() {
});
}

View file

@ -1,14 +1,14 @@
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.addldata.ADPigment;
import at.petrak.hexcasting.api.item.PigmentItem;
import at.petrak.hexcasting.api.pigment.ColorProvider;
import net.minecraft.world.item.ItemStack;
import java.util.UUID;
public record CapItemColorizer(ColorizerItem holder,
ItemStack stack) implements ADColorizer {
public record CapItemPigment(PigmentItem holder,
ItemStack stack) implements ADPigment {
@Override
public ColorProvider provideColor(UUID owner) {
return holder.provideColor(this.stack, owner);

View file

@ -4,7 +4,7 @@ import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.client.render.GaslightingTracker;
import at.petrak.hexcasting.common.blocks.BlockQuenchedAllay;
import at.petrak.hexcasting.common.items.ItemStaff;
import at.petrak.hexcasting.common.items.colorizer.ItemPrideColorizer;
import at.petrak.hexcasting.common.items.pigment.ItemPridePigment;
import at.petrak.hexcasting.common.items.magic.ItemMediaBattery;
import at.petrak.hexcasting.common.items.magic.ItemPackagedHex;
import at.petrak.hexcasting.common.items.storage.ItemFocus;
@ -138,18 +138,18 @@ public class HexItemModels extends PaucalItemModelProvider {
}
for (var dye : DyeColor.values()) {
singleTexture(getPath(HexItems.DYE_COLORIZERS.get(dye)),
singleTexture(getPath(HexItems.DYE_PIGMENTS.get(dye)),
new ResourceLocation("item/generated"),
"layer0", modLoc("item/colorizer/dye_" + dye.getName()));
}
for (var type : ItemPrideColorizer.Type.values()) {
singleTexture(getPath(HexItems.PRIDE_COLORIZERS.get(type)),
for (var type : ItemPridePigment.Type.values()) {
singleTexture(getPath(HexItems.PRIDE_PIGMENTS.get(type)),
new ResourceLocation("item/generated"),
"layer0", modLoc("item/colorizer/pride_" + type.getName()));
}
singleTexture(getPath(HexItems.UUID_COLORIZER), new ResourceLocation("item/generated"),
singleTexture(getPath(HexItems.UUID_PIGMENT), new ResourceLocation("item/generated"),
"layer0", modLoc("item/colorizer/uuid"));
singleTexture(getPath(HexItems.DEFAULT_COLORIZER), new ResourceLocation("item/generated"),
singleTexture(getPath(HexItems.DEFAULT_PIGMENT), new ResourceLocation("item/generated"),
"layer0", modLoc("item/colorizer/uuid"));
simpleItem(modLoc("slate_blank"));

View file

@ -43,8 +43,8 @@ public class ForgePacketHandler {
MsgBlinkS2C::deserialize, makeClientBoundHandler(MsgBlinkS2C::handle));
NETWORK.registerMessage(messageIdx++, MsgSentinelStatusUpdateAck.class, MsgSentinelStatusUpdateAck::serialize,
MsgSentinelStatusUpdateAck::deserialize, makeClientBoundHandler(MsgSentinelStatusUpdateAck::handle));
NETWORK.registerMessage(messageIdx++, MsgColorizerUpdateAck.class, MsgColorizerUpdateAck::serialize,
MsgColorizerUpdateAck::deserialize, makeClientBoundHandler(MsgColorizerUpdateAck::handle));
NETWORK.registerMessage(messageIdx++, MsgPigmentUpdateAck.class, MsgPigmentUpdateAck::serialize,
MsgPigmentUpdateAck::deserialize, makeClientBoundHandler(MsgPigmentUpdateAck::handle));
NETWORK.registerMessage(messageIdx++, MsgAltioraUpdateAck.class, MsgAltioraUpdateAck::serialize,
MsgAltioraUpdateAck::deserialize, makeClientBoundHandler(MsgAltioraUpdateAck::handle));
NETWORK.registerMessage(messageIdx++, MsgCastParticleS2C.class, MsgCastParticleS2C::serialize,

View file

@ -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(FrozenPigment update) implements IMessage {
public record MsgPigmentUpdateAck(FrozenPigment update) implements IMessage {
public static final ResourceLocation ID = modLoc("color");
@Override
@ -21,12 +21,12 @@ public record MsgColorizerUpdateAck(FrozenPigment update) implements IMessage {
return ID;
}
public static MsgColorizerUpdateAck deserialize(ByteBuf buffer) {
public static MsgPigmentUpdateAck deserialize(ByteBuf buffer) {
var buf = new FriendlyByteBuf(buffer);
var tag = buf.readAnySizeNbt();
var colorizer = FrozenPigment.fromNBT(tag);
return new MsgColorizerUpdateAck(colorizer);
return new MsgPigmentUpdateAck(colorizer);
}
@Override
@ -34,13 +34,13 @@ public record MsgColorizerUpdateAck(FrozenPigment update) implements IMessage {
buf.writeNbt(this.update.serializeToNBT());
}
public static void handle(MsgColorizerUpdateAck self) {
public static void handle(MsgPigmentUpdateAck self) {
Minecraft.getInstance().execute(new Runnable() {
@Override
public void run() {
var player = Minecraft.getInstance().player;
if (player != null) {
IXplatAbstractions.INSTANCE.setColorizer(player, self.update());
IXplatAbstractions.INSTANCE.setPigment(player, self.update());
}
}
});

View file

@ -57,10 +57,14 @@ public record MsgSentinelStatusUpdateAck(@Nullable Sentinel update) implements I
}
public static void handle(MsgSentinelStatusUpdateAck self) {
Minecraft.getInstance().execute(() -> {
var player = Minecraft.getInstance().player;
if (player != null) {
IXplatAbstractions.INSTANCE.setSentinel(player, self.update());
//noinspection Convert2Lambda
Minecraft.getInstance().execute(new Runnable() {
@Override
public void run() {
var player = Minecraft.getInstance().player;
if (player != null) {
IXplatAbstractions.INSTANCE.setSentinel(player, self.update());
}
}
});
}

View file

@ -181,13 +181,20 @@ public class ForgeXplatImpl implements IXplatAbstractions {
}
@Override
public void setColorizer(Player player, FrozenPigment colorizer) {
public @Nullable FrozenPigment setPigment(Player player, @Nullable FrozenPigment pigment) {
var old = getPigment(player);
CompoundTag tag = player.getPersistentData();
tag.put(TAG_COLOR, colorizer.serializeToNBT());
if (pigment != null)
tag.put(TAG_PIGMENT, pigment.serializeToNBT());
else
tag.remove(TAG_PIGMENT);
if (player instanceof ServerPlayer serverPlayer) {
CapSyncers.syncColorizer(serverPlayer);
CapSyncers.syncPigment(serverPlayer);
}
return old;
}
@Override
@ -255,8 +262,8 @@ public class ForgeXplatImpl implements IXplatAbstractions {
}
@Override
public FrozenPigment getColorizer(Player player) {
return FrozenPigment.fromNBT(player.getPersistentData().getCompound(TAG_COLOR));
public FrozenPigment getPigment(Player player) {
return FrozenPigment.fromNBT(player.getPersistentData().getCompound(TAG_PIGMENT));
}
@Override
@ -340,15 +347,15 @@ public class ForgeXplatImpl implements IXplatAbstractions {
}
@Override
public boolean isColorizer(ItemStack stack) {
public boolean isPigment(ItemStack stack) {
return stack.getCapability(HexCapabilities.COLOR).isPresent();
}
@Override
public ColorProvider getColorProvider(FrozenPigment colorizer) {
var maybeColorizer = colorizer.item().getCapability(HexCapabilities.COLOR).resolve();
if (maybeColorizer.isPresent()) {
return maybeColorizer.get().provideColor(colorizer.owner());
public ColorProvider getColorProvider(FrozenPigment pigment) {
var maybePigment = pigment.item().getCapability(HexCapabilities.COLOR).resolve();
if (maybePigment.isPresent()) {
return maybePigment.get().provideColor(pigment.owner());
}
return ColorProvider.MISSING;
}
@ -561,7 +568,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
public static final String TAG_SENTINEL_POSITION = "hexcasting:sentinel_position";
public static final String TAG_SENTINEL_DIMENSION = "hexcasting:sentinel_dimension";
public static final String TAG_COLOR = "hexcasting:colorizer";
public static final String TAG_PIGMENT = "hexcasting:pigment";
public static final String TAG_FLIGHT_ALLOWED = "hexcasting:flight_allowed";
public static final String TAG_FLIGHT_TIME = "hexcasting:flight_time";