From 7b4f9f924fc9627b0614d6d54b2f12d6fd269c88 Mon Sep 17 00:00:00 2001 From: PepperBell <44146161+PepperCode1@users.noreply.github.com> Date: Sun, 21 Nov 2021 00:44:37 -0800 Subject: [PATCH] Over-rendered - Replace AngleHelper.horizontalAngle with horizontalAngleNew (return 0 instead of -90 for vertical directions) - Fix FluidRenderer not calculating correct UVs for integer positions - Fix FluidRenderer rendering streams and flowing texture incorrectly - Slightly improve performance of outlines - Rename PartialBufferer to CachedBufferer - Move specific code out of SuperByteBufferCache into CachedBufferer and BakedModelRenderHelper - Move Compartment inside SuperByteBufferCache - Rename some methods and fields --- .../com/simibubi/create/AllBlockPartials.java | 183 +++++++++--------- .../com/simibubi/create/CreateClient.java | 4 + .../animations/AnimatedItemDrain.java | 2 +- .../category/animations/AnimatedSpout.java | 12 +- .../base/KineticTileEntityRenderer.java | 10 +- .../components/actors/DrillRenderer.java | 6 +- .../components/actors/HarvesterRenderer.java | 6 +- .../PortableStorageInterfaceRenderer.java | 6 +- .../components/clock/CuckooClockRenderer.java | 14 +- .../crafter/MechanicalCrafterRenderer.java | 6 +- .../components/crank/HandCrankRenderer.java | 4 +- .../deployer/DeployerActorInstance.java | 14 +- .../deployer/DeployerFilterSlot.java | 4 +- .../components/deployer/DeployerInstance.java | 18 +- .../components/deployer/DeployerRenderer.java | 24 +-- .../components/fan/EncasedFanRenderer.java | 6 +- .../components/flywheel/FlywheelBlock.java | 2 +- .../components/flywheel/FlywheelRenderer.java | 14 +- .../flywheel/engine/EngineRenderer.java | 4 +- .../millstone/MillstoneRenderer.java | 4 +- .../mixer/MechanicalMixerRenderer.java | 8 +- .../motor/CreativeMotorRenderer.java | 4 +- .../press/MechanicalPressRenderer.java | 4 +- .../components/saw/SawRenderer.java | 19 +- .../bearing/BearingRenderer.java | 6 +- .../StabilizedBearingMovementBehaviour.java | 4 +- .../chassis/StickerInstance.java | 86 ++++---- .../chassis/StickerRenderer.java | 10 +- .../gantry/GantryCarriageInstance.java | 141 +++++++------- .../gantry/GantryCarriageRenderer.java | 15 +- .../structureMovement/glue/GlueInstance.java | 2 +- .../glue/SuperGlueRenderer.java | 2 +- .../pulley/AbstractPulleyRenderer.java | 8 +- .../structureMovement/pulley/PulleyBlock.java | 4 - .../pulley/PulleyRenderer.java | 6 +- .../render/SBBContraptionManager.java | 8 +- .../train/CouplingRenderer.java | 8 +- .../contraptions/fluids/PumpRenderer.java | 6 +- .../fluids/actors/HosePulleyRenderer.java | 6 +- .../fluids/actors/ItemDrainRenderer.java | 4 +- .../fluids/actors/SpoutRenderer.java | 8 +- .../fluids/pipes/FluidValveInstance.java | 2 +- .../fluids/pipes/FluidValveRenderer.java | 6 +- .../fluids/tank/FluidTankRenderer.java | 2 +- .../processing/BasinRenderer.java | 2 +- .../burner/BlazeBurnerRenderer.java | 4 +- .../advanced/SpeedControllerRenderer.java | 7 +- .../relays/belt/BeltRenderer.java | 7 +- .../BracketedKineticTileRenderer.java | 6 +- .../relays/encased/ShaftlessCogRenderer.java | 4 +- .../relays/encased/SplitShaftRenderer.java | 4 +- .../relays/gauge/GaugeRenderer.java | 6 +- .../relays/gearbox/GearboxRenderer.java | 4 +- .../armor/CopperBacktankArmorLayer.java | 7 +- .../armor/CopperBacktankRenderer.java | 8 +- .../curiosities/bell/BellRenderer.java | 4 +- .../curiosities/toolbox/ToolboxRenderer.java | 6 +- .../curiosities/tools/BlueprintRenderer.java | 4 +- .../belts/tunnel/BeltTunnelRenderer.java | 4 +- .../block/depot/EjectorRenderer.java | 4 +- .../block/diodes/BrassDiodeRenderer.java | 4 +- .../block/funnel/FunnelRenderer.java | 4 +- .../block/mechanicalArm/ArmRenderer.java | 16 +- .../block/mechanicalArm/ArmTileEntity.java | 2 +- .../block/redstone/AnalogLeverRenderer.java | 6 +- .../block/SchematicannonRenderer.java | 6 +- .../foundation/fluid/FluidRenderer.java | 162 +++++++++------- .../gui/element/GuiGameElement.java | 4 +- .../ponder/elements/WorldSectionElement.java | 13 +- .../render/BakedModelRenderHelper.java | 50 +++++ .../foundation/render/CachedBufferer.java | 89 +++++++++ .../create/foundation/render/Compartment.java | 14 -- .../foundation/render/PartialBufferer.java | 61 ------ .../render/SuperByteBufferCache.java | 133 +++---------- .../behaviour/ValueBoxTransform.java | 2 +- .../scrollvalue/ScrollValueHandler.java | 8 +- .../foundation/utility/AngleHelper.java | 16 +- .../utility/ISimpleReloadListener.java | 1 + .../utility/outliner/BlockClusterOutline.java | 50 ++--- .../foundation/utility/outliner/Outline.java | 44 +++-- .../foundation/utility/outliner/Outliner.java | 56 +++--- 81 files changed, 755 insertions(+), 779 deletions(-) create mode 100644 src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java create mode 100644 src/main/java/com/simibubi/create/foundation/render/CachedBufferer.java delete mode 100644 src/main/java/com/simibubi/create/foundation/render/Compartment.java delete mode 100644 src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java diff --git a/src/main/java/com/simibubi/create/AllBlockPartials.java b/src/main/java/com/simibubi/create/AllBlockPartials.java index f3557c64e..fb4ea5e54 100644 --- a/src/main/java/com/simibubi/create/AllBlockPartials.java +++ b/src/main/java/com/simibubi/create/AllBlockPartials.java @@ -1,5 +1,6 @@ package com.simibubi.create; +import java.util.EnumMap; import java.util.HashMap; import java.util.Map; @@ -14,144 +15,144 @@ import net.minecraft.world.item.DyeColor; public class AllBlockPartials { - public static final PartialModel SCHEMATICANNON_CONNECTOR = get("schematicannon/connector"), - SCHEMATICANNON_PIPE = get("schematicannon/pipe"), + public static final PartialModel - SHAFTLESS_COGWHEEL = get("cogwheel_shaftless"), SHAFTLESS_LARGE_COGWHEEL = get("large_cogwheel_shaftless"), - COGWHEEL_SHAFT = get("cogwheel_shaft"), SHAFT_HALF = get("shaft_half"), + SCHEMATICANNON_CONNECTOR = block("schematicannon/connector"), + SCHEMATICANNON_PIPE = block("schematicannon/pipe"), - BELT_PULLEY = get("belt_pulley"), BELT_START = get("belt/start"), BELT_MIDDLE = get("belt/middle"), - BELT_END = get("belt/end"), BELT_START_BOTTOM = get("belt/start_bottom"), - BELT_MIDDLE_BOTTOM = get("belt/middle_bottom"), BELT_END_BOTTOM = get("belt/end_bottom"), - BELT_DIAGONAL_START = get("belt/diagonal_start"), BELT_DIAGONAL_MIDDLE = get("belt/diagonal_middle"), - BELT_DIAGONAL_END = get("belt/diagonal_end"), + SHAFTLESS_COGWHEEL = block("cogwheel_shaftless"), SHAFTLESS_LARGE_COGWHEEL = block("large_cogwheel_shaftless"), + COGWHEEL_SHAFT = block("cogwheel_shaft"), SHAFT_HALF = block("shaft_half"), - ENCASED_FAN_INNER = get("encased_fan/propeller"), HAND_CRANK_HANDLE = get("hand_crank/handle"), - MECHANICAL_PRESS_HEAD = get("mechanical_press/head"), MECHANICAL_MIXER_POLE = get("mechanical_mixer/pole"), - MECHANICAL_MIXER_HEAD = get("mechanical_mixer/head"), MECHANICAL_CRAFTER_LID = get("mechanical_crafter/lid"), - MECHANICAL_CRAFTER_ARROW = get("mechanical_crafter/arrow"), - MECHANICAL_CRAFTER_BELT_FRAME = get("mechanical_crafter/belt"), - MECHANICAL_CRAFTER_BELT = get("mechanical_crafter/belt_animated"), - SAW_BLADE_HORIZONTAL_ACTIVE = get("mechanical_saw/blade_horizontal_active"), - SAW_BLADE_HORIZONTAL_INACTIVE = get("mechanical_saw/blade_horizontal_inactive"), - SAW_BLADE_HORIZONTAL_REVERSED = get("mechanical_saw/blade_horizontal_reversed"), - SAW_BLADE_VERTICAL_ACTIVE = get("mechanical_saw/blade_vertical_active"), - SAW_BLADE_VERTICAL_INACTIVE = get("mechanical_saw/blade_vertical_inactive"), - SAW_BLADE_VERTICAL_REVERSED = get("mechanical_saw/blade_vertical_reversed"), GAUGE_DIAL = get("gauge/dial"), - GAUGE_INDICATOR = get("gauge/indicator"), GAUGE_HEAD_SPEED = get("gauge/speedometer/head"), - GAUGE_HEAD_STRESS = get("gauge/stressometer/head"), BEARING_TOP = get("bearing/top"), - BEARING_TOP_WOODEN = get("bearing/top_wooden"), DRILL_HEAD = get("mechanical_drill/head"), - HARVESTER_BLADE = get("mechanical_harvester/blade"), DEPLOYER_POLE = get("deployer/pole"), - DEPLOYER_HAND_POINTING = get("deployer/hand_pointing"), DEPLOYER_HAND_PUNCHING = get("deployer/hand_punching"), - DEPLOYER_HAND_HOLDING = get("deployer/hand_holding"), ANALOG_LEVER_HANDLE = get("analog_lever/handle"), - ANALOG_LEVER_INDICATOR = get("analog_lever/indicator"), FUNNEL_FLAP = get("funnel/flap"), - BELT_FUNNEL_FLAP = get("belt_funnel/flap"), BELT_TUNNEL_FLAP = get("belt_tunnel/flap"), - FLEXPEATER_INDICATOR = get("diodes/indicator"), FLYWHEEL = get("flywheel/wheel"), - FLYWHEEL_UPPER_ROTATING = get("flywheel/upper_rotating_connector"), + BELT_PULLEY = block("belt_pulley"), BELT_START = block("belt/start"), BELT_MIDDLE = block("belt/middle"), + BELT_END = block("belt/end"), BELT_START_BOTTOM = block("belt/start_bottom"), + BELT_MIDDLE_BOTTOM = block("belt/middle_bottom"), BELT_END_BOTTOM = block("belt/end_bottom"), + BELT_DIAGONAL_START = block("belt/diagonal_start"), BELT_DIAGONAL_MIDDLE = block("belt/diagonal_middle"), + BELT_DIAGONAL_END = block("belt/diagonal_end"), - FLYWHEEL_LOWER_ROTATING = get("flywheel/lower_rotating_connector"), - FLYWHEEL_UPPER_SLIDING = get("flywheel/upper_sliding_connector"), - FLYWHEEL_LOWER_SLIDING = get("flywheel/lower_sliding_connector"), - FURNACE_GENERATOR_FRAME = get("furnace_engine/frame"), CUCKOO_MINUTE_HAND = get("cuckoo_clock/minute_hand"), - CUCKOO_HOUR_HAND = get("cuckoo_clock/hour_hand"), CUCKOO_LEFT_DOOR = get("cuckoo_clock/left_door"), - CUCKOO_RIGHT_DOOR = get("cuckoo_clock/right_door"), CUCKOO_PIG = get("cuckoo_clock/pig"), - CUCKOO_CREEPER = get("cuckoo_clock/creeper"), + ENCASED_FAN_INNER = block("encased_fan/propeller"), HAND_CRANK_HANDLE = block("hand_crank/handle"), + MECHANICAL_PRESS_HEAD = block("mechanical_press/head"), MECHANICAL_MIXER_POLE = block("mechanical_mixer/pole"), + MECHANICAL_MIXER_HEAD = block("mechanical_mixer/head"), MECHANICAL_CRAFTER_LID = block("mechanical_crafter/lid"), + MECHANICAL_CRAFTER_ARROW = block("mechanical_crafter/arrow"), + MECHANICAL_CRAFTER_BELT_FRAME = block("mechanical_crafter/belt"), + MECHANICAL_CRAFTER_BELT = block("mechanical_crafter/belt_animated"), + SAW_BLADE_HORIZONTAL_ACTIVE = block("mechanical_saw/blade_horizontal_active"), + SAW_BLADE_HORIZONTAL_INACTIVE = block("mechanical_saw/blade_horizontal_inactive"), + SAW_BLADE_HORIZONTAL_REVERSED = block("mechanical_saw/blade_horizontal_reversed"), + SAW_BLADE_VERTICAL_ACTIVE = block("mechanical_saw/blade_vertical_active"), + SAW_BLADE_VERTICAL_INACTIVE = block("mechanical_saw/blade_vertical_inactive"), + SAW_BLADE_VERTICAL_REVERSED = block("mechanical_saw/blade_vertical_reversed"), GAUGE_DIAL = block("gauge/dial"), + GAUGE_INDICATOR = block("gauge/indicator"), GAUGE_HEAD_SPEED = block("gauge/speedometer/head"), + GAUGE_HEAD_STRESS = block("gauge/stressometer/head"), BEARING_TOP = block("bearing/top"), + BEARING_TOP_WOODEN = block("bearing/top_wooden"), DRILL_HEAD = block("mechanical_drill/head"), + HARVESTER_BLADE = block("mechanical_harvester/blade"), DEPLOYER_POLE = block("deployer/pole"), + DEPLOYER_HAND_POINTING = block("deployer/hand_pointing"), DEPLOYER_HAND_PUNCHING = block("deployer/hand_punching"), + DEPLOYER_HAND_HOLDING = block("deployer/hand_holding"), ANALOG_LEVER_HANDLE = block("analog_lever/handle"), + ANALOG_LEVER_INDICATOR = block("analog_lever/indicator"), FUNNEL_FLAP = block("funnel/flap"), + BELT_FUNNEL_FLAP = block("belt_funnel/flap"), BELT_TUNNEL_FLAP = block("belt_tunnel/flap"), + FLEXPEATER_INDICATOR = block("diodes/indicator"), FLYWHEEL = block("flywheel/wheel"), + FLYWHEEL_UPPER_ROTATING = block("flywheel/upper_rotating_connector"), - GANTRY_COGS = get("gantry_carriage/wheels"), + FLYWHEEL_LOWER_ROTATING = block("flywheel/lower_rotating_connector"), + FLYWHEEL_UPPER_SLIDING = block("flywheel/upper_sliding_connector"), + FLYWHEEL_LOWER_SLIDING = block("flywheel/lower_sliding_connector"), + FURNACE_GENERATOR_FRAME = block("furnace_engine/frame"), CUCKOO_MINUTE_HAND = block("cuckoo_clock/minute_hand"), + CUCKOO_HOUR_HAND = block("cuckoo_clock/hour_hand"), CUCKOO_LEFT_DOOR = block("cuckoo_clock/left_door"), + CUCKOO_RIGHT_DOOR = block("cuckoo_clock/right_door"), CUCKOO_PIG = block("cuckoo_clock/pig"), + CUCKOO_CREEPER = block("cuckoo_clock/creeper"), - ROPE_COIL = get("rope_pulley/rope_coil"), ROPE_HALF = get("rope_pulley/rope_half"), - ROPE_HALF_MAGNET = get("rope_pulley/rope_half_magnet"), + GANTRY_COGS = block("gantry_carriage/wheels"), - HOSE_COIL = get("hose_pulley/rope_coil"), HOSE = get("hose_pulley/rope"), - HOSE_MAGNET = get("hose_pulley/pulley_magnet"), HOSE_HALF = get("hose_pulley/rope_half"), - HOSE_HALF_MAGNET = get("hose_pulley/rope_half_magnet"), + ROPE_COIL = block("rope_pulley/rope_coil"), ROPE_HALF = block("rope_pulley/rope_half"), + ROPE_HALF_MAGNET = block("rope_pulley/rope_half_magnet"), - MILLSTONE_COG = get("millstone/inner"), + HOSE_COIL = block("hose_pulley/rope_coil"), HOSE = block("hose_pulley/rope"), + HOSE_MAGNET = block("hose_pulley/pulley_magnet"), HOSE_HALF = block("hose_pulley/rope_half"), + HOSE_HALF_MAGNET = block("hose_pulley/rope_half_magnet"), - SYMMETRY_PLANE = get("symmetry_effect/plane"), SYMMETRY_CROSSPLANE = get("symmetry_effect/crossplane"), - SYMMETRY_TRIPLEPLANE = get("symmetry_effect/tripleplane"), + MILLSTONE_COG = block("millstone/inner"), - STICKER_HEAD = get("sticker/head"), + SYMMETRY_PLANE = block("symmetry_effect/plane"), SYMMETRY_CROSSPLANE = block("symmetry_effect/crossplane"), + SYMMETRY_TRIPLEPLANE = block("symmetry_effect/tripleplane"), - PORTABLE_STORAGE_INTERFACE_MIDDLE = get("portable_storage_interface/block_middle"), - PORTABLE_STORAGE_INTERFACE_MIDDLE_POWERED = get("portable_storage_interface/block_middle_powered"), - PORTABLE_STORAGE_INTERFACE_TOP = get("portable_storage_interface/block_top"), + STICKER_HEAD = block("sticker/head"), - PORTABLE_FLUID_INTERFACE_MIDDLE = get("portable_fluid_interface/block_middle"), - PORTABLE_FLUID_INTERFACE_MIDDLE_POWERED = get("portable_fluid_interface/block_middle_powered"), - PORTABLE_FLUID_INTERFACE_TOP = get("portable_fluid_interface/block_top"), + PORTABLE_STORAGE_INTERFACE_MIDDLE = block("portable_storage_interface/block_middle"), + PORTABLE_STORAGE_INTERFACE_MIDDLE_POWERED = block("portable_storage_interface/block_middle_powered"), + PORTABLE_STORAGE_INTERFACE_TOP = block("portable_storage_interface/block_top"), - ARM_COG = get("mechanical_arm/cog"), ARM_BASE = get("mechanical_arm/base"), - ARM_LOWER_BODY = get("mechanical_arm/lower_body"), ARM_UPPER_BODY = get("mechanical_arm/upper_body"), - ARM_HEAD = get("mechanical_arm/head"), ARM_CLAW_BASE = get("mechanical_arm/claw_base"), - ARM_CLAW_GRIP = get("mechanical_arm/claw_grip"), + PORTABLE_FLUID_INTERFACE_MIDDLE = block("portable_fluid_interface/block_middle"), + PORTABLE_FLUID_INTERFACE_MIDDLE_POWERED = block("portable_fluid_interface/block_middle_powered"), + PORTABLE_FLUID_INTERFACE_TOP = block("portable_fluid_interface/block_top"), - FLAG_SHORT_IN = get("mechanical_arm/flag/short_in"), FLAG_SHORT_OUT = get("mechanical_arm/flag/short_out"), - FLAG_LONG_IN = get("mechanical_arm/flag/long_in"), FLAG_LONG_OUT = get("mechanical_arm/flag/long_out"), + ARM_COG = block("mechanical_arm/cog"), ARM_BASE = block("mechanical_arm/base"), + ARM_LOWER_BODY = block("mechanical_arm/lower_body"), ARM_UPPER_BODY = block("mechanical_arm/upper_body"), + ARM_HEAD = block("mechanical_arm/head"), ARM_CLAW_BASE = block("mechanical_arm/claw_base"), + ARM_CLAW_GRIP = block("mechanical_arm/claw_grip"), - MECHANICAL_PUMP_ARROW = get("mechanical_pump/arrow"), MECHANICAL_PUMP_COG = get("mechanical_pump/cog"), - FLUID_PIPE_CASING = get("fluid_pipe/casing"), FLUID_VALVE_POINTER = get("fluid_valve/pointer"), + FLAG_SHORT_IN = block("mechanical_arm/flag/short_in"), FLAG_SHORT_OUT = block("mechanical_arm/flag/short_out"), + FLAG_LONG_IN = block("mechanical_arm/flag/long_in"), FLAG_LONG_OUT = block("mechanical_arm/flag/long_out"), - SPOUT_TOP = get("spout/top"), SPOUT_MIDDLE = get("spout/middle"), SPOUT_BOTTOM = get("spout/bottom"), + MECHANICAL_PUMP_ARROW = block("mechanical_pump/arrow"), MECHANICAL_PUMP_COG = block("mechanical_pump/cog"), + FLUID_PIPE_CASING = block("fluid_pipe/casing"), FLUID_VALVE_POINTER = block("fluid_valve/pointer"), - PECULIAR_BELL = get("peculiar_bell"), HAUNTED_BELL = get("haunted_bell"), + SPOUT_TOP = block("spout/top"), SPOUT_MIDDLE = block("spout/middle"), SPOUT_BOTTOM = block("spout/bottom"), - TOOLBOX_DRAWER = get("toolbox/drawer"), + PECULIAR_BELL = block("peculiar_bell"), HAUNTED_BELL = block("haunted_bell"), - SPEED_CONTROLLER_BRACKET = get("rotation_speed_controller/bracket"), + TOOLBOX_DRAWER = block("toolbox/drawer"), - GOGGLES = get("goggles"), + SPEED_CONTROLLER_BRACKET = block("rotation_speed_controller/bracket"), - EJECTOR_TOP = get("weighted_ejector/top"), + GOGGLES = block("goggles"), - COPPER_BACKTANK_SHAFT = get("copper_backtank/block_shaft_input"), - COPPER_BACKTANK_COGS = get("copper_backtank/block_cogs"), + EJECTOR_TOP = block("weighted_ejector/top"), - CRAFTING_BLUEPRINT_1x1 = getEntity("crafting_blueprint_small"), - CRAFTING_BLUEPRINT_2x2 = getEntity("crafting_blueprint_medium"), - CRAFTING_BLUEPRINT_3x3 = getEntity("crafting_blueprint_large"), + COPPER_BACKTANK_SHAFT = block("copper_backtank/block_shaft_input"), + COPPER_BACKTANK_COGS = block("copper_backtank/block_cogs"), - COUPLING_ATTACHMENT = getEntity("minecart_coupling/attachment"), - COUPLING_RING = getEntity("minecart_coupling/ring"), - COUPLING_CONNECTOR = getEntity("minecart_coupling/connector"); + CRAFTING_BLUEPRINT_1x1 = entity("crafting_blueprint_small"), + CRAFTING_BLUEPRINT_2x2 = entity("crafting_blueprint_medium"), + CRAFTING_BLUEPRINT_3x3 = entity("crafting_blueprint_large"), + + COUPLING_ATTACHMENT = entity("minecart_coupling/attachment"), + COUPLING_RING = entity("minecart_coupling/ring"), + COUPLING_CONNECTOR = entity("minecart_coupling/connector") + + ; public static final Map> PIPE_ATTACHMENTS = - new HashMap<>(); - public static final Map TOOLBOX_LIDS = new HashMap<>(); - public static final Map BLAZES = new HashMap<>(); + new EnumMap<>(FluidTransportBehaviour.AttachmentTypes.class); + public static final Map BLAZES = new EnumMap<>(BlazeBurnerBlock.HeatLevel.class); + public static final Map TOOLBOX_LIDS = new EnumMap<>(DyeColor.class); static { - populateMaps(); - } - - static void populateMaps() { for (FluidTransportBehaviour.AttachmentTypes type : FluidTransportBehaviour.AttachmentTypes.values()) { if (!type.hasModel()) continue; Map map = new HashMap<>(); for (Direction d : Iterate.directions) { String asId = Lang.asId(type.name()); - map.put(d, get("fluid_pipe/" + asId + "/" + Lang.asId(d.getSerializedName()))); + map.put(d, block("fluid_pipe/" + asId + "/" + Lang.asId(d.getSerializedName()))); } PIPE_ATTACHMENTS.put(type, map); } for (BlazeBurnerBlock.HeatLevel heat : BlazeBurnerBlock.HeatLevel.values()) { if (heat == BlazeBurnerBlock.HeatLevel.NONE) continue; - BLAZES.put(heat, get("blaze_burner/blaze/" + heat.getSerializedName())); + BLAZES.put(heat, block("blaze_burner/blaze/" + heat.getSerializedName())); } for (DyeColor color : DyeColor.values()) - TOOLBOX_LIDS.put(color, get("toolbox/lid/" + Lang.asId(color.name()))); + TOOLBOX_LIDS.put(color, block("toolbox/lid/" + Lang.asId(color.name()))); } - private static PartialModel getEntity(String path) { - return new PartialModel(Create.asResource("entity/" + path)); - } - - private static PartialModel get(String path) { + private static PartialModel block(String path) { return new PartialModel(Create.asResource("block/" + path)); } + private static PartialModel entity(String path) { + return new PartialModel(Create.asResource("entity/" + path)); + } + public static void init() { // init static fields } diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 633387202..199c0a44c 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -16,6 +16,7 @@ import com.simibubi.create.foundation.gui.UIRenderHelper; import com.simibubi.create.foundation.ponder.content.PonderIndex; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.render.AllMaterialSpecs; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.CreateContexts; import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.utility.ModelSwapper; @@ -66,6 +67,9 @@ 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); BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20); diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedItemDrain.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedItemDrain.java index 6c9356f98..1c7e56913 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedItemDrain.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedItemDrain.java @@ -40,7 +40,7 @@ public class AnimatedItemDrain extends AnimatedKinetics { ms.scale(scale, scale, scale); float from = 2/16f; float to = 1f - from; - FluidRenderer.renderTiledFluidBB(fluid, from, from, from, to, 3/4f, to, buffer, ms, LightTexture.FULL_BRIGHT, false); + FluidRenderer.renderFluidBox(fluid, from, from, from, to, 3/4f, to, buffer, ms, LightTexture.FULL_BRIGHT, false); buffer.endBatch(); matrixStack.popPose(); diff --git a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSpout.java b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSpout.java index 2e19f9068..faac26a70 100644 --- a/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSpout.java +++ b/src/main/java/com/simibubi/create/compat/jei/category/animations/AnimatedSpout.java @@ -71,17 +71,19 @@ public class AnimatedSpout extends AnimatedKinetics { matrixStack.pushPose(); UIRenderHelper.flipForGuiRender(matrixStack); matrixStack.scale(16, 16, 16); - float from = 2/16f; - float to = 1f - from; - FluidRenderer.renderTiledFluidBB(fluids.get(0), from, from, from, to, to, to, buffer, matrixStack, LightTexture.FULL_BRIGHT, false); + float from = 3f / 16f; + float to = 17f / 16f; + FluidRenderer.renderFluidBox(fluids.get(0), from, from, from, to, to, to, buffer, matrixStack, LightTexture.FULL_BRIGHT, false); matrixStack.popPose(); float width = 1 / 128f * squeeze; matrixStack.translate(scale / 2f, scale * 1.5f, scale / 2f); UIRenderHelper.flipForGuiRender(matrixStack); matrixStack.scale(16, 16, 16); - matrixStack.translate(-width / 2, 0, -width / 2); - FluidRenderer.renderTiledFluidBB(fluids.get(0), 0, -0.001f, 0, width, 2.001f, width, buffer, matrixStack, LightTexture.FULL_BRIGHT, + matrixStack.translate(-0.5f, 0, -0.5f); + from = -width / 2 + 0.5f; + to = width / 2 + 0.5f; + FluidRenderer.renderFluidBox(fluids.get(0), from, 0, from, to, 2, to, buffer, matrixStack, LightTexture.FULL_BRIGHT, false); buffer.endBatch(); Lighting.setupFor3DItems(); 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 0a7c53bbe..fdae33fc3 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 @@ -4,11 +4,11 @@ import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlocks; -import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; -import com.simibubi.create.foundation.render.Compartment; +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 com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Color; @@ -29,7 +29,7 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @EventBusSubscriber(Dist.CLIENT) public class KineticTileEntityRenderer extends SafeTileEntityRenderer { - public static final Compartment KINETIC_TILE = new Compartment<>(); + public static final SuperByteBufferCache.Compartment KINETIC_TILE = new SuperByteBufferCache.Compartment<>(); public static boolean rainbowMode = false; public KineticTileEntityRenderer(BlockEntityRendererProvider.Context context) { @@ -47,7 +47,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer drawCallback) { - SuperByteBuffer middle = PartialBufferer.get(getMiddleForState(blockState, lit), blockState); - SuperByteBuffer top = PartialBufferer.get(getTopForState(blockState), blockState); + SuperByteBuffer middle = CachedBufferer.partial(getMiddleForState(blockState, lit), blockState); + SuperByteBuffer top = CachedBufferer.partial(getTopForState(blockState), blockState); if (local != null) { middle.transform(local); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockRenderer.java index 8f9fe31a0..71dd3f5d5 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/clock/CuckooClockRenderer.java @@ -7,7 +7,7 @@ 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.components.clock.CuckooClockTileEntity.Animation; -import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -38,8 +38,8 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer { VertexConsumer vb = buffer.getBuffer(RenderType.solid()); // Render Hands - SuperByteBuffer hourHand = PartialBufferer.get(AllBlockPartials.CUCKOO_HOUR_HAND, blockState); - SuperByteBuffer minuteHand = PartialBufferer.get(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState); + SuperByteBuffer hourHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_HOUR_HAND, blockState); + SuperByteBuffer minuteHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState); float hourAngle = clock.hourHand.get(partialTicks); float minuteAngle = clock.minuteHand.get(partialTicks); rotateHand(hourHand, hourAngle, direction).light(light) @@ -48,8 +48,8 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer { .renderInto(ms, vb); // Doors - SuperByteBuffer leftDoor = PartialBufferer.get(AllBlockPartials.CUCKOO_LEFT_DOOR, blockState); - SuperByteBuffer rightDoor = PartialBufferer.get(AllBlockPartials.CUCKOO_RIGHT_DOOR, blockState); + SuperByteBuffer leftDoor = CachedBufferer.partial(AllBlockPartials.CUCKOO_LEFT_DOOR, blockState); + SuperByteBuffer rightDoor = CachedBufferer.partial(AllBlockPartials.CUCKOO_RIGHT_DOOR, blockState); float angle = 0; float offset = 0; @@ -80,7 +80,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer { offset = -(angle / 135) * 1 / 2f + 10 / 16f; PartialModel partialModel = (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER); SuperByteBuffer figure = - PartialBufferer.get(partialModel, blockState); + CachedBufferer.partial(partialModel, blockState); figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.getCounterClockWise()))); figure.translate(offset, 0, 0); figure.light(light) @@ -95,7 +95,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer { } private SuperByteBuffer transform(PartialModel partial, KineticTileEntity te) { - return PartialBufferer.getFacing(partial, te.getBlockState(), te.getBlockState() + return CachedBufferer.partialFacing(partial, te.getBlockState(), te.getBlockState() .getValue(CuckooClockBlock.HORIZONTAL_FACING) .getOpposite()); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java index 6b03579a2..ad8101b37 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterRenderer.java @@ -13,7 +13,7 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllSpriteShifts; import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase; import com.simibubi.create.content.contraptions.components.crafter.RecipeGridHandler.GroupedItems; -import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -171,7 +171,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer boolean punching = te.mode == Mode.PUNCH; float yRot = AngleHelper.horizontalAngle(facing) + 180; - float zRot = facing == Direction.UP ? 90 : facing == Direction.DOWN ? 270 : 0; + float xRot = facing == Direction.UP ? 90 : facing == Direction.DOWN ? 270 : 0; boolean displayMode = facing == Direction.UP && te.getSpeed() == 0 && !punching; ms.mulPose(Vector3f.YP.rotationDegrees(yRot)); if (!displayMode) { - ms.mulPose(Vector3f.XP.rotationDegrees(zRot)); + ms.mulPose(Vector3f.XP.rotationDegrees(xRot)); ms.translate(0, 0, -11 / 16f); } @@ -116,8 +116,8 @@ public class DeployerRenderer extends SafeTileEntityRenderer BlockState blockState = te.getBlockState(); Vec3 offset = getHandOffset(te, partialTicks, blockState); - SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState); - SuperByteBuffer hand = PartialBufferer.get(te.getHandPose(), blockState); + SuperByteBuffer pole = CachedBufferer.partial(AllBlockPartials.DEPLOYER_POLE, blockState); + SuperByteBuffer hand = CachedBufferer.partial(te.getHandPose(), blockState); transform(pole.translate(offset.x, offset.y, offset.z), blockState, true) .light(light) @@ -139,15 +139,15 @@ public class DeployerRenderer extends SafeTileEntityRenderer private static SuperByteBuffer transform(SuperByteBuffer buffer, BlockState deployerState, boolean axisDirectionMatters) { Direction facing = deployerState.getValue(FACING); - float zRotLast = + float yRot = AngleHelper.horizontalAngle(facing); + float xRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; + float zRot = axisDirectionMatters && (deployerState.getValue(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Axis.Z) ? 90 : 0; - float yRot = AngleHelper.horizontalAngle(facing); - float zRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; - buffer.rotateCentered(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI)); buffer.rotateCentered(Direction.UP, (float) ((yRot) / 180 * Math.PI)); - buffer.rotateCentered(Direction.SOUTH, (float) ((zRotLast) / 180 * Math.PI)); + buffer.rotateCentered(Direction.EAST, (float) ((xRot) / 180 * Math.PI)); + buffer.rotateCentered(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI)); return buffer; } @@ -158,8 +158,8 @@ public class DeployerRenderer extends SafeTileEntityRenderer Mode mode = NBTHelper.readEnum(context.tileData, "Mode", Mode.class); PartialModel handPose = getHandPose(mode); - SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState); - SuperByteBuffer hand = PartialBufferer.get(handPose, blockState); + SuperByteBuffer pole = CachedBufferer.partial(AllBlockPartials.DEPLOYER_POLE, blockState); + SuperByteBuffer hand = CachedBufferer.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 6e56c6595..274f95237 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,7 +8,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -38,9 +38,9 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer { int lightInFront = LevelRenderer.getLightColor(te.getLevel(), te.getBlockPos().relative(direction)); SuperByteBuffer shaftHalf = - PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction.getOpposite()); + CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction.getOpposite()); SuperByteBuffer fanInner = - PartialBufferer.getFacing(AllBlockPartials.ENCASED_FAN_INNER, te.getBlockState(), direction.getOpposite()); + CachedBufferer.partialFacing(AllBlockPartials.ENCASED_FAN_INNER, te.getBlockState(), direction.getOpposite()); float time = AnimationTickHolder.getRenderTime(te.getLevel()); float speed = te.getSpeed() * 5; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelBlock.java index 20954228a..34ae99539 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelBlock.java @@ -25,7 +25,7 @@ import net.minecraft.world.level.block.state.properties.EnumProperty; public class FlywheelBlock extends HorizontalKineticBlock implements ITE { - public static EnumProperty CONNECTION = EnumProperty.create("connection", ConnectionState.class); + public static final EnumProperty CONNECTION = EnumProperty.create("connection", ConnectionState.class); public FlywheelBlock(Properties properties) { super(properties); 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 77af77f27..c816de46d 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 @@ -9,7 +9,7 @@ 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.components.flywheel.FlywheelBlock.ConnectionState; -import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -56,18 +56,18 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { boolean flip = blockState.getValue(FlywheelBlock.CONNECTION) == ConnectionState.LEFT; transformConnector( - rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true, + rotateToFacing(CachedBufferer.partial(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true, rotation, flip).light(light) .renderInto(ms, vb); transformConnector( - rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true, + rotateToFacing(CachedBufferer.partial(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true, rotation, flip).light(light) .renderInto(ms, vb); - transformConnector(rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_UPPER_SLIDING, blockState), connection), + transformConnector(rotateToFacing(CachedBufferer.partial(AllBlockPartials.FLYWHEEL_UPPER_SLIDING, blockState), connection), true, false, rotation, flip).light(light) .renderInto(ms, vb); - transformConnector(rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_LOWER_SLIDING, blockState), connection), + transformConnector(rotateToFacing(CachedBufferer.partial(AllBlockPartials.FLYWHEEL_LOWER_SLIDING, blockState), connection), false, false, rotation, flip).light(light) .renderInto(ms, vb); } @@ -78,7 +78,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { private void renderFlywheel(KineticTileEntity te, PoseStack ms, int light, BlockState blockState, float angle, VertexConsumer vb) { BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90); Direction facing = referenceState.getValue(BlockStateProperties.HORIZONTAL_FACING); - SuperByteBuffer wheel = PartialBufferer.getFacing(AllBlockPartials.FLYWHEEL, referenceState, facing); + SuperByteBuffer wheel = CachedBufferer.partialFacing(AllBlockPartials.FLYWHEEL, referenceState, facing); kineticRotationTransform(wheel, te, blockState.getValue(HORIZONTAL_FACING) .getAxis(), AngleHelper.rad(angle), light); wheel.renderInto(ms, vb); @@ -86,7 +86,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState() + return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState() .getValue(BlockStateProperties.HORIZONTAL_FACING) .getOpposite()); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java index 5d4d32ef7..1c9c904bd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/engine/EngineRenderer.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.core.PartialModel; import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -33,7 +33,7 @@ public class EngineRenderer extends SafeTileEntityRe Direction facing = te.getBlockState() .getValue(EngineBlock.FACING); float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing)); - PartialBufferer.get(frame, te.getBlockState()) + CachedBufferer.partial(frame, te.getBlockState()) .rotateCentered(Direction.UP, angle) .translate(0, 0, -1) .light(light) 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 a9931538e..52c2982cc 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 @@ -1,9 +1,9 @@ package com.simibubi.create.content.contraptions.components.millstone; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.CreateClient; 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.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -16,7 +16,7 @@ public class MillstoneRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return CreateClient.BUFFER_CACHE.renderPartial(AllBlockPartials.MILLSTONE_COG, te.getBlockState()); + return CachedBufferer.partial(AllBlockPartials.MILLSTONE_COG, te.getBlockState()); } } 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 cd264ce0b..83d05442f 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,7 +6,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -38,7 +38,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer { VertexConsumer vb = buffer.getBuffer(RenderType.solid()); - SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState); + SuperByteBuffer superBuffer = CachedBufferer.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 = AnimationTickHolder.getRenderTime(te.getLevel()); float angle = ((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI; - SuperByteBuffer poleRender = PartialBufferer.get(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState); + SuperByteBuffer poleRender = CachedBufferer.partial(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState); poleRender.translate(0, -renderedHeadOffset, 0) .light(light) .renderInto(ms, vb); - SuperByteBuffer headRender = PartialBufferer.get(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState); + SuperByteBuffer headRender = CachedBufferer.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 421109d1d..e027b6365 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,7 +3,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -16,7 +16,7 @@ public class CreativeMotorRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState()); + return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState()); } } 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 cdf0b95ef..5523a7b2e 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,7 +7,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import net.minecraft.client.renderer.MultiBufferSource; @@ -36,7 +36,7 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer { BlockState blockState = te.getBlockState(); float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks); - SuperByteBuffer headRender = PartialBufferer.getFacing(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState, blockState.getValue(HORIZONTAL_FACING)); + SuperByteBuffer headRender = CachedBufferer.partialFacing(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState, blockState.getValue(HORIZONTAL_FACING)); headRender.translate(0, -renderedHeadOffset, 0) .light(light) .renderInto(ms, buffer.getBuffer(RenderType.solid())); 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 5d1660b98..f71765866 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 @@ -8,13 +8,12 @@ import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Vector3f; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.base.KineticTileEntity; 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; @@ -82,7 +81,7 @@ public class SawRenderer extends SafeTileEntityRenderer { rotate = true; } - SuperByteBuffer superBuffer = PartialBufferer.getFacing(partial, blockState); + SuperByteBuffer superBuffer = CachedBufferer.partialFacing(partial, blockState); if (rotate) { superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(90)); } @@ -150,9 +149,9 @@ public class SawRenderer extends SafeTileEntityRenderer { if (state.getValue(FACING) .getAxis() .isHorizontal()) - return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, + return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, state.rotate(te.getLevel(), te.getBlockPos(), Rotation.CLOCKWISE_180)); - return CreateClient.BUFFER_CACHE.renderBlockIn(KineticTileEntityRenderer.KINETIC_TILE, + return CachedBufferer.block(KineticTileEntityRenderer.KINETIC_TILE, getRenderedBlockState(te)); } @@ -181,14 +180,14 @@ public class SawRenderer extends SafeTileEntityRenderer { SuperByteBuffer superBuffer; if (SawBlock.isHorizontal(state)) { if (shouldAnimate) - superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE, state); + superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE, state); else - superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE, state); + superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE, state); } else { if (shouldAnimate) - superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE, state); + superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE, state); else - superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state); + superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state); } PoseStack m = matrices.getModel(); @@ -199,7 +198,7 @@ public class SawRenderer extends SafeTileEntityRenderer { .rotateX(AngleHelper.verticalAngle(facing)); if (!SawBlock.isHorizontal(state)) MatrixTransformStack.of(m) - .rotateZ(state.getValue(SawBlock.AXIS_ALONG_FIRST_COORDINATE) ? 0 : 90); + .rotateZ(state.getValue(SawBlock.AXIS_ALONG_FIRST_COORDINATE) ? 90 : 0); MatrixTransformStack.of(m) .unCentre(); 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 682ab368c..b3961f558 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,7 +6,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -35,7 +35,7 @@ public class BearingRenderer extends KineticTileEntityRenderer { .getValue(BlockStateProperties.FACING); PartialModel top = bearingTe.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP; - SuperByteBuffer superBuffer = PartialBufferer.get(top, te.getBlockState()); + SuperByteBuffer superBuffer = CachedBufferer.partial(top, te.getBlockState()); float interpolatedAngle = bearingTe.getInterpolatedAngle(partialTicks - 1); kineticRotationTransform(superBuffer, te, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI), light); @@ -50,7 +50,7 @@ public class BearingRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState() + return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState() .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 0d62a4738..e2b396a71 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,7 +15,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; @@ -38,7 +38,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour { Direction facing = context.state.getValue(BlockStateProperties.FACING); PartialModel top = AllBlockPartials.BEARING_TOP; - SuperByteBuffer superBuffer = PartialBufferer.get(top, context.state); + SuperByteBuffer superBuffer = CachedBufferer.partial(top, context.state); float renderPartialTicks = AnimationTickHolder.getPartialTicks(); // rotate to match blockstate diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerInstance.java index 2f5e78640..d506ef8ff 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/StickerInstance.java @@ -16,61 +16,61 @@ import net.minecraft.util.Mth; public class StickerInstance extends TileEntityInstance implements IDynamicInstance { - float lastOffset = Float.NaN; - final Direction facing; - final boolean fakeWorld; - final int offset; + float lastOffset = Float.NaN; + final Direction facing; + final boolean fakeWorld; + final int offset; - private final ModelData head; + private final ModelData head; - public StickerInstance(MaterialManager modelManager, StickerTileEntity tile) { - super(modelManager, tile); + public StickerInstance(MaterialManager modelManager, StickerTileEntity tile) { + super(modelManager, tile); - head = getTransformMaterial().getModel(AllBlockPartials.STICKER_HEAD, blockState).createInstance(); + head = getTransformMaterial().getModel(AllBlockPartials.STICKER_HEAD, blockState).createInstance(); - fakeWorld = tile.getLevel() != Minecraft.getInstance().level; - facing = blockState.getValue(StickerBlock.FACING); - offset = blockState.getValue(StickerBlock.EXTENDED) ? 1 : 0; + fakeWorld = tile.getLevel() != Minecraft.getInstance().level; + facing = blockState.getValue(StickerBlock.FACING); + offset = blockState.getValue(StickerBlock.EXTENDED) ? 1 : 0; - animateHead(offset); - } + animateHead(offset); + } - @Override - public void beginFrame() { - float offset = tile.piston.getValue(AnimationTickHolder.getPartialTicks()); + @Override + public void beginFrame() { + float offset = tile.piston.getValue(AnimationTickHolder.getPartialTicks()); - if (fakeWorld) - offset = this.offset; + if (fakeWorld) + offset = this.offset; - if (Mth.equal(offset, lastOffset)) - return; + if (Mth.equal(offset, lastOffset)) + return; - animateHead(offset); + animateHead(offset); - lastOffset = offset; - } + lastOffset = offset; + } - private void animateHead(float offset) { - PoseStack stack = new PoseStack(); - MatrixTransformStack.of(stack) - .translate(getInstancePosition()) - .nudge(tile.hashCode()) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing) + 90) - .unCentre() - .translate(0, (offset * offset) * 4 / 16f, 0); + private void animateHead(float offset) { + PoseStack stack = new PoseStack(); + MatrixTransformStack.of(stack) + .translate(getInstancePosition()) + .nudge(tile.hashCode()) + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) + .rotateX(AngleHelper.verticalAngle(facing) + 90) + .unCentre() + .translate(0, (offset * offset) * 4 / 16f, 0); - head.setTransform(stack); - } + head.setTransform(stack); + } - @Override - public void updateLight() { - relight(pos, head); - } + @Override + public void updateLight() { + relight(pos, head); + } - @Override - public void remove() { - head.delete(); - } + @Override + public void remove() { + head.delete(); + } } 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 d5bb44269..20ca19568 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,7 +3,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -28,7 +28,7 @@ public class StickerRenderer extends SafeTileEntityRenderer { if (Backend.getInstance().canUseInstancing(te.getLevel())) return; BlockState state = te.getBlockState(); - SuperByteBuffer head = PartialBufferer.get(AllBlockPartials.STICKER_HEAD, state); + SuperByteBuffer head = CachedBufferer.partial(AllBlockPartials.STICKER_HEAD, state); float offset = te.piston.getValue(AnimationTickHolder.getPartialTicks(te.getLevel())); if (te.getLevel() != Minecraft.getInstance().level && !te.isVirtual()) @@ -36,9 +36,9 @@ public class StickerRenderer extends SafeTileEntityRenderer { Direction facing = state.getValue(StickerBlock.FACING); head.matrixStacker() - .nudge(te.hashCode()) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) + .nudge(te.hashCode()) + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) .rotateX(AngleHelper.verticalAngle(facing) + 90) .unCentre() .translate(0, (offset * offset) * 4 / 16f, 0); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java index abf49a69a..bb2c7e68a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryCarriageInstance.java @@ -5,7 +5,6 @@ import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; @@ -19,93 +18,93 @@ import net.minecraft.util.Mth; public class GantryCarriageInstance extends ShaftInstance implements IDynamicInstance { - private final ModelData gantryCogs; + private final ModelData gantryCogs; - final Direction facing; - final Boolean alongFirst; - final Direction.Axis rotationAxis; - final float rotationMult; - final BlockPos visualPos; + final Direction facing; + final Boolean alongFirst; + final Direction.Axis rotationAxis; + final float rotationMult; + final BlockPos visualPos; - private float lastAngle = Float.NaN; + private float lastAngle = Float.NaN; - public GantryCarriageInstance(MaterialManager dispatcher, KineticTileEntity tile) { - super(dispatcher, tile); + public GantryCarriageInstance(MaterialManager dispatcher, KineticTileEntity tile) { + super(dispatcher, tile); - gantryCogs = getTransformMaterial() - .getModel(AllBlockPartials.GANTRY_COGS, blockState) - .createInstance(); + gantryCogs = getTransformMaterial() + .getModel(AllBlockPartials.GANTRY_COGS, blockState) + .createInstance(); - facing = blockState.getValue(GantryCarriageBlock.FACING); - alongFirst = blockState.getValue(GantryCarriageBlock.AXIS_ALONG_FIRST_COORDINATE); - rotationAxis = KineticTileEntityRenderer.getRotationAxisOf(tile); + facing = blockState.getValue(GantryCarriageBlock.FACING); + alongFirst = blockState.getValue(GantryCarriageBlock.AXIS_ALONG_FIRST_COORDINATE); + rotationAxis = KineticTileEntityRenderer.getRotationAxisOf(tile); - rotationMult = getRotationMultiplier(getGantryAxis(), facing); + rotationMult = getRotationMultiplier(getGantryAxis(), facing); - visualPos = facing.getAxisDirection() == Direction.AxisDirection.POSITIVE ? tile.getBlockPos() - : tile.getBlockPos() - .relative(facing.getOpposite()); + visualPos = facing.getAxisDirection() == Direction.AxisDirection.POSITIVE ? tile.getBlockPos() + : tile.getBlockPos() + .relative(facing.getOpposite()); - animateCogs(getCogAngle()); - } + animateCogs(getCogAngle()); + } - @Override - public void beginFrame() { - float cogAngle = getCogAngle(); + @Override + public void beginFrame() { + float cogAngle = getCogAngle(); - if (Mth.equal(cogAngle, lastAngle)) return; + if (Mth.equal(cogAngle, lastAngle)) return; - animateCogs(cogAngle); - } + animateCogs(cogAngle); + } - private float getCogAngle() { - return GantryCarriageRenderer.getAngleForTe(tile, visualPos, rotationAxis) * rotationMult; - } + private float getCogAngle() { + return GantryCarriageRenderer.getAngleForTe(tile, visualPos, rotationAxis) * rotationMult; + } - private void animateCogs(float cogAngle) { - PoseStack ms = new PoseStack(); - MatrixTransformStack.of(ms) - .translate(getInstancePosition()) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) - .rotateY(alongFirst ^ facing.getAxis() == Direction.Axis.Z ? 90 : 0) - .translate(0, -9 / 16f, 0) - .multiply(Vector3f.XP.rotation(-cogAngle)) - .translate(0, 9 / 16f, 0) - .unCentre(); + private void animateCogs(float cogAngle) { + PoseStack ms = new PoseStack(); + MatrixTransformStack.of(ms) + .translate(getInstancePosition()) + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) + .rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) + .rotateY(alongFirst ^ facing.getAxis() == Direction.Axis.X ? 0 : 90) + .translate(0, -9 / 16f, 0) + .rotateX(-cogAngle) + .translate(0, 9 / 16f, 0) + .unCentre(); - gantryCogs.setTransform(ms); - } + gantryCogs.setTransform(ms); + } - static float getRotationMultiplier(Direction.Axis gantryAxis, Direction facing) { - float multiplier = 1; - if (gantryAxis == Direction.Axis.Z) - if (facing == Direction.DOWN) - multiplier *= -1; - if (gantryAxis == Direction.Axis.Y) - if (facing == Direction.NORTH || facing == Direction.EAST) - multiplier *= -1; + static float getRotationMultiplier(Direction.Axis gantryAxis, Direction facing) { + float multiplier = 1; + if (gantryAxis == Direction.Axis.X) + if (facing == Direction.UP) + multiplier *= -1; + if (gantryAxis == Direction.Axis.Y) + if (facing == Direction.NORTH || facing == Direction.EAST) + multiplier *= -1; - return multiplier; - } + return multiplier; + } - private Direction.Axis getGantryAxis() { - Direction.Axis gantryAxis = Direction.Axis.X; - for (Direction.Axis axis : Iterate.axes) - if (axis != rotationAxis && axis != facing.getAxis()) - gantryAxis = axis; - return gantryAxis; - } + private Direction.Axis getGantryAxis() { + Direction.Axis gantryAxis = Direction.Axis.X; + for (Direction.Axis axis : Iterate.axes) + if (axis != rotationAxis && axis != facing.getAxis()) + gantryAxis = axis; + return gantryAxis; + } - @Override - public void updateLight() { - relight(pos, gantryCogs, rotatingModel); - } + @Override + public void updateLight() { + relight(pos, gantryCogs, rotatingModel); + } - @Override - public void remove() { - super.remove(); - gantryCogs.delete(); - } + @Override + public void remove() { + super.remove(); + gantryCogs.delete(); + } } 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 b08996a15..d65f65cb4 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 @@ -2,11 +2,10 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ga import com.jozufozu.flywheel.backend.Backend; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; -import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -48,21 +47,21 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer { if (axis != rotationAxis && axis != facing.getAxis()) gantryAxis = axis; - if (gantryAxis == Axis.Z) - if (facing == Direction.DOWN) + if (gantryAxis == Axis.X) + if (facing == Direction.UP) angleForTe *= -1; if (gantryAxis == Axis.Y) if (facing == Direction.NORTH || facing == Direction.EAST) angleForTe *= -1; - SuperByteBuffer cogs = PartialBufferer.get(AllBlockPartials.GANTRY_COGS, state); + SuperByteBuffer cogs = CachedBufferer.partial(AllBlockPartials.GANTRY_COGS, state); cogs.matrixStacker() .centre() .rotateY(AngleHelper.horizontalAngle(facing)) .rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) - .rotateY(alongFirst ^ facing.getAxis() == Axis.Z ? 90 : 0) + .rotateY(alongFirst ^ facing.getAxis() == Axis.X ? 0 : 90) .translate(0, -9 / 16f, 0) - .multiply(Vector3f.XP.rotation(-angleForTe)) + .rotateX(-angleForTe) .translate(0, 9 / 16f, 0) .unCentre(); @@ -74,7 +73,7 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer { public static float getAngleForTe(KineticTileEntity te, final BlockPos pos, Axis axis) { float time = AnimationTickHolder.getRenderTime(te.getLevel()); float offset = getRotationOffsetForPosition(te, pos, axis); - return ((time * te.getSpeed() * 3f / 20 + offset) % 360) / 180 * (float) Math.PI; + return (time * te.getSpeed() * 3f / 20 + offset) % 360; } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java index 4bb0cf025..5d8564541 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/GlueInstance.java @@ -43,7 +43,7 @@ public class GlueInstance extends EntityInstance implements ITi Instancer instancer = getInstancer(materialManager, entity); Direction face = entity.getFacingDirection(); - rotation = new Quaternion(AngleHelper.verticalAngle(face), AngleHelper.horizontalAngleNew(face), 0, true); + rotation = new Quaternion(AngleHelper.verticalAngle(face), AngleHelper.horizontalAngle(face), 0, true); model = new ConditionalInstance<>(instancer) .withCondition(this::shouldShow) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueRenderer.java index 7fd4fd8bd..298486136 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueRenderer.java @@ -70,7 +70,7 @@ public class SuperGlueRenderer extends EntityRenderer { ms.pushPose(); MatrixTransformStack.of(ms) - .rotateY(AngleHelper.horizontalAngleNew(face)) + .rotateY(AngleHelper.horizontalAngle(face)) .rotateX(AngleHelper.verticalAngle(face)); Pose peek = ms.last(); 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 5b88c414c..f60c903ab 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,7 +7,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -61,8 +61,8 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { BlockState blockState = te.getBlockState(); BlockPos pos = te.getBlockPos(); - SuperByteBuffer halfMagnet = PartialBufferer.get(this.halfMagnet, blockState); - SuperByteBuffer halfRope = PartialBufferer.get(this.halfRope, blockState); + SuperByteBuffer halfMagnet = CachedBufferer.partial(this.halfMagnet, blockState); + SuperByteBuffer halfRope = CachedBufferer.partial(this.halfRope, blockState); SuperByteBuffer magnet = renderMagnet(te); SuperByteBuffer rope = renderRope(te); @@ -109,7 +109,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer { protected SuperByteBuffer getRotatedCoil(KineticTileEntity te) { BlockState blockState = te.getBlockState(); - return PartialBufferer.getFacing(getCoil(), blockState, + return CachedBufferer.partialFacing(getCoil(), blockState, Direction.get(AxisDirection.POSITIVE, getShaftAxis(te))); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java index 4461909be..91624fe30 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java @@ -8,7 +8,6 @@ import com.simibubi.create.foundation.block.ITE; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.core.Direction.Axis; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; @@ -24,7 +23,6 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition.Builder; import net.minecraft.world.level.block.state.properties.BlockStateProperties; -import net.minecraft.world.level.block.state.properties.EnumProperty; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.PushReaction; @@ -36,8 +34,6 @@ import net.minecraft.world.phys.shapes.VoxelShape; public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE { - public static EnumProperty HORIZONTAL_AXIS = BlockStateProperties.HORIZONTAL_AXIS; - public PulleyBlock(Properties properties) { super(properties); } 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 877c79d76..ce547d079 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 @@ -3,9 +3,9 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pu import com.jozufozu.flywheel.core.PartialModel; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlocks; -import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -31,12 +31,12 @@ public class PulleyRenderer extends AbstractPulleyRenderer { @Override protected SuperByteBuffer renderRope(KineticTileEntity te) { - return CreateClient.BUFFER_CACHE.renderBlock(AllBlocks.ROPE.getDefaultState()); + return CachedBufferer.block(AllBlocks.ROPE.getDefaultState()); } @Override protected SuperByteBuffer renderMagnet(KineticTileEntity te) { - return CreateClient.BUFFER_CACHE.renderBlock(AllBlocks.PULLEY_MAGNET.getDefaultState()); + return CachedBufferer.block(AllBlocks.PULLEY_MAGNET.getDefaultState()); } @Override 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 ab5961028..90df3034b 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 @@ -1,12 +1,10 @@ package com.simibubi.create.content.contraptions.components.structureMovement.render; -import static com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher.buildStructureBuffer; - import com.jozufozu.flywheel.event.RenderLayerEvent; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; -import com.simibubi.create.foundation.render.Compartment; import com.simibubi.create.foundation.render.SuperByteBuffer; +import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; @@ -14,7 +12,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.LevelAccessor; public class SBBContraptionManager extends ContraptionRenderManager { - public static final Compartment> CONTRAPTION = new Compartment<>(); + public static final SuperByteBufferCache.Compartment> CONTRAPTION = new SuperByteBufferCache.Compartment<>(); public SBBContraptionManager(LevelAccessor world) { super(world); @@ -45,7 +43,7 @@ public class SBBContraptionManager extends ContraptionRenderManager buildStructureBuffer(renderInfo.renderWorld, renderInfo.contraption, layer)); + SuperByteBuffer contraptionBuffer = CreateClient.BUFFER_CACHE.get(CONTRAPTION, Pair.of(renderInfo.contraption, layer), () -> ContraptionRenderDispatcher.buildStructureBuffer(renderInfo.renderWorld, renderInfo.contraption, layer)); if (!contraptionBuffer.isEmpty()) { ContraptionMatrices matrices = renderInfo.getMatrices(); 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 7e7a9a149..b58716450 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 @@ -10,7 +10,7 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.CreateClient; import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; -import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Color; @@ -66,9 +66,9 @@ public class CouplingRenderer { BlockState renderState = Blocks.AIR.defaultBlockState(); VertexConsumer builder = buffer.getBuffer(RenderType.solid()); - SuperByteBuffer attachment = PartialBufferer.get(AllBlockPartials.COUPLING_ATTACHMENT, renderState); - SuperByteBuffer ring = PartialBufferer.get(AllBlockPartials.COUPLING_RING, renderState); - SuperByteBuffer connector = PartialBufferer.get(AllBlockPartials.COUPLING_CONNECTOR, renderState); + SuperByteBuffer attachment = CachedBufferer.partial(AllBlockPartials.COUPLING_ATTACHMENT, renderState); + SuperByteBuffer ring = CachedBufferer.partial(AllBlockPartials.COUPLING_RING, renderState); + SuperByteBuffer connector = CachedBufferer.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/PumpRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/PumpRenderer.java index 68391015c..3ab5f528e 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,7 +5,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -35,7 +35,7 @@ public class PumpRenderer extends KineticTileEntityRenderer { float angle = Mth.lerp(pump.arrowDirection.getValue(partialTicks), 0, 90) - 90; for (float yRot : new float[] { 0, 90 }) { ms.pushPose(); - SuperByteBuffer arrow = PartialBufferer.get(AllBlockPartials.MECHANICAL_PUMP_ARROW, blockState); + SuperByteBuffer arrow = CachedBufferer.partial(AllBlockPartials.MECHANICAL_PUMP_ARROW, blockState); Direction direction = blockState.getValue(PumpBlock.FACING); MatrixTransformStack.of(ms) .centre() @@ -53,7 +53,7 @@ public class PumpRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return PartialBufferer.getFacing(AllBlockPartials.MECHANICAL_PUMP_COG, te.getBlockState()); + return CachedBufferer.partialFacing(AllBlockPartials.MECHANICAL_PUMP_COG, te.getBlockState()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/HosePulleyRenderer.java index 552e96172..5f14a97d9 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,7 +4,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -31,12 +31,12 @@ public class HosePulleyRenderer extends AbstractPulleyRenderer { @Override protected SuperByteBuffer renderRope(KineticTileEntity te) { - return PartialBufferer.get(AllBlockPartials.HOSE, te.getBlockState()); + return CachedBufferer.partial(AllBlockPartials.HOSE, te.getBlockState()); } @Override protected SuperByteBuffer renderMagnet(KineticTileEntity te) { - return PartialBufferer.get(AllBlockPartials.HOSE_MAGNET, te.getBlockState()); + return CachedBufferer.partial(AllBlockPartials.HOSE_MAGNET, te.getBlockState()); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/ItemDrainRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/ItemDrainRenderer.java index d0b7d2a21..a727f6ace 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/ItemDrainRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/actors/ItemDrainRenderer.java @@ -149,7 +149,7 @@ public class ItemDrainRenderer extends SmartTileEntityRenderer { float yOffset = (11 / 16f) * level; ms.pushPose(); ms.translate(0, yOffset, 0); - FluidRenderer.renderTiledFluidBB(fluidStack, min, min - yOffset, min, max, min, max, buffer, ms, light, + FluidRenderer.renderFluidBox(fluidStack, min, min - yOffset, min, max, min, max, buffer, ms, light, false); ms.popPose(); } @@ -58,7 +58,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer { if (processingTicks != -1) { radius = (float) (Math.pow(((2 * processingProgress) - 1), 2) - 1); AABB bb = new AABB(0.5, .5, 0.5, 0.5, -1.2, 0.5).inflate(radius / 32f); - FluidRenderer.renderTiledFluidBB(fluidStack, (float) bb.minX, (float) bb.minY, (float) bb.minZ, + FluidRenderer.renderFluidBox(fluidStack, (float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ, buffer, ms, light, true); } @@ -72,7 +72,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer { ms.pushPose(); for (PartialModel bit : BITS) { - PartialBufferer.get(bit, te.getBlockState()) + CachedBufferer.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/pipes/FluidValveInstance.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidValveInstance.java index 40130bf8a..ad63cec1b 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 @@ -35,7 +35,7 @@ public class FluidValveInstance extends ShaftInstance implements IDynamicInstanc Direction.Axis pipeAxis = FluidValveBlock.getPipeAxis(blockState); Direction.Axis shaftAxis = KineticTileEntityRenderer.getRotationAxisOf(tile); - boolean twist = pipeAxis.isHorizontal() && shaftAxis == Direction.Axis.Z || pipeAxis.isVertical(); + boolean twist = pipeAxis.isHorizontal() && shaftAxis == Direction.Axis.X || pipeAxis.isVertical(); pointerRotationOffset = twist ? 90 : 0; pointer = materialManager.defaultSolid() 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 351c5eedd..c5c309bf4 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 @@ -6,7 +6,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -32,7 +32,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); BlockState blockState = te.getBlockState(); - SuperByteBuffer pointer = PartialBufferer.get(AllBlockPartials.FLUID_VALVE_POINTER, blockState); + SuperByteBuffer pointer = CachedBufferer.partial(AllBlockPartials.FLUID_VALVE_POINTER, blockState); Direction facing = blockState.getValue(FluidValveBlock.FACING); if (!(te instanceof FluidValveTileEntity)) @@ -43,7 +43,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer { Axis shaftAxis = KineticTileEntityRenderer.getRotationAxisOf(te); int pointerRotationOffset = 0; - if (pipeAxis.isHorizontal() && shaftAxis == Axis.Z || pipeAxis.isVertical()) + if (pipeAxis.isHorizontal() && shaftAxis == Axis.X || pipeAxis.isVertical()) pointerRotationOffset = 90; MatrixTransformStack.of(ms) 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 52aae668b..a8311a3c4 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 @@ -63,7 +63,7 @@ public class FluidTankRenderer extends SafeTileEntityRenderer { float partial = Mth.clamp(units / totalUnits, 0, 1); xMax += partial * 12 / 16f; - FluidRenderer.renderTiledFluidBB(renderedFluid, xMin, yMin, zMin, xMax, yMax, zMax, buffer, ms, light, + FluidRenderer.renderFluidBox(renderedFluid, xMin, yMin, zMin, xMax, yMax, zMax, buffer, ms, light, false); xMin = xMax; diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java index 48792eec6..c27cf7bea 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/burner/BlazeBurnerRenderer.java @@ -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.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel; -import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -33,7 +33,7 @@ public class BlazeBurnerRenderer extends SafeTileEntityRenderer { PartialModel beltPartial = getBeltPartial(diagonal, start, end, bottom); - SuperByteBuffer beltBuffer = PartialBufferer.get(beltPartial, blockState) + SuperByteBuffer beltBuffer = CachedBufferer.partial(beltPartial, blockState) .light(light); SpriteShiftEntry spriteShift = getSpriteShiftEntry(color, diagonal, bottom); @@ -142,7 +141,7 @@ public class BeltRenderer extends SafeTileEntityRenderer { return stack; }; - SuperByteBuffer superBuffer = CreateClient.BUFFER_CACHE.renderDirectionalPartial(AllBlockPartials.BELT_PULLEY, blockState, dir, matrixStackSupplier); + SuperByteBuffer superBuffer = CachedBufferer.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/elementary/BracketedKineticTileRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/elementary/BracketedKineticTileRenderer.java index 675249471..f8f5754a1 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,7 +6,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -45,7 +45,7 @@ public class BracketedKineticTileRenderer extends KineticTileEntityRenderer { Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE); renderRotatingBuffer(te, - PartialBufferer.getFacingVertical(AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL, te.getBlockState(), facing), + CachedBufferer.partialFacingVertical(AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL, te.getBlockState(), facing), ms, buffer.getBuffer(RenderType.solid()), light); float offset = getShaftAngleOffset(axis, pos); @@ -53,7 +53,7 @@ public class BracketedKineticTileRenderer extends KineticTileEntityRenderer { float angle = ((time * te.getSpeed() * 3f / 10 + offset) % 360) / 180 * (float) Math.PI; SuperByteBuffer shaft = - PartialBufferer.getFacingVertical(AllBlockPartials.COGWHEEL_SHAFT, te.getBlockState(), facing); + CachedBufferer.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/ShaftlessCogRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ShaftlessCogRenderer.java index c82b5f669..158945ebd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ShaftlessCogRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/ShaftlessCogRenderer.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.relays.encased; import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; -import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; @@ -29,7 +29,7 @@ public class ShaftlessCogRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return PartialBufferer.getFacingVertical( + return CachedBufferer.partialFacingVertical( large ? AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL : AllBlockPartials.SHAFTLESS_COGWHEEL, te.getBlockState(), Direction.fromAxisAndDirection(te.getBlockState() .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 82362fb9d..dd7dce660 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,7 +6,7 @@ import com.simibubi.create.AllBlockPartials; import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; -import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Iterate; @@ -52,7 +52,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer { angle = angle / 180f * (float) Math.PI; SuperByteBuffer superByteBuffer = - PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction); + CachedBufferer.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 4a83e994e..ce495f0bd 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,7 +8,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.Iterate; @@ -48,8 +48,8 @@ public class GaugeRenderer extends KineticTileEntityRenderer { PartialModel partialModel = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS); SuperByteBuffer headBuffer = - PartialBufferer.get(partialModel, gaugeState); - SuperByteBuffer dialBuffer = PartialBufferer.get(AllBlockPartials.GAUGE_DIAL, gaugeState); + CachedBufferer.partial(partialModel, gaugeState); + SuperByteBuffer dialBuffer = CachedBufferer.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 ee29235ee..56194ec81 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,7 +5,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Iterate; @@ -38,7 +38,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer { if (boxAxis == axis) continue; - SuperByteBuffer shaft = PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction); + SuperByteBuffer shaft = CachedBufferer.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/curiosities/armor/CopperBacktankArmorLayer.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankArmorLayer.java index 94ff87ca7..743e250e6 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 @@ -5,8 +5,8 @@ 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.CreateClient; import com.simibubi.create.foundation.gui.element.GuiGameElement; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AnimationTickHolder; @@ -58,9 +58,8 @@ public class CopperBacktankArmorLayer extends SafeTileEnt Direction facing = state.getValue(BellBlock.FACING); BellAttachType attachment = state.getValue(BellBlock.ATTACHMENT); - SuperByteBuffer bell = PartialBufferer.get(te.getBellModel(), state); + SuperByteBuffer bell = CachedBufferer.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/toolbox/ToolboxRenderer.java b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxRenderer.java index 3eb77e3e7..5eec0a1bd 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxRenderer.java +++ b/src/main/java/com/simibubi/create/content/curiosities/toolbox/ToolboxRenderer.java @@ -3,7 +3,7 @@ package com.simibubi.create.content.curiosities.toolbox; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import com.simibubi.create.foundation.utility.Iterate; @@ -28,8 +28,8 @@ public class ToolboxRenderer extends SmartTileEntityRenderer Direction facing = blockState.getValue(ToolboxBlock.FACING) .getOpposite(); SuperByteBuffer lid = - PartialBufferer.get(AllBlockPartials.TOOLBOX_LIDS.get(tileEntityIn.getColor()), blockState); - SuperByteBuffer drawer = PartialBufferer.get(AllBlockPartials.TOOLBOX_DRAWER, blockState); + CachedBufferer.partial(AllBlockPartials.TOOLBOX_LIDS.get(tileEntityIn.getColor()), blockState); + SuperByteBuffer drawer = CachedBufferer.partial(AllBlockPartials.TOOLBOX_DRAWER, blockState); float lidAngle = tileEntityIn.lid.getValue(partialTicks); float drawerOffset = tileEntityIn.drawers.getValue(partialTicks); 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 11f5589b6..2597b3faa 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,7 +6,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.Couple; @@ -33,7 +33,7 @@ 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 = PartialBufferer.get(partialModel, Blocks.AIR.defaultBlockState()); + SuperByteBuffer sbb = CachedBufferer.partial(partialModel, Blocks.AIR.defaultBlockState()); sbb.matrixStacker() .rotateY(-yaw) .rotateX(90.0F + entity.getXRot()) 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 2ed3866f0..c86378987 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,7 +5,7 @@ import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllBlockPartials; -import com.simibubi.create.foundation.render.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -33,7 +33,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer { VertexConsumer vb = buffer.getBuffer(RenderType.solid()); PartialModel partialModel = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP : AllBlockPartials.BELT_FUNNEL_FLAP); - SuperByteBuffer flapBuffer = PartialBufferer.get(partialModel, blockState); + SuperByteBuffer flapBuffer = CachedBufferer.partial(partialModel, blockState); Vec3 pivot = VecHelper.voxelSpace(0, 10, 9.5f); MatrixTransformStack msr = MatrixTransformStack.of(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 26d0b3a22..bbea65714 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,7 +8,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.Color; @@ -110,12 +110,12 @@ public class ArmRenderer extends KineticTileEntityRenderer { } private void renderArm(VertexConsumer builder, PoseStack ms, PoseStack msLocal, MatrixTransformStack msr, BlockState blockState, int color, float baseAngle, float lowerArmAngle, float upperArmAngle, float headAngle, boolean hasItem, boolean isBlockItem, int light) { - SuperByteBuffer base = PartialBufferer.get(AllBlockPartials.ARM_BASE, blockState).light(light); - SuperByteBuffer lowerBody = PartialBufferer.get(AllBlockPartials.ARM_LOWER_BODY, blockState).light(light); - SuperByteBuffer upperBody = PartialBufferer.get(AllBlockPartials.ARM_UPPER_BODY, blockState).light(light); - SuperByteBuffer head = PartialBufferer.get(AllBlockPartials.ARM_HEAD, blockState).light(light); - SuperByteBuffer claw = PartialBufferer.get(AllBlockPartials.ARM_CLAW_BASE, blockState).light(light); - SuperByteBuffer clawGrip = PartialBufferer.get(AllBlockPartials.ARM_CLAW_GRIP, blockState); + SuperByteBuffer base = CachedBufferer.partial(AllBlockPartials.ARM_BASE, blockState).light(light); + SuperByteBuffer lowerBody = CachedBufferer.partial(AllBlockPartials.ARM_LOWER_BODY, blockState).light(light); + SuperByteBuffer upperBody = CachedBufferer.partial(AllBlockPartials.ARM_UPPER_BODY, blockState).light(light); + SuperByteBuffer head = CachedBufferer.partial(AllBlockPartials.ARM_HEAD, blockState).light(light); + SuperByteBuffer claw = CachedBufferer.partial(AllBlockPartials.ARM_CLAW_BASE, blockState).light(light); + SuperByteBuffer clawGrip = CachedBufferer.partial(AllBlockPartials.ARM_CLAW_GRIP, blockState); transformBase(msr, baseAngle); base.transform(msLocal) @@ -188,7 +188,7 @@ public class ArmRenderer extends KineticTileEntityRenderer { @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return PartialBufferer.get(AllBlockPartials.ARM_COG, te.getBlockState()); + return CachedBufferer.partial(AllBlockPartials.ARM_COG, te.getBlockState()); } } 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 e8e92c852..ac9e62acb 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 @@ -527,7 +527,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE private class SelectionModeValueBox extends CenteredSideValueBoxTransform { public SelectionModeValueBox() { - super((blockState, direction) -> direction != Direction.DOWN && direction != Direction.UP); + super((blockState, direction) -> !direction.getAxis().isVertical()); } @Override 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 114f25794..481e3dda7 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,7 +4,7 @@ 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.PartialBufferer; +import com.simibubi.create.foundation.render.CachedBufferer; import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.utility.AngleHelper; @@ -34,7 +34,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer> DOC_WORLD_SECTION = new Compartment<>(); + public static final SuperByteBufferCache.Compartment> DOC_WORLD_SECTION = new SuperByteBufferCache.Compartment<>(); List renderedTileEntities; List>> tickableTileEntities; @@ -396,12 +393,11 @@ public class WorldSectionElement extends AnimatedSceneElement { private SuperByteBuffer buildStructureBuffer(PonderWorld world, RenderType layer) { ForgeHooksClient.setRenderLayer(layer); - PoseStack ms = new PoseStack(); BlockRenderDispatcher dispatcher = Minecraft.getInstance() .getBlockRenderer(); - ModelBlockRenderer blockRenderer = dispatcher.getModelRenderer(); + PoseStack ms = new PoseStack(); Random random = new Random(); - BufferBuilder builder = new BufferBuilder(DefaultVertexFormat.BLOCK.getIntegerSize()); + BufferBuilder builder = new BufferBuilder(512); builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); world.setMask(this.section); @@ -412,8 +408,7 @@ public class WorldSectionElement extends AnimatedSceneElement { ms.pushPose(); ms.translate(pos.getX(), pos.getY(), pos.getZ()); - if (state.getRenderShape() != RenderShape.ENTITYBLOCK_ANIMATED && state.getBlock() != Blocks.AIR - && ItemBlockRenderTypes.canRenderInLayer(state, layer)) { + if (state.getRenderShape() == RenderShape.MODEL && ItemBlockRenderTypes.canRenderInLayer(state, layer)) { BlockEntity tileEntity = world.getBlockEntity(pos); dispatcher.renderBatched(state, pos, world, ms, builder, true, random, tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE); diff --git a/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java b/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java new file mode 100644 index 000000000..fe859a516 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/BakedModelRenderHelper.java @@ -0,0 +1,50 @@ +package com.simibubi.create.foundation.render; + +import java.util.Random; + +import com.jozufozu.flywheel.util.VirtualEmptyModelData; +import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.DefaultVertexFormat; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexFormat; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import net.minecraft.client.renderer.block.ModelBlockRenderer; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.BlockPos; +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 = getBufferBuilder(model, referenceState, ms); + + return new SuperByteBuffer(builder); + } + + public static BufferBuilder getBufferBuilder(BakedModel model, BlockState referenceState, PoseStack ms) { + Minecraft mc = Minecraft.getInstance(); + BlockRenderDispatcher dispatcher = mc.getBlockRenderer(); + ModelBlockRenderer blockRenderer = dispatcher.getModelRenderer(); + BufferBuilder builder = new BufferBuilder(512); + + builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); + blockRenderer.tesselateBlock(mc.level, model, referenceState, BlockPos.ZERO.above(255), ms, builder, true, + new Random(), 42, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); + builder.end(); + return builder; + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/render/CachedBufferer.java b/src/main/java/com/simibubi/create/foundation/render/CachedBufferer.java new file mode 100644 index 000000000..fe0243b4d --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/render/CachedBufferer.java @@ -0,0 +1,89 @@ +package com.simibubi.create.foundation.render; + +import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING; + +import java.util.function.Supplier; + +import org.apache.commons.lang3.tuple.Pair; + +import com.jozufozu.flywheel.core.PartialModel; +import com.jozufozu.flywheel.util.transform.MatrixTransformStack; +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.CreateClient; +import com.simibubi.create.foundation.render.SuperByteBufferCache.Compartment; +import com.simibubi.create.foundation.utility.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 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)); + } + + public static SuperByteBuffer partial(PartialModel partial, BlockState referenceState, + Supplier modelTransform) { + return CreateClient.BUFFER_CACHE.get(PARTIAL, partial, + () -> BakedModelRenderHelper.standardModelRender(partial.get(), referenceState, modelTransform.get())); + } + + public static SuperByteBuffer partialFacing(PartialModel partial, BlockState referenceState) { + Direction facing = referenceState.getValue(FACING); + return partialFacing(partial, referenceState, facing); + } + + public static SuperByteBuffer partialFacing(PartialModel partial, BlockState referenceState, Direction facing) { + return partialDirectional(partial, referenceState, facing, + rotateToFace(facing)); + } + + public static SuperByteBuffer partialFacingVertical(PartialModel partial, BlockState referenceState, Direction facing) { + return partialDirectional(partial, referenceState, facing, + rotateToFaceVertical(facing)); + } + + 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())); + } + + public static Supplier rotateToFace(Direction facing) { + return () -> { + PoseStack stack = new PoseStack(); + MatrixTransformStack.of(stack) + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) + .rotateX(AngleHelper.verticalAngle(facing)) + .unCentre(); + return stack; + }; + } + + public static Supplier rotateToFaceVertical(Direction facing) { + return () -> { + PoseStack stack = new PoseStack(); + MatrixTransformStack.of(stack) + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) + .rotateX(AngleHelper.verticalAngle(facing) + 90) + .unCentre(); + return stack; + }; + } + +} diff --git a/src/main/java/com/simibubi/create/foundation/render/Compartment.java b/src/main/java/com/simibubi/create/foundation/render/Compartment.java deleted file mode 100644 index d0b3bd8ff..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/Compartment.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.simibubi.create.foundation.render; - -import org.apache.commons.lang3.tuple.Pair; - -import com.jozufozu.flywheel.core.PartialModel; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.BlockState; - -public class Compartment { - public static final Compartment GENERIC_TILE = new Compartment<>(); - public static final Compartment PARTIAL = new Compartment<>(); - public static final Compartment> DIRECTIONAL_PARTIAL = new Compartment<>(); -} diff --git a/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java b/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java deleted file mode 100644 index de2e3e718..000000000 --- a/src/main/java/com/simibubi/create/foundation/render/PartialBufferer.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.simibubi.create.foundation.render; - -import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING; - -import java.util.function.Supplier; - -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.transform.MatrixTransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.CreateClient; -import com.simibubi.create.foundation.utility.AngleHelper; - -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.BlockState; - -public class PartialBufferer { - - public static SuperByteBuffer get(PartialModel partial, BlockState referenceState) { - return CreateClient.BUFFER_CACHE.renderPartial(partial, referenceState); - } - - public static SuperByteBuffer getFacing(PartialModel partial, BlockState referenceState) { - Direction facing = referenceState.getValue(FACING); - return getFacing(partial, referenceState, facing); - } - - public static SuperByteBuffer getFacing(PartialModel partial, BlockState referenceState, Direction facing) { - return CreateClient.BUFFER_CACHE.renderDirectionalPartial(partial, referenceState, facing, - rotateToFace(facing)); - } - - public static SuperByteBuffer getFacingVertical(PartialModel partial, BlockState referenceState, Direction facing) { - return CreateClient.BUFFER_CACHE.renderDirectionalPartial(partial, referenceState, facing, - rotateToFaceVertical(facing)); - } - - public static Supplier rotateToFace(Direction facing) { - return () -> { - PoseStack stack = new PoseStack(); - MatrixTransformStack.of(stack) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing)) - .unCentre(); - return stack; - }; - } - - public static Supplier rotateToFaceVertical(Direction facing) { - return () -> { - PoseStack stack = new PoseStack(); - MatrixTransformStack.of(stack) - .centre() - .rotateY(AngleHelper.horizontalAngle(facing)) - .rotateX(AngleHelper.verticalAngle(facing) + 90) - .unCentre(); - return stack; - }; - } - -} diff --git a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java index 850170019..f11ea9b94 100644 --- a/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java +++ b/src/main/java/com/simibubi/create/foundation/render/SuperByteBufferCache.java @@ -2,136 +2,53 @@ 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 java.util.function.Supplier; - -import org.apache.commons.lang3.tuple.Pair; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import com.jozufozu.flywheel.core.PartialModel; -import com.jozufozu.flywheel.util.VirtualEmptyModelData; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexFormat; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; -import net.minecraft.client.renderer.block.ModelBlockRenderer; -import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.block.state.BlockState; public class SuperByteBufferCache { - private Map, Cache> cache; + protected final Map, Cache> caches = new HashMap<>(); - public SuperByteBufferCache() { - cache = new HashMap<>(); - registerCompartment(Compartment.GENERIC_TILE); - registerCompartment(Compartment.PARTIAL); - registerCompartment(Compartment.DIRECTIONAL_PARTIAL); + public synchronized void registerCompartment(Compartment compartment) { + caches.put(compartment, CacheBuilder.newBuilder() + .build()); } - public SuperByteBuffer renderBlock(BlockState toRender) { - return getGeneric(toRender, () -> standardBlockRender(toRender)); + public synchronized void registerCompartment(Compartment compartment, long ticksUntilExpired) { + caches.put(compartment, CacheBuilder.newBuilder() + .expireAfterAccess(ticksUntilExpired * 50, TimeUnit.MILLISECONDS) + .build()); } - public SuperByteBuffer renderPartial(PartialModel partial, BlockState referenceState) { - return get(Compartment.PARTIAL, partial, () -> standardModelRender(partial.get(), referenceState)); - } - - public SuperByteBuffer renderPartial(PartialModel partial, BlockState referenceState, - Supplier modelTransform) { - return get(Compartment.PARTIAL, partial, - () -> standardModelRender(partial.get(), referenceState, modelTransform.get())); - } - - public SuperByteBuffer renderDirectionalPartial(PartialModel partial, BlockState referenceState, - Direction dir) { - return get(Compartment.DIRECTIONAL_PARTIAL, Pair.of(dir, partial), - () -> standardModelRender(partial.get(), referenceState)); - } - - public SuperByteBuffer renderDirectionalPartial(PartialModel partial, BlockState referenceState, Direction dir, - Supplier modelTransform) { - return get(Compartment.DIRECTIONAL_PARTIAL, Pair.of(dir, partial), - () -> standardModelRender(partial.get(), referenceState, modelTransform.get())); - } - - public SuperByteBuffer renderBlockIn(Compartment compartment, BlockState toRender) { - return get(compartment, toRender, () -> standardBlockRender(toRender)); - } - - SuperByteBuffer getGeneric(BlockState key, Supplier supplier) { - return get(Compartment.GENERIC_TILE, key, supplier); - } - - public SuperByteBuffer get(Compartment compartment, T key, Supplier supplier) { - Cache compartmentCache = this.cache.get(compartment); - try { - return compartmentCache.get(key, supplier::get); - } catch (ExecutionException e) { - e.printStackTrace(); - return null; + 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) { - Cache compartmentCache = this.cache.get(compartment); - compartmentCache.invalidate(key); + caches.get(compartment).invalidate(key); } - public void registerCompartment(Compartment instance) { - synchronized (cache) { - cache.put(instance, CacheBuilder.newBuilder() - .build()); - } - } - - public void registerCompartment(Compartment instance, long ticksUntilExpired) { - synchronized (cache) { - cache.put(instance, CacheBuilder.newBuilder() - .expireAfterAccess(ticksUntilExpired * 50, TimeUnit.MILLISECONDS) - .build()); - } - } - - private SuperByteBuffer standardBlockRender(BlockState renderedState) { - BlockRenderDispatcher dispatcher = Minecraft.getInstance() - .getBlockRenderer(); - return standardModelRender(dispatcher.getBlockModel(renderedState), renderedState); - } - - private SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState) { - return standardModelRender(model, referenceState, new PoseStack()); - } - - private SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState, PoseStack ms) { - BufferBuilder builder = getBufferBuilder(model, referenceState, ms); - - return new SuperByteBuffer(builder); - } - - public static BufferBuilder getBufferBuilder(BakedModel model, BlockState referenceState, PoseStack ms) { - Minecraft mc = Minecraft.getInstance(); - BlockRenderDispatcher dispatcher = mc.getBlockRenderer(); - ModelBlockRenderer blockRenderer = dispatcher.getModelRenderer(); - BufferBuilder builder = new BufferBuilder(512); - - builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); - blockRenderer.tesselateBlock(mc.level, model, referenceState, BlockPos.ZERO.above(255), ms, builder, true, - mc.level.random, 42, OverlayTexture.NO_OVERLAY, VirtualEmptyModelData.INSTANCE); - builder.end(); - return builder; + public void invalidate(Compartment compartment) { + caches.get(compartment).invalidateAll(); } public void invalidate() { - cache.forEach((comp, cache) -> cache.invalidateAll()); + caches.forEach((compartment, cache) -> cache.invalidateAll()); + } + + public static class Compartment { } } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBoxTransform.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBoxTransform.java index f9ebdec95..cc8197e9a 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBoxTransform.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/ValueBoxTransform.java @@ -99,7 +99,7 @@ public abstract class ValueBoxTransform { protected Vec3 getLocalOffset(BlockState state) { Vec3 location = getSouthLocation(); location = VecHelper.rotateCentered(location, AngleHelper.horizontalAngle(getSide()), Axis.Y); - location = VecHelper.rotateCentered(location, AngleHelper.verticalAngle(getSide()), Axis.Z); + location = VecHelper.rotateCentered(location, AngleHelper.verticalAngle(getSide()), Axis.X); return location; } diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueHandler.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueHandler.java index ef5bec5cd..f3b4d0824 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueHandler.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/scrollvalue/ScrollValueHandler.java @@ -30,12 +30,12 @@ public class ScrollValueHandler { @OnlyIn(Dist.CLIENT) public static boolean onScroll(double delta) { - HitResult objectMouseOver = Minecraft.getInstance().hitResult; + Minecraft mc = Minecraft.getInstance(); + HitResult objectMouseOver = mc.hitResult; if (!(objectMouseOver instanceof BlockHitResult)) return false; BlockHitResult result = (BlockHitResult) objectMouseOver; - Minecraft mc = Minecraft.getInstance(); ClientLevel world = mc.level; BlockPos blockPos = result.getBlockPos(); @@ -46,13 +46,13 @@ public class ScrollValueHandler { return false; if (!mc.player.mayBuild()) return false; + if (scrolling.needsWrench && !AllItems.WRENCH.isIn(mc.player.getMainHandItem())) + return false; passiveScrollDirection = (float) -delta; wrenchCog.bump(3, -delta * 10); int prev = scrolling.scrollableValue; - if (scrolling.needsWrench && !AllItems.WRENCH.isIn(mc.player.getMainHandItem())) - return false; if (scrolling.slotPositioning instanceof Sided) ((Sided) scrolling.slotPositioning).fromSide(result.getDirection()); if (!scrolling.testHit(objectMouseOver.getLocation())) diff --git a/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java b/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java index 33d007d79..9a3e2a393 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/AngleHelper.java @@ -5,23 +5,9 @@ import net.minecraft.core.Direction.Axis; public class AngleHelper { - /** - * Legacy method. See {@link #horizontalAngleNew(Direction)} for new method. - */ public static float horizontalAngle(Direction facing) { - float angle = facing.toYRot(); - if (facing.getAxis() == Axis.X) - angle = -angle; - return angle; - } - - /** - * Same as {@link #horizontalAngle(Direction)}, but returns 0 instead of -90 for vertical directions. - */ - public static float horizontalAngleNew(Direction facing) { - if (facing.getAxis().isVertical()) { + if (facing.getAxis().isVertical()) return 0; - } float angle = facing.toYRot(); if (facing.getAxis() == Axis.X) angle = -angle; diff --git a/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java b/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java index 76df3e755..fadea7379 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java +++ b/src/main/java/com/simibubi/create/foundation/utility/ISimpleReloadListener.java @@ -8,6 +8,7 @@ import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.util.Unit; import net.minecraft.util.profiling.ProfilerFiller; +// TODO 1.18: remove and replace all usages with ResourceManagerReloadListener @FunctionalInterface public interface ISimpleReloadListener extends PreparableReloadListener { diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java index ab27c0ce9..fb914f2cb 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/BlockClusterOutline.java @@ -11,6 +11,7 @@ import com.mojang.blaze3d.vertex.VertexConsumer; import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.foundation.render.RenderTypes; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; +import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.client.renderer.RenderType; @@ -31,23 +32,12 @@ public class BlockClusterOutline extends Outline { @Override public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) { - for (MergeEntry edge : cluster.visibleEdges) { + cluster.visibleEdges.forEach(edge -> { Vec3 start = Vec3.atLowerCornerOf(edge.pos); Direction direction = Direction.get(AxisDirection.POSITIVE, edge.axis); renderAACuboidLine(ms, buffer, start, Vec3.atLowerCornerOf(edge.pos.relative(direction))); - } + }); - for (MergeEntry face : cluster.visibleFaces.keySet()) { - AxisDirection axisDirection = cluster.visibleFaces.get(face); - Direction direction = Direction.get(axisDirection, face.axis); - BlockPos pos = face.pos; - if (axisDirection == AxisDirection.POSITIVE) - pos = pos.relative(direction.getOpposite()); - renderBlockFace(ms, buffer, pos, direction); - } - } - - protected void renderBlockFace(PoseStack ms, SuperRenderTypeBuffer buffer, BlockPos pos, Direction face) { Optional faceTexture = params.faceTexture; if (!faceTexture.isPresent()) return; @@ -56,12 +46,22 @@ public class BlockClusterOutline extends Outline { .getLocation(), true); VertexConsumer builder = buffer.getLateBuffer(translucentType); + cluster.visibleFaces.forEach((face, axisDirection) -> { + Direction direction = Direction.get(axisDirection, face.axis); + BlockPos pos = face.pos; + if (axisDirection == AxisDirection.POSITIVE) + pos = pos.relative(direction.getOpposite()); + renderBlockFace(ms, builder, pos, direction); + }); + } + + protected void renderBlockFace(PoseStack ms, VertexConsumer builder, BlockPos pos, Direction face) { Vec3 center = VecHelper.getCenterOf(pos); Vec3 offset = Vec3.atLowerCornerOf(face.getNormal()); Vec3 plane = VecHelper.axisAlingedPlaneOf(offset); Axis axis = face.getAxis(); - offset = offset.scale(1 / 2f + 1 / 64d); + offset = offset.scale(1 / 2f + 1 / 128d); plane = plane.scale(1 / 2f) .add(offset); @@ -80,8 +80,8 @@ public class BlockClusterOutline extends Outline { private static class Cluster { - Map visibleFaces; - Set visibleEdges; + private Map visibleFaces; + private Set visibleEdges; public Cluster() { visibleEdges = new HashSet<>(); @@ -91,9 +91,9 @@ public class BlockClusterOutline extends Outline { public void include(BlockPos pos) { // 6 FACES - for (Axis axis : Axis.values()) { + for (Axis axis : Iterate.axes) { Direction direction = Direction.get(AxisDirection.POSITIVE, axis); - for (int offset : new int[] { 0, 1 }) { + for (int offset : Iterate.zeroAndOne) { MergeEntry entry = new MergeEntry(axis, pos.relative(direction, offset)); if (visibleFaces.remove(entry) == null) visibleFaces.put(entry, offset == 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE); @@ -101,11 +101,11 @@ public class BlockClusterOutline extends Outline { } // 12 EDGES - for (Axis axis : Axis.values()) { - for (Axis axis2 : Axis.values()) { + for (Axis axis : Iterate.axes) { + for (Axis axis2 : Iterate.axes) { if (axis == axis2) continue; - for (Axis axis3 : Axis.values()) { + for (Axis axis3 : Iterate.axes) { if (axis == axis3) continue; if (axis2 == axis3) @@ -114,9 +114,9 @@ public class BlockClusterOutline extends Outline { Direction direction = Direction.get(AxisDirection.POSITIVE, axis2); Direction direction2 = Direction.get(AxisDirection.POSITIVE, axis3); - for (int offset : new int[] { 0, 1 }) { + for (int offset : Iterate.zeroAndOne) { BlockPos entryPos = pos.relative(direction, offset); - for (int offset2 : new int[] { 0, 1 }) { + for (int offset2 : Iterate.zeroAndOne) { entryPos = entryPos.relative(direction2, offset2); MergeEntry entry = new MergeEntry(axis, entryPos); if (!visibleEdges.remove(entry)) @@ -135,8 +135,8 @@ public class BlockClusterOutline extends Outline { private static class MergeEntry { - Axis axis; - BlockPos pos; + private Axis axis; + private BlockPos pos; public MergeEntry(Axis axis, BlockPos pos) { this.axis = axis; diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java index 12713bda4..33e73072c 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outline.java @@ -6,7 +6,6 @@ import javax.annotation.Nullable; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.PoseStack.Pose; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Matrix3f; import com.simibubi.create.AllSpecialTextures; @@ -16,6 +15,7 @@ import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.VecHelper; +import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.core.Direction; import net.minecraft.core.Direction.Axis; @@ -25,7 +25,7 @@ import net.minecraft.world.phys.Vec3; public abstract class Outline { protected OutlineParams params; - protected Matrix3f transformNormals; + protected Matrix3f transformNormals; // TODO: not used? public Outline() { params = new OutlineParams(); @@ -33,6 +33,12 @@ public abstract class Outline { public abstract void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt); + public void tick() {} + + public OutlineParams getParams() { + return params; + } + public void renderCuboidLine(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 start, Vec3 end) { Vec3 diff = end.subtract(start); float hAngle = AngleHelper.deg(Mth.atan2(diff.x, diff.z)); @@ -125,13 +131,13 @@ public abstract class Outline { } protected void putVertex(PoseStack ms, VertexConsumer builder, Vec3 pos, float u, float v, Direction normal) { - int i = 15 << 20 | 15 << 4; - int j = i >> 16 & '\uffff'; - int k = i & '\uffff'; - Pose peek = ms.last(); + putVertex(ms.last(), builder, (float) pos.x, (float) pos.y, (float) pos.z, u, v, normal); + } + + protected void putVertex(PoseStack.Pose pose, VertexConsumer builder, float x, float y, float z, float u, float v, Direction normal) { Color rgb = params.rgb; if (transformNormals == null) - transformNormals = peek.normal(); + transformNormals = pose.normal(); int xOffset = 0; int yOffset = 0; @@ -143,23 +149,17 @@ public abstract class Outline { zOffset = normal.getStepZ(); } - builder.vertex(peek.pose(), (float) pos.x, (float) pos.y, (float) pos.z) + builder.vertex(pose.pose(), x, y, z) .color(rgb.getRedAsFloat(), rgb.getGreenAsFloat(), rgb.getBlueAsFloat(), rgb.getAlphaAsFloat() * params.alpha) .uv(u, v) .overlayCoords(OverlayTexture.NO_OVERLAY) - .uv2(j, k) - .normal(peek.normal(), xOffset, yOffset, zOffset) + .uv2(params.lightMap) + .normal(pose.normal(), xOffset, yOffset, zOffset) .endVertex(); transformNormals = null; } - public void tick() {} - - public OutlineParams getParams() { - return params; - } - public static class OutlineParams { protected Optional faceTexture; protected Optional hightlightedFaceTexture; @@ -168,7 +168,7 @@ public abstract class Outline { protected boolean disableCull; protected boolean disableNormals; protected float alpha; - protected int lightMapU, lightMapV; + protected int lightMap; protected Color rgb; private float lineWidth; @@ -178,10 +178,7 @@ public abstract class Outline { lineWidth = 1 / 32f; fadeLineWidth = true; rgb = Color.WHITE; - - int i = 15 << 20 | 15 << 4; - lightMapU = i >> 16 & '\uffff'; - lightMapV = i & '\uffff'; + lightMap = LightTexture.FULL_BRIGHT; } // builder @@ -196,6 +193,11 @@ public abstract class Outline { return this; } + public OutlineParams lightMap(int light) { + lightMap = light; + return this; + } + public OutlineParams lineWidth(float width) { this.lineWidth = width; return this; diff --git a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java index f1fa5dc06..e94edaeb4 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java +++ b/src/main/java/com/simibubi/create/foundation/utility/outliner/Outliner.java @@ -2,10 +2,9 @@ package com.simibubi.create.foundation.utility.outliner; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; +import java.util.Iterator; import java.util.Map; import java.util.Optional; -import java.util.Set; import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; @@ -20,11 +19,8 @@ import net.minecraft.world.phys.Vec3; public class Outliner { - final Map outlines; - - public Map getOutlines() { - return Collections.unmodifiableMap(outlines); - } + private final Map outlines = Collections.synchronizedMap(new HashMap<>()); + private final Map outlinesView = Collections.unmodifiableMap(outlines); // Facade @@ -103,6 +99,10 @@ public class Outliner { return Optional.empty(); } + public Map getOutlines() { + return outlinesView; + } + // Utility private void createAABBOutlineIfMissing(Object slot, AABB bb) { @@ -126,39 +126,30 @@ public class Outliner { // Maintenance - public Outliner() { - outlines = Collections.synchronizedMap(new HashMap<>()); - } - public void tickOutlines() { - Set toClear = new HashSet<>(); - - outlines.forEach((key, entry) -> { - entry.ticksTillRemoval--; - entry.getOutline() - .tick(); - if (entry.isAlive()) - return; - toClear.add(key); - }); - - toClear.forEach(outlines::remove); + Iterator iterator = outlines.values().iterator(); + while (iterator.hasNext()) { + OutlineEntry entry = iterator.next(); + entry.tick(); + if (!entry.isAlive()) + iterator.remove(); + } } public void renderOutlines(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) { outlines.forEach((key, entry) -> { Outline outline = entry.getOutline(); - outline.params.alpha = 1; - if (entry.ticksTillRemoval < 0) { - + OutlineParams params = outline.getParams(); + params.alpha = 1; + if (entry.isFading()) { int prevTicks = entry.ticksTillRemoval + 1; float fadeticks = OutlineEntry.fadeTicks; float lastAlpha = prevTicks >= 0 ? 1 : 1 + (prevTicks / fadeticks); float currentAlpha = 1 + (entry.ticksTillRemoval / fadeticks); float alpha = Mth.lerp(pt, lastAlpha, currentAlpha); - outline.params.alpha = alpha * alpha * alpha; - if (outline.params.alpha < 1 / 8f) + params.alpha = alpha * alpha * alpha; + if (params.alpha < 1 / 8f) return; } outline.render(ms, buffer, pt); @@ -176,10 +167,19 @@ public class Outliner { ticksTillRemoval = 1; } + public void tick() { + ticksTillRemoval--; + outline.tick(); + } + public boolean isAlive() { return ticksTillRemoval >= -fadeTicks; } + public boolean isFading() { + return ticksTillRemoval < 0; + } + public Outline getOutline() { return outline; }