not sure if this is a good look? might go with a BER after all

This commit is contained in:
petrak@ 2023-02-15 19:14:26 -06:00
parent 588a554efa
commit 88a0234cec
24 changed files with 506 additions and 280 deletions

View file

@ -1,4 +1,4 @@
// 1.19.2 2022-11-05T14:30:43.69127 Block States: hexcasting
// 1.19.2 2023-02-15T18:25:55.007347158 Block States: hexcasting
901e38574bdaa40ea4a0f6e773a88a95d9c03e55 assets/hexcasting/blockstates/akashic_bookshelf.json
32a77ef668198002563d68be35a24fa93c8d454a assets/hexcasting/blockstates/akashic_connector.json
85080ce0a0387583a839e4788517d675a1a35e24 assets/hexcasting/blockstates/akashic_record.json
@ -134,6 +134,10 @@ de2a5fd9b621e5086852f2191c360d9274b9b10c assets/hexcasting/models/block/impetus_
7ac5cb74f321b061c1e93b859540b508c7dcdaa4 assets/hexcasting/models/block/impetus_storedplayer_lit_south.json
46c29660e3fa78aeaa264268b43017f4b0c0d655 assets/hexcasting/models/block/impetus_storedplayer_lit_up.json
4d22557274958179da4671c43c2f387336a701a2 assets/hexcasting/models/block/impetus_storedplayer_lit_west.json
9af2754cb1e53eeaa85618cf92651b4878cf62b1 assets/hexcasting/models/block/quenched_allay_0.json
de4ff723b4332d4e26bd01f74e0485e28c9a2178 assets/hexcasting/models/block/quenched_allay_1.json
4c29163e07f3a903017e38a9cc102f4b37db20b1 assets/hexcasting/models/block/quenched_allay_2.json
487d34cd8e70b3e468337228b74af5c1b4d14c53 assets/hexcasting/models/block/quenched_allay_3.json
e1e7ce0bcc08a53b3e6634f7e5b7a6cf488cf45b assets/hexcasting/models/block/redstone_directrix_powered_dim_down.json
fb22e529f1ca638b7e952176694ab1912eb4274b assets/hexcasting/models/block/redstone_directrix_powered_dim_east.json
a5a53ec6a3cd54592dcb224245a4515a2b3b72ed assets/hexcasting/models/block/redstone_directrix_powered_dim_north.json
@ -185,6 +189,10 @@ d4a109488c27fc5d60e9054cd1485f1982040ff3 assets/hexcasting/models/item/ancient_s
40e22b81ff5a65154cbb82e2a17a19abbc898e63 assets/hexcasting/models/item/impetus_look.json
485b2fdbe038c1671f7d67747e8d640a2f171266 assets/hexcasting/models/item/impetus_rightclick.json
064caa7c4c05c5f0736fe09745ad42eb4515e767 assets/hexcasting/models/item/impetus_storedplayer.json
bab05b6c9632359d9a2961221d18bf63abccf803 assets/hexcasting/models/item/quenched_allay_0.json
2df419ac393b73acc2c679394d89b38db5af4b04 assets/hexcasting/models/item/quenched_allay_1.json
9e0bcaf7d32799af125ce3487f8a6cdd03bf7c49 assets/hexcasting/models/item/quenched_allay_2.json
da748fddb87f4130b21a30f70f11159f98b0125d assets/hexcasting/models/item/quenched_allay_3.json
769dcfb4a504e4dcd28a43cf603a18c66f57e594 assets/hexcasting/models/item/scroll_paper.json
222e40e5754f5cb5a04321c4ed4cee27748c9224 assets/hexcasting/models/item/scroll_paper_lantern.json
145db42b0d90bdb4fd82f5a7eea229be4c0f9675 assets/hexcasting/models/item/slate_block.json

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "hexcasting:block/quenched_allay_0"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "hexcasting:block/quenched_allay_1"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "hexcasting:block/quenched_allay_2"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "hexcasting:block/quenched_allay_3"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "hexcasting:block/quenched_allay_0"
}

View file

@ -0,0 +1,3 @@
{
"parent": "hexcasting:block/quenched_allay_1"
}

View file

@ -0,0 +1,3 @@
{
"parent": "hexcasting:block/quenched_allay_2"
}

View file

@ -0,0 +1,3 @@
{
"parent": "hexcasting:block/quenched_allay_3"
}

View file

