From b2fe04a3c87fb3c39a6d369d00916ad1566777aa Mon Sep 17 00:00:00 2001 From: zelophed Date: Mon, 19 Sep 2022 12:57:31 +0200 Subject: [PATCH] Pondering Alone, Part III - move SuperByteBuffer and its caching to catnip - move sprite shifter to catnip - no longer use StitchedSprites for (ct) sprite shifts - fix ponder fluid rendering by using SBB for WorldSectionElement again - allow catnip-forge to load without being present on the server --- .../com/simibubi/create/AllSpriteShifts.java | 4 +- .../com/simibubi/create/CreateClient.java | 21 ++-- .../animations/AnimatedBlazeBurner.java | 6 +- .../content/contraptions/KineticDebugger.java | 4 +- .../base/KineticTileEntityRenderer.java | 10 +- .../contraptions/base/flwdata/BeltData.java | 2 +- .../components/actors/DrillRenderer.java | 32 ++--- .../components/actors/HarvesterRenderer.java | 8 +- .../PortableStorageInterfaceRenderer.java | 16 +-- .../components/clock/CuckooClockRenderer.java | 16 +-- .../crafter/MechanicalCrafterRenderer.java | 8 +- .../components/crank/HandCrankRenderer.java | 6 +- .../components/deployer/DeployerRenderer.java | 15 +-- .../components/fan/EncasedFanRenderer.java | 8 +- .../components/fan/NozzleTileEntity.java | 2 +- .../components/flywheel/FlywheelRenderer.java | 6 +- .../millstone/MillstoneRenderer.java | 6 +- .../mixer/MechanicalMixerRenderer.java | 10 +- .../motor/CreativeMotorRenderer.java | 6 +- .../press/MechanicalPressRenderer.java | 6 +- .../components/saw/SawRenderer.java | 30 +++-- .../components/steam/SteamEngineRenderer.java | 15 +-- .../steam/whistle/WhistleRenderer.java | 8 +- .../bearing/BearingInstance.java | 4 +- .../bearing/BearingRenderer.java | 10 +- .../StabilizedBearingMovementBehaviour.java | 11 +- .../chassis/StickerRenderer.java | 25 ++-- .../gantry/GantryCarriageRenderer.java | 16 ++- .../controls/ControlsRenderer.java | 12 +- .../pulley/AbstractPulleyRenderer.java | 10 +- .../pulley/PulleyRenderer.java | 12 +- .../render/ContraptionInstanceManager.java | 2 - .../render/ContraptionRenderDispatcher.java | 5 +- .../render/FlwContraption.java | 2 +- .../render/SBBContraptionManager.java | 19 +-- .../train/CouplingHandler.java | 4 +- .../train/CouplingHandlerClient.java | 2 +- .../train/CouplingPhysics.java | 2 +- .../train/CouplingRenderer.java | 10 +- .../contraptions/fluids/OpenEndedPipe.java | 2 +- .../contraptions/fluids/PumpRenderer.java | 17 +-- .../fluids/actors/HosePulleyRenderer.java | 8 +- .../fluids/actors/SpoutRenderer.java | 4 +- .../fluids/particle/BasinFluidParticle.java | 2 +- .../fluids/pipes/AxisPipeBlock.java | 2 +- .../fluids/pipes/FluidValveInstance.java | 4 +- .../fluids/pipes/FluidValveRenderer.java | 27 ++-- .../fluids/pipes/FluidValveTileEntity.java | 2 +- .../fluids/pipes/SmartFluidPipeBlock.java | 2 +- .../pipes/SmartFluidPipeTileEntity.java | 4 +- .../fluids/tank/FluidTankRenderer.java | 16 +-- .../contraptions/processing/BasinRecipe.java | 2 +- .../processing/BasinRenderer.java | 6 +- .../processing/BasinTileEntity.java | 2 +- .../burner/BlazeBurnerRenderer.java | 26 ++-- .../advanced/SpeedControllerRenderer.java | 9 +- .../contraptions/relays/belt/BeltBlock.java | 2 +- .../relays/belt/BeltInstance.java | 2 +- .../contraptions/relays/belt/BeltModel.java | 2 +- .../relays/belt/BeltRenderer.java | 10 +- .../relays/belt/item/BeltConnectorItem.java | 2 +- .../BracketedKineticBlockModel.java | 6 +- .../BracketedKineticTileRenderer.java | 8 +- .../relays/encased/EncasedCogRenderer.java | 8 +- .../relays/encased/SplitShaftRenderer.java | 6 +- .../relays/gauge/GaugeRenderer.java | 8 +- .../relays/gearbox/GearboxRenderer.java | 6 +- .../wrench/WrenchItemRenderer.java | 2 +- .../curiosities/NoGravMagicalDohickyItem.java | 1 - .../armor/CopperBacktankArmorLayer.java | 43 ++++--- .../armor/CopperBacktankRenderer.java | 16 ++- .../armor/CopperBacktankTileEntity.java | 2 +- .../curiosities/bell/BellRenderer.java | 8 +- .../curiosities/bell/SoulPulseEffect.java | 2 +- .../deco/SlidingDoorMovementBehaviour.java | 2 +- .../curiosities/deco/SlidingDoorRenderer.java | 6 +- .../deco/SlidingDoorTileEntity.java | 2 +- .../curiosities/toolbox/ToolboxRenderer.java | 21 ++-- .../curiosities/tools/BlueprintRenderer.java | 28 +++-- .../curiosities/zapper/ZapperItem.java | 2 +- .../WorldshaperItemRenderer.java | 2 +- .../terrainzapper/WorldshaperScreen.java | 2 +- .../belts/tunnel/BeltTunnelRenderer.java | 6 +- .../SmartChuteFilterSlotPositioning.java | 4 +- .../block/depot/EjectorRenderer.java | 12 +- .../block/diodes/BrassDiodeRenderer.java | 6 +- .../block/display/DisplayLinkRenderer.java | 18 +-- .../block/funnel/FunnelRenderer.java | 6 +- .../block/mechanicalArm/ArmRenderer.java | 18 +-- .../block/mechanicalArm/ArmTileEntity.java | 7 +- .../block/redstone/AnalogLeverRenderer.java | 8 +- .../block/redstone/NixieTubeBlock.java | 2 +- .../block/redstone/NixieTubeRenderer.java | 53 ++++---- .../block/redstone/NixieTubeTileEntity.java | 2 +- .../item/filter/AttributeFilterContainer.java | 2 +- .../item/filter/AttributeFilterScreen.java | 2 +- .../trains/entity/ArrivalSoundQueue.java | 2 +- .../entity/CarriageCouplingRenderer.java | 21 ++-- .../logistics/trains/entity/Navigation.java | 2 +- .../display/FlapDisplayRenderer.java | 6 +- .../edgePoint/TrackTargetingBehaviour.java | 4 +- .../edgePoint/signal/SignalEdgeGroup.java | 2 +- .../edgePoint/signal/SignalPropagator.java | 1 + .../edgePoint/signal/SignalRenderer.java | 8 +- .../edgePoint/signal/SignalTileEntity.java | 2 +- .../edgePoint/station/StationRenderer.java | 27 ++-- .../schedule/TrainHatArmorLayer.java | 8 +- .../trains/track/StandardBogeyBlock.java | 36 +++--- .../logistics/trains/track/TrackRenderer.java | 24 ++-- .../block/SchematicannonRenderer.java | 8 +- .../schematics/client/SchematicRenderer.java | 5 +- .../block/connected/CTSpriteShiftEntry.java | 6 +- .../block/connected/CTSpriteShifter.java | 13 +- .../block/render/SpriteShiftEntry.java | 50 -------- .../block/render/SpriteShifter.java | 23 ---- .../command/ClearBufferCacheCommand.java | 2 + .../render/BakedModelRenderHelper.java | 29 ----- ...ufferer.java => CachedPartialBuffers.java} | 31 ++--- .../render/FlwSuperBufferFactory.java | 28 +++++ ...yteBuffer.java => FlwSuperByteBuffer.java} | 119 +++++++++--------- .../render/SuperByteBufferCache.java | 54 -------- .../render/TileEntityRenderHelper.java | 2 +- .../ColoredOverlayTileEntityRenderer.java | 2 +- 123 files changed, 652 insertions(+), 734 deletions(-) delete mode 100644 src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java delete mode 100644 src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java delete mode 100644 src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java rename src/main/java/com/simibubi/create/foundation/render/{CachedBufferer.java => CachedPartialBuffers.java} (69%) create mode 100644 src/main/java/com/simibubi/create/foundation/render/FlwSuperBufferFactory.java rename src/main/java/com/simibubi/create/foundation/render/{SuperByteBuffer.java => FlwSuperByteBuffer.java} (79%) delete mode 100644 src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java diff --git a/src/main/java/com/simibubi/create/AllSpriteShifts.java b/src/main/java/com/simibubi/create/AllSpriteShifts.java index 2e33669c3..e5eb174c3 100644 --- a/src/main/java/com/simibubi/create/AllSpriteShifts.java +++ b/src/main/java/com/simibubi/create/AllSpriteShifts.java @@ -9,9 +9,9 @@ import com.simibubi.create.foundation.block.connected.AllCTTypes; import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry; import com.simibubi.create.foundation.block.connected.CTSpriteShifter; import com.simibubi.create.foundation.block.connected.CTType; -import com.simibubi.create.foundation.block.render.SpriteShiftEntry; -import com.simibubi.create.foundation.block.render.SpriteShifter; +import net.createmod.catnip.render.SpriteShiftEntry; +import net.createmod.catnip.render.SpriteShifter; import net.createmod.catnip.utility.Couple; import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.block.state.properties.WoodType; diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index fa3bcdd02..61e4cc77e 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -22,12 +22,14 @@ import com.simibubi.create.foundation.ClientResourceReloadListener; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.ponder.CreatePonderPlugin; import com.simibubi.create.foundation.ponder.CreateSharedPonderText; -import com.simibubi.create.foundation.render.CachedBufferer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import com.simibubi.create.foundation.render.CreateContexts; -import com.simibubi.create.foundation.render.SuperByteBufferCache; +import com.simibubi.create.foundation.render.FlwSuperBufferFactory; import com.simibubi.create.foundation.utility.ModelSwapper; import com.simibubi.create.foundation.utility.ShippedResourcePacks; +import net.createmod.catnip.render.SuperBufferFactory; +import net.createmod.catnip.render.SuperByteBufferCache; import net.createmod.ponder.foundation.PonderIndex; import net.minecraft.ChatFormatting; import net.minecraft.client.GraphicsStatus; @@ -45,8 +47,6 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; public class CreateClient { - public static final SuperByteBufferCache BUFFER_CACHE = new SuperByteBufferCache(); - //public static final Outliner OUTLINER = new Outliner(); public static final ModelSwapper MODEL_SWAPPER = new ModelSwapper(); public static final CasingConnectivity CASING_CONNECTIVITY = new CasingConnectivity(); @@ -77,11 +77,12 @@ public class CreateClient { } public static void clientInit(final FMLClientSetupEvent event) { - BUFFER_CACHE.registerCompartment(CachedBufferer.GENERIC_TILE); - BUFFER_CACHE.registerCompartment(CachedBufferer.PARTIAL); - BUFFER_CACHE.registerCompartment(CachedBufferer.DIRECTIONAL_PARTIAL); - BUFFER_CACHE.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE); - BUFFER_CACHE.registerCompartment(SBBContraptionManager.CONTRAPTION, 20); + SuperBufferFactory.setInstance(new FlwSuperBufferFactory()); + + SuperByteBufferCache.getInstance().registerCompartment(CachedPartialBuffers.PARTIAL); + SuperByteBufferCache.getInstance().registerCompartment(CachedPartialBuffers.DIRECTIONAL_PARTIAL); + SuperByteBufferCache.getInstance().registerCompartment(KineticTileEntityRenderer.KINETIC_TILE); + SuperByteBufferCache.getInstance().registerCompartment(SBBContraptionManager.CONTRAPTION, 20); ShippedResourcePacks.extractFiles("Copper Legacy Pack"); @@ -107,8 +108,6 @@ public class CreateClient { } public static void invalidateRenderers() { - BUFFER_CACHE.invalidate(); - SCHEMATIC_HANDLER.updateRenderers(); ContraptionRenderDispatcher.reset(); } 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 d34187d97..04ce87abf 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 @@ -8,9 +8,9 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllSpriteShifts; import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel; -import com.simibubi.create.foundation.block.render.SpriteShiftEntry; -import com.simibubi.create.foundation.render.CachedBufferer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SpriteShiftEntry; import net.createmod.catnip.utility.AnimationTickHolder; import net.createmod.ponder.utility.WorldTickHolder; import net.minecraft.client.Minecraft; @@ -87,7 +87,7 @@ public class AnimatedBlazeBurner extends AnimatedKinetics { MultiBufferSource.BufferSource buffer = mc.renderBuffers() .bufferSource(); VertexConsumer vb = buffer.getBuffer(RenderType.cutoutMipped()); - CachedBufferer.partial(AllBlockPartials.BLAZE_BURNER_FLAME, Blocks.AIR.defaultBlockState()) + CachedPartialBuffers.partial(AllBlockPartials.BLAZE_BURNER_FLAME, Blocks.AIR.defaultBlockState()) .shiftUVScrolling(spriteShift, (float) uScroll, (float) vScroll) .light(LightTexture.FULL_BRIGHT) .renderInto(matrixStack, vb); diff --git a/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java b/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java index 2fc6a546e..53e03fd01 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java +++ b/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java @@ -1,12 +1,12 @@ package com.simibubi.create.content.contraptions; -import com.simibubi.create.CreateClient; 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.config.AllConfigs; import net.createmod.catnip.CatnipClient; +import net.createmod.catnip.render.SuperByteBufferCache; import net.createmod.catnip.utility.VecHelper; import net.createmod.catnip.utility.theme.Color; import net.minecraft.client.Minecraft; @@ -29,7 +29,7 @@ public class KineticDebugger { if (!isActive()) { if (KineticTileEntityRenderer.rainbowMode) { KineticTileEntityRenderer.rainbowMode = false; - CreateClient.BUFFER_CACHE.invalidate(); + SuperByteBufferCache.getInstance().invalidate(); } return; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java index 4b3b17bba..82b52ccf9 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java @@ -8,11 +8,11 @@ import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; +import net.createmod.catnip.render.CachedBlockBuffers; +import net.createmod.catnip.render.SuperByteBuffer; +import net.createmod.catnip.render.SuperByteBufferCache; import net.createmod.catnip.utility.theme.Color; import net.createmod.ponder.utility.WorldTickHolder; import net.minecraft.client.renderer.ItemBlockRenderTypes; @@ -62,12 +62,12 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer { + superByteBuffer + .transform(matrices.getModel()) + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) + .rotateX(AngleHelper.verticalAngle(facing)) + .rotateZ(angle) + .unCentre() + .light(matrices.getWorld(), + ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) + .renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid())); + }); + } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java index 6cdd17929..09125719d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/HarvesterRenderer.java @@ -8,10 +8,10 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.VecHelper; import net.createmod.catnip.utility.math.AngleHelper; import net.createmod.ponder.utility.WorldTickHolder; @@ -33,7 +33,7 @@ public class HarvesterRenderer extends SafeTileEntityRenderer drawCallback) { - SuperByteBuffer middle = CachedBufferer.partial(getMiddleForState(blockState, lit), blockState); - SuperByteBuffer top = CachedBufferer.partial(getTopForState(blockState), blockState); + SuperByteBuffer middle = CachedPartialBuffers.partial(getMiddleForState(blockState, lit), blockState); + SuperByteBuffer top = CachedPartialBuffers.partial(getTopForState(blockState), blockState); if (local != null) { middle.transform(local); @@ -80,10 +80,10 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer BlockState blockState = te.getBlockState(); Vec3 offset = getHandOffset(te, partialTicks, blockState); - SuperByteBuffer pole = CachedBufferer.partial(AllBlockPartials.DEPLOYER_POLE, blockState); - SuperByteBuffer hand = CachedBufferer.partial(te.getHandPose(), blockState); + SuperByteBuffer pole = CachedPartialBuffers.partial(AllBlockPartials.DEPLOYER_POLE, blockState); + SuperByteBuffer hand = CachedPartialBuffers.partial(te.getHandPose(), blockState); transform(pole.translate(offset.x, offset.y, offset.z), blockState, true) .light(light) @@ -167,9 +168,9 @@ public class DeployerRenderer extends SafeTileEntityRenderer if (context.contraption.stalled) speed = 0; - SuperByteBuffer shaft = CachedBufferer.block(AllBlocks.SHAFT.getDefaultState()); - SuperByteBuffer pole = CachedBufferer.partial(AllBlockPartials.DEPLOYER_POLE, blockState); - SuperByteBuffer hand = CachedBufferer.partial(handPose, blockState); + SuperByteBuffer shaft = CachedBlockBuffers.block(AllBlocks.SHAFT.getDefaultState()); + SuperByteBuffer pole = CachedPartialBuffers.partial(AllBlockPartials.DEPLOYER_POLE, blockState); + SuperByteBuffer hand = CachedPartialBuffers.partial(handPose, blockState); double factor; if (context.contraption.stalled || context.position == null || context.data.contains("StationaryTimer")) { 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 7c7b54f44..136ea476f 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 @@ -8,9 +8,9 @@ import com.mojang.blaze3d.vertex.VertexConsumer; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.ponder.utility.WorldTickHolder; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; @@ -38,9 +38,9 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer { int lightInFront = LevelRenderer.getLightColor(te.getLevel(), te.getBlockPos().relative(direction)); SuperByteBuffer shaftHalf = - CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction.getOpposite()); + CachedPartialBuffers.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction.getOpposite()); SuperByteBuffer fanInner = - CachedBufferer.partialFacing(AllBlockPartials.ENCASED_FAN_INNER, te.getBlockState(), direction.getOpposite()); + CachedPartialBuffers.partialFacing(AllBlockPartials.ENCASED_FAN_INNER, te.getBlockState(), direction.getOpposite()); float time = WorldTickHolder.getRenderTime(te.getLevel()); float speed = te.getSpeed() * 5; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java index 504b3376f..5f8da3516 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/fan/NozzleTileEntity.java @@ -7,8 +7,8 @@ import java.util.List; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.createmod.catnip.utility.VecHelper; +import net.createmod.catnip.utility.VecHelper; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; 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 4e46948ff..b3a40ddae 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 @@ -5,9 +5,9 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import net.createmod.catnip.render.CachedBlockBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -40,7 +40,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { private void renderFlywheel(KineticTileEntity te, PoseStack ms, int light, BlockState blockState, float angle, VertexConsumer vb) { - SuperByteBuffer wheel = CachedBufferer.block(blockState); + SuperByteBuffer wheel = CachedBlockBuffers.block(blockState); kineticRotationTransform(wheel, te, getRotationAxisOf(te), AngleHelper.rad(angle), light); wheel.renderInto(ms, vb); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneRenderer.java index 0dfd15517..3f6ab496f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/millstone/MillstoneRenderer.java @@ -3,9 +3,9 @@ package com.simibubi.create.content.contraptions.components.millstone; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.world.level.block.state.BlockState; @@ -17,7 +17,7 @@ public class MillstoneRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) { - return CachedBufferer.partial(AllBlockPartials.MILLSTONE_COG, state); + return CachedPartialBuffers.partial(AllBlockPartials.MILLSTONE_COG, state); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java index 1d5736840..b3882edde 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java @@ -6,9 +6,9 @@ import com.mojang.blaze3d.vertex.VertexConsumer; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.ponder.utility.WorldTickHolder; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -38,7 +38,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer { VertexConsumer vb = buffer.getBuffer(RenderType.solid()); - SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState); + SuperByteBuffer superBuffer = CachedPartialBuffers.partial(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState); standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb); float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks); @@ -46,12 +46,12 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer { float time = WorldTickHolder.getRenderTime(te.getLevel()); float angle = ((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI; - SuperByteBuffer poleRender = CachedBufferer.partial(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState); + SuperByteBuffer poleRender = CachedPartialBuffers.partial(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState); poleRender.translate(0, -renderedHeadOffset, 0) .light(light) .renderInto(ms, vb); - SuperByteBuffer headRender = CachedBufferer.partial(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState); + SuperByteBuffer headRender = CachedPartialBuffers.partial(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState); headRender.rotateCentered(Direction.UP, angle) .translate(0, -renderedHeadOffset, 0) .light(light) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorRenderer.java index 6885a9ea8..68ab979ee 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorRenderer.java @@ -3,9 +3,9 @@ package com.simibubi.create.content.contraptions.components.motor; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.world.level.block.state.BlockState; @@ -17,7 +17,7 @@ public class CreativeMotorRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) { - return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, state); + return CachedPartialBuffers.partialFacing(AllBlockPartials.SHAFT_HALF, state); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java index 44302ce7c..2911b6193 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java @@ -7,9 +7,9 @@ import com.mojang.blaze3d.vertex.PoseStack; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -39,7 +39,7 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer { float renderedHeadOffset = pressingBehaviour.getRenderedHeadOffset(partialTicks) * pressingBehaviour.mode.headOffset; - SuperByteBuffer headRender = CachedBufferer.partialFacing(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState, + SuperByteBuffer headRender = CachedPartialBuffers.partialFacing(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState, blockState.getValue(HORIZONTAL_FACING)); headRender.translate(0, -renderedHeadOffset, 0) .light(light) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index e2877c068..871a60fa2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -2,6 +2,8 @@ package com.simibubi.create.content.contraptions.components.saw; import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING; +import java.util.Optional; + import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; @@ -13,11 +15,13 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; +import net.createmod.catnip.render.CachedBlockBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.VecHelper; import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.client.Minecraft; @@ -79,7 +83,7 @@ public class SawRenderer extends SafeTileEntityRenderer { rotate = true; } - SuperByteBuffer superBuffer = CachedBufferer.partialFacing(partial, blockState); + SuperByteBuffer superBuffer = CachedPartialBuffers.partialFacing(partial, blockState); if (rotate) { superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(90)); } @@ -147,9 +151,9 @@ public class SawRenderer extends SafeTileEntityRenderer { if (state.getValue(FACING) .getAxis() .isHorizontal()) - return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, + return CachedPartialBuffers.partialFacing(AllBlockPartials.SHAFT_HALF, state.rotate(te.getLevel(), te.getBlockPos(), Rotation.CLOCKWISE_180)); - return CachedBufferer.block(KineticTileEntityRenderer.KINETIC_TILE, + return CachedBlockBuffers.block(KineticTileEntityRenderer.KINETIC_TILE, getRenderedBlockState(te)); } @@ -175,19 +179,25 @@ public class SawRenderer extends SafeTileEntityRenderer { boolean shouldAnimate = (context.contraption.stalled && horizontal) || (!context.contraption.stalled && !backwards && moving); - SuperByteBuffer superBuffer; + SuperByteBuffer sBuffer; if (SawBlock.isHorizontal(state)) { if (shouldAnimate) - superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE, state); + sBuffer = CachedPartialBuffers.partial(AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE, state); else - superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE, state); + sBuffer = CachedPartialBuffers.partial(AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE, state); } else { if (shouldAnimate) - superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE, state); + sBuffer = CachedPartialBuffers.partial(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE, state); else - superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state); + sBuffer = CachedPartialBuffers.partial(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state); } + Optional optional = FlwSuperByteBuffer.cast(sBuffer); + if (optional.isEmpty()) + return; + + FlwSuperByteBuffer superBuffer = optional.get(); + superBuffer.transform(matrices.getModel()) .centre() .rotateY(AngleHelper.horizontalAngle(facing)) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/steam/SteamEngineRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/steam/SteamEngineRenderer.java index 723736f52..e50c2bad0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/steam/SteamEngineRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/steam/SteamEngineRenderer.java @@ -5,8 +5,8 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import net.createmod.catnip.utility.math.AngleHelper; @@ -71,11 +71,12 @@ public class SteamEngineRenderer extends SafeTileEntityRenderer { offset -= Math.sin(wiggleProgress * (2 * Mth.PI) * (4 - size.ordinal())) / 16f; } - CachedBufferer.partial(mouth, blockState) - .centre() - .rotateY(AngleHelper.horizontalAngle(direction)) - .unCentre() + CachedPartialBuffers.partial(mouth, blockState) + .rotateCentered(Direction.Axis.Y, Mth.DEG_TO_RAD * AngleHelper.horizontalAngle(direction)) .translate(0, offset * 4 / 16f, 0) .light(light) .renderInto(ms, buffer.getBuffer(RenderType.solid())); 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 46f0405b0..78af1e8c8 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 @@ -9,9 +9,9 @@ import com.mojang.math.Vector3f; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.BackHalfShaftInstance; import com.simibubi.create.content.contraptions.base.KineticTileEntity; -import net.createmod.catnip.utility.math.AngleHelper; -import net.createmod.catnip.utility.AnimationTickHolder; +import net.createmod.catnip.utility.AnimationTickHolder; +import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.core.Direction; import net.minecraft.world.level.block.state.properties.BlockStateProperties; 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 715ae5c0c..f73161d22 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 @@ -6,10 +6,10 @@ import com.mojang.blaze3d.vertex.PoseStack; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; -import net.createmod.catnip.utility.math.AngleHelper; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; +import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -36,7 +36,7 @@ public class BearingRenderer extends KineticTileEntityRenderer { .getValue(BlockStateProperties.FACING); PartialModel top = bearingTe.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP; - SuperByteBuffer superBuffer = CachedBufferer.partial(top, te.getBlockState()); + SuperByteBuffer superBuffer = CachedPartialBuffers.partial(top, te.getBlockState()); float interpolatedAngle = bearingTe.getInterpolatedAngle(partialTicks - 1); kineticRotationTransform(superBuffer, te, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI), light); @@ -51,7 +51,7 @@ public class BearingRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) { - return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, state, state + return CachedPartialBuffers.partialFacing(AllBlockPartials.SHAFT_HALF, state, state .getValue(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 4185af03d..d17ce71e0 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,9 +15,10 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Ori import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.AnimationTickHolder; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -38,7 +39,7 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour { Direction facing = context.state.getValue(BlockStateProperties.FACING); PartialModel top = AllBlockPartials.BEARING_TOP; - SuperByteBuffer superBuffer = CachedBufferer.partial(top, context.state); + SuperByteBuffer superBuffer = CachedPartialBuffers.partial(top, context.state); float renderPartialTicks = AnimationTickHolder.getPartialTicks(); // rotate to match blockstate @@ -53,10 +54,8 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour { rotation.mul(orientation); - orientation = rotation; - superBuffer.transform(matrices.getModel()); - superBuffer.rotateCentered(orientation); + FlwSuperByteBuffer.cast(superBuffer).ifPresent(flwBuffer -> flwBuffer.rotateCentered(rotation)); // render superBuffer diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java index d33f73eab..c9fdfad4c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerRenderer.java @@ -3,10 +3,11 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.math.AngleHelper; import net.createmod.ponder.utility.WorldTickHolder; import net.minecraft.client.Minecraft; @@ -28,19 +29,23 @@ public class StickerRenderer extends SafeTileEntityRenderer { if (Backend.canUseInstancing(te.getLevel())) return; BlockState state = te.getBlockState(); - SuperByteBuffer head = CachedBufferer.partial(AllBlockPartials.STICKER_HEAD, state); - float offset = te.piston.getValue(WorldTickHolder.getPartialTicks(te.getLevel())); + SuperByteBuffer head = CachedPartialBuffers.partial(AllBlockPartials.STICKER_HEAD, state); + float offset; if (te.getLevel() != Minecraft.getInstance().level && !te.isVirtual()) offset = state.getValue(StickerBlock.EXTENDED) ? 1 : 0; + else + offset = te.piston.getValue(WorldTickHolder.getPartialTicks(te.getLevel())); Direction facing = state.getValue(StickerBlock.FACING); - head.nudge(te.hashCode()) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing) + 90) - .unCentre() - .translate(0, (offset * offset) * 4 / 16f, 0); + FlwSuperByteBuffer.cast(head).ifPresent(flwBuffer -> flwBuffer + .nudge(te.hashCode()) + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) + .rotateX(AngleHelper.verticalAngle(facing) + 90) + .unCentre() + .translate(0, (offset * offset) * 4 / 16f, 0)); + head.light(light) .renderInto(ms, buffer.getBuffer(RenderType.solid())); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java index b2e52eb9f..9f7900b5b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageRenderer.java @@ -5,9 +5,10 @@ import com.mojang.blaze3d.vertex.PoseStack; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.Iterate; import net.createmod.catnip.utility.math.AngleHelper; import net.createmod.ponder.utility.WorldTickHolder; @@ -54,15 +55,18 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer { if (facing == Direction.NORTH || facing == Direction.EAST) angleForTe *= -1; - SuperByteBuffer cogs = CachedBufferer.partial(AllBlockPartials.GANTRY_COGS, state); - cogs.centre() + SuperByteBuffer cogs = CachedPartialBuffers.partial(AllBlockPartials.GANTRY_COGS, state); + float finalAngleForTe = angleForTe; + FlwSuperByteBuffer.cast(cogs).ifPresent(flwBuffer -> flwBuffer + .centre() .rotateY(AngleHelper.horizontalAngle(facing)) .rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) .rotateY(alongFirst ^ facing.getAxis() == Axis.X ? 0 : 90) .translate(0, -9 / 16f, 0) - .rotateX(-angleForTe) + .rotateX(-finalAngleForTe) .translate(0, 9 / 16f, 0) - .unCentre(); + .unCentre() + ); cogs.light(light) .renderInto(ms, buffer.getBuffer(RenderType.solid())); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/controls/ControlsRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/controls/ControlsRenderer.java index a18d92934..67deebf70 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/controls/ControlsRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/interaction/controls/ControlsRenderer.java @@ -7,9 +7,9 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.Iterate; import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.client.renderer.MultiBufferSource; @@ -25,13 +25,11 @@ public class ControlsRenderer { BlockState state = context.state; Direction facing = state.getValue(ControlsBlock.FACING); - SuperByteBuffer cover = CachedBufferer.partial(AllBlockPartials.TRAIN_CONTROLS_COVER, state); + SuperByteBuffer cover = CachedPartialBuffers.partial(AllBlockPartials.TRAIN_CONTROLS_COVER, state); float hAngle = 180 + AngleHelper.horizontalAngle(facing); PoseStack ms = matrices.getModel(); cover.transform(ms) - .centre() - .rotateY(hAngle) - .unCentre() + .rotateCentered(Direction.Axis.Y, Mth.DEG_TO_RAD * hAngle) .light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld)) .renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.cutoutMipped())); @@ -39,7 +37,7 @@ public class ControlsRenderer { for (boolean first : Iterate.trueAndFalse) { float vAngle = (float) Mth.clamp(first ? firstLever * 70 - 25 : secondLever * 15, -45, 45); - SuperByteBuffer lever = CachedBufferer.partial(AllBlockPartials.TRAIN_CONTROLS_LEVER, state); + SuperByteBuffer lever = CachedPartialBuffers.partial(AllBlockPartials.TRAIN_CONTROLS_LEVER, state); ms.pushPose(); TransformStack.cast(ms) .centre() 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 1feb2bef1..52eaaa729 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 @@ -7,9 +7,9 @@ import com.mojang.blaze3d.vertex.VertexConsumer; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; @@ -60,8 +60,8 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { BlockState blockState = te.getBlockState(); BlockPos pos = te.getBlockPos(); - SuperByteBuffer halfMagnet = CachedBufferer.partial(this.halfMagnet, blockState); - SuperByteBuffer halfRope = CachedBufferer.partial(this.halfRope, blockState); + SuperByteBuffer halfMagnet = CachedPartialBuffers.partial(this.halfMagnet, blockState); + SuperByteBuffer halfRope = CachedPartialBuffers.partial(this.halfRope, blockState); SuperByteBuffer magnet = renderMagnet(te); SuperByteBuffer rope = renderRope(te); @@ -108,7 +108,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { protected SuperByteBuffer getRotatedCoil(KineticTileEntity te) { BlockState blockState = te.getBlockState(); - return CachedBufferer.partialFacing(getCoil(), blockState, + return CachedPartialBuffers.partialFacing(getCoil(), blockState, Direction.get(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 ce547d079..0948d0227 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 @@ -5,9 +5,9 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import net.createmod.catnip.render.CachedBlockBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.core.Direction.Axis; import net.minecraft.util.Mth; @@ -31,12 +31,12 @@ public class PulleyRenderer extends AbstractPulleyRenderer { @Override protected SuperByteBuffer renderRope(KineticTileEntity te) { - return CachedBufferer.block(AllBlocks.ROPE.getDefaultState()); + return CachedBlockBuffers.block(AllBlocks.ROPE.getDefaultState()); } @Override protected SuperByteBuffer renderMagnet(KineticTileEntity te) { - return CachedBufferer.block(AllBlocks.PULLEY_MAGNET.getDefaultState()); + return CachedBlockBuffers.block(AllBlocks.PULLEY_MAGNET.getDefaultState()); } @Override @@ -63,10 +63,10 @@ public class PulleyRenderer extends AbstractPulleyRenderer { return offset; } - + @Override public int getViewDistance() { return 128; } - + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java index df1ed3059..e23505303 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java @@ -8,8 +8,6 @@ import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.api.MaterialManager; import com.jozufozu.flywheel.api.instance.DynamicInstance; -import com.jozufozu.flywheel.api.instance.TickableInstance; -import com.jozufozu.flywheel.backend.instancing.AbstractInstance; import com.jozufozu.flywheel.backend.instancing.TaskEngine; import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstanceManager; import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java index c6c5e30cf..e34a04dd5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionRenderDispatcher.java @@ -23,9 +23,10 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionWorld; import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; import com.simibubi.create.foundation.render.TileEntityRenderHelper; +import net.createmod.catnip.render.SuperByteBuffer; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LightTexture; @@ -175,7 +176,7 @@ public class ContraptionRenderDispatcher { .withBlocks(values) .withModelData(c.modelData) .build(); - return new SuperByteBuffer(builder); + return new FlwSuperByteBuffer(builder); } public static int getLight(Level world, float lx, float ly, float lz) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraption.java index 2f04034a5..bc07e08e0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/FlwContraption.java @@ -23,8 +23,8 @@ import com.mojang.math.Matrix4f; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.foundation.render.CreateContexts; -import net.createmod.catnip.utility.AnimationTickHolder; +import net.createmod.catnip.utility.AnimationTickHolder; import net.minecraft.client.renderer.RenderType; import net.minecraft.util.Mth; import net.minecraft.world.level.Level; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/SBBContraptionManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/SBBContraptionManager.java index 0cbfdcdf0..94c33da0d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/SBBContraptionManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/SBBContraptionManager.java @@ -3,11 +3,10 @@ package com.simibubi.create.content.contraptions.components.structureMovement.re import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.jozufozu.flywheel.event.RenderLayerEvent; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; -import com.simibubi.create.foundation.render.SuperByteBuffer; -import com.simibubi.create.foundation.render.SuperByteBufferCache; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; +import net.createmod.catnip.render.SuperByteBufferCache; import net.createmod.catnip.utility.Pair; import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.LevelAccessor; @@ -33,7 +32,7 @@ public class SBBContraptionManager extends ContraptionRenderingWorld ContraptionRenderDispatcher.buildStructureBuffer(renderInfo.renderWorld, renderInfo.contraption, layer)); + FlwSuperByteBuffer.cast( + SuperByteBufferCache.getInstance().get(CONTRAPTION, Pair.of(renderInfo.contraption, layer), () -> ContraptionRenderDispatcher.buildStructureBuffer(renderInfo.renderWorld, renderInfo.contraption, layer)) + ).ifPresent(superBuffer -> { + if (superBuffer.isEmpty()) + return; - if (!contraptionBuffer.isEmpty()) { ContraptionMatrices matrices = renderInfo.getMatrices(); - contraptionBuffer.transform(matrices.getModel()) + superBuffer.transform(matrices.getModel()) .light(matrices.getWorld()) .hybridLight() .renderInto(matrices.getViewProjection(), consumer); - } - + }); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandler.java index 21a0a8d22..5dc6aab80 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandler.java @@ -12,10 +12,10 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Abs import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; import com.simibubi.create.foundation.config.AllConfigs; -import net.createmod.catnip.utility.Couple; -import net.createmod.catnip.utility.Iterate; import com.simibubi.create.foundation.utility.CreateLang; +import net.createmod.catnip.utility.Couple; +import net.createmod.catnip.utility.Iterate; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandlerClient.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandlerClient.java index 4fe1a74be..ddbe3ad13 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandlerClient.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingHandlerClient.java @@ -5,8 +5,8 @@ import java.util.Random; import com.mojang.math.Vector3f; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.networking.AllPackets; -import net.createmod.catnip.utility.VecHelper; +import net.createmod.catnip.utility.VecHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.player.LocalPlayer; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingPhysics.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingPhysics.java index b158459c1..d73bb7605 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingPhysics.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingPhysics.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.contraptions.components.structureMovement.train; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; + import net.createmod.catnip.utility.Couple; import net.createmod.catnip.utility.Iterate; import net.createmod.catnip.utility.VecHelper; - import net.minecraft.core.BlockPos; import net.minecraft.tags.BlockTags; import net.minecraft.util.Mth; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingRenderer.java index ed79cd25f..f34f3c736 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/train/CouplingRenderer.java @@ -9,10 +9,10 @@ import com.mojang.math.Vector3f; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import net.createmod.catnip.CatnipClient; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.AnimationTickHolder; import net.createmod.catnip.utility.Couple; import net.createmod.catnip.utility.VecHelper; @@ -66,9 +66,9 @@ public class CouplingRenderer { BlockState renderState = Blocks.AIR.defaultBlockState(); VertexConsumer builder = buffer.getBuffer(RenderType.solid()); - SuperByteBuffer attachment = CachedBufferer.partial(AllBlockPartials.COUPLING_ATTACHMENT, renderState); - SuperByteBuffer ring = CachedBufferer.partial(AllBlockPartials.COUPLING_RING, renderState); - SuperByteBuffer connector = CachedBufferer.partial(AllBlockPartials.COUPLING_CONNECTOR, renderState); + SuperByteBuffer attachment = CachedPartialBuffers.partial(AllBlockPartials.COUPLING_ATTACHMENT, renderState); + SuperByteBuffer ring = CachedPartialBuffers.partial(AllBlockPartials.COUPLING_RING, renderState); + SuperByteBuffer connector = CachedPartialBuffers.partial(AllBlockPartials.COUPLING_CONNECTOR, renderState); Vec3 zero = Vec3.ZERO; Vec3 firstEndpoint = transforms.getFirst() diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java index c281ceede..cfa5d8b3c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/OpenEndedPipe.java @@ -14,8 +14,8 @@ import com.simibubi.create.foundation.advancement.AdvancementBehaviour; import com.simibubi.create.foundation.advancement.AllAdvancements; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.fluid.FluidHelper; -import net.createmod.catnip.utility.BlockFace; +import net.createmod.catnip.utility.BlockFace; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; 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 16a3cf01c..568dce60e 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 @@ -5,9 +5,10 @@ import com.mojang.blaze3d.vertex.PoseStack; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -33,10 +34,11 @@ public class PumpRenderer extends KineticTileEntityRenderer { Vec3 rotationOffset = new Vec3(.5, 14 / 16f, .5); BlockState blockState = te.getBlockState(); float angle = Mth.lerp(pump.arrowDirection.getValue(partialTicks), 0, 90) - 90; - SuperByteBuffer arrow = CachedBufferer.partial(AllBlockPartials.MECHANICAL_PUMP_ARROW, blockState); + SuperByteBuffer arrow = CachedPartialBuffers.partial(AllBlockPartials.MECHANICAL_PUMP_ARROW, blockState); for (float yRot : new float[] { 0, 90 }) { Direction direction = blockState.getValue(PumpBlock.FACING); - arrow.centre() + FlwSuperByteBuffer.cast(arrow).ifPresent(flwBuffer -> flwBuffer + .centre() .rotateY(AngleHelper.horizontalAngle(direction) + 180) .rotateX(-AngleHelper.verticalAngle(direction) - 90) .unCentre() @@ -44,14 +46,15 @@ public class PumpRenderer extends KineticTileEntityRenderer { .rotateY(yRot) .rotateZ(angle) .translateBack(rotationOffset) - .light(light) - .renderInto(ms, buffer.getBuffer(RenderType.solid())); + ); + + arrow.light(light).renderInto(ms, buffer.getBuffer(RenderType.solid())); } } @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) { - return CachedBufferer.partialFacing(AllBlockPartials.MECHANICAL_PUMP_COG, state); + return CachedPartialBuffers.partialFacing(AllBlockPartials.MECHANICAL_PUMP_COG, state); } } 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 5f14a97d9..8541aeb3f 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 @@ -4,9 +4,9 @@ import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.pulley.AbstractPulleyRenderer; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.core.Direction.Axis; @@ -31,12 +31,12 @@ public class HosePulleyRenderer extends AbstractPulleyRenderer { @Override protected SuperByteBuffer renderRope(KineticTileEntity te) { - return CachedBufferer.partial(AllBlockPartials.HOSE, te.getBlockState()); + return CachedPartialBuffers.partial(AllBlockPartials.HOSE, te.getBlockState()); } @Override protected SuperByteBuffer renderMagnet(KineticTileEntity te) { - return CachedBufferer.partial(AllBlockPartials.HOSE_MAGNET, te.getBlockState()); + return CachedPartialBuffers.partial(AllBlockPartials.HOSE_MAGNET, te.getBlockState()); } @Override 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 cc6443589..4c2e498ac 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,7 +4,7 @@ import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.fluid.FluidRenderer; -import com.simibubi.create.foundation.render.CachedBufferer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; 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; @@ -72,7 +72,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer { ms.pushPose(); for (PartialModel bit : BITS) { - CachedBufferer.partial(bit, te.getBlockState()) + CachedPartialBuffers.partial(bit, te.getBlockState()) .light(light) .renderInto(ms, buffer.getBuffer(RenderType.solid())); ms.translate(0, -3 * squeeze / 32f, 0); diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/BasinFluidParticle.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/BasinFluidParticle.java index 847b7be1a..d79e64abf 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/BasinFluidParticle.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/particle/BasinFluidParticle.java @@ -4,8 +4,8 @@ import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Quaternion; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.processing.BasinTileEntity; -import net.createmod.catnip.utility.VecHelper; +import net.createmod.catnip.utility.VecHelper; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/AxisPipeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/AxisPipeBlock.java index f91b869e1..c40dc7958 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/AxisPipeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/AxisPipeBlock.java @@ -12,8 +12,8 @@ import com.simibubi.create.content.contraptions.relays.elementary.BracketedTileE import com.simibubi.create.content.contraptions.wrench.IWrenchableWithBracket; import com.simibubi.create.foundation.advancement.AdvancementBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.createmod.catnip.utility.Iterate; +import net.createmod.catnip.utility.Iterate; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java index 068167f93..e9e7efa51 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java @@ -8,9 +8,9 @@ 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.content.contraptions.relays.encased.ShaftInstance; -import net.createmod.catnip.utility.math.AngleHelper; -import net.createmod.catnip.utility.AnimationTickHolder; +import net.createmod.catnip.utility.AnimationTickHolder; +import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.core.Direction; import net.minecraft.util.Mth; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java index e13b565c4..cbf7b9f28 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveRenderer.java @@ -5,10 +5,11 @@ import com.mojang.blaze3d.vertex.PoseStack; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; -import net.createmod.catnip.utility.math.AngleHelper; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; +import net.createmod.catnip.render.SuperByteBuffer; +import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -31,7 +32,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); BlockState blockState = te.getBlockState(); - SuperByteBuffer pointer = CachedBufferer.partial(AllBlockPartials.FLUID_VALVE_POINTER, blockState); + SuperByteBuffer pointer = CachedPartialBuffers.partial(AllBlockPartials.FLUID_VALVE_POINTER, blockState); Direction facing = blockState.getValue(FluidValveBlock.FACING); if (!(te instanceof FluidValveTileEntity valve)) @@ -41,15 +42,21 @@ public class FluidValveRenderer extends KineticTileEntityRenderer { Axis pipeAxis = FluidValveBlock.getPipeAxis(blockState); Axis shaftAxis = KineticTileEntityRenderer.getRotationAxisOf(te); - int pointerRotationOffset = 0; + int pointerRotationOffset; if (pipeAxis.isHorizontal() && shaftAxis == Axis.X || pipeAxis.isVertical()) pointerRotationOffset = 90; + else + pointerRotationOffset = 0; - pointer.centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) - .rotateY(pointerRotationOffset + pointerRotation) - .unCentre() + FlwSuperByteBuffer.cast(pointer).ifPresent(flwBuffer -> flwBuffer + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) + .rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) + .rotateY(pointerRotationOffset + pointerRotation) + .unCentre() + ); + + pointer .light(light) .renderInto(ms, buffer.getBuffer(RenderType.solid())); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveTileEntity.java index d0c1768c1..2f932753b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveTileEntity.java @@ -7,9 +7,9 @@ import com.simibubi.create.content.contraptions.fluids.FluidPropagator; import com.simibubi.create.content.contraptions.fluids.pipes.StraightPipeTileEntity.StraightPipeFluidTransportBehaviour; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; + import net.createmod.catnip.utility.animation.LerpedFloat; import net.createmod.catnip.utility.animation.LerpedFloat.Chaser; - import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeBlock.java index 560fa3899..d2f0551f6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeBlock.java @@ -8,9 +8,9 @@ import com.simibubi.create.content.contraptions.fluids.FluidPropagator; import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.advancement.AdvancementBehaviour; import com.simibubi.create.foundation.block.ITE; + import net.createmod.catnip.utility.Iterate; import net.createmod.catnip.utility.VoxelShaper; - import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeTileEntity.java index b5619ea61..ea218cc7d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/SmartFluidPipeTileEntity.java @@ -10,9 +10,9 @@ import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour; -import net.createmod.catnip.utility.math.AngleHelper; -import net.createmod.catnip.utility.VecHelper; +import net.createmod.catnip.utility.VecHelper; +import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankRenderer.java index 8d671b431..ba946a9e8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/tank/FluidTankRenderer.java @@ -5,7 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.foundation.fluid.FluidRenderer; -import com.simibubi.create.foundation.render.CachedBufferer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import net.createmod.catnip.utility.Iterate; @@ -90,18 +90,18 @@ public class FluidTankRenderer extends SafeTileEntityRenderer { PartialModel beltPartial = getBeltPartial(diagonal, start, end, bottom); - SuperByteBuffer beltBuffer = CachedBufferer.partial(beltPartial, blockState) + SuperByteBuffer beltBuffer = CachedPartialBuffers.partial(beltPartial, blockState) .light(light); SpriteShiftEntry spriteShift = getSpriteShiftEntry(color, diagonal, bottom); @@ -140,7 +140,7 @@ public class BeltRenderer extends SafeTileEntityRenderer { return stack; }; - SuperByteBuffer superBuffer = CachedBufferer.partialDirectional(AllBlockPartials.BELT_PULLEY, blockState, dir, matrixStackSupplier); + SuperByteBuffer superBuffer = CachedPartialBuffers.partialDirectional(AllBlockPartials.BELT_PULLEY, blockState, dir, matrixStackSupplier); KineticTileEntityRenderer.standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java index d2c2d006b..6d808ccd7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java @@ -15,8 +15,8 @@ import com.simibubi.create.content.contraptions.relays.elementary.AbstractSimple import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock; import com.simibubi.create.foundation.advancement.AllAdvancements; import com.simibubi.create.foundation.config.AllConfigs; -import net.createmod.catnip.utility.VecHelper; +import net.createmod.catnip.utility.VecHelper; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java index ec5b472d0..467966846 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticBlockModel.java @@ -7,6 +7,7 @@ import java.util.Random; import com.jozufozu.flywheel.core.virtual.VirtualEmptyModelData; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; +import net.createmod.catnip.ForgeCatnipClient; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.resources.model.BakedModel; @@ -15,7 +16,6 @@ import net.minecraft.core.Direction; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.client.model.BakedModelWrapper; -import net.minecraftforge.client.model.data.EmptyModelData; import net.minecraftforge.client.model.data.IModelData; import net.minecraftforge.client.model.data.ModelDataMap; import net.minecraftforge.client.model.data.ModelProperty; @@ -30,7 +30,7 @@ public class BracketedKineticBlockModel extends BakedModelWrapper { @Override public IModelData getModelData(BlockAndTintGetter world, BlockPos pos, BlockState state, IModelData tileData) { - if (VirtualEmptyModelData.is(tileData) || tileData.equals(EmptyModelData.INSTANCE)) + if (VirtualEmptyModelData.is(tileData)) return tileData; BracketedModelData data = new BracketedModelData(); @@ -44,7 +44,7 @@ public class BracketedKineticBlockModel extends BakedModelWrapper { @Override public List getQuads(BlockState state, Direction side, Random rand, IModelData data) { - if (VirtualEmptyModelData.is(data) || data.equals(EmptyModelData.INSTANCE)) { + if (VirtualEmptyModelData.is(data) || data.equals(ForgeCatnipClient.NoModelData)) { return super.getQuads(state, side, rand, data); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileRenderer.java index cc1dde575..d3b65a5d6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileRenderer.java @@ -6,9 +6,9 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.ponder.utility.WorldTickHolder; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -44,7 +44,7 @@ public class BracketedKineticTileRenderer extends KineticTileEntityRenderer { Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE); renderRotatingBuffer(te, - CachedBufferer.partialFacingVertical(AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL, te.getBlockState(), facing), + CachedPartialBuffers.partialFacingVertical(AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL, te.getBlockState(), facing), ms, buffer.getBuffer(RenderType.solid()), light); float offset = getShaftAngleOffset(axis, pos); @@ -52,7 +52,7 @@ public class BracketedKineticTileRenderer extends KineticTileEntityRenderer { float angle = ((time * te.getSpeed() * 3f / 10 + offset) % 360) / 180 * (float) Math.PI; SuperByteBuffer shaft = - CachedBufferer.partialFacingVertical(AllBlockPartials.COGWHEEL_SHAFT, te.getBlockState(), facing); + CachedPartialBuffers.partialFacingVertical(AllBlockPartials.COGWHEEL_SHAFT, te.getBlockState(), facing); kineticRotationTransform(shaft, te, axis, angle, light); shaft.renderInto(ms, buffer.getBuffer(RenderType.solid())); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCogRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCogRenderer.java index 40e5ae91b..809cb1f00 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCogRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedCogRenderer.java @@ -6,9 +6,9 @@ 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.Iterate; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -51,14 +51,14 @@ public class EncasedCogRenderer extends KineticTileEntityRenderer { for (Direction d : Iterate.directionsInAxis(getRotationAxisOf(te))) { if (!def.hasShaftTowards(te.getLevel(), te.getBlockPos(), blockState, d)) continue; - renderRotatingBuffer(te, CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), d), + renderRotatingBuffer(te, CachedPartialBuffers.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), d), ms, buffer.getBuffer(RenderType.solid()), light); } } @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) { - return CachedBufferer.partialFacingVertical( + return CachedPartialBuffers.partialFacingVertical( large ? AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL : AllBlockPartials.SHAFTLESS_COGWHEEL, state, Direction.fromAxisAndDirection(state.getValue(EncasedCogwheelBlock.AXIS), AxisDirection.POSITIVE)); } 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 d048c8828..a2b4518e6 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 @@ -6,9 +6,9 @@ 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.Iterate; import net.createmod.ponder.utility.WorldTickHolder; import net.minecraft.client.renderer.MultiBufferSource; @@ -52,7 +52,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer { angle = angle / 180f * (float) Math.PI; SuperByteBuffer superByteBuffer = - CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction); + CachedPartialBuffers.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction); kineticRotationTransform(superByteBuffer, te, axis, angle, light); superByteBuffer.renderInto(ms, buffer.getBuffer(RenderType.solid())); } 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 38e3798b5..41ac6e65f 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 @@ -8,9 +8,9 @@ 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.content.contraptions.relays.gauge.GaugeBlock.Type; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.Iterate; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -48,8 +48,8 @@ public class GaugeRenderer extends KineticTileEntityRenderer { PartialModel partialModel = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS); SuperByteBuffer headBuffer = - CachedBufferer.partial(partialModel, gaugeState); - SuperByteBuffer dialBuffer = CachedBufferer.partial(AllBlockPartials.GAUGE_DIAL, gaugeState); + CachedPartialBuffers.partial(partialModel, gaugeState); + SuperByteBuffer dialBuffer = CachedPartialBuffers.partial(AllBlockPartials.GAUGE_DIAL, gaugeState); float dialPivot = 5.75f / 16; float progress = Mth.lerp(partialTicks, gaugeTE.prevDialState, gaugeTE.dialState); 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 d5babb04e..0ef72e4d4 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 @@ -5,9 +5,9 @@ import com.mojang.blaze3d.vertex.PoseStack; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.Iterate; import net.createmod.ponder.utility.WorldTickHolder; import net.minecraft.client.renderer.MultiBufferSource; @@ -38,7 +38,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer { if (boxAxis == axis) continue; - SuperByteBuffer shaft = CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction); + SuperByteBuffer shaft = CachedPartialBuffers.partialFacing(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/contraptions/wrench/WrenchItemRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java index f6ab1c9e0..ef305f117 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/wrench/WrenchItemRenderer.java @@ -5,8 +5,8 @@ import com.mojang.math.Vector3f; import com.simibubi.create.foundation.item.render.CustomRenderedItemModelRenderer; import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueHandler; -import net.createmod.catnip.utility.AnimationTickHolder; +import net.createmod.catnip.utility.AnimationTickHolder; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.resources.model.BakedModel; diff --git a/src/main/java/com/simibubi/create/content/curiosities/NoGravMagicalDohickyItem.java b/src/main/java/com/simibubi/create/content/curiosities/NoGravMagicalDohickyItem.java index 6224a431e..6bdae263f 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/NoGravMagicalDohickyItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/NoGravMagicalDohickyItem.java @@ -1,7 +1,6 @@ package com.simibubi.create.content.curiosities; import net.createmod.catnip.utility.VecHelper; - import net.minecraft.core.NonNullList; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java index 58201e55a..1253dd535 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java @@ -4,15 +4,15 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllItems; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; + import net.createmod.catnip.gui.element.GuiGameElement; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import net.createmod.catnip.render.CachedBlockBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.math.AngleHelper; - -import net.createmod.ponder.utility.WorldTickHolder; - import net.createmod.catnip.utility.theme.Color; - +import net.createmod.ponder.utility.WorldTickHolder; import net.minecraft.client.Minecraft; import net.minecraft.client.model.EntityModel; import net.minecraft.client.model.HumanoidModel; @@ -63,8 +63,8 @@ public class CopperBacktankArmorLayer flwBuffer + .forEntityRender() + .light(light) + .renderInto(ms, buffer.getBuffer(renderType)) + ); - cogs.centre() - .rotateY(180) - .unCentre() - .translate(0, 6.5f / 16, 11f / 16) - .rotate(Direction.EAST, AngleHelper.rad(2 * WorldTickHolder.getRenderTime(entity.level) % 360)) - .translate(0, -6.5f / 16, -11f / 16); + FlwSuperByteBuffer.cast(cogs).ifPresent(flwBuffer -> flwBuffer + .centre() + .rotateY(180) + .unCentre() + .translate(0, 6.5f / 16, 11f / 16) + .rotate(Direction.EAST, AngleHelper.rad(2 * WorldTickHolder.getRenderTime(entity.level) % 360)) + .translate(0, -6.5f / 16, -11f / 16) + .forEntityRender() + ); - cogs.forEntityRender() - .light(light) - .renderInto(ms, buffer.getBuffer(renderType)); + cogs.light(light).renderInto(ms, buffer.getBuffer(renderType)); ms.popPose(); } diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankRenderer.java index cdebfcb14..c4df6f90c 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankRenderer.java @@ -4,16 +4,16 @@ import com.mojang.blaze3d.vertex.PoseStack; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; + +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.math.AngleHelper; - import net.createmod.ponder.utility.WorldTickHolder; - import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.core.Direction; +import net.minecraft.util.Mth; import net.minecraft.world.level.block.state.BlockState; public class CopperBacktankRenderer extends KineticTileEntityRenderer { @@ -28,10 +28,8 @@ public class CopperBacktankRenderer extends KineticTileEntityRenderer { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); BlockState blockState = te.getBlockState(); - SuperByteBuffer cogs = CachedBufferer.partial(AllBlockPartials.COPPER_BACKTANK_COGS, blockState); - cogs.centre() - .rotateY(180 + AngleHelper.horizontalAngle(blockState.getValue(CopperBacktankBlock.HORIZONTAL_FACING))) - .unCentre() + SuperByteBuffer cogs = CachedPartialBuffers.partial(AllBlockPartials.COPPER_BACKTANK_COGS, blockState); + cogs.rotateCentered(Direction.Axis.Y, Mth.DEG_TO_RAD * (180 + AngleHelper.horizontalAngle(blockState.getValue(CopperBacktankBlock.HORIZONTAL_FACING)))) .translate(0, 6.5f / 16, 11f / 16) .rotate(Direction.EAST, AngleHelper.rad(te.getSpeed() / 4f * WorldTickHolder.getRenderTime(te.getLevel()) % 360)) @@ -42,7 +40,7 @@ public class CopperBacktankRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) { - return CachedBufferer.partial(AllBlockPartials.COPPER_BACKTANK_SHAFT, state); + return CachedPartialBuffers.partial(AllBlockPartials.COPPER_BACKTANK_SHAFT, state); } } diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankTileEntity.java index ad9133ed1..f24043699 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankTileEntity.java @@ -10,8 +10,8 @@ import com.simibubi.create.content.contraptions.particle.AirParticleData; import com.simibubi.create.foundation.advancement.AllAdvancements; import com.simibubi.create.foundation.tileEntity.ComparatorUtil; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.createmod.catnip.utility.VecHelper; +import net.createmod.catnip.utility.VecHelper; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction.Axis; import net.minecraft.core.particles.ParticleTypes; diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/BellRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/bell/BellRenderer.java index 65476e0b6..0b13b7b9f 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/BellRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/BellRenderer.java @@ -1,11 +1,11 @@ package com.simibubi.create.content.curiosities.bell; import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; -import net.createmod.catnip.utility.math.AngleHelper; +import net.createmod.catnip.render.SuperByteBuffer; +import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -26,7 +26,7 @@ public class BellRenderer extends SafeTileEnt Direction facing = state.getValue(BellBlock.FACING); BellAttachType attachment = state.getValue(BellBlock.ATTACHMENT); - SuperByteBuffer bell = CachedBufferer.partial(te.getBellModel(), state); + SuperByteBuffer bell = CachedPartialBuffers.partial(te.getBellModel(), state); if (te.isRinging) bell.rotateCentered(te.ringDirection.getCounterClockWise(), getSwingAngle(te.ringingTicks + partialTicks)); diff --git a/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffect.java b/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffect.java index e90a1dfa9..bba8951f0 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffect.java +++ b/src/main/java/com/simibubi/create/content/curiosities/bell/SoulPulseEffect.java @@ -7,8 +7,8 @@ import java.util.stream.Stream; import com.google.common.collect.Streams; import com.simibubi.create.content.curiosities.bell.SoulParticle.ExpandingPerimeterData; -import net.createmod.catnip.utility.VecHelper; +import net.createmod.catnip.utility.VecHelper; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.SpawnPlacements; diff --git a/src/main/java/com/simibubi/create/content/curiosities/deco/SlidingDoorMovementBehaviour.java b/src/main/java/com/simibubi/create/content/curiosities/deco/SlidingDoorMovementBehaviour.java index 5ed747f68..ecea33eaf 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/deco/SlidingDoorMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/curiosities/deco/SlidingDoorMovementBehaviour.java @@ -7,8 +7,8 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.logistics.trains.entity.CarriageContraptionEntity; import com.simibubi.create.content.logistics.trains.entity.CarriageSyncData; -import net.createmod.catnip.utility.animation.LerpedFloat.Chaser; +import net.createmod.catnip.utility.animation.LerpedFloat.Chaser; import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; diff --git a/src/main/java/com/simibubi/create/content/curiosities/deco/SlidingDoorRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/deco/SlidingDoorRenderer.java index 0b9ca3d86..8afa39a3b 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/deco/SlidingDoorRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/deco/SlidingDoorRenderer.java @@ -2,9 +2,9 @@ package com.simibubi.create.content.curiosities.deco; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; +import net.createmod.catnip.render.CachedBlockBuffers; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context; @@ -43,10 +43,10 @@ public class SlidingDoorRenderer extends SafeTileEntityRenderer { @@ -28,26 +29,24 @@ public class ToolboxRenderer extends SmartTileEntityRenderer Direction facing = blockState.getValue(ToolboxBlock.FACING) .getOpposite(); SuperByteBuffer lid = - CachedBufferer.partial(AllBlockPartials.TOOLBOX_LIDS.get(tileEntityIn.getColor()), blockState); - SuperByteBuffer drawer = CachedBufferer.partial(AllBlockPartials.TOOLBOX_DRAWER, blockState); + CachedPartialBuffers.partial(AllBlockPartials.TOOLBOX_LIDS.get(tileEntityIn.getColor()), blockState); + SuperByteBuffer drawer = CachedPartialBuffers.partial(AllBlockPartials.TOOLBOX_DRAWER, blockState); float lidAngle = tileEntityIn.lid.getValue(partialTicks); float drawerOffset = tileEntityIn.drawers.getValue(partialTicks); VertexConsumer builder = buffer.getBuffer(RenderType.cutoutMipped()); - lid.centre() - .rotateY(-facing.toYRot()) - .unCentre() + lid + .rotateCentered(Direction.Axis.Y, Mth.DEG_TO_RAD * -facing.toYRot()) .translate(0, 6 / 16f, 12 / 16f) - .rotateX(135 * lidAngle) + .rotate(Direction.Axis.X, Mth.DEG_TO_RAD * (135 * lidAngle)) .translate(0, -6 / 16f, -12 / 16f) .light(light) .renderInto(ms, builder); for (int offset : Iterate.zeroAndOne) { - drawer.centre() - .rotateY(-facing.toYRot()) - .unCentre() + drawer + .rotateCentered(Direction.Axis.Y, Mth.DEG_TO_RAD * -facing.toYRot()) .translate(0, offset * 1 / 8f, -drawerOffset * .175f * (2 - offset)) .light(light) .renderInto(ms, builder); diff --git a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintRenderer.java index 64813303c..d81e93975 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/tools/BlueprintRenderer.java @@ -6,9 +6,10 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Matrix3f; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.curiosities.tools.BlueprintEntity.BlueprintSection; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.Couple; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; @@ -33,16 +34,21 @@ public class BlueprintRenderer extends EntityRenderer { int light) { PartialModel partialModel = entity.size == 3 ? AllBlockPartials.CRAFTING_BLUEPRINT_3x3 : entity.size == 2 ? AllBlockPartials.CRAFTING_BLUEPRINT_2x2 : AllBlockPartials.CRAFTING_BLUEPRINT_1x1; - SuperByteBuffer sbb = CachedBufferer.partial(partialModel, Blocks.AIR.defaultBlockState()); - sbb.rotateY(-yaw) - .rotateX(90.0F + entity.getXRot()) - .translate(-.5, -1 / 32f, -.5); - if (entity.size == 2) - sbb.translate(.5, 0, -.5); + SuperByteBuffer sbb = CachedPartialBuffers.partial(partialModel, Blocks.AIR.defaultBlockState()); + FlwSuperByteBuffer.cast(sbb).ifPresent(flwBuffer -> { + flwBuffer + .rotateY(-yaw) + .rotateX(90.0F + entity.getXRot()) + .translate(-.5, -1 / 32f, -.5); + + if (entity.size == 2) + flwBuffer.translate(.5, 0, -.5); + + flwBuffer.forEntityRender() + .light(light) + .renderInto(ms, buffer.getBuffer(Sheets.solidBlockSheet())); + }); - sbb.forEntityRender() - .light(light) - .renderInto(ms, buffer.getBuffer(Sheets.solidBlockSheet())); super.render(entity, yaw, pt, ms, buffer, light); ms.pushPose(); diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java index f913cdae9..261c9f68f 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/ZapperItem.java @@ -10,9 +10,9 @@ import com.simibubi.create.CreateClient; import com.simibubi.create.foundation.item.ItemDescription; import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.CreateLang; -import net.createmod.catnip.utility.NBTHelper; import com.simibubi.create.foundation.utility.NBTProcessors; +import net.createmod.catnip.utility.NBTHelper; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItemRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItemRenderer.java index c7facd63f..9986edd82 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItemRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperItemRenderer.java @@ -6,8 +6,8 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Vector3f; import com.simibubi.create.content.curiosities.zapper.ZapperItemRenderer; import com.simibubi.create.foundation.item.render.PartialItemModelRenderer; -import net.createmod.catnip.utility.AnimationTickHolder; +import net.createmod.catnip.utility.AnimationTickHolder; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.LightTexture; diff --git a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperScreen.java b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperScreen.java index 51994ec45..3abfc96a5 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperScreen.java +++ b/src/main/java/com/simibubi/create/content/curiosities/zapper/terrainzapper/WorldshaperScreen.java @@ -15,8 +15,8 @@ import com.simibubi.create.foundation.gui.widget.Label; import com.simibubi.create.foundation.gui.widget.ScrollInput; import com.simibubi.create.foundation.gui.widget.SelectionScrollInput; import com.simibubi.create.foundation.utility.CreateLang; -import net.createmod.catnip.utility.NBTHelper; +import net.createmod.catnip.utility.NBTHelper; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtUtils; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java index e8b94dddc..adf1f92b8 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java @@ -5,10 +5,10 @@ import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.Iterate; import net.createmod.catnip.utility.VecHelper; import net.createmod.catnip.utility.math.AngleHelper; @@ -34,7 +34,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer applyLidAngle(te, angle, flwBuffer)); + model.light(light).renderInto(ms, vertexBuilder); } TransformStack msr = TransformStack.cast(ms); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/diodes/BrassDiodeRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/diodes/BrassDiodeRenderer.java index 828a1cf63..adf8983b2 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/diodes/BrassDiodeRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/diodes/BrassDiodeRenderer.java @@ -1,10 +1,10 @@ package com.simibubi.create.content.logistics.block.diodes; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import com.simibubi.create.foundation.tileEntity.renderer.ColoredOverlayTileEntityRenderer; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.theme.Color; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -21,7 +21,7 @@ public class BrassDiodeRenderer extends ColoredOverlayTileEntityRenderer flwBuffer + .light(LightTexture.FULL_BRIGHT) + .color(color, color, color, 255) + .disableDiffuse() + .renderInto(ms, buffer.getBuffer(RenderTypes.getAdditive())) + ); ms.popPose(); } 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 08ac338d5..71b76a77a 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,10 +6,10 @@ import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.VecHelper; import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.client.renderer.MultiBufferSource; @@ -37,7 +37,7 @@ public class FunnelRenderer extends SmartTileEntityRenderer { VertexConsumer vb = buffer.getBuffer(RenderType.solid()); PartialModel partialModel = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP : AllBlockPartials.BELT_FUNNEL_FLAP); - SuperByteBuffer flapBuffer = CachedBufferer.partial(partialModel, blockState); + SuperByteBuffer flapBuffer = CachedPartialBuffers.partial(partialModel, blockState); Vec3 pivot = VecHelper.voxelSpace(0, 10, 9.5f); TransformStack msr = TransformStack.cast(ms); diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java index a7b592082..3e6a10752 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmRenderer.java @@ -8,9 +8,9 @@ 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.content.logistics.block.mechanicalArm.ArmTileEntity.Phase; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.AnimationTickHolder; import net.createmod.catnip.utility.Iterate; import net.createmod.catnip.utility.theme.Color; @@ -113,17 +113,17 @@ public class ArmRenderer extends KineticTileEntityRenderer { private void renderArm(VertexConsumer builder, PoseStack ms, PoseStack msLocal, TransformStack msr, BlockState blockState, int color, float baseAngle, float lowerArmAngle, float upperArmAngle, float headAngle, boolean hasItem, boolean isBlockItem, int light) { - SuperByteBuffer base = CachedBufferer.partial(AllBlockPartials.ARM_BASE, blockState) + SuperByteBuffer base = CachedPartialBuffers.partial(AllBlockPartials.ARM_BASE, blockState) .light(light); - SuperByteBuffer lowerBody = CachedBufferer.partial(AllBlockPartials.ARM_LOWER_BODY, blockState) + SuperByteBuffer lowerBody = CachedPartialBuffers.partial(AllBlockPartials.ARM_LOWER_BODY, blockState) .light(light); - SuperByteBuffer upperBody = CachedBufferer.partial(AllBlockPartials.ARM_UPPER_BODY, blockState) + SuperByteBuffer upperBody = CachedPartialBuffers.partial(AllBlockPartials.ARM_UPPER_BODY, blockState) .light(light); - SuperByteBuffer head = CachedBufferer.partial(AllBlockPartials.ARM_HEAD, blockState) + SuperByteBuffer head = CachedPartialBuffers.partial(AllBlockPartials.ARM_HEAD, blockState) .light(light); - SuperByteBuffer claw = CachedBufferer.partial(AllBlockPartials.ARM_CLAW_BASE, blockState) + SuperByteBuffer claw = CachedPartialBuffers.partial(AllBlockPartials.ARM_CLAW_BASE, blockState) .light(light); - SuperByteBuffer clawGrip = CachedBufferer.partial(AllBlockPartials.ARM_CLAW_GRIP, blockState); + SuperByteBuffer clawGrip = CachedPartialBuffers.partial(AllBlockPartials.ARM_CLAW_GRIP, blockState); transformBase(msr, baseAngle); base.transform(msLocal) @@ -204,7 +204,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) { - return CachedBufferer.partial(AllBlockPartials.ARM_COG, state); + return CachedPartialBuffers.partial(AllBlockPartials.ARM_COG, state); } } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java index e3f047099..8d7c4d239 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmTileEntity.java @@ -19,14 +19,13 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.INamedIconOptions; import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollOptionBehaviour; - -import net.createmod.catnip.utility.lang.Lang; -import net.createmod.catnip.utility.math.AngleHelper; import com.simibubi.create.foundation.utility.CreateLang; + import net.createmod.catnip.utility.NBTHelper; import net.createmod.catnip.utility.VecHelper; import net.createmod.catnip.utility.animation.LerpedFloat; - +import net.createmod.catnip.utility.lang.Lang; +import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java index f8bfb13b4..a3c7c8338 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/AnalogLeverRenderer.java @@ -4,10 +4,10 @@ import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.math.AngleHelper; import net.createmod.catnip.utility.theme.Color; import net.minecraft.client.renderer.MultiBufferSource; @@ -34,7 +34,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer flwBuffer + .light(0xf000f0) + .disableDiffuse() + .scale(vert ? longSide : 1, vert ? 1 : longSide, 1) + .renderInto(ms, buffer.getBuffer(RenderType.translucent())) + ); - CachedBufferer + FlwSuperByteBuffer.cast(CachedPartialBuffers .partial( first ? AllBlockPartials.SIGNAL_RED_GLOW : yellow ? AllBlockPartials.SIGNAL_YELLOW_GLOW : AllBlockPartials.SIGNAL_WHITE_GLOW, - blockState) - .light(0xf000f0) - .disableDiffuse() - .scale(vert ? longSideGlow : 2, vert ? 2 : longSideGlow, 2) - .renderInto(ms, buffer.getBuffer(RenderTypes.getAdditive())); + blockState)).ifPresent(flwBuffer -> flwBuffer + .light(0xf000f0) + .disableDiffuse() + .scale(vert ? longSideGlow : 2, vert ? 2 : longSideGlow, 2) + .renderInto(ms, buffer.getBuffer(RenderTypes.getAdditive())) + ); } - CachedBufferer + FlwSuperByteBuffer.cast(CachedPartialBuffers .partial(first ? AllBlockPartials.SIGNAL_RED - : yellow ? AllBlockPartials.SIGNAL_YELLOW : AllBlockPartials.SIGNAL_WHITE, blockState) - .light(0xF000F0) - .disableDiffuse() - .scale(1 + 1 / 16f) - .renderInto(ms, buffer.getBuffer(RenderTypes.getAdditive())); + : yellow ? AllBlockPartials.SIGNAL_YELLOW : AllBlockPartials.SIGNAL_WHITE, blockState)) + .ifPresent(flwBuffer -> flwBuffer + .light(0xF000F0) + .disableDiffuse() + .scale(1 + 1 / 16f) + .renderInto(ms, buffer.getBuffer(RenderTypes.getAdditive())) + ); ms.popPose(); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeTileEntity.java index 28099269a..563b6edaa 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/redstone/NixieTubeTileEntity.java @@ -9,9 +9,9 @@ import com.simibubi.create.content.logistics.trains.management.edgePoint.signal. import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalTileEntity.SignalState; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.createmod.catnip.utility.Couple; import com.simibubi.create.foundation.utility.DynamicComponent; +import net.createmod.catnip.utility.Couple; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java index 1f7fa4db2..43c390c76 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java @@ -4,8 +4,8 @@ import java.util.ArrayList; import java.util.List; import com.simibubi.create.AllContainerTypes; -import net.createmod.catnip.utility.Pair; +import net.createmod.catnip.utility.Pair; import net.minecraft.ChatFormatting; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterScreen.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterScreen.java index 394721315..6e0006dbc 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterScreen.java @@ -16,8 +16,8 @@ import com.simibubi.create.foundation.gui.widget.Label; import com.simibubi.create.foundation.gui.widget.SelectionScrollInput; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.CreateLang; -import net.createmod.catnip.utility.Pair; +import net.createmod.catnip.utility.Pair; import net.minecraft.ChatFormatting; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/ArrivalSoundQueue.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/ArrivalSoundQueue.java index 2c3400ce3..b8da7d418 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/ArrivalSoundQueue.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/ArrivalSoundQueue.java @@ -12,9 +12,9 @@ import com.simibubi.create.AllSoundEvents; import com.simibubi.create.content.contraptions.components.steam.whistle.WhistleBlock; import com.simibubi.create.content.contraptions.components.steam.whistle.WhistleBlock.WhistleSize; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; + import net.createmod.catnip.utility.NBTHelper; import net.createmod.catnip.utility.Pair; - import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtUtils; diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageCouplingRenderer.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageCouplingRenderer.java index 47a4bd0d6..322d0239a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageCouplingRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageCouplingRenderer.java @@ -7,7 +7,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.CreateClient; -import com.simibubi.create.foundation.render.CachedBufferer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import net.createmod.catnip.utility.AnimationTickHolder; import net.createmod.catnip.utility.math.AngleHelper; @@ -16,6 +16,7 @@ import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; @@ -74,9 +75,9 @@ public class CarriageCouplingRenderer { ms.pushPose(); ms.pushPose(); ms.translate(anchor.x, anchor.y, anchor.z); - CachedBufferer.partial(AllBlockPartials.TRAIN_COUPLING_HEAD, air) - .rotateY(-yRot) - .rotateX(xRot) + CachedPartialBuffers.partial(AllBlockPartials.TRAIN_COUPLING_HEAD, air) + .rotate(Direction.Axis.Y, Mth.DEG_TO_RAD * -yRot) + .rotate(Direction.Axis.X, Mth.DEG_TO_RAD * xRot) .light(lightCoords) .renderInto(ms, vb); @@ -86,9 +87,9 @@ public class CarriageCouplingRenderer { int couplingSegments = (int) Math.round(couplingDistance * 4); double stretch = ((anchor2.distanceTo(anchor) - 2 * margin) * 4) / couplingSegments; for (int j = 0; j < couplingSegments; j++) { - CachedBufferer.partial(AllBlockPartials.TRAIN_COUPLING_CABLE, air) - .rotateY(-yRot + 180) - .rotateX(-xRot) + CachedPartialBuffers.partial(AllBlockPartials.TRAIN_COUPLING_CABLE, air) + .rotate(Direction.Axis.Y, Mth.DEG_TO_RAD * (-yRot + 180)) + .rotate(Direction.Axis.X, Mth.DEG_TO_RAD * -xRot) .translate(0, 0, margin + 2 / 16f) .scale(1, 1, (float) stretch) .translate(0, 0, j / 4f) @@ -102,9 +103,9 @@ public class CarriageCouplingRenderer { ms.translate(-position.x, -position.y, -position.z); ms.translate(position2.x, position2.y, position2.z); ms.translate(anchor2.x, anchor2.y, anchor2.z); - CachedBufferer.partial(AllBlockPartials.TRAIN_COUPLING_HEAD, air) - .rotateY(-yRot + 180) - .rotateX(-xRot) + CachedPartialBuffers.partial(AllBlockPartials.TRAIN_COUPLING_HEAD, air) + .rotate(Direction.Axis.Y, Mth.DEG_TO_RAD * (-yRot + 180)) + .rotate(Direction.Axis.X, Mth.DEG_TO_RAD * -xRot) .light(lightCoords2) .renderInto(ms, vb); ms.popPose(); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/Navigation.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/Navigation.java index 73090dbcd..55b20a67f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/Navigation.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/Navigation.java @@ -31,11 +31,11 @@ import com.simibubi.create.content.logistics.trains.management.edgePoint.signal. import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalEdgeGroup; import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.TrackEdgePoint; import com.simibubi.create.content.logistics.trains.management.edgePoint.station.GlobalStation; + import net.createmod.catnip.utility.Couple; import net.createmod.catnip.utility.Iterate; import net.createmod.catnip.utility.NBTHelper; import net.createmod.catnip.utility.Pair; - import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; import net.minecraft.util.Mth; diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/display/FlapDisplayRenderer.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/display/FlapDisplayRenderer.java index 675a7eb9d..aeaeb4681 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/display/FlapDisplayRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/display/FlapDisplayRenderer.java @@ -11,9 +11,9 @@ import com.mojang.math.Matrix4f; 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.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.SuperByteBuffer; import net.createmod.catnip.utility.math.AngleHelper; import net.createmod.ponder.utility.WorldTickHolder; import net.minecraft.client.Minecraft; @@ -232,7 +232,7 @@ public class FlapDisplayRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te, BlockState state) { - return CachedBufferer.partialFacingVertical(AllBlockPartials.SHAFTLESS_COGWHEEL, state, + return CachedPartialBuffers.partialFacingVertical(AllBlockPartials.SHAFTLESS_COGWHEEL, state, state.getValue(FlapDisplayBlock.HORIZONTAL_FACING)); } diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/TrackTargetingBehaviour.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/TrackTargetingBehaviour.java index 75df6c09c..240a8eded 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/TrackTargetingBehaviour.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/TrackTargetingBehaviour.java @@ -21,7 +21,7 @@ import com.simibubi.create.content.logistics.trains.management.edgePoint.signal. import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.TrackEdgePoint; import com.simibubi.create.content.logistics.trains.track.BezierTrackPointLocation; import com.simibubi.create.content.logistics.trains.track.TrackTileEntity; -import com.simibubi.create.foundation.render.CachedBufferer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; @@ -327,7 +327,7 @@ public class TrackTargetingBehaviour extends TileEntit ITrackBlock track = (ITrackBlock) block; PartialModel partial = track.prepareTrackOverlay(level, pos, trackState, bezier, direction, ms, type); if (partial != null) - CachedBufferer.partial(partial, trackState) + CachedPartialBuffers.partial(partial, trackState) .translate(.5, 0, .5) .scale(scale) .translate(-.5, 0, -.5) diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalEdgeGroup.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalEdgeGroup.java index f2828d817..8f1e04e0d 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalEdgeGroup.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalEdgeGroup.java @@ -13,8 +13,8 @@ import org.apache.commons.lang3.mutable.MutableInt; import com.google.common.base.Predicates; import com.simibubi.create.Create; import com.simibubi.create.content.logistics.trains.entity.Train; -import net.createmod.catnip.utility.NBTHelper; +import net.createmod.catnip.utility.NBTHelper; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalPropagator.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalPropagator.java index f1581b665..a05c14f18 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalPropagator.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalPropagator.java @@ -20,6 +20,7 @@ import com.simibubi.create.content.logistics.trains.TrackNodeLocation; import com.simibubi.create.content.logistics.trains.entity.Train; import com.simibubi.create.content.logistics.trains.management.edgePoint.EdgeData; import com.simibubi.create.content.logistics.trains.management.edgePoint.EdgePointType; + import net.createmod.catnip.utility.Couple; import net.createmod.catnip.utility.Iterate; import net.createmod.catnip.utility.Pair; diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalRenderer.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalRenderer.java index 506ec06b9..1145d93c5 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalRenderer.java @@ -7,10 +7,10 @@ import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTa import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour.RenderedTrackOverlayType; import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalTileEntity.OverlayState; import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalTileEntity.SignalState; -import com.simibubi.create.foundation.render.CachedBufferer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; -import net.createmod.ponder.utility.WorldTickHolder; +import net.createmod.ponder.utility.WorldTickHolder; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -32,10 +32,10 @@ public class SignalRenderer extends SafeTileEntityRenderer { float renderTime = WorldTickHolder.getRenderTime(te.getLevel()); if (signalState.isRedLight(renderTime)) - CachedBufferer.partial(AllBlockPartials.SIGNAL_ON, blockState) + CachedPartialBuffers.partial(AllBlockPartials.SIGNAL_ON, blockState) .renderInto(ms, buffer.getBuffer(RenderType.solid())); else - CachedBufferer.partial(AllBlockPartials.SIGNAL_OFF, blockState) + CachedPartialBuffers.partial(AllBlockPartials.SIGNAL_OFF, blockState) .light(light) .renderInto(ms, buffer.getBuffer(RenderType.solid())); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalTileEntity.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalTileEntity.java index 3910a3389..42f9d7925 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalTileEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/signal/SignalTileEntity.java @@ -11,8 +11,8 @@ import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTa import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalBlock.SignalType; import com.simibubi.create.foundation.tileEntity.SmartTileEntity; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; -import net.createmod.catnip.utility.NBTHelper; +import net.createmod.catnip.utility.NBTHelper; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.entity.BlockEntityType; diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationRenderer.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationRenderer.java index e71fdf1ed..359842271 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/edgePoint/station/StationRenderer.java @@ -9,10 +9,11 @@ import com.simibubi.create.content.logistics.block.depot.DepotRenderer; import com.simibubi.create.content.logistics.trains.ITrackBlock; import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour; import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour.RenderedTrackOverlayType; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; +import net.createmod.catnip.render.SuperByteBuffer; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -48,7 +49,7 @@ public class StationRenderer extends SafeTileEntityRenderer { GlobalStation station = te.getStation(); boolean isAssembling = te.getBlockState() .getValue(StationBlock.ASSEMBLING); - + if (!isAssembling || (station == null || station.getPresentTrain() != null) && !te.isVirtual()) { renderFlag( te.flag.getValue(partialTicks) > 0.75f ? AllBlockPartials.STATION_ON : AllBlockPartials.STATION_OFF, te, @@ -68,7 +69,7 @@ public class StationRenderer extends SafeTileEntityRenderer { if (te.isVirtual() && te.bogeyLocations == null) te.refreshAssemblyInfo(); - + if (direction == null || te.assemblyLength == 0 || te.bogeyLocations == null) return; @@ -97,7 +98,7 @@ public class StationRenderer extends SafeTileEntityRenderer { if (valid != -1) { int lightColor = LevelRenderer.getLightColor(level, currentPos); - SuperByteBuffer sbb = CachedBufferer.partial(assemblyOverlay, trackState); + SuperByteBuffer sbb = CachedPartialBuffers.partial(assemblyOverlay, trackState); sbb.color(valid); sbb.light(lightColor); sbb.renderInto(ms, vb); @@ -113,13 +114,15 @@ public class StationRenderer extends SafeTileEntityRenderer { MultiBufferSource buffer, int light, int overlay) { if (!te.resolveFlagAngle()) return; - SuperByteBuffer flagBB = CachedBufferer.partial(flag, te.getBlockState()); - transformFlag(flagBB, te, partialTicks, te.flagYRot, te.flagFlipped); - flagBB.translate(0.5f / 16, 0, 0) - .rotateY(te.flagFlipped ? 0 : 180) - .translate(-0.5f / 16, 0, 0) - .light(light) - .renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped())); + SuperByteBuffer flagBB = CachedPartialBuffers.partial(flag, te.getBlockState()); + FlwSuperByteBuffer.cast(flagBB).ifPresent(flwBuffer -> { + transformFlag(flwBuffer, te, partialTicks, te.flagYRot, te.flagFlipped); + flwBuffer.translate(0.5f / 16, 0, 0) + .rotateY(te.flagFlipped ? 0 : 180) + .translate(-0.5f / 16, 0, 0); + }); + + flagBB.light(light).renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped())); } public static void transformFlag(Transform flag, StationTileEntity te, float partialTicks, int yRot, diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/TrainHatArmorLayer.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/TrainHatArmorLayer.java index 0f64e7599..09ea45961 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/TrainHatArmorLayer.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/TrainHatArmorLayer.java @@ -7,7 +7,8 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con import com.simibubi.create.content.logistics.trains.entity.CarriageContraption; import com.simibubi.create.content.logistics.trains.entity.CarriageContraptionEntity; import com.simibubi.create.foundation.mixin.accessor.AgeableListModelAccessor; -import com.simibubi.create.foundation.render.CachedBufferer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; import net.createmod.catnip.utility.Couple; import net.minecraft.client.model.AgeableListModel; @@ -113,10 +114,11 @@ public class TrainHatArmorLayer ms.translate(0, -2.25f / 16f, 0); msr.rotateX(-8.5f); BlockState air = Blocks.AIR.defaultBlockState(); - CachedBufferer.partial(AllBlockPartials.TRAIN_HAT, air) + FlwSuperByteBuffer.cast(CachedPartialBuffers.partial(AllBlockPartials.TRAIN_HAT, air)).ifPresent(sbb -> sbb .forEntityRender() .light(light) - .renderInto(ms, buffer.getBuffer(renderType)); + .renderInto(ms, buffer.getBuffer(renderType)) + ); } ms.popPose(); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/track/StandardBogeyBlock.java b/src/main/java/com/simibubi/create/content/logistics/trains/track/StandardBogeyBlock.java index 1b7a571ca..9452a1d67 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/track/StandardBogeyBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/track/StandardBogeyBlock.java @@ -18,8 +18,9 @@ import com.simibubi.create.content.schematics.ItemRequirement; import com.simibubi.create.content.schematics.ItemRequirement.ItemUseType; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.block.ProperWaterloggedBlock; -import com.simibubi.create.foundation.render.CachedBufferer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import net.createmod.catnip.render.CachedBlockBuffers; import net.createmod.catnip.utility.Iterate; import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.client.renderer.MultiBufferSource; @@ -27,6 +28,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; +import net.minecraft.util.Mth; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; @@ -132,12 +134,10 @@ public class StandardBogeyBlock extends Block BlockState air = Blocks.AIR.defaultBlockState(); for (int i : Iterate.zeroAndOne) - CachedBufferer.block(AllBlocks.SHAFT.getDefaultState() + CachedBlockBuffers.block(AllBlocks.SHAFT.getDefaultState() .setValue(ShaftBlock.AXIS, Axis.Z)) .translate(-.5f, .25f, i * -1) - .centre() - .rotateZ(wheelAngle) - .unCentre() + .rotateCentered(Axis.Z, Mth.DEG_TO_RAD * wheelAngle) .light(light) .renderInto(ms, vb); @@ -149,16 +149,16 @@ public class StandardBogeyBlock extends Block } private void renderBogey(float wheelAngle, PoseStack ms, int light, VertexConsumer vb, BlockState air) { - CachedBufferer.partial(AllBlockPartials.BOGEY_FRAME, air) + CachedPartialBuffers.partial(AllBlockPartials.BOGEY_FRAME, air) .scale(1 - 1 / 512f) .light(light) .renderInto(ms, vb); for (int side : Iterate.positiveAndNegative) { ms.pushPose(); - CachedBufferer.partial(AllBlockPartials.SMALL_BOGEY_WHEELS, air) + CachedPartialBuffers.partial(AllBlockPartials.SMALL_BOGEY_WHEELS, air) .translate(0, 12 / 16f, side) - .rotateX(wheelAngle) + .rotate(Axis.X, Mth.DEG_TO_RAD * wheelAngle) .light(light) .renderInto(ms, vb); ms.popPose(); @@ -167,35 +167,33 @@ public class StandardBogeyBlock extends Block private void renderLargeBogey(float wheelAngle, PoseStack ms, int light, VertexConsumer vb, BlockState air) { for (int i : Iterate.zeroAndOne) - CachedBufferer.block(AllBlocks.SHAFT.getDefaultState() + CachedBlockBuffers.block(AllBlocks.SHAFT.getDefaultState() .setValue(ShaftBlock.AXIS, Axis.X)) .translate(-.5f, .25f, .5f + i * -2) - .centre() - .rotateX(wheelAngle) - .unCentre() + .rotateCentered(Axis.X, Mth.DEG_TO_RAD * wheelAngle) .light(light) .renderInto(ms, vb); - CachedBufferer.partial(AllBlockPartials.BOGEY_DRIVE, air) + CachedPartialBuffers.partial(AllBlockPartials.BOGEY_DRIVE, air) .scale(1 - 1 / 512f) .light(light) .renderInto(ms, vb); - CachedBufferer.partial(AllBlockPartials.BOGEY_PISTON, air) + CachedPartialBuffers.partial(AllBlockPartials.BOGEY_PISTON, air) .translate(0, 0, 1 / 4f * Math.sin(AngleHelper.rad(wheelAngle))) .light(light) .renderInto(ms, vb); ms.pushPose(); - CachedBufferer.partial(AllBlockPartials.LARGE_BOGEY_WHEELS, air) + CachedPartialBuffers.partial(AllBlockPartials.LARGE_BOGEY_WHEELS, air) .translate(0, 1, 0) - .rotateX(wheelAngle) + .rotate(Axis.X, Mth.DEG_TO_RAD * wheelAngle) .light(light) .renderInto(ms, vb); - CachedBufferer.partial(AllBlockPartials.BOGEY_PIN, air) + CachedPartialBuffers.partial(AllBlockPartials.BOGEY_PIN, air) .translate(0, 1, 0) - .rotateX(wheelAngle) + .rotate(Axis.X, Mth.DEG_TO_RAD * wheelAngle) .translate(0, 1 / 4f, 0) - .rotateX(-wheelAngle) + .rotate(Axis.X, Mth.DEG_TO_RAD * -wheelAngle) .light(light) .renderInto(ms, vb); ms.popPose(); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackRenderer.java b/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackRenderer.java index bbe999bc5..771c100cc 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/track/TrackRenderer.java @@ -15,7 +15,8 @@ import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.content.logistics.trains.BezierConnection; import com.simibubi.create.content.logistics.trains.BezierConnection.GirderAngles; import com.simibubi.create.content.logistics.trains.BezierConnection.SegmentAngles; -import com.simibubi.create.foundation.render.CachedBufferer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; +import com.simibubi.create.foundation.render.FlwSuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import net.createmod.catnip.utility.Iterate; @@ -66,19 +67,20 @@ public class TrackRenderer extends SafeTileEntityRenderer { SegmentAngles segment = segments[i]; int light = LevelRenderer.getLightColor(level, segment.lightPosition.offset(tePosition)); - CachedBufferer.partial(TRACK_TIE, air) + FlwSuperByteBuffer.cast(CachedPartialBuffers.partial(TRACK_TIE, air)).ifPresent(sbb -> sbb .mulPose(segment.tieTransform.pose()) .mulNormal(segment.tieTransform.normal()) .light(light) - .renderInto(ms, vb); + .renderInto(ms, vb) + ); for (boolean first : Iterate.trueAndFalse) { Pose transform = segment.railTransforms.get(first); - CachedBufferer.partial(first ? TRACK_SEGMENT_LEFT : TRACK_SEGMENT_RIGHT, air) - .mulPose(transform.pose()) + FlwSuperByteBuffer.cast(CachedPartialBuffers.partial(first ? TRACK_SEGMENT_LEFT : TRACK_SEGMENT_RIGHT, air)).ifPresent(sbb -> sbb .mulPose(transform.pose()) .mulNormal(transform.normal()) .light(light) - .renderInto(ms, vb); + .renderInto(ms, vb) + ); } } @@ -99,20 +101,22 @@ public class TrackRenderer extends SafeTileEntityRenderer { for (boolean first : Iterate.trueAndFalse) { Pose beamTransform = segment.beams.get(first); - CachedBufferer.partial(GIRDER_SEGMENT_MIDDLE, air) + FlwSuperByteBuffer.cast(CachedPartialBuffers.partial(GIRDER_SEGMENT_MIDDLE, air)).ifPresent(sbb -> sbb .mulPose(beamTransform.pose()) .mulNormal(beamTransform.normal()) .light(light) - .renderInto(ms, vb); + .renderInto(ms, vb) + ); for (boolean top : Iterate.trueAndFalse) { Pose beamCapTransform = segment.beamCaps.get(top) .get(first); - CachedBufferer.partial(top ? GIRDER_SEGMENT_TOP : GIRDER_SEGMENT_BOTTOM, air) + FlwSuperByteBuffer.cast(CachedPartialBuffers.partial(top ? GIRDER_SEGMENT_TOP : GIRDER_SEGMENT_BOTTOM, air)).ifPresent(sbb -> sbb .mulPose(beamCapTransform.pose()) .mulNormal(beamCapTransform.normal()) .light(light) - .renderInto(ms, vb); + .renderInto(ms, vb) + ); } } } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java index f41be9754..ae7bf5bd4 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java @@ -12,10 +12,10 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.content.schematics.block.LaunchedItem.ForBelt; import com.simibubi.create.content.schematics.block.LaunchedItem.ForBlockState; import com.simibubi.create.content.schematics.block.LaunchedItem.ForEntity; -import com.simibubi.create.foundation.render.CachedBufferer; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.CachedPartialBuffers; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; +import net.createmod.catnip.render.SuperByteBuffer; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -57,14 +57,14 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer ENTRY_CACHE = new HashMap<>(); + //private static final Map ENTRY_CACHE = new HashMap<>(); public static CTSpriteShiftEntry getCT(CTType type, ResourceLocation blockTexture, ResourceLocation connectedTexture) { String key = blockTexture + "->" + connectedTexture + "+" + type.getId(); if (ENTRY_CACHE.containsKey(key)) return (CTSpriteShiftEntry) ENTRY_CACHE.get(key); - CTSpriteShiftEntry entry = new CTSpriteShiftEntry(type); - entry.set(blockTexture, connectedTexture); + CTSpriteShiftEntry entry = new CTSpriteShiftEntry(type, blockTexture, connectedTexture); ENTRY_CACHE.put(key, entry); return entry; } diff --git a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java deleted file mode 100644 index 537ff9d68..000000000 --- a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShiftEntry.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.simibubi.create.foundation.block.render; - -import com.jozufozu.flywheel.core.StitchedSprite; - -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.resources.ResourceLocation; - -public class SpriteShiftEntry { - protected StitchedSprite original; - protected StitchedSprite target; - - public void set(ResourceLocation originalTextureLocation, ResourceLocation targetTextureLocation) { - original = new StitchedSprite(originalTextureLocation); - target = new StitchedSprite(targetTextureLocation); - } - - public ResourceLocation getOriginalResourceLocation() { - return original.getLocation(); - } - - public ResourceLocation getTargetResourceLocation() { - return target.getLocation(); - } - - public TextureAtlasSprite getOriginal() { - return original.get(); - } - - public TextureAtlasSprite getTarget() { - return target.get(); - } - - public float getTargetU(float localU) { - return getTarget().getU(getUnInterpolatedU(getOriginal(), localU)); - } - - public float getTargetV(float localV) { - return getTarget().getV(getUnInterpolatedV(getOriginal(), localV)); - } - - public static float getUnInterpolatedU(TextureAtlasSprite sprite, float u) { - float f = sprite.getU1() - sprite.getU0(); - return (u - sprite.getU0()) / f * 16.0F; - } - - public static float getUnInterpolatedV(TextureAtlasSprite sprite, float v) { - float f = sprite.getV1() - sprite.getV0(); - return (v - sprite.getV0()) / f * 16.0F; - } -} diff --git a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java b/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java deleted file mode 100644 index 0b97d60b7..000000000 --- a/src/main/java/com/simibubi/create/foundation/block/render/SpriteShifter.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.simibubi.create.foundation.block.render; - -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.resources.ResourceLocation; - -public class SpriteShifter { - - private static final Map ENTRY_CACHE = new HashMap<>(); - - public static SpriteShiftEntry get(ResourceLocation originalLocation, ResourceLocation targetLocation) { - String key = originalLocation + "->" + targetLocation; - if (ENTRY_CACHE.containsKey(key)) - return ENTRY_CACHE.get(key); - - SpriteShiftEntry entry = new SpriteShiftEntry(); - entry.set(originalLocation, targetLocation); - ENTRY_CACHE.put(key, entry); - return entry; - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/command/ClearBufferCacheCommand.java b/src/main/java/com/simibubi/create/foundation/command/ClearBufferCacheCommand.java index 34a47169c..755e5e48a 100644 --- a/src/main/java/com/simibubi/create/foundation/command/ClearBufferCacheCommand.java +++ b/src/main/java/com/simibubi/create/foundation/command/ClearBufferCacheCommand.java @@ -3,6 +3,7 @@ package com.simibubi.create.foundation.command; import com.mojang.brigadier.builder.ArgumentBuilder; import com.simibubi.create.CreateClient; +import net.createmod.catnip.CatnipClient; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.network.chat.TextComponent; @@ -25,6 +26,7 @@ public class ClearBufferCacheCommand { @OnlyIn(Dist.CLIENT) private static void execute() { + CatnipClient.invalidateRenderers(); CreateClient.invalidateRenderers(); } } diff --git a/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java deleted file mode 100644 index aa8300cde..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.simibubi.create.foundation.render; - -import com.jozufozu.flywheel.core.model.ModelUtil; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.PoseStack; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.world.level.block.state.BlockState; - -public class BakedModelRenderHelper { - - public static SuperByteBuffer standardBlockRender(BlockState renderedState) { - BlockRenderDispatcher dispatcher = Minecraft.getInstance() - .getBlockRenderer(); - return standardModelRender(dispatcher.getBlockModel(renderedState), renderedState); - } - - public static SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState) { - return standardModelRender(model, referenceState, new PoseStack()); - } - - public static SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState, PoseStack ms) { - BufferBuilder builder = ModelUtil.getBufferBuilder(model, referenceState, ms); - return new SuperByteBuffer(builder); - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/render/CachedBufferer.java b/src/main/java/com/simibubi/create/foundation/render/CachedPartialBuffers.java similarity index 69% rename from src/main/java/com/simibubi/create/foundation/render/CachedBufferer.java rename to src/main/java/com/simibubi/create/foundation/render/CachedPartialBuffers.java index de205a5f6..248925090 100644 --- a/src/main/java/com/simibubi/create/foundation/render/CachedBufferer.java +++ b/src/main/java/com/simibubi/create/foundation/render/CachedPartialBuffers.java @@ -9,36 +9,28 @@ import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.util.transform.TransformStack; import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.CreateClient; -import com.simibubi.create.foundation.render.SuperByteBufferCache.Compartment; +import net.createmod.catnip.render.SuperBufferFactory; +import net.createmod.catnip.render.SuperByteBuffer; +import net.createmod.catnip.render.SuperByteBufferCache; +import net.createmod.catnip.render.SuperByteBufferCache.Compartment; import net.createmod.catnip.utility.math.AngleHelper; import net.minecraft.core.Direction; import net.minecraft.world.level.block.state.BlockState; -public class CachedBufferer { - - public static final Compartment GENERIC_TILE = new Compartment<>(); +public class CachedPartialBuffers { public static final Compartment PARTIAL = new Compartment<>(); public static final Compartment> DIRECTIONAL_PARTIAL = new Compartment<>(); - public static SuperByteBuffer block(BlockState toRender) { - return block(GENERIC_TILE, toRender); - } - - public static SuperByteBuffer block(Compartment compartment, BlockState toRender) { - return CreateClient.BUFFER_CACHE.get(compartment, toRender, () -> BakedModelRenderHelper.standardBlockRender(toRender)); - } - public static SuperByteBuffer partial(PartialModel partial, BlockState referenceState) { - return CreateClient.BUFFER_CACHE.get(PARTIAL, partial, - () -> BakedModelRenderHelper.standardModelRender(partial.get(), referenceState)); + return SuperByteBufferCache.getInstance().get(PARTIAL, partial, + () -> SuperBufferFactory.getInstance().createForBlock(partial.get(), referenceState)); } public static SuperByteBuffer partial(PartialModel partial, BlockState referenceState, Supplier modelTransform) { - return CreateClient.BUFFER_CACHE.get(PARTIAL, partial, - () -> BakedModelRenderHelper.standardModelRender(partial.get(), referenceState, modelTransform.get())); + return SuperByteBufferCache.getInstance().get(PARTIAL, partial, + () -> SuperBufferFactory.getInstance().createForBlock(partial.get(), referenceState, modelTransform.get())); } public static SuperByteBuffer partialFacing(PartialModel partial, BlockState referenceState) { @@ -58,8 +50,8 @@ public class CachedBufferer { public static SuperByteBuffer partialDirectional(PartialModel partial, BlockState referenceState, Direction dir, Supplier modelTransform) { - return CreateClient.BUFFER_CACHE.get(DIRECTIONAL_PARTIAL, Pair.of(dir, partial), - () -> BakedModelRenderHelper.standardModelRender(partial.get(), referenceState, modelTransform.get())); + return SuperByteBufferCache.getInstance().get(DIRECTIONAL_PARTIAL, Pair.of(dir, partial), + () -> SuperBufferFactory.getInstance().createForBlock(partial.get(), referenceState, modelTransform.get())); } public static Supplier rotateToFace(Direction facing) { @@ -85,5 +77,4 @@ public class CachedBufferer { return stack; }; } - } diff --git a/src/main/java/com/simibubi/create/foundation/render/FlwSuperBufferFactory.java b/src/main/java/com/simibubi/create/foundation/render/FlwSuperBufferFactory.java new file mode 100644 index 000000000..c7137ff8e --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/FlwSuperBufferFactory.java @@ -0,0 +1,28 @@ +package com.simibubi.create.foundation.render; + +import javax.annotation.ParametersAreNonnullByDefault; + +import com.jozufozu.flywheel.core.model.ModelUtil; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.PoseStack; + +import net.createmod.catnip.render.SuperBufferFactory; +import net.createmod.catnip.render.SuperByteBuffer; +import net.minecraft.MethodsReturnNonnullByDefault; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.world.level.block.state.BlockState; + +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +public class FlwSuperBufferFactory implements SuperBufferFactory { + + @Override + public SuperByteBuffer create(BufferBuilder builder) { + return new FlwSuperByteBuffer(builder); + } + + @Override + public SuperByteBuffer createForBlock(BakedModel model, BlockState referenceState, PoseStack ms) { + return create(ModelUtil.getBufferBuilder(model, referenceState, ms)); + } +} diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java b/src/main/java/com/simibubi/create/foundation/render/FlwSuperByteBuffer.java similarity index 79% rename from src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java rename to src/main/java/com/simibubi/create/foundation/render/FlwSuperByteBuffer.java index 85897cf5a..42dbc27b1 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBuffer.java +++ b/src/main/java/com/simibubi/create/foundation/render/FlwSuperByteBuffer.java @@ -1,7 +1,10 @@ package com.simibubi.create.foundation.render; +import java.util.Optional; import java.util.function.IntPredicate; +import javax.annotation.ParametersAreNonnullByDefault; + import com.jozufozu.flywheel.api.vertex.ShadedVertexList; import com.jozufozu.flywheel.api.vertex.VertexList; import com.jozufozu.flywheel.backend.ShadersModHandler; @@ -18,11 +21,12 @@ import com.mojang.math.Matrix4f; import com.mojang.math.Quaternion; import com.mojang.math.Vector3f; import com.mojang.math.Vector4f; -import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import it.unimi.dsi.fastutil.longs.Long2IntMap; import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; -import net.createmod.catnip.utility.theme.Color; +import net.createmod.catnip.render.SpriteShiftEntry; +import net.createmod.catnip.render.SuperByteBuffer; +import net.minecraft.MethodsReturnNonnullByDefault; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LightTexture; @@ -32,7 +36,10 @@ import net.minecraft.core.Direction; import net.minecraft.util.Mth; import net.minecraft.world.level.Level; -public class SuperByteBuffer implements Transform, TStack { +@SuppressWarnings("unchecked") +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault +public class FlwSuperByteBuffer implements Transform, TStack, SuperByteBuffer { private final VertexList template; private final IntPredicate shadedPredicate; @@ -66,7 +73,7 @@ public class SuperByteBuffer implements Transform, TStack, TStack, TStack, TStack, TStack, TStack> 16) & 0xFF); g = ((color >> 8) & 0xFF); @@ -328,37 +352,27 @@ public class SuperByteBuffer implements Transform, TStack { - builder.uv(entry.getTargetU(u), entry.getTargetV(v)); - }; + public FlwSuperByteBuffer shiftUV(SpriteShiftEntry entry) { + this.spriteShiftFunc = (builder, u, v) -> builder.uv(entry.getTargetU(u), entry.getTargetV(v)); return this; } - public SuperByteBuffer shiftUVScrolling(SpriteShiftEntry entry, float scrollV) { - return this.shiftUVScrolling(entry, 0, scrollV); - } - - public SuperByteBuffer shiftUVScrolling(SpriteShiftEntry entry, float scrollU, float scrollV) { + public FlwSuperByteBuffer shiftUVScrolling(SpriteShiftEntry entry, float scrollU, float scrollV) { this.spriteShiftFunc = (builder, u, v) -> { float targetU = u - entry.getOriginal() .getU0() + entry.getTarget() @@ -373,7 +387,7 @@ public class SuperByteBuffer implements Transform, TStack { float targetU = entry.getTarget() .getU((SpriteShiftEntry.getUnInterpolatedU(entry.getOriginal(), u) / sheetSize) + uTarget * 16); @@ -384,46 +398,40 @@ public class SuperByteBuffer implements Transform, TStack, TStack cast(SuperByteBuffer buffer) { + if (!(buffer instanceof FlwSuperByteBuffer flwBuffer)) + return Optional.empty(); + + return Optional.of(flwBuffer); + } + public static int transformColor(byte component, float scale) { return Mth.clamp((int) (Byte.toUnsignedInt(component) * scale), 0, 255); } @@ -465,14 +480,4 @@ public class SuperByteBuffer implements Transform, TStack LevelRenderer.getLightColor(world, pos)); } - @FunctionalInterface - public interface SpriteShiftFunc { - void shift(VertexConsumer builder, float u, float v); - } - - @FunctionalInterface - public interface VertexLighter { - int getPackedLight(float x, float y, float z); - } - } diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java deleted file mode 100644 index f11ea9b94..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.simibubi.create.foundation.render; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; - -public class SuperByteBufferCache { - - protected final Map, Cache> caches = new HashMap<>(); - - public synchronized void registerCompartment(Compartment compartment) { - caches.put(compartment, CacheBuilder.newBuilder() - .build()); - } - - public synchronized void registerCompartment(Compartment compartment, long ticksUntilExpired) { - caches.put(compartment, CacheBuilder.newBuilder() - .expireAfterAccess(ticksUntilExpired * 50, TimeUnit.MILLISECONDS) - .build()); - } - - public SuperByteBuffer get(Compartment compartment, T key, Callable callable) { - Cache cache = caches.get(compartment); - if (cache != null) { - try { - return cache.get(key, callable); - } catch (ExecutionException e) { - e.printStackTrace(); - } - } - return null; - } - - public void invalidate(Compartment compartment, T key) { - caches.get(compartment).invalidate(key); - } - - public void invalidate(Compartment compartment) { - caches.get(compartment).invalidateAll(); - } - - public void invalidate() { - caches.forEach((compartment, cache) -> cache.invalidateAll()); - } - - public static class Compartment { - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java index b8d322de4..4484f6434 100644 --- a/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/render/TileEntityRenderHelper.java @@ -107,7 +107,7 @@ public class TileEntityRenderHelper { if (renderWorld != null) { int renderWorldLight = LevelRenderer.getLightColor(renderWorld, renderWorldPos); - return SuperByteBuffer.maxLight(worldLight, renderWorldLight); + return FlwSuperByteBuffer.maxLight(worldLight, renderWorldLight); } return worldLight; diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java index 8ba1894ac..5e9fcc274 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/renderer/ColoredOverlayTileEntityRenderer.java @@ -2,8 +2,8 @@ package com.simibubi.create.foundation.tileEntity.renderer; import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.foundation.render.SuperByteBuffer; +import net.createmod.catnip.render.SuperByteBuffer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;