Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/1.20.1/dev' into 1.…
Browse files Browse the repository at this point in the history
…21.1/dev
  • Loading branch information
PepperCode1 committed Feb 28, 2025
2 parents 7adc132 + 8c8f6bc commit 8315a3f
Show file tree
Hide file tree
Showing 19 changed files with 253 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import dev.engine_room.flywheel.lib.model.SimpleModel;
import dev.engine_room.flywheel.lib.model.baked.BakedModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.BlockModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.MultiBlockModelBuilder;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -20,6 +19,4 @@ public interface FlwLibXplat {
SimpleModel buildBakedModelBuilder(BakedModelBuilder builder);

SimpleModel buildBlockModelBuilder(BlockModelBuilder builder);

SimpleModel buildMultiBlockModelBuilder(MultiBlockModelBuilder builder);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.engine_room.flywheel.lib.model;

import java.util.List;
import java.util.function.BiConsumer;

import com.mojang.blaze3d.vertex.PoseStack;
Expand All @@ -8,8 +9,10 @@
import dev.engine_room.flywheel.lib.model.baked.BakedModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.BlockModelBuilder;
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
import dev.engine_room.flywheel.lib.model.baked.SinglePosVirtualBlockGetter;
import dev.engine_room.flywheel.lib.transform.TransformStack;
import dev.engine_room.flywheel.lib.util.RendererReloadCache;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;

Expand All @@ -20,7 +23,8 @@
* method with the same parameters will return the same object.
*/
public final class Models {
private static final RendererReloadCache<BlockState, Model> BLOCK_STATE = new RendererReloadCache<>(it -> new BlockModelBuilder(it)
private static final RendererReloadCache<BlockState, Model> BLOCK_STATE = new RendererReloadCache<>(it -> new BlockModelBuilder(SinglePosVirtualBlockGetter.createFullDark()
.blockState(it), List.of(BlockPos.ZERO))
.build());
private static final RendererReloadCache<PartialModel, Model> PARTIAL = new RendererReloadCache<>(it -> new BakedModelBuilder(it.get())
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
import dev.engine_room.flywheel.lib.model.SimpleModel;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;

public final class BakedModelBuilder {
final BakedModel bakedModel;
@Nullable
BlockAndTintGetter level;
@Nullable
BlockState blockState;
BlockPos pos;
@Nullable
PoseStack poseStack;
@Nullable
Expand All @@ -30,27 +30,33 @@ public BakedModelBuilder(BakedModel bakedModel) {
this.bakedModel = bakedModel;
}

public BakedModelBuilder level(BlockAndTintGetter level) {
public BakedModelBuilder level(@Nullable BlockAndTintGetter level) {
this.level = level;
return this;
}

public BakedModelBuilder blockState(BlockState blockState) {
this.blockState = blockState;
public BakedModelBuilder pos(@Nullable BlockPos pos) {
this.pos = pos;
return this;
}

public BakedModelBuilder poseStack(PoseStack poseStack) {
public BakedModelBuilder poseStack(@Nullable PoseStack poseStack) {
this.poseStack = poseStack;
return this;
}

public BakedModelBuilder materialFunc(BiFunction<RenderType, Boolean, Material> materialFunc) {
public BakedModelBuilder materialFunc(@Nullable BiFunction<RenderType, Boolean, Material> materialFunc) {
this.materialFunc = materialFunc;
return this;
}

public SimpleModel build() {
if (level == null) {
level = EmptyVirtualBlockGetter.FULL_DARK;
}
if (pos == null) {
pos = BlockPos.ZERO;
}
if (materialFunc == null) {
materialFunc = ModelUtil::getMaterial;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,34 @@
import dev.engine_room.flywheel.lib.model.ModelUtil;
import dev.engine_room.flywheel.lib.model.SimpleModel;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;

public final class BlockModelBuilder {
final BlockState state;
@Nullable
BlockAndTintGetter level;
final BlockAndTintGetter level;
final Iterable<BlockPos> positions;
@Nullable
PoseStack poseStack;
boolean renderFluids = false;
@Nullable
BiFunction<RenderType, Boolean, Material> materialFunc;

public BlockModelBuilder(BlockState state) {
this.state = state;
public BlockModelBuilder(BlockAndTintGetter level, Iterable<BlockPos> positions) {
this.level = level;
this.positions = positions;
}

public BlockModelBuilder level(BlockAndTintGetter level) {
this.level = level;
public BlockModelBuilder poseStack(@Nullable PoseStack poseStack) {
this.poseStack = poseStack;
return this;
}

public BlockModelBuilder poseStack(PoseStack poseStack) {
this.poseStack = poseStack;
public BlockModelBuilder renderFluids(boolean renderFluids) {
this.renderFluids = renderFluids;
return this;
}

public BlockModelBuilder materialFunc(BiFunction<RenderType, Boolean, Material> materialFunc) {
public BlockModelBuilder materialFunc(@Nullable BiFunction<RenderType, Boolean, Material> materialFunc) {
this.materialFunc = materialFunc;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,20 @@
import org.jetbrains.annotations.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;

public class VirtualEmptyBlockGetter extends VirtualBlockGetter {
public static final VirtualEmptyBlockGetter INSTANCE = new VirtualEmptyBlockGetter(p -> 0, p -> 15);
public static final VirtualEmptyBlockGetter FULL_BRIGHT = new VirtualEmptyBlockGetter(p -> 15, p -> 15);
public static final VirtualEmptyBlockGetter FULL_DARK = new VirtualEmptyBlockGetter(p -> 0, p -> 0);
public class EmptyVirtualBlockGetter extends VirtualBlockGetter {
public static final EmptyVirtualBlockGetter FULL_DARK = new EmptyVirtualBlockGetter(p -> 0, p -> 0);
public static final EmptyVirtualBlockGetter FULL_BRIGHT = new EmptyVirtualBlockGetter(p -> 15, p -> 15);

public VirtualEmptyBlockGetter(ToIntFunction<BlockPos> blockLightFunc, ToIntFunction<BlockPos> skyLightFunc) {
public EmptyVirtualBlockGetter(ToIntFunction<BlockPos> blockLightFunc, ToIntFunction<BlockPos> skyLightFunc) {
super(blockLightFunc, skyLightFunc);
}

public static boolean is(BlockAndTintGetter blockGetter) {
return blockGetter instanceof VirtualEmptyBlockGetter;
}

@Override
@Nullable
public final BlockEntity getBlockEntity(BlockPos pos) {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package dev.engine_room.flywheel.lib.model.baked;

import java.util.function.ToIntFunction;

import org.jetbrains.annotations.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;

public class SinglePosVirtualBlockGetter extends VirtualBlockGetter {
protected BlockPos pos = BlockPos.ZERO;
protected BlockState blockState = Blocks.AIR.defaultBlockState();
@Nullable
protected BlockEntity blockEntity;

public SinglePosVirtualBlockGetter(ToIntFunction<BlockPos> blockLightFunc, ToIntFunction<BlockPos> skyLightFunc) {
super(blockLightFunc, skyLightFunc);
}

public static SinglePosVirtualBlockGetter createFullDark() {
return new SinglePosVirtualBlockGetter(p -> 0, p -> 0);
}

public static SinglePosVirtualBlockGetter createFullBright() {
return new SinglePosVirtualBlockGetter(p -> 15, p -> 15);
}

public SinglePosVirtualBlockGetter pos(BlockPos pos) {
this.pos = pos;
return this;
}

public SinglePosVirtualBlockGetter blockState(BlockState state) {
blockState = state;
return this;
}

public SinglePosVirtualBlockGetter blockEntity(@Nullable BlockEntity blockEntity) {
this.blockEntity = blockEntity;
return this;
}

@Override
@Nullable
public BlockEntity getBlockEntity(BlockPos pos) {
if (pos.equals(this.pos)) {
return blockEntity;
}

return null;
}

@Override
public BlockState getBlockState(BlockPos pos) {
if (pos.equals(this.pos)) {
return blockState;
}

return Blocks.AIR.defaultBlockState();
}

@Override
public int getHeight() {
return 1;
}

@Override
public int getMinBuildHeight() {
return pos.getY();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import dev.engine_room.vanillin.config.BlockEntityVisualizerBuilder;
import dev.engine_room.vanillin.config.Configurator;
import dev.engine_room.vanillin.config.EntityVisualizerBuilder;
import dev.engine_room.vanillin.visuals.*;
import dev.engine_room.vanillin.visuals.BellVisual;
import dev.engine_room.vanillin.visuals.ChestVisual;
import dev.engine_room.vanillin.visuals.MinecartVisual;
import dev.engine_room.vanillin.visuals.ShulkerBoxVisual;
import dev.engine_room.vanillin.visuals.SignVisual;
import dev.engine_room.vanillin.visuals.TntMinecartVisual;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.engine_room.flywheel.backend.compile;

import dev.engine_room.flywheel.lib.util.ResourceUtil;
import dev.engine_room.flywheel.backend.NoiseTextures;
import dev.engine_room.flywheel.lib.util.ResourceUtil;
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
Expand Down
Loading

0 comments on commit 8315a3f

Please sign in to comment.