@ -0,0 +1,69 @@
package at.petrak.hexcasting;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemOverrides;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.Direction;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class GaslightingModel implements BakedModel {
private static int GASLIGHTING_AMOUNT = 0;
private static boolean HAS_RENDERED_THIS_FRAME = false;
private final List<BakedModel> variants;
private final BakedModel wrapped;
public GaslightingModel(List<BakedModel> variants) {
this.variants = variants;
this.wrapped = this.variants.get(0);
}
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction direction, RandomSource random) {
HAS_RENDERED_THIS_FRAME = true;
var idx = Math.abs(GASLIGHTING_AMOUNT % this.variants.size());
return this.variants.get(idx).getQuads(state, direction, random);
}
public boolean useAmbientOcclusion() {
return this.wrapped.useAmbientOcclusion();
}
public boolean isGui3d() {
return this.wrapped.isGui3d();
}
public boolean usesBlockLight() {
return this.wrapped.usesBlockLight();
}
public boolean isCustomRenderer() {
return this.wrapped.isCustomRenderer();
}
public TextureAtlasSprite getParticleIcon() {
return this.wrapped.getParticleIcon();
}
public ItemTransforms getTransforms() {
return this.wrapped.getTransforms();
}
public ItemOverrides getOverrides() {
return this.wrapped.getOverrides();
}
public static void postFrameCheckRendered() {
if (!HAS_RENDERED_THIS_FRAME) {
GASLIGHTING_AMOUNT += 1;
}
HAS_RENDERED_THIS_FRAME = false;
}
}

View file

