diff --git a/src/main/java/com/simibubi/create/AllBlockPartials.java b/src/main/java/com/simibubi/create/AllBlockPartials.java index d32c28e3d..102fc4412 100644 --- a/src/main/java/com/simibubi/create/AllBlockPartials.java +++ b/src/main/java/com/simibubi/create/AllBlockPartials.java @@ -1,27 +1,20 @@ package com.simibubi.create; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; -import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour.AttachmentTypes; -import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel; +import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour; +import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Lang; -import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.client.event.ModelRegistryEvent; -import net.minecraftforge.client.model.ModelLoader; public class AllBlockPartials { - private static final List all = new ArrayList<>(); - - public static final AllBlockPartials SCHEMATICANNON_CONNECTOR = get("schematicannon/connector"), + public static final PartialModel SCHEMATICANNON_CONNECTOR = get("schematicannon/connector"), SCHEMATICANNON_PIPE = get("schematicannon/pipe"), SHAFTLESS_COGWHEEL = get("cogwheel_shaftless"), SHAFT_HALF = get("shaft_half"), @@ -112,69 +105,40 @@ public class AllBlockPartials { ; - public static final Map> PIPE_ATTACHMENTS = map(); - public static final Map BLAZES = map(); + public static final Map> PIPE_ATTACHMENTS = new HashMap<>(); + public static final Map BLAZES = new HashMap<>(); static { populateMaps(); } - ; - - private ResourceLocation modelLocation; - private IBakedModel bakedModel; - - private AllBlockPartials() {} - - private static void populateMaps() { - for (AttachmentTypes type : AttachmentTypes.values()) { + static void populateMaps() { + for (FluidTransportBehaviour.AttachmentTypes type : FluidTransportBehaviour.AttachmentTypes.values()) { if (!type.hasModel()) continue; - Map map = map(); + Map map = new HashMap<>(); for (Direction d : Iterate.directions) { String asId = Lang.asId(type.name()); map.put(d, get("fluid_pipe/" + asId + "/" + Lang.asId(d.getString()))); } PIPE_ATTACHMENTS.put(type, map); } - for (HeatLevel heat : HeatLevel.values()) { - if (heat == HeatLevel.NONE) + for (BlazeBurnerBlock.HeatLevel heat : BlazeBurnerBlock.HeatLevel.values()) { + if (heat == BlazeBurnerBlock.HeatLevel.NONE) continue; BLAZES.put(heat, get("blaze_burner/blaze/" + heat.getString())); } } - private static Map map() { - return new HashMap<>(); + private static PartialModel getEntity(String path) { + return new PartialModel(new ResourceLocation(Create.ID, "entity/" + path)); } - private static AllBlockPartials getEntity(String path) { - AllBlockPartials partials = new AllBlockPartials(); - partials.modelLocation = new ResourceLocation(Create.ID, "entity/" + path); - all.add(partials); - return partials; + private static PartialModel get(String path) { + return new PartialModel(new ResourceLocation(Create.ID, "block/" + path)); } - private static AllBlockPartials get(String path) { - AllBlockPartials partials = new AllBlockPartials(); - partials.modelLocation = new ResourceLocation(Create.ID, "block/" + path); - all.add(partials); - return partials; + public static void clientInit() { + // init static fields } - - public static void onModelRegistry(ModelRegistryEvent event) { - for (AllBlockPartials partial : all) - ModelLoader.addSpecialModel(partial.modelLocation); - } - - public static void onModelBake(ModelBakeEvent event) { - Map modelRegistry = event.getModelRegistry(); - for (AllBlockPartials partial : all) - partial.bakedModel = modelRegistry.get(partial.modelLocation); - } - - public IBakedModel get() { - return bakedModel; - } - } diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 103166ff1..2940b484d 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -27,6 +27,7 @@ import com.simibubi.create.foundation.render.KineticRenderer; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.render.backend.Backend; import com.simibubi.create.foundation.render.backend.OptifineHandler; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.WorldAttached; import com.simibubi.create.foundation.utility.ghost.GhostBlocks; @@ -115,6 +116,8 @@ public class CreateClient { .getResourceManager(); if (resourceManager instanceof IReloadableResourceManager) ((IReloadableResourceManager) resourceManager).addReloadListener(new ResourceReloadHandler()); + + AllBlockPartials.clientInit(); } public static void onTextureStitch(TextureStitchEvent.Pre event) { @@ -128,7 +131,7 @@ public class CreateClient { public static void onModelBake(ModelBakeEvent event) { Map modelRegistry = event.getModelRegistry(); - AllBlockPartials.onModelBake(event); + PartialModel.onModelBake(event); getCustomBlockModels() .foreach((block, modelFunc) -> swapModels(modelRegistry, getAllBlockStateModelLocations(block), modelFunc)); @@ -141,7 +144,7 @@ public class CreateClient { } public static void onModelRegistry(ModelRegistryEvent event) { - AllBlockPartials.onModelRegistry(event); + PartialModel.onModelRegistry(event); getCustomRenderedItems().foreach((item, modelFunc) -> modelFunc.apply(null) .getModelLocations() diff --git a/src/main/java/com/simibubi/create/compat/jei/category/ProcessingViaFanCategory.java b/src/main/java/com/simibubi/create/compat/jei/category/ProcessingViaFanCategory.java index 207baa023..2f03d2056 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/ProcessingViaFanCategory.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/ProcessingViaFanCategory.java @@ -28,7 +28,7 @@ public abstract class ProcessingViaFanCategory> extends Cre public ProcessingViaFanCategory(IDrawable icon) { this(177, icon); } - + protected ProcessingViaFanCategory(int width, IDrawable icon) { super(icon, emptyBackground(width, 71)); } diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java index 8ec5983de..920ab0bf3 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedBlazeBurner.java @@ -5,6 +5,7 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel; import com.simibubi.create.foundation.gui.GuiGameElement; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import mezz.jei.api.gui.drawable.IDrawable; import net.minecraft.util.math.vector.Vector3f; @@ -30,7 +31,7 @@ public class AnimatedBlazeBurner implements IDrawable { .scale(scale) .render(matrixStack); - AllBlockPartials blaze = AllBlockPartials.BLAZES.get(heatLevel); + PartialModel blaze = AllBlockPartials.BLAZES.get(heatLevel); GuiGameElement.of(blaze) .atLocal(1, 1.65, 1) .rotate(0, 180, 0) diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java index ef9e662ce..fb0e5a880 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedKinetics.java @@ -2,6 +2,7 @@ package com.simibubi.create.compat.jei.category.animations; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AnimationTickHolder; import mezz.jei.api.gui.drawable.IDrawable; @@ -14,15 +15,15 @@ public abstract class AnimatedKinetics implements IDrawable { public static float getCurrentAngle() { return ((AnimationTickHolder.getRenderTime()) * 4f) % 360; } - + protected BlockState shaft(Axis axis) { return AllBlocks.SHAFT.getDefaultState().with(BlockStateProperties.AXIS, axis); } - - protected AllBlockPartials cogwheel() { + + protected PartialModel cogwheel() { return AllBlockPartials.SHAFTLESS_COGWHEEL; } - + @Override public int getWidth() { return 50; diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java index 80bc6a479..8e98eb372 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedMillstone.java @@ -20,7 +20,7 @@ public class AnimatedMillstone extends AnimatedKinetics { .rotateBlock(22.5, getCurrentAngle() * 2, 0) .scale(scale) .render(matrixStack); - + GuiGameElement.of(AllBlocks.MILLSTONE.getDefaultState()) .rotateBlock(22.5, 22.5, 0) .scale(scale) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java index 288451551..3734c3509 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/DrillRenderer.java @@ -26,7 +26,7 @@ public class DrillRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return PartialBufferer.getDirectionalSouth(AllBlockPartials.DRILL_HEAD, te.getBlockState()); + return PartialBufferer.getFacing(AllBlockPartials.DRILL_HEAD, te.getBlockState()); } public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceRenderer.java index 31c4eea44..01c3d4d6f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/PortableStorageInterfaceRenderer.java @@ -10,6 +10,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -110,7 +111,7 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer getTileEntityClass() { return HandCrankTileEntity.class; } - + @Override public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankInstance.java index b26402bb3..843882dce 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankInstance.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.contraptions.components.crank; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.SingleRotatingInstance; import com.simibubi.create.foundation.render.backend.core.ModelData; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; @@ -25,7 +25,7 @@ public class HandCrankInstance extends SingleRotatingInstance implements IDynami this.tile = tile; Block block = blockState.getBlock(); - AllBlockPartials renderedHandle = null; + PartialModel renderedHandle = null; if (block instanceof HandCrankBlock) renderedHandle = ((HandCrankBlock) block).getRenderedHandle(); if (renderedHandle == null) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java index bbf3ec4f6..7db258093 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java @@ -3,12 +3,12 @@ package com.simibubi.create.content.contraptions.components.crank; import static net.minecraft.state.properties.BlockStateProperties.FACING; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -32,14 +32,14 @@ public class HandCrankRenderer extends KineticTileEntityRenderer { BlockState state = te.getBlockState(); Block block = state.getBlock(); - AllBlockPartials renderedHandle = null; + PartialModel renderedHandle = null; if (block instanceof HandCrankBlock) renderedHandle = ((HandCrankBlock) block).getRenderedHandle(); if (renderedHandle == null) return; Direction facing = state.get(FACING); - SuperByteBuffer handle = PartialBufferer.getDirectionalSouth(renderedHandle, state, facing.getOpposite()); + SuperByteBuffer handle = PartialBufferer.getFacing(renderedHandle, state, facing.getOpposite()); HandCrankTileEntity crank = (HandCrankTileEntity) te; kineticRotationTransform(handle, te, facing.getAxis(), (crank.independentAngle + partialTicks * crank.chasingVelocity) / 360, light); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java index bca18a69a..e9e8c32d7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/ValveHandleBlock.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.crank; import javax.annotation.ParametersAreNonnullByDefault; -import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.DyeHelper; import net.minecraft.block.BlockState; @@ -68,7 +68,7 @@ public class ValveHandleBlock extends HandCrankBlock { @Override @OnlyIn(Dist.CLIENT) - public AllBlockPartials getRenderedHandle() { + public PartialModel getRenderedHandle() { return null; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java index a62bf37d8..e91bc8a0d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerActorInstance.java @@ -14,6 +14,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionProgram; import com.simibubi.create.foundation.render.backend.core.ModelData; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial; import com.simibubi.create.foundation.utility.AngleHelper; @@ -48,7 +49,7 @@ public class DeployerActorInstance extends ActorInstance { BlockState state = context.state; DeployerTileEntity.Mode mode = NBTHelper.readEnum(context.tileData, "Mode", DeployerTileEntity.Mode.class); - AllBlockPartials handPose = DeployerRenderer.getHandPose(mode); + PartialModel handPose = DeployerRenderer.getHandPose(mode); stationaryTimer = context.data.contains("StationaryTimer"); facing = state.get(FACING); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java index 3ffd3339b..31b1d7665 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerInstance.java @@ -7,6 +7,7 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance; import com.simibubi.create.foundation.render.backend.core.OrientedData; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; import com.simibubi.create.foundation.render.backend.instancing.ITickableInstance; import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; @@ -31,7 +32,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance, protected OrientedData hand; - AllBlockPartials currentHand; + PartialModel currentHand; float progress; private boolean newHand = false; @@ -89,7 +90,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance, } private boolean updateHandPose() { - AllBlockPartials handPose = tile.getHandPose(); + PartialModel handPose = tile.getHandPose(); if (currentHand == handPose) return false; currentHand = handPose; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java index 84eccae4c..0261f9651 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java @@ -14,6 +14,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -161,7 +162,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer BlockPos pos = BlockPos.ZERO; Mode mode = NBTHelper.readEnum(context.tileData, "Mode", Mode.class); World world = context.world; - AllBlockPartials handPose = getHandPose(mode); + PartialModel handPose = getHandPose(mode); SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState); SuperByteBuffer hand = PartialBufferer.get(handPose, blockState); @@ -192,7 +193,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer .renderInto(ms, builder); } - static AllBlockPartials getHandPose(DeployerTileEntity.Mode mode) { + static PartialModel getHandPose(DeployerTileEntity.Mode mode) { return mode == DeployerTileEntity.Mode.PUNCH ? AllBlockPartials.DEPLOYER_HAND_PUNCHING : AllBlockPartials.DEPLOYER_HAND_POINTING; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java index 8705330ba..c1e5493a1 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntity.java @@ -11,6 +11,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.curiosities.tools.SandPaperItem; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.item.TooltipHelper; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; import com.simibubi.create.foundation.utility.NBTHelper; @@ -113,7 +114,7 @@ public class DeployerTileEntity extends KineticTileEntity { @Override public void tick() { super.tick(); - + if (getSpeed() == 0) return; if (!world.isRemote && player != null && player.blockBreakingProgress != null) { @@ -331,7 +332,7 @@ public class DeployerTileEntity extends KineticTileEntity { private IItemHandlerModifiable createHandler() { return new DeployerItemHandler(this); } - + public void redstoneUpdate() { if (world.isRemote) return; @@ -342,7 +343,7 @@ public class DeployerTileEntity extends KineticTileEntity { sendData(); } - public AllBlockPartials getHandPose() { + public PartialModel getHandPose() { return mode == Mode.PUNCH ? AllBlockPartials.DEPLOYER_HAND_PUNCHING : heldItem.isEmpty() ? AllBlockPartials.DEPLOYER_HAND_POINTING : AllBlockPartials.DEPLOYER_HAND_HOLDING; } @@ -395,7 +396,7 @@ public class DeployerTileEntity extends KineticTileEntity { float progress = 0; int timerSpeed = getTimerSpeed(); - AllBlockPartials handPose = getHandPose(); + PartialModel handPose = getHandPose(); if (state == State.EXPANDING) progress = 1 - (timer - partialTicks * timerSpeed) / 1000f; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java index 0cf853af1..6491d16e3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/EncasedFanRenderer.java @@ -38,9 +38,9 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer { int lightInFront = WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getPos().offset(direction)); SuperByteBuffer shaftHalf = - PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction.getOpposite()); + PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction.getOpposite()); SuperByteBuffer fanInner = - PartialBufferer.getDirectionalSouth(AllBlockPartials.ENCASED_FAN_INNER, te.getBlockState(), direction.getOpposite()); + PartialBufferer.getFacing(AllBlockPartials.ENCASED_FAN_INNER, te.getBlockState(), direction.getOpposite()); float time = AnimationTickHolder.getRenderTime(te.getWorld()); float speed = te.getSpeed() * 5; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java index f219c4ec4..bf3b46295 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java @@ -72,7 +72,13 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { .renderInto(ms, vb); } - SuperByteBuffer wheel = PartialBufferer.getHorizontal(AllBlockPartials.FLYWHEEL, blockState.rotate(Rotation.CLOCKWISE_90)); + renderFlywheel(te, ms, light, blockState, angle, vb); + } + + private void renderFlywheel(KineticTileEntity te, MatrixStack ms, int light, BlockState blockState, float angle, IVertexBuilder vb) { + BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90); + Direction facing = referenceState.get(BlockStateProperties.HORIZONTAL_FACING); + SuperByteBuffer wheel = PartialBufferer.getFacing(AllBlockPartials.FLYWHEEL, referenceState, facing); kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING) .getAxis(), AngleHelper.rad(angle), light); wheel.renderInto(ms, vb); @@ -80,7 +86,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState() + return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState() .get(BlockStateProperties.HORIZONTAL_FACING) .getOpposite()); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java index 268aa65cc..f3d07cf66 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineBlock.java @@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine; import javax.annotation.Nullable; -import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.wrench.IWrenchable; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.Block; @@ -37,12 +37,12 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable public boolean hasTileEntity(BlockState state) { return true; } - + @Override public ActionResultType onWrenched(BlockState state, ItemUseContext context) { return ActionResultType.FAIL; } - + @Override public abstract TileEntity createTileEntity(BlockState state, IBlockReader world); @@ -88,14 +88,14 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable return true; } - + public static BlockPos getBaseBlockPos(BlockState state, BlockPos pos) { return pos.offset(state.get(HORIZONTAL_FACING).getOpposite()); } @Nullable @OnlyIn(Dist.CLIENT) - public abstract AllBlockPartials getFrameModel(); + public abstract PartialModel getFrameModel(); protected abstract boolean isValidBaseBlock(BlockState baseBlock, IBlockReader world, BlockPos pos); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java index a88cbbd1a..3f76914d0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineInstance.java @@ -1,8 +1,8 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.backend.core.ModelData; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.render.backend.instancing.TileEntityInstance; import com.simibubi.create.foundation.utility.AngleHelper; @@ -25,7 +25,7 @@ public class EngineInstance extends TileEntityInstance { return; EngineBlock engineBlock = (EngineBlock) block; - AllBlockPartials frame = engineBlock.getFrameModel(); + PartialModel frame = engineBlock.getFrameModel(); Direction facing = blockState.get(BlockStateProperties.HORIZONTAL_FACING); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java index c96459be9..42be5bedf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java @@ -1,9 +1,9 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -30,7 +30,7 @@ public class EngineRenderer extends SafeTileEntityRe .getBlock(); if (block instanceof EngineBlock) { EngineBlock engineBlock = (EngineBlock) block; - AllBlockPartials frame = engineBlock.getFrameModel(); + PartialModel frame = engineBlock.getFrameModel(); if (frame != null) { Direction facing = te.getBlockState() .get(EngineBlock.HORIZONTAL_FACING); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineBlock.java index 85a84e172..e50508ad0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/FurnaceEngineBlock.java @@ -5,6 +5,7 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.foundation.block.ITE; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import net.minecraft.block.AbstractFurnaceBlock; @@ -41,7 +42,7 @@ public class FurnaceEngineBlock extends EngineBlock implements ITE { protected void renderBlade(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light) { BlockState blockState = te.getBlockState(); SuperByteBuffer superBuffer; - AllBlockPartials partial; + PartialModel partial; float speed = te.getSpeed(); ms.push(); @@ -82,7 +83,7 @@ public class SawRenderer extends SafeTileEntityRenderer { .rotateY(90) .unCentre(); } - superBuffer = PartialBufferer.getDirectionalSouth(partial, blockState); + superBuffer = PartialBufferer.getFacing(partial, blockState); superBuffer.light(light) .renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped())); @@ -141,7 +142,7 @@ public class SawRenderer extends SafeTileEntityRenderer { protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { BlockState state = te.getBlockState(); if (state.get(FACING).getAxis().isHorizontal()) - return PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, state.rotate(te.getWorld(), te.getPos(), Rotation.CLOCKWISE_180)); + return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, state.rotate(te.getWorld(), te.getPos(), Rotation.CLOCKWISE_180)); return CreateClient.bufferCache.renderBlockIn(KineticTileEntityRenderer.KINETIC_TILE, getRenderedBlockState(te)); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java index a4ce86d26..f3c46d7d6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingInstance.java @@ -4,6 +4,7 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.BackHalfShaftInstance; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.foundation.render.backend.core.OrientedData; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -31,7 +32,7 @@ public class BearingInstance e blockOrientation = getBlockStateOrientation(facing); - AllBlockPartials top = + PartialModel top = bearing.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP; topInstance = getOrientedMaterial().getModel(top, blockState).createInstance(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java index d176eccbb..cf6f59b7c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java @@ -7,6 +7,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AngleHelper; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -32,7 +33,7 @@ public class BearingRenderer extends KineticTileEntityRenderer { IBearingTileEntity bearingTe = (IBearingTileEntity) te; final Direction facing = te.getBlockState() .get(BlockStateProperties.FACING); - AllBlockPartials top = + PartialModel top = bearingTe.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP; SuperByteBuffer superBuffer = PartialBufferer.get(top, te.getBlockState()); @@ -49,7 +50,7 @@ public class BearingRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState() + return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState() .get(BearingBlock.FACING) .getOpposite()); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java index 4cab614ba..9d776cb3a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/StabilizedBearingMovementBehaviour.java @@ -15,6 +15,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AnimationTickHolder; import net.minecraft.client.renderer.IRenderTypeBuffer; @@ -35,7 +36,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { if (FastRenderDispatcher.available()) return; Direction facing = context.state.get(BlockStateProperties.FACING); - AllBlockPartials top = AllBlockPartials.BEARING_TOP; + PartialModel top = AllBlockPartials.BEARING_TOP; SuperByteBuffer superBuffer = PartialBufferer.get(top, context.state); float renderPartialTicks = AnimationTickHolder.getPartialTicks(); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java index 3a7a2b3ff..481b065d0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyRenderer.java @@ -2,13 +2,13 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pu import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AngleHelper; import net.minecraft.block.BlockState; @@ -25,11 +25,11 @@ import net.minecraft.world.World; public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { - private AllBlockPartials halfRope; - private AllBlockPartials halfMagnet; + private PartialModel halfRope; + private PartialModel halfMagnet; - public AbstractPulleyRenderer(TileEntityRendererDispatcher dispatcher, AllBlockPartials halfRope, - AllBlockPartials halfMagnet) { + public AbstractPulleyRenderer(TileEntityRendererDispatcher dispatcher, PartialModel halfRope, + PartialModel halfMagnet) { super(dispatcher); this.halfRope = halfRope; this.halfMagnet = halfMagnet; @@ -90,7 +90,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { protected abstract Axis getShaftAxis(KineticTileEntity te); - protected abstract AllBlockPartials getCoil(); + protected abstract PartialModel getCoil(); protected abstract SuperByteBuffer renderRope(KineticTileEntity te); @@ -107,7 +107,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { protected SuperByteBuffer getRotatedCoil(KineticTileEntity te) { BlockState blockState = te.getBlockState(); - return PartialBufferer.getDirectionalSouth(getCoil(), blockState, Direction.getFacingFromAxis(AxisDirection.POSITIVE, getShaftAxis(te))); + return PartialBufferer.getFacing(getCoil(), blockState, Direction.getFacingFromAxis(AxisDirection.POSITIVE, getShaftAxis(te))); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java index 740302722..4db922553 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyRenderer.java @@ -6,6 +6,7 @@ import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.Direction.Axis; @@ -24,7 +25,7 @@ public class PulleyRenderer extends AbstractPulleyRenderer { } @Override - protected AllBlockPartials getCoil() { + protected PartialModel getCoil() { return AllBlockPartials.ROPE_COIL; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java index b26a6d5a1..8ecc077a4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java @@ -53,7 +53,7 @@ public class PumpRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return PartialBufferer.getDirectionalSouth(AllBlockPartials.MECHANICAL_PUMP_COG, te.getBlockState()); + return PartialBufferer.getFacing(AllBlockPartials.MECHANICAL_PUMP_COG, te.getBlockState()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyRenderer.java index d73652919..3e1a43506 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyRenderer.java @@ -5,6 +5,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.pulley.AbstractPulleyRenderer; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.Direction.Axis; @@ -24,7 +25,7 @@ public class HosePulleyRenderer extends AbstractPulleyRenderer { } @Override - protected AllBlockPartials getCoil() { + protected PartialModel getCoil() { return AllBlockPartials.HOSE_COIL; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutRenderer.java index f4364a14e..2cbacbd36 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/SpoutRenderer.java @@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; @@ -21,7 +22,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer { super(dispatcher); } - static final AllBlockPartials[] BITS = + static final PartialModel[] BITS = { AllBlockPartials.SPOUT_TOP, AllBlockPartials.SPOUT_MIDDLE, AllBlockPartials.SPOUT_BOTTOM }; @Override @@ -70,7 +71,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer { squeeze = -1; ms.push(); - for (AllBlockPartials bit : BITS) { + for (PartialModel bit : BITS) { PartialBufferer.get(bit, te.getBlockState()) .light(light) .renderInto(ms, buffer.getBuffer(RenderType.getSolid())); diff --git a/src/main/java/com/simibubi/create/content/contraptions/goggles/GogglesModel.java b/src/main/java/com/simibubi/create/content/contraptions/goggles/GogglesModel.java index 333f65bbd..0702465f7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/goggles/GogglesModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/goggles/GogglesModel.java @@ -21,4 +21,4 @@ public class GogglesModel extends WrappedBakedModel { return super.handlePerspective(cameraTransformType, mat); } -} \ No newline at end of file +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java index c12ce5b23..1d3765ac6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java @@ -5,6 +5,7 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -31,7 +32,7 @@ public class BlazeBurnerRenderer extends SafeTileEntityRenderer { DyeColor color = tile.color.orElse(null); for (boolean bottom : Iterate.trueAndFalse) { - AllBlockPartials beltPartial = BeltRenderer.getBeltPartial(diagonal, start, end, bottom); + PartialModel beltPartial = BeltRenderer.getBeltPartial(diagonal, start, end, bottom); SpriteShiftEntry spriteShift = BeltRenderer.getSpriteShiftEntry(color, diagonal, bottom); InstancedModel beltModel = modelManager.getMaterial(KineticRenderMaterials.BELTS).getModel(beltPartial, blockState); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java index 8e628d4aa..4beec3bb0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java @@ -16,6 +16,7 @@ import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.ShadowRenderHelper; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -95,7 +96,7 @@ public class BeltRenderer extends SafeTileEntityRenderer { for (boolean bottom : Iterate.trueAndFalse) { - AllBlockPartials beltPartial = getBeltPartial(diagonal, start, end, bottom); + PartialModel beltPartial = getBeltPartial(diagonal, start, end, bottom); SuperByteBuffer beltBuffer = PartialBufferer.get(beltPartial, blockState) .light(light); @@ -159,7 +160,7 @@ public class BeltRenderer extends SafeTileEntityRenderer { : bottom ? AllSpriteShifts.BELT_OFFSET : AllSpriteShifts.BELT; } - public static AllBlockPartials getBeltPartial(boolean diagonal, boolean start, boolean end, boolean bottom) { + public static PartialModel getBeltPartial(boolean diagonal, boolean start, boolean end, boolean bottom) { if (diagonal) { if (start) return AllBlockPartials.BELT_DIAGONAL_START; if (end) return AllBlockPartials.BELT_DIAGONAL_END; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java index 4e35c6bdc..cac191681 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java @@ -52,7 +52,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer { angle = angle / 180f * (float) Math.PI; SuperByteBuffer superByteBuffer = - PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction); + PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction); kineticRotationTransform(superByteBuffer, te, axis, angle, light); superByteBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid())); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java index 5a1d37e39..56c9fb89b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java @@ -9,6 +9,7 @@ import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock.Type; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Iterate; import net.minecraft.block.BlockState; @@ -46,9 +47,9 @@ public class GaugeRenderer extends KineticTileEntityRenderer { GaugeTileEntity gaugeTE = (GaugeTileEntity) te; int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), gaugeState, te.getPos()); - AllBlockPartials allBlockPartials = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS); + PartialModel partialModel = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS); SuperByteBuffer headBuffer = - PartialBufferer.get(allBlockPartials, gaugeState); + PartialBufferer.get(partialModel, gaugeState); SuperByteBuffer dialBuffer = PartialBufferer.get(AllBlockPartials.GAUGE_DIAL, gaugeState); float dialPivot = 5.75f / 16; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java index 78a1206a9..72c2e09e8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java @@ -38,7 +38,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer { if (boxAxis == axis) continue; - SuperByteBuffer shaft = PartialBufferer.getDirectionalSouth(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction); + SuperByteBuffer shaft = PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction); float offset = getRotationOffsetForPosition(te, pos, axis); float angle = (time * te.getSpeed() * 3f / 10) % 360; diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/CrossPlaneMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/CrossPlaneMirror.java index ccdd17720..805673bec 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/CrossPlaneMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/CrossPlaneMirror.java @@ -7,6 +7,7 @@ import java.util.Map; import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.MatrixStacker; @@ -86,7 +87,7 @@ public class CrossPlaneMirror extends SymmetryMirror { } @Override - public AllBlockPartials getModel() { + public PartialModel getModel() { return AllBlockPartials.SYMMETRY_CROSSPLANE; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/EmptyMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/EmptyMirror.java index d7cdd00b5..9e953ae5b 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/EmptyMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/EmptyMirror.java @@ -5,7 +5,7 @@ import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableList; -import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import net.minecraft.block.BlockState; import net.minecraft.util.IStringSerializable; @@ -17,13 +17,13 @@ public class EmptyMirror extends SymmetryMirror { public static enum Align implements IStringSerializable { None("none"); - + private final String name; private Align(String name) { this.name = name; } @Override public String getString() { return name; } @Override public String toString() { return name; } } - + public EmptyMirror(Vector3d pos) { super(pos); orientation = Align.None; @@ -50,10 +50,10 @@ public class EmptyMirror extends SymmetryMirror { } @Override - public AllBlockPartials getModel() { + public PartialModel getModel() { return null; } - + @Override public List getAlignToolTips() { return ImmutableList.of(); diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/PlaneMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/PlaneMirror.java index 497ecc269..53f8a55c3 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/PlaneMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/PlaneMirror.java @@ -7,6 +7,7 @@ import java.util.Map; import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.MatrixStacker; @@ -82,7 +83,7 @@ public class PlaneMirror extends SymmetryMirror { } @Override - public AllBlockPartials getModel() { + public PartialModel getModel() { return AllBlockPartials.SYMMETRY_PLANE; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java index 33f4f5ff2..02e950e9e 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/SymmetryMirror.java @@ -6,7 +6,7 @@ import java.util.Map; import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.block.BlockState; @@ -80,7 +80,7 @@ public abstract class SymmetryMirror { public abstract String typeName(); - public abstract AllBlockPartials getModel(); + public abstract PartialModel getModel(); public void applyModelTransform(MatrixStack ms) {} diff --git a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/TriplePlaneMirror.java b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/TriplePlaneMirror.java index 586b4145b..838d4b366 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/TriplePlaneMirror.java +++ b/src/main/java/com/simibubi/create/content/curiosities/symmetry/mirror/TriplePlaneMirror.java @@ -6,6 +6,7 @@ import java.util.Map; import com.google.common.collect.ImmutableList; import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.block.BlockState; @@ -43,7 +44,7 @@ public class TriplePlaneMirror extends SymmetryMirror { } @Override - public AllBlockPartials getModel() { + public PartialModel getModel() { return AllBlockPartials.SYMMETRY_TRIPLEPLANE; } @@ -54,12 +55,12 @@ public class TriplePlaneMirror extends SymmetryMirror { @Override public void setOrientation(int index) { } - + @Override public IStringSerializable getOrientation() { return CrossPlaneMirror.Align.Y; } - + @Override public List getAlignToolTips() { return ImmutableList.of(Lang.translate("orientation.horizontal")); diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripRenderHandler.java b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripRenderHandler.java index 1943ebf4d..847935f56 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripRenderHandler.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/ExtendoGripRenderHandler.java @@ -3,6 +3,7 @@ package com.simibubi.create.content.curiosities.tools; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllItems; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.MatrixStacker; @@ -28,7 +29,7 @@ public class ExtendoGripRenderHandler { public static float mainHandAnimation; public static float lastMainHandAnimation; - public static AllBlockPartials pose = AllBlockPartials.DEPLOYER_HAND_PUNCHING; + public static PartialModel pose = AllBlockPartials.DEPLOYER_HAND_PUNCHING; public static void tick() { lastMainHandAnimation = mainHandAnimation; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java index 36cf2bbd7..81793455e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelInstance.java @@ -66,7 +66,7 @@ public class BeltTunnelInstance extends TileEntityInstance tunnelFlaps.put(direction, flaps); }); } - + @Override public boolean shouldReset() { return super.shouldReset() || tunnelFlaps.size() != tile.flaps.size(); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java index 32207fd68..16090ddbd 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelInstance.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticRenderMaterials; import com.simibubi.create.content.logistics.block.FlapData; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance; import com.simibubi.create.foundation.render.backend.instancing.InstanceData; import com.simibubi.create.foundation.render.backend.instancing.InstancedModel; @@ -26,7 +27,7 @@ public class FunnelInstance extends TileEntityInstance impleme if (!tile.hasFlap()) return; - AllBlockPartials flapPartial = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP + PartialModel flapPartial = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP : AllBlockPartials.BELT_FUNNEL_FLAP); InstancedModel model = modelManager.getMaterial(KineticRenderMaterials.FLAPS) .getModel(flapPartial, blockState); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java index a59417f15..87d762e51 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/funnel/FunnelRenderer.java @@ -6,6 +6,7 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.MatrixStacker; @@ -34,9 +35,9 @@ public class FunnelRenderer extends SmartTileEntityRenderer { BlockState blockState = te.getBlockState(); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); - AllBlockPartials allBlockPartials = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP + PartialModel partialModel = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP : AllBlockPartials.BELT_FUNNEL_FLAP); - SuperByteBuffer flapBuffer = PartialBufferer.get(allBlockPartials, blockState); + SuperByteBuffer flapBuffer = PartialBufferer.get(partialModel, blockState); Vector3d pivot = VecHelper.voxelSpace(0, 10, 9.5f); MatrixStacker msr = MatrixStacker.of(ms); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java index 50d9a041b..84baeee39 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPoint.java @@ -27,6 +27,7 @@ import com.simibubi.create.content.logistics.block.funnel.FunnelBlock; import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.item.SmartInventory; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult; @@ -100,7 +101,7 @@ public abstract class ArmInteractionPoint { @OnlyIn(Dist.CLIENT) void transformFlag(MatrixStack stack) {} - AllBlockPartials getFlagType() { + PartialModel getFlagType() { return mode == Mode.TAKE ? AllBlockPartials.FLAG_LONG_OUT : AllBlockPartials.FLAG_LONG_IN; } diff --git a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java index a9b3c24a4..385f1a019 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java +++ b/src/main/java/com/simibubi/create/foundation/gui/GuiGameElement.java @@ -8,8 +8,8 @@ import com.mojang.blaze3d.platform.GlStateManager.DestFactor; import com.mojang.blaze3d.platform.GlStateManager.SourceFactor; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.fluid.FluidRenderer; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VirtualEmptyModelData; @@ -53,7 +53,7 @@ public class GuiGameElement { return new GuiBlockStateRenderBuilder(state); } - public static GuiRenderBuilder of(AllBlockPartials partial) { + public static GuiRenderBuilder of(PartialModel partial) { return new GuiBlockPartialRenderBuilder(partial); } @@ -251,7 +251,7 @@ public class GuiGameElement { public static class GuiBlockPartialRenderBuilder extends GuiBlockModelRenderBuilder { - public GuiBlockPartialRenderBuilder(AllBlockPartials partial) { + public GuiBlockPartialRenderBuilder(PartialModel partial) { super(partial.get(), null); } diff --git a/src/main/java/com/simibubi/create/foundation/render/Compartment.java b/src/main/java/com/simibubi/create/foundation/render/Compartment.java index 33d1ba678..01087fc22 100644 --- a/src/main/java/com/simibubi/create/foundation/render/Compartment.java +++ b/src/main/java/com/simibubi/create/foundation/render/Compartment.java @@ -2,13 +2,13 @@ package com.simibubi.create.foundation.render; import org.apache.commons.lang3.tuple.Pair; -import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import net.minecraft.block.BlockState; import net.minecraft.util.Direction; public class Compartment { public static final Compartment GENERIC_TILE = new Compartment<>(); - public static final Compartment PARTIAL = new Compartment<>(); - public static final Compartment> DIRECTIONAL_PARTIAL = new Compartment<>(); + public static final Compartment PARTIAL = new Compartment<>(); + public static final Compartment> DIRECTIONAL_PARTIAL = new Compartment<>(); } diff --git a/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java b/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java index 91d70d238..4ed176c64 100644 --- a/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java +++ b/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java @@ -1,13 +1,12 @@ package com.simibubi.create.foundation.render; import static net.minecraft.state.properties.BlockStateProperties.FACING; -import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; import java.util.function.Supplier; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.AllBlockPartials; import com.simibubi.create.CreateClient; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.MatrixStacker; @@ -16,43 +15,19 @@ import net.minecraft.util.Direction; public class PartialBufferer { - public static SuperByteBuffer get(AllBlockPartials partial, BlockState referenceState) { + public static SuperByteBuffer get(PartialModel partial, BlockState referenceState) { return CreateClient.bufferCache.renderPartial(partial, referenceState); } - public static SuperByteBuffer getDirectionalSouth(AllBlockPartials partial, BlockState referenceState) { + public static SuperByteBuffer getFacing(PartialModel partial, BlockState referenceState) { Direction facing = referenceState.get(FACING); - return getDirectionalSouth(partial, referenceState, facing); + return getFacing(partial, referenceState, facing); } - public static SuperByteBuffer getDirectional(AllBlockPartials partial, BlockState referenceState) { - Direction facing = referenceState.get(FACING); - return getDirectional(partial, referenceState, facing); - } - - public static SuperByteBuffer getHorizontal(AllBlockPartials partial, BlockState referenceState) { - Direction facing = referenceState.get(HORIZONTAL_FACING); - return getDirectionalSouth(partial, referenceState, facing); - } - - public static SuperByteBuffer getDirectionalSouth(AllBlockPartials partial, BlockState referenceState, Direction facing) { + public static SuperByteBuffer getFacing(PartialModel partial, BlockState referenceState, Direction facing) { return CreateClient.bufferCache.renderDirectionalPartial(partial, referenceState, facing, rotateToFace(facing)); } - public static SuperByteBuffer getDirectional(AllBlockPartials partial, BlockState referenceState, Direction facing) { - Supplier ms = () -> { - MatrixStack stack = new MatrixStack(); - MatrixStacker.of(stack) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) - .unCentre(); - - return stack; - }; - return CreateClient.bufferCache.renderDirectionalPartial(partial, referenceState, facing, ms); - } - public static Supplier rotateToFace(Direction facing) { return () -> { MatrixStack stack = new MatrixStack(); diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java index 2293037d2..f5f7d7559 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java @@ -12,7 +12,7 @@ import org.lwjgl.opengl.GL11; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.AllBlockPartials; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.utility.VirtualEmptyModelData; import net.minecraft.block.BlockState; @@ -41,23 +41,23 @@ public class SuperByteBufferCache { return getGeneric(toRender, () -> standardBlockRender(toRender)); } - public SuperByteBuffer renderPartial(AllBlockPartials partial, BlockState referenceState) { + public SuperByteBuffer renderPartial(PartialModel partial, BlockState referenceState) { return get(Compartment.PARTIAL, partial, () -> standardModelRender(partial.get(), referenceState)); } - public SuperByteBuffer renderPartial(AllBlockPartials partial, BlockState referenceState, + public SuperByteBuffer renderPartial(PartialModel partial, BlockState referenceState, Supplier modelTransform) { return get(Compartment.PARTIAL, partial, () -> standardModelRender(partial.get(), referenceState, modelTransform.get())); } - public SuperByteBuffer renderDirectionalPartial(AllBlockPartials partial, BlockState referenceState, - Direction dir) { + public SuperByteBuffer renderDirectionalPartial(PartialModel partial, BlockState referenceState, + Direction dir) { return get(Compartment.DIRECTIONAL_PARTIAL, Pair.of(dir, partial), () -> standardModelRender(partial.get(), referenceState)); } - public SuperByteBuffer renderDirectionalPartial(AllBlockPartials partial, BlockState referenceState, Direction dir, + public SuperByteBuffer renderDirectionalPartial(PartialModel partial, BlockState referenceState, Direction dir, Supplier modelTransform) { return get(Compartment.DIRECTIONAL_PARTIAL, Pair.of(dir, partial), () -> standardModelRender(partial.get(), referenceState, modelTransform.get())); diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/core/PartialModel.java b/src/main/java/com/simibubi/create/foundation/render/backend/core/PartialModel.java new file mode 100644 index 000000000..87fafb9dd --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/backend/core/PartialModel.java @@ -0,0 +1,56 @@ +package com.simibubi.create.foundation.render.backend.core; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.ModelBakeEvent; +import net.minecraftforge.client.event.ModelRegistryEvent; +import net.minecraftforge.client.model.ModelLoader; + +/** + * A helper class for loading and accessing json models. + *

+ * Creating a PartialModel will make the associated modelLocation automatically load. + * As such, PartialModels must be initialized at or before {@link ModelRegistryEvent}. + * Once {@link ModelBakeEvent} finishes, all PartialModels (with valid modelLocations) + * will have their bakedModel fields populated. + *

+ * Attempting to create a PartialModel after ModelRegistryEvent will cause an error. + */ +public class PartialModel { + + private static boolean tooLate = false; + private static final List all = new ArrayList<>(); + + protected final ResourceLocation modelLocation; + protected IBakedModel bakedModel; + + public PartialModel(ResourceLocation modelLocation) { + + if (tooLate) throw new RuntimeException("PartialModel '" + modelLocation + "' loaded after ModelRegistryEvent"); + + this.modelLocation = modelLocation; + all.add(this); + } + + public static void onModelRegistry(ModelRegistryEvent event) { + for (PartialModel partial : all) + ModelLoader.addSpecialModel(partial.modelLocation); + + tooLate = true; + } + + public static void onModelBake(ModelBakeEvent event) { + Map modelRegistry = event.getModelRegistry(); + for (PartialModel partial : all) + partial.bakedModel = modelRegistry.get(partial.modelLocation); + } + + public IBakedModel get() { + return bakedModel; + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/RenderMaterial.java b/src/main/java/com/simibubi/create/foundation/render/backend/instancing/RenderMaterial.java index f383bad97..fe7517b8f 100644 --- a/src/main/java/com/simibubi/create/foundation/render/backend/instancing/RenderMaterial.java +++ b/src/main/java/com/simibubi/create/foundation/render/backend/instancing/RenderMaterial.java @@ -14,11 +14,11 @@ import org.apache.commons.lang3.tuple.Pair; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.mojang.blaze3d.matrix.MatrixStack; -import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.render.Compartment; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.render.backend.Backend; import com.simibubi.create.foundation.render.backend.FastRenderDispatcher; +import com.simibubi.create.foundation.render.backend.core.PartialModel; import com.simibubi.create.foundation.render.backend.gl.BasicProgram; import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec; import com.simibubi.create.foundation.render.backend.gl.shader.ShaderCallback; @@ -101,15 +101,15 @@ public class RenderMaterial

buildModel(partial.get(), referenceState)); } - public MODEL getModel(AllBlockPartials partial, BlockState referenceState, Direction dir) { + public MODEL getModel(PartialModel partial, BlockState referenceState, Direction dir) { return getModel(partial, referenceState, dir, rotateToFace(dir)); } - public MODEL getModel(AllBlockPartials partial, BlockState referenceState, Direction dir, Supplier modelTransform) { + public MODEL getModel(PartialModel partial, BlockState referenceState, Direction dir, Supplier modelTransform) { return get(Compartment.DIRECTIONAL_PARTIAL, Pair.of(dir, partial), () -> buildModel(partial.get(), referenceState, modelTransform.get())); }