fix up colorizers a little more, also push new toml with uuids
This commit is contained in:
parent
3032a0bbcf
commit
74bd0b82b0
16 changed files with 243 additions and 244 deletions
|
@ -2,27 +2,40 @@
|
|||
# https://github.com/TheElectronWill/night-config/issues/96
|
||||
# So we use int codes. aa.
|
||||
|
||||
[petra_the_kat]
|
||||
# Also we use UUID keys, this way we can just store the UUID with a block.
|
||||
# https://gameplay.tools/minecraft/uuid
|
||||
|
||||
# petra_the_kat
|
||||
["a2ce9382-2518-4752-87b2-c6a5c97f173e"]
|
||||
# colorizer = [0xebad1c, 0xc7c7bd, 0x7c2e94, 0x2e060f]
|
||||
colorizer = [15445276, 13092797, 8137012, 3016207]
|
||||
|
||||
[Hudeler]
|
||||
# Hudeler
|
||||
["23978392-a78c-49cf-9f52-35a151fd4083"]
|
||||
#colorizer = [0x825ec2]
|
||||
colorizer = [8543938]
|
||||
|
||||
[AmyMiyalee]
|
||||
# AmyMialee
|
||||
["2793cdc6-7710-4e7e-9d81-cf918e067729"]
|
||||
#colorizer = [0xb992ff]
|
||||
colorizer = [12161791]
|
||||
|
||||
[Alwinfy]
|
||||
# Alwinfy
|
||||
["64f6e5fc-981c-442c-8d6a-578e8e8cbcd3"]
|
||||
#colorizer = [0x3327e3]
|
||||
colorizer = [3352547]
|
||||
|
||||
[Noobulus]
|
||||
# Noobulus
|
||||
["89719de3-6445-4445-abe2-509659db930d"]
|
||||
#colorizer = [0x92a1ff, 0x6b7fff]
|
||||
colorizer = [9609727, 7045119]
|
||||
|
||||
[Dev]
|
||||
# nbyzantine
|
||||
["e055cae1-dd93-42b7-abad-8f2dc758a9f2"]
|
||||
# dfe0e8 f2da00 e66910 383138
|
||||
colorizer = [14672104, 15915520, 15100176, 3682616]
|
||||
|
||||
# [Dev]
|
||||
# 0xff0000 0x00ff00 0x0000ff
|
||||
# For testing purposes
|
||||
colorizer = [16711680, 65280, 255]
|
||||
# colorizer = [16711680, 65280, 255]
|
||||
|
|
|
@ -82,10 +82,8 @@ public class HexAdditionalRenderers {
|
|||
var normal = new Vector3f(r[0] - l[0], r[1] - l[1], r[2] - l[2]);
|
||||
normal.normalize();
|
||||
if (finalCap != null) {
|
||||
lcolor = CapPreferredColorizer.getColor(finalCap.colorizer, owner, time,
|
||||
new Vec3(l[0], l[1], l[2]));
|
||||
rcolor = CapPreferredColorizer.getColor(finalCap.colorizer, owner, time,
|
||||
new Vec3(r[0], r[1], r[2]));
|
||||
lcolor = finalCap.colorizer.getColor(time, new Vec3(l[0], l[1], l[2]));
|
||||
rcolor = finalCap.colorizer.getColor(time, new Vec3(r[0], r[1], r[2]));
|
||||
}
|
||||
buf.vertex(neo, l[0], l[1], l[2])
|
||||
.color(lcolor)
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
package at.petrak.hexcasting.common
|
||||
|
||||
import at.petrak.hexcasting.HexMod
|
||||
import com.electronwill.nightconfig.core.AbstractConfig
|
||||
import com.electronwill.nightconfig.toml.TomlParser
|
||||
import net.minecraft.DefaultUncaughtExceptionHandler
|
||||
import java.io.IOException
|
||||
import java.net.URL
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object ContributorList {
|
||||
private val contributors = ConcurrentHashMap<String, ContributorInfo>()
|
||||
private val contributors = ConcurrentHashMap<UUID, ContributorInfo>()
|
||||
private var startedLoading = false
|
||||
|
||||
@JvmStatic
|
||||
fun getContributor(name: String): ContributorInfo? =
|
||||
this.contributors[name]
|
||||
fun getContributor(uuid: UUID): ContributorInfo? =
|
||||
this.contributors[uuid]
|
||||
|
||||
|
||||
fun loadContributors() {
|
||||
|
@ -35,11 +37,11 @@ object ContributorList {
|
|||
|
||||
val keys = toml.valueMap().keys
|
||||
for (key in keys) {
|
||||
val infoRaw: ContributorInfoInner = toml.get(key)
|
||||
val infoRaw: AbstractConfig = toml.get(key)
|
||||
val info = ContributorInfo(
|
||||
infoRaw.colorizer.stream().mapToInt { i -> i or 0xff_000000.toInt() }.toArray()
|
||||
infoRaw.get("colorizer")
|
||||
)
|
||||
contributors[key] = info
|
||||
contributors[UUID.fromString(key)] = info
|
||||
}
|
||||
HexMod.getLogger().info("Loaded ${contributors.size} contributors!")
|
||||
} catch (e: IOException) {
|
||||
|
@ -47,6 +49,5 @@ object ContributorList {
|
|||
}
|
||||
}
|
||||
|
||||
private data class ContributorInfoInner(val colorizer: List<Int>)
|
||||
data class ContributorInfo(val colorizer: IntArray)
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package at.petrak.hexcasting.common.blocks;
|
||||
|
||||
import at.petrak.hexcasting.common.casting.colors.FrozenColorizer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
@ -8,7 +9,6 @@ import net.minecraft.world.entity.EntityType;
|
|||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.SpawnPlacements;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
@ -16,7 +16,7 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
||||
import net.minecraft.world.level.block.entity.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
|
@ -51,7 +51,8 @@ public class BlockConjured extends Block implements SimpleWaterloggedBlock, Enti
|
|||
}
|
||||
|
||||
@Override
|
||||
public void animateTick(@NotNull BlockState pState, @NotNull Level pLevel, @NotNull BlockPos pPos, @NotNull Random pRand) {
|
||||
public void animateTick(@NotNull BlockState pState, @NotNull Level pLevel, @NotNull BlockPos pPos,
|
||||
@NotNull Random pRand) {
|
||||
BlockEntity tile = pLevel.getBlockEntity(pPos);
|
||||
if (tile instanceof BlockEntityConjured) {
|
||||
((BlockEntityConjured) tile).particleEffect();
|
||||
|
@ -70,21 +71,23 @@ public class BlockConjured extends Block implements SimpleWaterloggedBlock, Enti
|
|||
return new BlockEntityConjured(pPos, pState);
|
||||
}
|
||||
|
||||
public static void setColor(LevelAccessor pLevel, BlockPos pPos, ItemStack pRecordStack) {
|
||||
public static void setColor(LevelAccessor pLevel, BlockPos pPos, FrozenColorizer colorizer) {
|
||||
BlockEntity blockentity = pLevel.getBlockEntity(pPos);
|
||||
if (blockentity instanceof BlockEntityConjured tile) {
|
||||
tile.setColor(pRecordStack.copy());
|
||||
tile.setColorizer(colorizer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(@NotNull BlockState pState, Level pLevel, @NotNull BlockPos pPos, @NotNull BlockState pOldState, boolean pIsMoving) {
|
||||
public void onPlace(@NotNull BlockState pState, Level pLevel, @NotNull BlockPos pPos, @NotNull BlockState pOldState,
|
||||
boolean pIsMoving) {
|
||||
pLevel.sendBlockUpdated(pPos, pState, pState, Block.UPDATE_CLIENTS);
|
||||
super.onPlace(pState, pLevel, pPos, pOldState, pIsMoving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull VoxelShape getShape(@NotNull BlockState state, @NotNull BlockGetter level, @NotNull BlockPos pos, @NotNull CollisionContext context) {
|
||||
public @NotNull VoxelShape getShape(@NotNull BlockState state, @NotNull BlockGetter level, @NotNull BlockPos pos,
|
||||
@NotNull CollisionContext context) {
|
||||
return state.getValue(LIGHT) ? LIGHT_SHAPE : super.getShape(state, level, pos, context);
|
||||
}
|
||||
|
||||
|
@ -94,7 +97,8 @@ public class BlockConjured extends Block implements SimpleWaterloggedBlock, Enti
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(@NotNull BlockState pState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos) {
|
||||
public boolean propagatesSkylightDown(@NotNull BlockState pState, @NotNull BlockGetter pLevel,
|
||||
@NotNull BlockPos pPos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -104,17 +108,20 @@ public class BlockConjured extends Block implements SimpleWaterloggedBlock, Enti
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(BlockState state, BlockGetter world, BlockPos pos, @Nullable Direction direction) {
|
||||
public boolean canConnectRedstone(BlockState state, BlockGetter world, BlockPos pos,
|
||||
@Nullable Direction direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidSpawn(BlockState state, BlockGetter world, BlockPos pos, SpawnPlacements.Type type, EntityType<?> entityType) {
|
||||
public boolean isValidSpawn(BlockState state, BlockGetter world, BlockPos pos, SpawnPlacements.Type type,
|
||||
EntityType<?> entityType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull VoxelShape getVisualShape(@NotNull BlockState pState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos, @NotNull CollisionContext pContext) {
|
||||
public @NotNull VoxelShape getVisualShape(@NotNull BlockState pState, @NotNull BlockGetter pLevel,
|
||||
@NotNull BlockPos pPos, @NotNull CollisionContext pContext) {
|
||||
return Shapes.empty();
|
||||
}
|
||||
|
||||
|
@ -129,15 +136,18 @@ public class BlockConjured extends Block implements SimpleWaterloggedBlock, Enti
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NotNull VoxelShape getCollisionShape(@NotNull BlockState state, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos, @NotNull CollisionContext pContext) {
|
||||
public @NotNull VoxelShape getCollisionShape(@NotNull BlockState state, @NotNull BlockGetter pLevel,
|
||||
@NotNull BlockPos pPos, @NotNull CollisionContext pContext) {
|
||||
return state.getValue(LIGHT) ? Shapes.empty() : super.getCollisionShape(state, pLevel, pPos, pContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void spawnDestroyParticles(Level pLevel, Player pPlayer, BlockPos pPos, BlockState pState) {}
|
||||
protected void spawnDestroyParticles(Level pLevel, Player pPlayer, BlockPos pPos, BlockState pState) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addLandingEffects(BlockState state1, ServerLevel worldserver, BlockPos pos, BlockState state2, LivingEntity entity, int numberOfParticles) {
|
||||
public boolean addLandingEffects(BlockState state1, ServerLevel worldserver, BlockPos pos, BlockState state2,
|
||||
LivingEntity entity, int numberOfParticles) {
|
||||
BlockEntity tile = worldserver.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityConjured) {
|
||||
((BlockEntityConjured) tile).landParticle(entity, numberOfParticles);
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
package at.petrak.hexcasting.common.blocks;
|
||||
|
||||
import at.petrak.hexcasting.common.items.colorizer.ItemColorizer;
|
||||
import at.petrak.hexcasting.common.casting.colors.FrozenColorizer;
|
||||
import at.petrak.hexcasting.common.particles.HexParticles;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
import net.minecraft.util.FastColor;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
|
@ -18,96 +19,78 @@ import java.util.Random;
|
|||
|
||||
public class BlockEntityConjured extends BlockEntity {
|
||||
private static final Random RANDOM = new Random();
|
||||
private ItemStack color = ItemStack.EMPTY;
|
||||
private FrozenColorizer colorizer = FrozenColorizer.DEFAULT;
|
||||
|
||||
public static final String TAG_COLORIZER = "tag_colorizer";
|
||||
|
||||
public BlockEntityConjured(BlockPos pos, BlockState state) {
|
||||
super(HexBlocks.CONJURED_TILE.get(), pos, state);
|
||||
}
|
||||
|
||||
public void walkParticle(Entity pEntity) {
|
||||
int[] colors;
|
||||
if (color.getItem() instanceof ItemColorizer colorizer) {
|
||||
colors = colorizer.getColors();
|
||||
} else {
|
||||
colors = new int[]{11767539};
|
||||
}
|
||||
|
||||
if (getBlockState().getBlock() instanceof BlockConjured) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
int j = RANDOM.nextInt(colors.length);
|
||||
double d0 = (double)(colors[j] >> 16 & 255) / 255.0D;
|
||||
double d1 = (double)(colors[j] >> 8 & 255) / 255.0D;
|
||||
double d2 = (double)(colors[j] & 255) / 255.0D;
|
||||
int color = this.colorizer.getColor(pEntity.tickCount, pEntity.position()
|
||||
.add(new Vec3(RANDOM.nextFloat(), RANDOM.nextFloat(), RANDOM.nextFloat()).scale(
|
||||
RANDOM.nextFloat() * 3)));
|
||||
int r = FastColor.ARGB32.red(color);
|
||||
int g = FastColor.ARGB32.green(color);
|
||||
int b = FastColor.ARGB32.blue(color);
|
||||
assert level != null;
|
||||
level.addParticle(HexParticles.CONJURE_BLOCK_PARTICLE.get(),
|
||||
pEntity.getX() + (RANDOM.nextFloat() * 0.6D) - 0.3D,
|
||||
getBlockPos().getY() + (RANDOM.nextFloat() * 0.05D) + 0.95D,
|
||||
pEntity.getZ() + (RANDOM.nextFloat() * 0.6D) - 0.3D, d0, d1, d2);
|
||||
pEntity.getX() + (RANDOM.nextFloat() * 0.6D) - 0.3D,
|
||||
getBlockPos().getY() + (RANDOM.nextFloat() * 0.05D) + 0.95D,
|
||||
pEntity.getZ() + (RANDOM.nextFloat() * 0.6D) - 0.3D, r / 255d, g / 255d, b / 255d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void particleEffect() {
|
||||
int[] colors;
|
||||
if (color.getItem() instanceof ItemColorizer colorizer) {
|
||||
colors = colorizer.getColors();
|
||||
} else {
|
||||
colors = new int[]{11767539};
|
||||
}
|
||||
|
||||
if (getBlockState().getBlock() instanceof BlockConjured) {
|
||||
int color = this.colorizer.getColor(RANDOM.nextFloat() * 16384,
|
||||
new Vec3(RANDOM.nextFloat(), RANDOM.nextFloat(), RANDOM.nextFloat()).scale(
|
||||
RANDOM.nextFloat() * 3));
|
||||
double r = FastColor.ARGB32.red(color) / 255d;
|
||||
double g = FastColor.ARGB32.green(color) / 255d;
|
||||
double b = FastColor.ARGB32.blue(color) / 255d;
|
||||
assert level != null;
|
||||
if (getBlockState().getValue(BlockConjured.LIGHT)) {
|
||||
int j = RANDOM.nextInt(colors.length);
|
||||
double d0 = (double)(colors[j] >> 16 & 255) / 255.0D;
|
||||
double d1 = (double)(colors[j] >> 8 & 255) / 255.0D;
|
||||
double d2 = (double)(colors[j] & 255) / 255.0D;
|
||||
assert level != null;
|
||||
level.addParticle(HexParticles.CONJURE_LIGHT_PARTICLE.get(),
|
||||
(double)getBlockPos().getX() + 0.4D + (RANDOM.nextFloat() * 0.2D),
|
||||
(double)getBlockPos().getY() + 0.4D + (RANDOM.nextFloat() * 0.2D),
|
||||
(double)getBlockPos().getZ() + 0.4D + (RANDOM.nextFloat() * 0.2D), d0, d1, d2);
|
||||
(double) getBlockPos().getX() + 0.4D + (RANDOM.nextFloat() * 0.2D),
|
||||
(double) getBlockPos().getY() + 0.4D + (RANDOM.nextFloat() * 0.2D),
|
||||
(double) getBlockPos().getZ() + 0.4D + (RANDOM.nextFloat() * 0.2D), r, g, b);
|
||||
} else {
|
||||
if (RANDOM.nextBoolean()) {
|
||||
int j = RANDOM.nextInt(colors.length);
|
||||
double d0 = (double) (colors[j] >> 16 & 255) / 255.0D;
|
||||
double d1 = (double) (colors[j] >> 8 & 255) / 255.0D;
|
||||
double d2 = (double) (colors[j] & 255) / 255.0D;
|
||||
assert level != null;
|
||||
level.addParticle(HexParticles.CONJURE_BLOCK_PARTICLE.get(),
|
||||
(double) getBlockPos().getX() + RANDOM.nextFloat(),
|
||||
(double) getBlockPos().getY() + RANDOM.nextFloat(),
|
||||
(double) getBlockPos().getZ() + RANDOM.nextFloat(), d0, d1, d2);
|
||||
(double) getBlockPos().getX() + RANDOM.nextFloat(),
|
||||
(double) getBlockPos().getY() + RANDOM.nextFloat(),
|
||||
(double) getBlockPos().getZ() + RANDOM.nextFloat(), r, g, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void landParticle(Entity entity, int number) {
|
||||
int[] colors;
|
||||
if (color.getItem() instanceof ItemColorizer colorizer) {
|
||||
colors = colorizer.getColors();
|
||||
} else {
|
||||
colors = new int[]{11767539};
|
||||
}
|
||||
|
||||
if (getBlockState().getBlock() instanceof BlockConjured) {
|
||||
for (int i = 0; i < number * 2; i++) {
|
||||
int j = RANDOM.nextInt(colors.length);
|
||||
double d0 = (double)(colors[j] >> 16 & 255) / 255.0D;
|
||||
double d1 = (double)(colors[j] >> 8 & 255) / 255.0D;
|
||||
double d2 = (double)(colors[j] & 255) / 255.0D;
|
||||
int color = this.colorizer.getColor(entity.tickCount, entity.position()
|
||||
.add(new Vec3(RANDOM.nextFloat(), RANDOM.nextFloat(), RANDOM.nextFloat()).scale(
|
||||
RANDOM.nextFloat() * 3)));
|
||||
double r = FastColor.ARGB32.red(color) / 255d;
|
||||
double g = FastColor.ARGB32.green(color) / 255d;
|
||||
double b = FastColor.ARGB32.blue(color) / 255d;
|
||||
assert level != null;
|
||||
level.addParticle(HexParticles.CONJURE_BLOCK_PARTICLE.get(),
|
||||
entity.getX() + (RANDOM.nextFloat() * 0.8D) - 0.2D,
|
||||
getBlockPos().getY() + (RANDOM.nextFloat() * 0.05D) + 0.95D,
|
||||
entity.getZ() + (RANDOM.nextFloat() * 0.8D) - 0.2D, d0, d1, d2);
|
||||
entity.getX() + (RANDOM.nextFloat() * 0.8D) - 0.2D,
|
||||
getBlockPos().getY() + (RANDOM.nextFloat() * 0.05D) + 0.95D,
|
||||
entity.getZ() + (RANDOM.nextFloat() * 0.8D) - 0.2D, r, g, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAdditional(CompoundTag pTag) {
|
||||
pTag.put("Colorizer", this.getColor().save(new CompoundTag()));
|
||||
pTag.put(TAG_COLORIZER, this.colorizer.serialize());
|
||||
super.saveAdditional(pTag);
|
||||
}
|
||||
|
||||
|
@ -116,25 +99,28 @@ public class BlockEntityConjured extends BlockEntity {
|
|||
readPacketNBT(tag);
|
||||
}
|
||||
|
||||
public ItemStack getColor() {
|
||||
return this.color;
|
||||
public FrozenColorizer getColorizer() {
|
||||
return this.colorizer;
|
||||
}
|
||||
|
||||
public void setColor(ItemStack colourizer) {
|
||||
this.color = colourizer;
|
||||
public void setColorizer(FrozenColorizer colorizer) {
|
||||
this.colorizer = colorizer;
|
||||
this.setChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChanged() {
|
||||
if (this.level == null) return;
|
||||
this.level.sendBlockUpdated(this.worldPosition, this.getBlockState(), this.getBlockState(), Block.UPDATE_CLIENTS);
|
||||
if (this.level == null) {
|
||||
return;
|
||||
}
|
||||
this.level.sendBlockUpdated(this.worldPosition, this.getBlockState(), this.getBlockState(),
|
||||
Block.UPDATE_CLIENTS);
|
||||
super.setChanged();
|
||||
}
|
||||
|
||||
public void readPacketNBT(CompoundTag tag) {
|
||||
if (tag.contains("Colorizer")) {
|
||||
this.setColor(ItemStack.of(tag.getCompound("Colorizer")));
|
||||
if (tag.contains(TAG_COLORIZER)) {
|
||||
this.setColorizer(FrozenColorizer.deserialize(tag.getCompound(TAG_COLORIZER)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.casting
|
|||
import at.petrak.hexcasting.HexMod
|
||||
import at.petrak.hexcasting.api.PatternRegistry
|
||||
import at.petrak.hexcasting.api.SpellDatum
|
||||
import at.petrak.hexcasting.common.items.HexItems
|
||||
import at.petrak.hexcasting.common.casting.colors.FrozenColorizer
|
||||
import at.petrak.hexcasting.common.items.ItemWand
|
||||
import at.petrak.hexcasting.common.items.magic.ItemPackagedSpell
|
||||
import at.petrak.hexcasting.common.lib.HexCapabilities
|
||||
|
@ -17,7 +17,6 @@ import net.minecraft.nbt.Tag
|
|||
import net.minecraft.server.level.ServerLevel
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import java.util.*
|
||||
import kotlin.math.min
|
||||
|
||||
|
@ -31,7 +30,7 @@ class CastingHarness private constructor(
|
|||
var parenthesized: List<HexPattern>,
|
||||
var escapeNext: Boolean,
|
||||
val ctx: CastingContext,
|
||||
val prepackagedColorizer: ItemStack?
|
||||
val prepackagedColorizer: FrozenColorizer?
|
||||
) {
|
||||
|
||||
constructor(ctx: CastingContext) : this(mutableListOf(), 0, mutableListOf(), false, ctx, null)
|
||||
|
@ -271,14 +270,14 @@ class CastingHarness private constructor(
|
|||
return costLeft
|
||||
}
|
||||
|
||||
fun getColorizer(): ItemStack {
|
||||
fun getColorizer(): FrozenColorizer {
|
||||
if (this.prepackagedColorizer != null)
|
||||
return this.prepackagedColorizer
|
||||
|
||||
val maybeCap = this.ctx.caster.getCapability(HexCapabilities.PREFERRED_COLORIZER).resolve()
|
||||
if (maybeCap.isEmpty) {
|
||||
// uh oh
|
||||
return ItemStack(HexItems.DYE_COLORIZERS[0].get())
|
||||
return FrozenColorizer.DEFAULT
|
||||
}
|
||||
return maybeCap.get().colorizer
|
||||
}
|
||||
|
@ -301,7 +300,7 @@ class CastingHarness private constructor(
|
|||
out.put(TAG_PARENTHESIZED, parensTag)
|
||||
|
||||
if (this.prepackagedColorizer != null) {
|
||||
out.put(TAG_PREPACKAGED_COLORIZER, this.prepackagedColorizer.serializeNBT())
|
||||
out.put(TAG_PREPACKAGED_COLORIZER, this.prepackagedColorizer.serialize())
|
||||
}
|
||||
|
||||
return out
|
||||
|
@ -338,7 +337,7 @@ class CastingHarness private constructor(
|
|||
val escapeNext = nbt.getBoolean(TAG_ESCAPE_NEXT)
|
||||
|
||||
val colorizer = if (nbt.contains(TAG_PREPACKAGED_COLORIZER)) {
|
||||
ItemStack.of(nbt.getCompound(TAG_PREPACKAGED_COLORIZER))
|
||||
FrozenColorizer.deserialize(nbt.getCompound(TAG_PREPACKAGED_COLORIZER))
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package at.petrak.hexcasting.common.casting
|
|||
|
||||
import at.petrak.hexcasting.api.RenderedSpell
|
||||
import at.petrak.hexcasting.api.SpellDatum
|
||||
import at.petrak.hexcasting.common.casting.colors.CapPreferredColorizer
|
||||
import at.petrak.hexcasting.datagen.Advancements
|
||||
import com.mojang.math.Vector3f
|
||||
import net.minecraft.Util
|
||||
|
@ -57,14 +56,8 @@ sealed class OperatorSideEffect {
|
|||
|
||||
for (i in 0 until 20) {
|
||||
// For the colors, pick any random time to get a mix of colors
|
||||
val color =
|
||||
CapPreferredColorizer.getColor(
|
||||
colorizer,
|
||||
harness.ctx.caster,
|
||||
Random.nextFloat() * 256f,
|
||||
Vec3.ZERO
|
||||
)
|
||||
|
||||
val color = colorizer.getColor(Random.nextFloat() * 256f, Vec3.ZERO)
|
||||
|
||||
harness.ctx.world.sendParticles(
|
||||
DustParticleOptions(Vector3f(Vec3.fromRGB24(color)), 1f),
|
||||
position.x,
|
||||
|
|
|
@ -5,6 +5,7 @@ import at.petrak.hexcasting.api.Operator;
|
|||
import at.petrak.hexcasting.api.PatternRegistry;
|
||||
import at.petrak.hexcasting.api.SpellDatum;
|
||||
import at.petrak.hexcasting.common.casting.operators.*;
|
||||
import at.petrak.hexcasting.common.casting.operators.eval.OpEval;
|
||||
import at.petrak.hexcasting.common.casting.operators.eval.OpEvalDelay;
|
||||
import at.petrak.hexcasting.common.casting.operators.eval.OpForEach;
|
||||
import at.petrak.hexcasting.common.casting.operators.lists.OpAppend;
|
||||
|
@ -33,8 +34,6 @@ import net.minecraft.world.phys.Vec3;
|
|||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static at.petrak.hexcasting.common.lib.RegisterHelper.prefix;
|
||||
|
||||
public class RegisterPatterns {
|
||||
|
@ -109,13 +108,14 @@ public class RegisterPatterns {
|
|||
prefix("colorize"),
|
||||
OpColorize.INSTANCE);
|
||||
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqawqadaq", HexDir.SOUTH_EAST), prefix("create_water"),
|
||||
OpCreateWater.INSTANCE);
|
||||
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dedwedade", HexDir.SOUTH_WEST), prefix("destroy_water"),
|
||||
OpDestroyWater.INSTANCE);
|
||||
OpCreateWater.INSTANCE);
|
||||
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dedwedade", HexDir.SOUTH_WEST),
|
||||
prefix("destroy_water"),
|
||||
OpDestroyWater.INSTANCE);
|
||||
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqa", HexDir.NORTH_EAST), prefix("conjure_block"),
|
||||
new OpConjure(false));
|
||||
new OpConjure(false));
|
||||
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqd", HexDir.NORTH_EAST), prefix("conjure_light"),
|
||||
new OpConjure(true));
|
||||
new OpConjure(true));
|
||||
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waawawaawa", HexDir.NORTH_EAST), prefix("bonemeal"),
|
||||
OpTheOnlyReasonAnyoneDownloadedPsi.INSTANCE);
|
||||
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwaeaeaeaeaea", HexDir.NORTH_WEST),
|
||||
|
|
|
@ -1,19 +1,9 @@
|
|||
package at.petrak.hexcasting.common.casting.colors;
|
||||
|
||||
import at.petrak.hexcasting.common.ContributorList;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.items.colorizer.ItemDyeColorizer;
|
||||
import at.petrak.hexcasting.common.items.colorizer.ItemPoliticalColorizer;
|
||||
import at.petrak.hexcasting.common.lib.HexCapabilities;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.FastColor;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
@ -27,73 +17,12 @@ public class CapPreferredColorizer implements ICapabilitySerializable<CompoundTa
|
|||
public static final String CAP_NAME = "preferred_colorizer";
|
||||
public static final String TAG_COLOR = "colorizer";
|
||||
|
||||
public ItemStack colorizer;
|
||||
public FrozenColorizer colorizer;
|
||||
|
||||
public CapPreferredColorizer(ItemStack colorizer) {
|
||||
public CapPreferredColorizer(FrozenColorizer colorizer) {
|
||||
this.colorizer = colorizer;
|
||||
}
|
||||
|
||||
public static boolean isColorizer(Item item) {
|
||||
return item instanceof ItemDyeColorizer
|
||||
|| item instanceof ItemPoliticalColorizer
|
||||
|| item == HexItems.UUID_COLORIZER.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param time absolute world time in ticks
|
||||
* @param position a position for the icosahedron, a randomish number for particles.
|
||||
* @return an AARRGGBB color.
|
||||
*/
|
||||
public static int getColor(ItemStack colorizer, Player asker, float time, Vec3 position) {
|
||||
var proto = colorizer.getItem();
|
||||
if (proto instanceof ItemDyeColorizer dye) {
|
||||
return DyeColor.values()[dye.getDyeIdx()].getTextColor() | 0xff_000000;
|
||||
} else if (proto instanceof ItemPoliticalColorizer politics) {
|
||||
var colors = politics.getColors();
|
||||
return morphBetweenColors(colors, new Vec3(0.1, 0.1, 0.1), time / 20 / 20, position);
|
||||
} else if (proto == HexItems.UUID_COLORIZER.get()) {
|
||||
var playerName = asker.getName().getContents();
|
||||
var info = ContributorList.getContributor(playerName);
|
||||
if (info != null) {
|
||||
return morphBetweenColors(info.getColorizer(), new Vec3(0.1, 0.1, 0.1), time / 20 / 20, position);
|
||||
} else {
|
||||
var uuid = asker.getUUID();
|
||||
return FastColor.ARGB32.color(255,
|
||||
(int) (uuid.getLeastSignificantBits() & 0xff),
|
||||
(int) (uuid.getLeastSignificantBits() >>> 32 & 0xff),
|
||||
(int) (uuid.getMostSignificantBits() & 0xff));
|
||||
}
|
||||
}
|
||||
|
||||
return 0xff_ff00dc; // missing color
|
||||
}
|
||||
|
||||
private static int morphBetweenColors(int[] colors, Vec3 gradientDir, float time, Vec3 position) {
|
||||
float fIdx = ((time + (float) gradientDir.dot(position)) % 1f) * colors.length;
|
||||
|
||||
int baseIdx = Mth.floor(fIdx);
|
||||
float tRaw = fIdx - baseIdx;
|
||||
// float t = -(float) (Math.cbrt(Mth.cos(tRaw * Mth.PI)) / 2) + 0.5f;
|
||||
float t = tRaw;
|
||||
int start = colors[baseIdx];
|
||||
int end = colors[(baseIdx + 1) % colors.length];
|
||||
|
||||
var r1 = FastColor.ARGB32.red(start);
|
||||
var g1 = FastColor.ARGB32.green(start);
|
||||
var b1 = FastColor.ARGB32.blue(start);
|
||||
var a1 = FastColor.ARGB32.alpha(start);
|
||||
var r2 = FastColor.ARGB32.red(end);
|
||||
var g2 = FastColor.ARGB32.green(end);
|
||||
var b2 = FastColor.ARGB32.blue(end);
|
||||
var a2 = FastColor.ARGB32.alpha(end);
|
||||
|
||||
var r = Mth.lerp(t, r1, r2);
|
||||
var g = Mth.lerp(t, g1, g2);
|
||||
var b = Mth.lerp(t, b1, b2);
|
||||
var a = Mth.lerp(t, a1, a2);
|
||||
|
||||
return FastColor.ARGB32.color((int) a, (int) r, (int) g, (int) b);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
@ -104,13 +33,17 @@ public class CapPreferredColorizer implements ICapabilitySerializable<CompoundTa
|
|||
@Override
|
||||
public CompoundTag serializeNBT() {
|
||||
var tag = new CompoundTag();
|
||||
tag.put(TAG_COLOR, this.colorizer.serializeNBT());
|
||||
tag.put(TAG_COLOR, this.colorizer.serialize());
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundTag nbt) {
|
||||
var itemTag = nbt.getCompound(TAG_COLOR);
|
||||
this.colorizer = ItemStack.of(itemTag);
|
||||
if (nbt.contains(TAG_COLOR, Tag.TAG_COMPOUND)) {
|
||||
var colorizerTag = nbt.getCompound(TAG_COLOR);
|
||||
this.colorizer = FrozenColorizer.deserialize(colorizerTag);
|
||||
} else {
|
||||
this.colorizer = FrozenColorizer.DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
package at.petrak.hexcasting.common.casting.colors;
|
||||
|
||||
import at.petrak.hexcasting.common.ContributorList;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.items.colorizer.ItemDyeColorizer;
|
||||
import at.petrak.hexcasting.common.items.colorizer.ItemPoliticalColorizer;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.FastColor;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A colorizer item and the player who owned it at the time of making the color.
|
||||
*/
|
||||
public record FrozenColorizer(Item item, UUID owner) {
|
||||
public static final String TAG_ITEM = "item";
|
||||
public static final String TAG_OWNER = "owner";
|
||||
|
||||
public static final FrozenColorizer DEFAULT = new FrozenColorizer(HexItems.DYE_COLORIZERS[0].get(), Util.NIL_UUID);
|
||||
|
||||
public CompoundTag serialize() {
|
||||
var out = new CompoundTag();
|
||||
out.putString(TAG_ITEM, ForgeRegistries.ITEMS.getKey(this.item).toString());
|
||||
out.putUUID(TAG_OWNER, this.owner);
|
||||
return out;
|
||||
}
|
||||
|
||||
public static FrozenColorizer deserialize(CompoundTag tag) {
|
||||
var itemID = new ResourceLocation(tag.getString(TAG_ITEM));
|
||||
var item = ForgeRegistries.ITEMS.getValue(itemID);
|
||||
var uuid = tag.getUUID(TAG_OWNER);
|
||||
return new FrozenColorizer(item, uuid);
|
||||
}
|
||||
|
||||
public static boolean isColorizer(Item item) {
|
||||
return item instanceof ItemDyeColorizer
|
||||
|| item instanceof ItemPoliticalColorizer
|
||||
|| item == HexItems.UUID_COLORIZER.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
if (this.item instanceof ItemDyeColorizer dye) {
|
||||
return DyeColor.values()[dye.getDyeIdx()].getTextColor() | 0xff_000000;
|
||||
} else if (this.item instanceof ItemPoliticalColorizer politics) {
|
||||
var colors = politics.getColors();
|
||||
return morphBetweenColors(colors, new Vec3(0.1, 0.1, 0.1), time / 20 / 20, position);
|
||||
} else if (this.item == HexItems.UUID_COLORIZER.get()) {
|
||||
var info = ContributorList.getContributor(this.owner);
|
||||
if (info != null) {
|
||||
return morphBetweenColors(info.getColorizer(), new Vec3(0.1, 0.1, 0.1), time / 20 / 20, position);
|
||||
} else {
|
||||
// randomly scrungle the bits
|
||||
return FastColor.ARGB32.color(255,
|
||||
(int) (this.owner.getLeastSignificantBits() & 0xff),
|
||||
(int) (this.owner.getLeastSignificantBits() >>> 32 & 0xff),
|
||||
(int) (this.owner.getMostSignificantBits() & 0xff));
|
||||
}
|
||||
}
|
||||
|
||||
return 0xff_ff00dc; // missing color
|
||||
}
|
||||
|
||||
private static int morphBetweenColors(int[] colors, Vec3 gradientDir, float time, Vec3 position) {
|
||||
float fIdx = ((time + (float) gradientDir.dot(position)) % 1f) * colors.length;
|
||||
|
||||
int baseIdx = Mth.floor(fIdx);
|
||||
float tRaw = fIdx - baseIdx;
|
||||
// float t = -(float) (Math.cbrt(Mth.cos(tRaw * Mth.PI)) / 2) + 0.5f;
|
||||
float t = tRaw;
|
||||
int start = colors[baseIdx];
|
||||
int end = colors[(baseIdx + 1) % colors.length];
|
||||
|
||||
var r1 = FastColor.ARGB32.red(start);
|
||||
var g1 = FastColor.ARGB32.green(start);
|
||||
var b1 = FastColor.ARGB32.blue(start);
|
||||
var a1 = FastColor.ARGB32.alpha(start);
|
||||
var r2 = FastColor.ARGB32.red(end);
|
||||
var g2 = FastColor.ARGB32.green(end);
|
||||
var b2 = FastColor.ARGB32.blue(end);
|
||||
var a2 = FastColor.ARGB32.alpha(end);
|
||||
|
||||
var r = Mth.lerp(t, r1, r2);
|
||||
var g = Mth.lerp(t, g1, g2);
|
||||
var b = Mth.lerp(t, b1, b2);
|
||||
var a = Mth.lerp(t, a1, a2);
|
||||
|
||||
return FastColor.ARGB32.color((int) a, (int) r, (int) g, (int) b);
|
||||
}
|
||||
}
|
|
@ -4,11 +4,10 @@ import at.petrak.hexcasting.api.RenderedSpell
|
|||
import at.petrak.hexcasting.api.SpellDatum
|
||||
import at.petrak.hexcasting.api.SpellOperator
|
||||
import at.petrak.hexcasting.common.casting.CastingContext
|
||||
import at.petrak.hexcasting.common.casting.colors.CapPreferredColorizer
|
||||
import at.petrak.hexcasting.common.casting.colors.FrozenColorizer
|
||||
import at.petrak.hexcasting.common.lib.HexCapabilities
|
||||
import at.petrak.hexcasting.common.network.HexMessages
|
||||
import at.petrak.hexcasting.common.network.MsgColorizerUpdateAck
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import net.minecraftforge.network.PacketDistributor
|
||||
|
||||
|
@ -31,10 +30,9 @@ object OpColorize : SpellOperator {
|
|||
val cap = maybeCap.get()
|
||||
|
||||
val otherHandItem = ctx.caster.getItemInHand(ctx.otherHand)
|
||||
if (CapPreferredColorizer.isColorizer(otherHandItem.item)) {
|
||||
val copied = ItemStack(otherHandItem.item, 1)
|
||||
if (FrozenColorizer.isColorizer(otherHandItem.item)) {
|
||||
cap.colorizer = FrozenColorizer(otherHandItem.item, ctx.caster.uuid)
|
||||
ctx.withdrawItem(otherHandItem.item, 1, true)
|
||||
cap.colorizer = copied
|
||||
|
||||
HexMessages.getNetwork().send(PacketDistributor.PLAYER.with { ctx.caster }, MsgColorizerUpdateAck(cap))
|
||||
}
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
package at.petrak.hexcasting.common.items.colorizer;
|
||||
|
||||
import at.petrak.hexcasting.common.blocks.BlockConjured;
|
||||
import at.petrak.hexcasting.common.blocks.HexBlocks;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class ItemColorizer extends Item {
|
||||
public ItemColorizer(Properties pProperties) {
|
||||
super(pProperties);
|
||||
}
|
||||
|
||||
public abstract int[] getColors();
|
||||
|
||||
@Override
|
||||
public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {
|
||||
boolean enabled = false;
|
||||
if (enabled && !pContext.getLevel().isClientSide()) {
|
||||
pContext.getLevel().setBlock(pContext.getClickedPos().relative(pContext.getClickedFace()), HexBlocks.CONJURED.get().defaultBlockState(), 3);
|
||||
if (pContext.getLevel().getBlockState(pContext.getClickedPos().relative(pContext.getClickedFace())).getBlock() instanceof BlockConjured) {
|
||||
BlockConjured.setColor(pContext.getLevel(), pContext.getClickedPos().relative(pContext.getClickedFace()), pContext.getItemInHand());
|
||||
}
|
||||
}
|
||||
return super.useOn(pContext);
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package at.petrak.hexcasting.common.items.colorizer;
|
||||
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class ItemDyeColorizer extends ItemColorizer {
|
||||
public class ItemDyeColorizer extends Item {
|
||||
private final int dyeIdx;
|
||||
|
||||
public ItemDyeColorizer(int dyeIdx, Properties pProperties) {
|
||||
|
@ -13,9 +13,4 @@ public class ItemDyeColorizer extends ItemColorizer {
|
|||
public int getDyeIdx() {
|
||||
return dyeIdx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getColors() {
|
||||
return new int[]{DyeColor.byId(getDyeIdx()).getFireworkColor()};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package at.petrak.hexcasting.common.items.colorizer;
|
||||
|
||||
public class ItemPoliticalColorizer extends ItemColorizer {
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class ItemPoliticalColorizer extends Item {
|
||||
private final int idx;
|
||||
|
||||
public ItemPoliticalColorizer(int idx, Properties pProperties) {
|
||||
|
|
|
@ -2,9 +2,9 @@ package at.petrak.hexcasting.common.lib;
|
|||
|
||||
import at.petrak.hexcasting.HexMod;
|
||||
import at.petrak.hexcasting.common.casting.colors.CapPreferredColorizer;
|
||||
import at.petrak.hexcasting.common.casting.colors.FrozenColorizer;
|
||||
import at.petrak.hexcasting.common.casting.operators.spells.great.OpFlight;
|
||||
import at.petrak.hexcasting.common.casting.operators.spells.sentinel.CapSentinel;
|
||||
import at.petrak.hexcasting.common.items.HexItems;
|
||||
import at.petrak.hexcasting.common.network.HexMessages;
|
||||
import at.petrak.hexcasting.common.network.MsgColorizerUpdateAck;
|
||||
import at.petrak.hexcasting.common.network.MsgSentinelStatusUpdateAck;
|
||||
|
@ -12,7 +12,6 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
|
@ -48,7 +47,7 @@ public class HexCapabilities {
|
|||
evt.addCapability(new ResourceLocation(HexMod.MOD_ID, CapSentinel.CAP_NAME),
|
||||
new CapSentinel(false, false, Vec3.ZERO));
|
||||
evt.addCapability(new ResourceLocation(HexMod.MOD_ID, CapPreferredColorizer.CAP_NAME),
|
||||
new CapPreferredColorizer(new ItemStack(HexItems.DYE_COLORIZERS[0].get())));
|
||||
new CapPreferredColorizer(FrozenColorizer.DEFAULT));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package at.petrak.hexcasting.common.network;
|
||||
|
||||
import at.petrak.hexcasting.common.casting.colors.CapPreferredColorizer;
|
||||
import at.petrak.hexcasting.common.casting.colors.FrozenColorizer;
|
||||
import at.petrak.hexcasting.common.lib.HexCapabilities;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
@ -21,9 +20,9 @@ public record MsgColorizerUpdateAck(CapPreferredColorizer update) {
|
|||
var buf = new FriendlyByteBuf(buffer);
|
||||
|
||||
var tag = buf.readAnySizeNbt();
|
||||
var sentinel = new CapPreferredColorizer(new ItemStack(Items.AIR));
|
||||
sentinel.deserializeNBT(tag);
|
||||
return new MsgColorizerUpdateAck(sentinel);
|
||||
var colorizer = new CapPreferredColorizer(FrozenColorizer.DEFAULT);
|
||||
colorizer.deserializeNBT(tag);
|
||||
return new MsgColorizerUpdateAck(colorizer);
|
||||
}
|
||||
|
||||
public void serialize(ByteBuf buffer) {
|
||||
|
|
Loading…
Reference in a new issue