@ -1,5 +1,6 @@
package at.petrak.hexcasting.client;
import at.petrak.hexcasting.GaslightingModel;
import net.minecraft.client.Minecraft;
public class ClientTickCounter {
@ -7,7 +8,7 @@ public class ClientTickCounter {
public static float partialTicks = 0.0F;
public static float getTotal() {
return (float)ticksInGame + partialTicks;
return (float) ticksInGame + partialTicks;
}
public static void renderTickStart(float renderTickTime) {
@ -18,6 +19,7 @@ public class ClientTickCounter {
if (!Minecraft.getInstance().isPaused()) {
++ticksInGame;
partialTicks = 0.0F;
GaslightingModel.postFrameCheckRendered();
}
}
}

View file

@ -1,8 +1,6 @@
package at.petrak.hexcasting.client;
import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus;
import at.petrak.hexcasting.api.block.circle.BlockEntityAbstractImpetus;
import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry;
import at.petrak.hexcasting.GaslightingModel;
import at.petrak.hexcasting.api.item.IotaHolderItem;
import at.petrak.hexcasting.api.item.MediaHolderItem;
import at.petrak.hexcasting.api.misc.MediaConstants;
@ -10,6 +8,7 @@ import at.petrak.hexcasting.api.utils.NBTHelper;
import at.petrak.hexcasting.client.be.BlockEntityAkashicBookshelfRenderer;
import at.petrak.hexcasting.client.be.BlockEntitySlateRenderer;
import at.petrak.hexcasting.client.entity.WallScrollRenderer;
import at.petrak.hexcasting.common.blocks.BlockQuenchedAllay;
import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicBookshelf;
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicBookshelf;
import at.petrak.hexcasting.common.entities.HexEntities;
@ -22,37 +21,31 @@ import at.petrak.hexcasting.common.lib.HexBlocks;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
import com.mojang.datafixers.util.Pair;
import net.minecraft.ChatFormatting;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextColor;
import net.minecraft.util.Mth;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.ComparatorMode;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.block.state.properties.RailShape;
import net.minecraft.world.level.material.MaterialColor;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.ToIntFunction;
import java.util.function.UnaryOperator;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
public class RegisterClientStuff {
public static void init() {
@ -126,7 +119,7 @@ public class RegisterClientStuff {
// Minecraft.getInstance().getTextureManager().bindForSetup(tex);
// }
addScryingLensStuff();
ScryingLensOverlays.addScryingLensStuff();
}
public static void registerColorProviders(BiConsumer<ItemColor, Item> itemColorRegistry,
@ -166,152 +159,6 @@ public class RegisterClientStuff {
};
}
private static void addScryingLensStuff() {
ScryingLensOverlayRegistry.addPredicateDisplayer(
(state, pos, observer, world, direction) -> state.getBlock() instanceof BlockAbstractImpetus,
(lines, state, pos, observer, world, direction) -> {
if (world.getBlockEntity(pos) instanceof BlockEntityAbstractImpetus beai) {
beai.applyScryingLensOverlay(lines, state, pos, observer, world, direction);
}
});
ScryingLensOverlayRegistry.addDisplayer(Blocks.NOTE_BLOCK,
(lines, state, pos, observer, world, direction) -> {
int note = state.getValue(NoteBlock.NOTE);
float rCol = Math.max(0.0F, Mth.sin((note / 24F + 0.0F) * Mth.TWO_PI) * 0.65F + 0.35F);
float gCol = Math.max(0.0F, Mth.sin((note / 24F + 0.33333334F) * Mth.TWO_PI) * 0.65F + 0.35F);
float bCol = Math.max(0.0F, Mth.sin((note / 24F + 0.6666667F) * Mth.TWO_PI) * 0.65F + 0.35F);
int noteColor = 0xFF_000000 | Mth.color(rCol, gCol, bCol);
var instrument = state.getValue(NoteBlock.INSTRUMENT);
lines.add(new Pair<>(
new ItemStack(Items.MUSIC_DISC_CHIRP),
Component.literal(String.valueOf(instrument.ordinal()))
.withStyle(color(instrumentColor(instrument)))));
lines.add(new Pair<>(
new ItemStack(Items.NOTE_BLOCK),
Component.literal(String.valueOf(note))
.withStyle(color(noteColor))));
});
ScryingLensOverlayRegistry.addDisplayer(HexBlocks.AKASHIC_BOOKSHELF,
(lines, state, pos, observer, world, direction) -> {
if (world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile) {
var iotaTag = tile.getIotaTag();
if (iotaTag != null) {
var display = HexIotaTypes.getDisplay(iotaTag);
lines.add(new Pair<>(new ItemStack(Items.BOOK), display));
}
}
});
ScryingLensOverlayRegistry.addDisplayer(Blocks.COMPARATOR,
(lines, state, pos, observer, world, direction) -> {
int comparatorValue = ScryingLensOverlayRegistry.getComparatorValue(true);
lines.add(new Pair<>(
new ItemStack(Items.REDSTONE),
Component.literal(comparatorValue == -1 ? "" : String.valueOf(comparatorValue))
.withStyle(redstoneColor(comparatorValue))));
boolean compare = state.getValue(ComparatorBlock.MODE) == ComparatorMode.COMPARE;
lines.add(new Pair<>(
new ItemStack(Items.REDSTONE_TORCH),
Component.literal(compare ? ">=" : "-")
.withStyle(redstoneColor(compare ? 0 : 15))));
});
ScryingLensOverlayRegistry.addDisplayer(Blocks.POWERED_RAIL,
(lines, state, pos, observer, world, direction) -> {
int power = getPoweredRailStrength(world, pos, state);
lines.add(new Pair<>(
new ItemStack(Items.POWERED_RAIL),
Component.literal(String.valueOf(power))
.withStyle(redstoneColor(power, 9))));
});
ScryingLensOverlayRegistry.addDisplayer(Blocks.REPEATER,
(lines, state, pos, observer, world, direction) -> lines.add(new Pair<>(
new ItemStack(Items.CLOCK),
Component.literal(String.valueOf(state.getValue(RepeaterBlock.DELAY)))
.withStyle(ChatFormatting.YELLOW))));
ScryingLensOverlayRegistry.addPredicateDisplayer(
(state, pos, observer, world, direction) -> state.getBlock() instanceof BeehiveBlock,
(lines, state, pos, observer, world, direction) -> {
int count = ScryingLensOverlayRegistry.getBeeValue();
lines.add(new Pair<>(new ItemStack(Items.BEE_NEST), count == -1 ? Component.empty() :
Component.translatable(
"hexcasting.tooltip.lens.bee" + (count == 1 ? ".single" : ""),
count
)));
});
ScryingLensOverlayRegistry.addPredicateDisplayer(
(state, pos, observer, world, direction) -> state.isSignalSource() && !state.is(
Blocks.COMPARATOR),
(lines, state, pos, observer, world, direction) -> {
int signalStrength = 0;
if (state.getBlock() instanceof RedStoneWireBlock) {
signalStrength = state.getValue(RedStoneWireBlock.POWER);
} else {
for (Direction dir : Direction.values()) {
signalStrength = Math.max(signalStrength, state.getSignal(world, pos, dir));
}
}
lines.add(0, new Pair<>(
new ItemStack(Items.REDSTONE),
Component.literal(String.valueOf(signalStrength))
.withStyle(redstoneColor(signalStrength))));
});
ScryingLensOverlayRegistry.addPredicateDisplayer(
(state, pos, observer, world, direction) -> state.hasAnalogOutputSignal(),
(lines, state, pos, observer, world, direction) -> {
int comparatorValue = ScryingLensOverlayRegistry.getComparatorValue(false);
lines.add(
new Pair<>(
new ItemStack(Items.COMPARATOR),
Component.literal(comparatorValue == -1 ? "" : String.valueOf(comparatorValue))
.withStyle(redstoneColor(comparatorValue))));
});
}
private static UnaryOperator<Style> color(int color) {
return (style) -> style.withColor(TextColor.fromRgb(color));
}
private static UnaryOperator<Style> redstoneColor(int power) {
return redstoneColor(power, 15);
}
private static UnaryOperator<Style> redstoneColor(int power, int max) {
return color(RedStoneWireBlock.getColorForPower(Mth.clamp((power * max) / 15, 0, 15)));
}
private static int instrumentColor(NoteBlockInstrument instrument) {
return switch (instrument) {
case BASEDRUM -> MaterialColor.STONE.col;
case SNARE, XYLOPHONE, PLING -> MaterialColor.SAND.col;
case HAT -> MaterialColor.QUARTZ.col;
case BASS -> MaterialColor.WOOD.col;
case FLUTE -> MaterialColor.CLAY.col;
case BELL -> MaterialColor.GOLD.col;
case GUITAR -> MaterialColor.WOOL.col;
case CHIME -> MaterialColor.ICE.col;
case IRON_XYLOPHONE -> MaterialColor.METAL.col;
case COW_BELL -> MaterialColor.COLOR_BROWN.col;
case DIDGERIDOO -> MaterialColor.COLOR_ORANGE.col;
case BIT -> MaterialColor.EMERALD.col;
case BANJO -> MaterialColor.COLOR_YELLOW.col;
default -> -1;
};
}
private static void registerSealableDataHolderOverrides(IotaHolderItem item, Predicate<ItemStack> hasIota,
Predicate<ItemStack> isSealed) {
IClientXplatAbstractions.INSTANCE.registerItemProperty((Item) item, ItemFocus.OVERLAY_PRED,
@ -326,116 +173,6 @@ public class RegisterClientStuff {
});
}
private static int getPoweredRailStrength(Level level, BlockPos pos, BlockState state) {
if (level.hasNeighborSignal(pos))
return 9;
int positiveValue = findPoweredRailSignal(level, pos, state, true, 0);
int negativeValue = findPoweredRailSignal(level, pos, state, false, 0);
return Math.max(positiveValue, negativeValue);
}
// Copypasta from PoweredRailBlock.class
private static int findPoweredRailSignal(Level level, BlockPos pos, BlockState state, boolean travelPositive,
int depth) {
if (depth >= 8) {
return 0;
} else {
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
boolean descending = true;
RailShape shape = state.getValue(PoweredRailBlock.SHAPE);
switch (shape) {
case NORTH_SOUTH:
if (travelPositive) {
++z;
} else {
--z;
}
break;
case EAST_WEST:
if (travelPositive) {
--x;
} else {
++x;
}
break;
case ASCENDING_EAST:
if (travelPositive) {
--x;
} else {
++x;
++y;
descending = false;
}
shape = RailShape.EAST_WEST;
break;
case ASCENDING_WEST:
if (travelPositive) {
--x;
++y;
descending = false;
} else {
++x;
}
shape = RailShape.EAST_WEST;
break;
case ASCENDING_NORTH:
if (travelPositive) {
++z;
} else {
--z;
++y;
descending = false;
}
shape = RailShape.NORTH_SOUTH;
break;
case ASCENDING_SOUTH:
if (travelPositive) {
++z;
++y;
descending = false;
} else {
--z;
}
shape = RailShape.NORTH_SOUTH;
}
int power = getPowerFromRail(level, new BlockPos(x, y, z), travelPositive, depth, shape);
if (power > 0) {
return power;
} else if (descending) {
return getPowerFromRail(level, new BlockPos(x, y - 1, z), travelPositive, depth, shape);
} else {
return 0;
}
}
}
private static int getPowerFromRail(Level level, BlockPos pos, boolean travelPositive, int depth, RailShape shape) {
BlockState otherState = level.getBlockState(pos);
if (!otherState.is(Blocks.POWERED_RAIL)) {
return 0;
} else {
RailShape otherShape = otherState.getValue(PoweredRailBlock.SHAPE);
if (shape == RailShape.EAST_WEST && (otherShape == RailShape.NORTH_SOUTH || otherShape == RailShape.ASCENDING_NORTH || otherShape == RailShape.ASCENDING_SOUTH)) {
return 0;
} else if (shape == RailShape.NORTH_SOUTH && (otherShape == RailShape.EAST_WEST || otherShape == RailShape.ASCENDING_EAST || otherShape == RailShape.ASCENDING_WEST)) {
return 0;
} else if (otherState.getValue(PoweredRailBlock.POWERED)) {
return level.hasNeighborSignal(pos) ? 8 - depth : findPoweredRailSignal(level, pos, otherState,
travelPositive, depth + 1);
} else {
return 0;
}
}
}
private static void registerScrollOverrides(ItemScroll scroll) {
IClientXplatAbstractions.INSTANCE.registerItemProperty(scroll, ItemScroll.ANCIENT_PREDICATE,
(stack, level, holder, holderID) -> NBTHelper.hasString(stack, ItemScroll.TAG_OP_ID) ? 1f : 0f);
@ -474,4 +211,20 @@ public class RegisterClientStuff {
<T extends BlockEntity> void registerBlockEntityRenderer(BlockEntityType<T> type,
BlockEntityRendererProvider<? super T> berp);
}
public static void onModelRegister(ResourceManager recMan, Consumer<ResourceLocation> extraModels) {
for (int i = 0; i < BlockQuenchedAllay.VARIANTS; i++) {
extraModels.accept(modLoc("block/quenched_allay_" + i));
}
}
public static void onModelBake(ModelBakery loader, Map<ResourceLocation, BakedModel> map) {
var quenchedName = new ModelResourceLocation(modLoc("quenched_allay"), "");
var variants = new ArrayList<BakedModel>(BlockQuenchedAllay.VARIANTS);
for (int i = 0; i < BlockQuenchedAllay.VARIANTS; i++) {
var variantLoc = modLoc("block/quenched_allay_" + i);
variants.add(map.get(variantLoc));
}
map.put(quenchedName, new GaslightingModel(variants));
}
}

View file

@ -0,0 +1,288 @@
package at.petrak.hexcasting.client;
import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus;
import at.petrak.hexcasting.api.block.circle.BlockEntityAbstractImpetus;
import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry;
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicBookshelf;
import at.petrak.hexcasting.common.lib.HexBlocks;
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import com.mojang.datafixers.util.Pair;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextColor;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.ComparatorMode;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.block.state.properties.RailShape;
import net.minecraft.world.level.material.MaterialColor;
import java.util.function.UnaryOperator;
public class ScryingLensOverlays {
public static void addScryingLensStuff() {
ScryingLensOverlayRegistry.addPredicateDisplayer(
(state, pos, observer, world, direction) -> state.getBlock() instanceof BlockAbstractImpetus,
(lines, state, pos, observer, world, direction) -> {
if (world.getBlockEntity(pos) instanceof BlockEntityAbstractImpetus beai) {
beai.applyScryingLensOverlay(lines, state, pos, observer, world, direction);
}
});
ScryingLensOverlayRegistry.addDisplayer(Blocks.NOTE_BLOCK,
(lines, state, pos, observer, world, direction) -> {
int note = state.getValue(NoteBlock.NOTE);
float rCol = Math.max(0.0F, Mth.sin((note / 24F + 0.0F) * Mth.TWO_PI) * 0.65F + 0.35F);
float gCol = Math.max(0.0F, Mth.sin((note / 24F + 0.33333334F) * Mth.TWO_PI) * 0.65F + 0.35F);
float bCol = Math.max(0.0F, Mth.sin((note / 24F + 0.6666667F) * Mth.TWO_PI) * 0.65F + 0.35F);
int noteColor = 0xFF_000000 | Mth.color(rCol, gCol, bCol);
var instrument = state.getValue(NoteBlock.INSTRUMENT);
lines.add(new Pair<>(
new ItemStack(Items.MUSIC_DISC_CHIRP),
Component.literal(String.valueOf(instrument.ordinal()))
.withStyle(color(instrumentColor(instrument)))));
lines.add(new Pair<>(
new ItemStack(Items.NOTE_BLOCK),
Component.literal(String.valueOf(note))
.withStyle(color(noteColor))));
});
ScryingLensOverlayRegistry.addDisplayer(HexBlocks.AKASHIC_BOOKSHELF,
(lines, state, pos, observer, world, direction) -> {
if (world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile) {
var iotaTag = tile.getIotaTag();
if (iotaTag != null) {
var display = HexIotaTypes.getDisplay(iotaTag);
lines.add(new Pair<>(new ItemStack(Items.BOOK), display));
}
}
});
ScryingLensOverlayRegistry.addDisplayer(Blocks.COMPARATOR,
(lines, state, pos, observer, world, direction) -> {
int comparatorValue = ScryingLensOverlayRegistry.getComparatorValue(true);
lines.add(new Pair<>(
new ItemStack(Items.REDSTONE),
Component.literal(comparatorValue == -1 ? "" : String.valueOf(comparatorValue))
.withStyle(redstoneColor(comparatorValue))));
boolean compare = state.getValue(ComparatorBlock.MODE) == ComparatorMode.COMPARE;
lines.add(new Pair<>(
new ItemStack(Items.REDSTONE_TORCH),
Component.literal(compare ? ">=" : "-")
.withStyle(redstoneColor(compare ? 0 : 15))));
});
ScryingLensOverlayRegistry.addDisplayer(Blocks.POWERED_RAIL,
(lines, state, pos, observer, world, direction) -> {
int power = getPoweredRailStrength(world, pos, state);
lines.add(new Pair<>(
new ItemStack(Items.POWERED_RAIL),
Component.literal(String.valueOf(power))
.withStyle(redstoneColor(power, 9))));
});
ScryingLensOverlayRegistry.addDisplayer(Blocks.REPEATER,
(lines, state, pos, observer, world, direction) -> lines.add(new Pair<>(
new ItemStack(Items.CLOCK),
Component.literal(String.valueOf(state.getValue(RepeaterBlock.DELAY)))
.withStyle(ChatFormatting.YELLOW))));
ScryingLensOverlayRegistry.addPredicateDisplayer(
(state, pos, observer, world, direction) -> state.getBlock() instanceof BeehiveBlock,
(lines, state, pos, observer, world, direction) -> {
int count = ScryingLensOverlayRegistry.getBeeValue();
lines.add(new Pair<>(new ItemStack(Items.BEE_NEST), count == -1 ? Component.empty() :
Component.translatable(
"hexcasting.tooltip.lens.bee" + (count == 1 ? ".single" : ""),
count
)));
});
ScryingLensOverlayRegistry.addPredicateDisplayer(
(state, pos, observer, world, direction) -> state.isSignalSource() && !state.is(
Blocks.COMPARATOR),
(lines, state, pos, observer, world, direction) -> {
int signalStrength = 0;
if (state.getBlock() instanceof RedStoneWireBlock) {
signalStrength = state.getValue(RedStoneWireBlock.POWER);
} else {
for (Direction dir : Direction.values()) {
signalStrength = Math.max(signalStrength, state.getSignal(world, pos, dir));
}
}
lines.add(0, new Pair<>(
new ItemStack(Items.REDSTONE),
Component.literal(String.valueOf(signalStrength))
.withStyle(redstoneColor(signalStrength))));
});
ScryingLensOverlayRegistry.addPredicateDisplayer(
(state, pos, observer, world, direction) -> state.hasAnalogOutputSignal(),
(lines, state, pos, observer, world, direction) -> {
int comparatorValue = ScryingLensOverlayRegistry.getComparatorValue(false);
lines.add(
new Pair<>(
new ItemStack(Items.COMPARATOR),
Component.literal(comparatorValue == -1 ? "" : String.valueOf(comparatorValue))
.withStyle(redstoneColor(comparatorValue))));
});
}
private static int getPoweredRailStrength(Level level, BlockPos pos, BlockState state) {
if (level.hasNeighborSignal(pos))
return 9;
int positiveValue = findPoweredRailSignal(level, pos, state, true, 0);
int negativeValue = findPoweredRailSignal(level, pos, state, false, 0);
return Math.max(positiveValue, negativeValue);
}
// Copypasta from PoweredRailBlock.class
private static int findPoweredRailSignal(Level level, BlockPos pos, BlockState state, boolean travelPositive,
int depth) {
if (depth >= 8) {
return 0;
} else {
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
boolean descending = true;
RailShape shape = state.getValue(PoweredRailBlock.SHAPE);
switch (shape) {
case NORTH_SOUTH:
if (travelPositive) {
++z;
} else {
--z;
}
break;
case EAST_WEST:
if (travelPositive) {
--x;
} else {
++x;
}
break;
case ASCENDING_EAST:
if (travelPositive) {
--x;
} else {
++x;
++y;
descending = false;
}
shape = RailShape.EAST_WEST;
break;
case ASCENDING_WEST:
if (travelPositive) {
--x;
++y;
descending = false;
} else {
++x;
}
shape = RailShape.EAST_WEST;
break;
case ASCENDING_NORTH:
if (travelPositive) {
++z;
} else {
--z;
++y;
descending = false;
}
shape = RailShape.NORTH_SOUTH;
break;
case ASCENDING_SOUTH:
if (travelPositive) {
++z;
++y;
descending = false;
} else {
--z;
}
shape = RailShape.NORTH_SOUTH;
}
int power = getPowerFromRail(level, new BlockPos(x, y, z), travelPositive, depth,
shape);
if (power > 0) {
return power;
} else if (descending) {
return getPowerFromRail(level, new BlockPos(x, y - 1, z), travelPositive, depth,
shape);
} else {
return 0;
}
}
}
private static UnaryOperator<Style> color(int color) {
return (style) -> style.withColor(TextColor.fromRgb(color));
}
private static UnaryOperator<Style> redstoneColor(int power) {
return redstoneColor(power, 15);
}
private static UnaryOperator<Style> redstoneColor(int power, int max) {
return color(RedStoneWireBlock.getColorForPower(Mth.clamp((power * max) / 15, 0, 15)));
}
private static int instrumentColor(NoteBlockInstrument instrument) {
return switch (instrument) {
case BASEDRUM -> MaterialColor.STONE.col;
case SNARE, XYLOPHONE, PLING -> MaterialColor.SAND.col;
case HAT -> MaterialColor.QUARTZ.col;
case BASS -> MaterialColor.WOOD.col;
case FLUTE -> MaterialColor.CLAY.col;
case BELL -> MaterialColor.GOLD.col;
case GUITAR -> MaterialColor.WOOL.col;
case CHIME -> MaterialColor.ICE.col;
case IRON_XYLOPHONE -> MaterialColor.METAL.col;
case COW_BELL -> MaterialColor.COLOR_BROWN.col;
case DIDGERIDOO -> MaterialColor.COLOR_ORANGE.col;
case BIT -> MaterialColor.EMERALD.col;
case BANJO -> MaterialColor.COLOR_YELLOW.col;
default -> -1;
};
}
private static int getPowerFromRail(Level level, BlockPos pos, boolean travelPositive, int depth, RailShape shape) {
BlockState otherState = level.getBlockState(pos);
if (!otherState.is(Blocks.POWERED_RAIL)) {
return 0;
} else {
RailShape otherShape = otherState.getValue(PoweredRailBlock.SHAPE);
if (shape == RailShape.EAST_WEST && (otherShape == RailShape.NORTH_SOUTH || otherShape == RailShape.ASCENDING_NORTH || otherShape == RailShape.ASCENDING_SOUTH)) {
return 0;
} else if (shape == RailShape.NORTH_SOUTH && (otherShape == RailShape.EAST_WEST || otherShape == RailShape.ASCENDING_EAST || otherShape == RailShape.ASCENDING_WEST)) {
return 0;
} else if (otherState.getValue(PoweredRailBlock.POWERED)) {
return level.hasNeighborSignal(pos) ? 8 - depth : findPoweredRailSignal(level, pos, otherState,
travelPositive, depth + 1);
} else {
return 0;
}
}
}
}

View file

@ -0,0 +1,11 @@
package at.petrak.hexcasting.common.blocks;
import net.minecraft.world.level.block.Block;
public class BlockQuenchedAllay extends Block {
public static final int VARIANTS = 4;
public BlockQuenchedAllay(Properties properties) {
super(properties);
}
}

View file

@ -4,6 +4,7 @@ import at.petrak.hexcasting.api.block.circle.BlockAbstractImpetus;
import at.petrak.hexcasting.common.blocks.BlockConjured;
import at.petrak.hexcasting.common.blocks.BlockConjuredLight;
import at.petrak.hexcasting.common.blocks.BlockFlammable;
import at.petrak.hexcasting.common.blocks.BlockQuenchedAllay;
import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicBookshelf;
import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicLigature;
import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicRecord;
@ -146,6 +147,9 @@ public class HexBlocks {
public static final BlockAkashicLigature AKASHIC_LIGATURE = blockItem("akashic_connector",
new BlockAkashicLigature(akashicWoodyHard().lightLevel(bs -> 4)));
public static final BlockQuenchedAllay QUENCHED_ALLAY = blockItem("quenched_allay",
new BlockQuenchedAllay(BlockBehaviour.Properties.copy(Blocks.AMETHYST_BLOCK)));
// Decoration?!
public static final Block SLATE_BLOCK = blockItem("slate_block", new Block(slateish().strength(2f, 4f)));
public static final SandBlock AMETHYST_DUST_BLOCK = blockItem("amethyst_dust_block",

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

View file

@ -12,6 +12,7 @@ import at.petrak.hexcasting.fabric.network.FabricPacketHandler
import at.petrak.hexcasting.interop.HexInterop
import net.fabricmc.api.ClientModInitializer
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry
import net.fabricmc.fabric.api.client.rendering.v1.*
@ -67,5 +68,6 @@ object FabricHexClientInitializer : ClientModInitializer {
RegisterClientStuff.registerColorProviders(
{ colorizer, item -> ColorProviderRegistry.ITEM.register(colorizer, item) },
{ colorizer, block -> ColorProviderRegistry.BLOCK.register(colorizer, block) })
ModelLoadingRegistry.INSTANCE.registerModelProvider(RegisterClientStuff::onModelRegister)
}
}

View file

@ -0,0 +1,32 @@
package at.petrak.hexcasting.fabric.mixin.client;
import at.petrak.hexcasting.client.RegisterClientStuff;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.util.profiling.ProfilerFiller;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Map;
// https://github.com/VazkiiMods/Botania/blob/986dff2e8cd9f40f7e4d6ed7b30c98944bdb3b87/Fabric/src/main/java/vazkii/botania/fabric/mixin/client/ModelManagerFabricMixin.java#L34
@Mixin(ModelManager.class)
public class FabricModelManagerMixin {
@Shadow
private Map<ResourceLocation, BakedModel> bakedRegistry;
@Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/resources/model/ModelBakery;" +
"getBakedTopLevelModels()Ljava/util/Map;", shift = At.Shift.AFTER), method = "apply(Lnet/minecraft/client" +
"/resources/model/ModelBakery;Lnet/minecraft/server/packs/resources/ResourceManager;" +
"Lnet/minecraft/util/profiling/ProfilerFiller;)V")
private void onModelBake(ModelBakery modelLoader, ResourceManager resourceManager, ProfilerFiller profiler,
CallbackInfo ci) {
RegisterClientStuff.onModelBake(modelLoader, this.bakedRegistry);
}
}

View file

@ -10,6 +10,7 @@ import at.petrak.hexcasting.common.casting.PatternRegistryManifest;
import at.petrak.hexcasting.common.lib.HexParticles;
import at.petrak.hexcasting.common.misc.PatternTooltip;
import at.petrak.hexcasting.interop.HexInterop;
import net.minecraft.client.Minecraft;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.item.ItemColors;
import net.minecraft.client.particle.ParticleProvider;
@ -104,4 +105,15 @@ public class ForgeHexClientInitializer {
public static void registerTooltipComponents(RegisterClientTooltipComponentFactoriesEvent evt) {
evt.register(PatternTooltip.class, PatternTooltipComponent::new);
}
@SubscribeEvent
public static void onModelRegister(ModelEvent.RegisterAdditional evt) {
var recMan = Minecraft.getInstance().getResourceManager();
RegisterClientStuff.onModelRegister(recMan, evt::register);
}
@SubscribeEvent
public static void onModelBake(ModelEvent.BakingCompleted evt) {
RegisterClientStuff.onModelBake(evt.getModelBakery(), evt.getModels());
}
}

View file

@ -2,6 +2,7 @@ package at.petrak.hexcasting.forge.datagen.xplat;
import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.api.block.circle.BlockCircleComponent;
import at.petrak.hexcasting.common.blocks.BlockQuenchedAllay;
import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicBookshelf;
import at.petrak.hexcasting.common.blocks.circles.BlockSlate;
import at.petrak.hexcasting.common.blocks.circles.directrix.BlockRedstoneDirectrix;
@ -238,7 +239,8 @@ public class HexBlockStatesAndModels extends PaucalBlockStateAndModelProvider {
.texture("all", modLoc("block/citrine_edified_leaves"))
.renderType("cutout_mipped"));
doorBlockWithRenderType(HexBlocks.EDIFIED_DOOR, modLoc("block/edified_door_lower"), modLoc("block/edified_door_upper"), "cutout");
doorBlockWithRenderType(HexBlocks.EDIFIED_DOOR, modLoc("block/edified_door_lower"), modLoc("block" +
"/edified_door_upper"), "cutout");
// door model via the given texture
trapdoorBlockWithRenderType(HexBlocks.EDIFIED_TRAPDOOR, modLoc("block/edified_trapdoor"), true, "cutout");
@ -268,6 +270,13 @@ public class HexBlockStatesAndModels extends PaucalBlockStateAndModelProvider {
.renderType("cutout");
simpleBlock(HexBlocks.CONJURED_BLOCK, conjuredModel);
simpleBlock(HexBlocks.CONJURED_LIGHT, conjuredModel);
for (int i = 0; i < BlockQuenchedAllay.VARIANTS; i++) {
var name = "quenched_allay_" + i;
var textureLoc = modLoc("block/" + name);
var model = models().cubeAll(name, textureLoc);
itemModels().getBuilder(name).parent(model);
}
}
private void impetus(Block block, String name, String stub) {