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
This commit is contained in:
PepperBell 2021-11-21 00:44:37 -08:00
parent d15b2281c1
commit 7b4f9f924f
81 changed files with 755 additions and 779 deletions

View file

@ -1,5 +1,6 @@
package com.simibubi.create; package com.simibubi.create;
import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -14,144 +15,144 @@ import net.minecraft.world.item.DyeColor;
public class AllBlockPartials { public class AllBlockPartials {
public static final PartialModel SCHEMATICANNON_CONNECTOR = get("schematicannon/connector"), public static final PartialModel
SCHEMATICANNON_PIPE = get("schematicannon/pipe"),
SHAFTLESS_COGWHEEL = get("cogwheel_shaftless"), SHAFTLESS_LARGE_COGWHEEL = get("large_cogwheel_shaftless"), SCHEMATICANNON_CONNECTOR = block("schematicannon/connector"),
COGWHEEL_SHAFT = get("cogwheel_shaft"), SHAFT_HALF = get("shaft_half"), SCHEMATICANNON_PIPE = block("schematicannon/pipe"),
BELT_PULLEY = get("belt_pulley"), BELT_START = get("belt/start"), BELT_MIDDLE = get("belt/middle"), SHAFTLESS_COGWHEEL = block("cogwheel_shaftless"), SHAFTLESS_LARGE_COGWHEEL = block("large_cogwheel_shaftless"),
BELT_END = get("belt/end"), BELT_START_BOTTOM = get("belt/start_bottom"), COGWHEEL_SHAFT = block("cogwheel_shaft"), SHAFT_HALF = block("shaft_half"),
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"),
ENCASED_FAN_INNER = get("encased_fan/propeller"), HAND_CRANK_HANDLE = get("hand_crank/handle"), BELT_PULLEY = block("belt_pulley"), BELT_START = block("belt/start"), BELT_MIDDLE = block("belt/middle"),
MECHANICAL_PRESS_HEAD = get("mechanical_press/head"), MECHANICAL_MIXER_POLE = get("mechanical_mixer/pole"), BELT_END = block("belt/end"), BELT_START_BOTTOM = block("belt/start_bottom"),
MECHANICAL_MIXER_HEAD = get("mechanical_mixer/head"), MECHANICAL_CRAFTER_LID = get("mechanical_crafter/lid"), BELT_MIDDLE_BOTTOM = block("belt/middle_bottom"), BELT_END_BOTTOM = block("belt/end_bottom"),
MECHANICAL_CRAFTER_ARROW = get("mechanical_crafter/arrow"), BELT_DIAGONAL_START = block("belt/diagonal_start"), BELT_DIAGONAL_MIDDLE = block("belt/diagonal_middle"),
MECHANICAL_CRAFTER_BELT_FRAME = get("mechanical_crafter/belt"), BELT_DIAGONAL_END = block("belt/diagonal_end"),
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"),
FLYWHEEL_LOWER_ROTATING = get("flywheel/lower_rotating_connector"), ENCASED_FAN_INNER = block("encased_fan/propeller"), HAND_CRANK_HANDLE = block("hand_crank/handle"),
FLYWHEEL_UPPER_SLIDING = get("flywheel/upper_sliding_connector"), MECHANICAL_PRESS_HEAD = block("mechanical_press/head"), MECHANICAL_MIXER_POLE = block("mechanical_mixer/pole"),
FLYWHEEL_LOWER_SLIDING = get("flywheel/lower_sliding_connector"), MECHANICAL_MIXER_HEAD = block("mechanical_mixer/head"), MECHANICAL_CRAFTER_LID = block("mechanical_crafter/lid"),
FURNACE_GENERATOR_FRAME = get("furnace_engine/frame"), CUCKOO_MINUTE_HAND = get("cuckoo_clock/minute_hand"), MECHANICAL_CRAFTER_ARROW = block("mechanical_crafter/arrow"),
CUCKOO_HOUR_HAND = get("cuckoo_clock/hour_hand"), CUCKOO_LEFT_DOOR = get("cuckoo_clock/left_door"), MECHANICAL_CRAFTER_BELT_FRAME = block("mechanical_crafter/belt"),
CUCKOO_RIGHT_DOOR = get("cuckoo_clock/right_door"), CUCKOO_PIG = get("cuckoo_clock/pig"), MECHANICAL_CRAFTER_BELT = block("mechanical_crafter/belt_animated"),
CUCKOO_CREEPER = get("cuckoo_clock/creeper"), 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"), GANTRY_COGS = block("gantry_carriage/wheels"),
ROPE_HALF_MAGNET = get("rope_pulley/rope_half_magnet"),
HOSE_COIL = get("hose_pulley/rope_coil"), HOSE = get("hose_pulley/rope"), ROPE_COIL = block("rope_pulley/rope_coil"), ROPE_HALF = block("rope_pulley/rope_half"),
HOSE_MAGNET = get("hose_pulley/pulley_magnet"), HOSE_HALF = get("hose_pulley/rope_half"), ROPE_HALF_MAGNET = block("rope_pulley/rope_half_magnet"),
HOSE_HALF_MAGNET = get("hose_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"), MILLSTONE_COG = block("millstone/inner"),
SYMMETRY_TRIPLEPLANE = get("symmetry_effect/tripleplane"),
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"), STICKER_HEAD = block("sticker/head"),
PORTABLE_STORAGE_INTERFACE_MIDDLE_POWERED = get("portable_storage_interface/block_middle_powered"),
PORTABLE_STORAGE_INTERFACE_TOP = get("portable_storage_interface/block_top"),
PORTABLE_FLUID_INTERFACE_MIDDLE = get("portable_fluid_interface/block_middle"), PORTABLE_STORAGE_INTERFACE_MIDDLE = block("portable_storage_interface/block_middle"),
PORTABLE_FLUID_INTERFACE_MIDDLE_POWERED = get("portable_fluid_interface/block_middle_powered"), PORTABLE_STORAGE_INTERFACE_MIDDLE_POWERED = block("portable_storage_interface/block_middle_powered"),
PORTABLE_FLUID_INTERFACE_TOP = get("portable_fluid_interface/block_top"), PORTABLE_STORAGE_INTERFACE_TOP = block("portable_storage_interface/block_top"),
ARM_COG = get("mechanical_arm/cog"), ARM_BASE = get("mechanical_arm/base"), PORTABLE_FLUID_INTERFACE_MIDDLE = block("portable_fluid_interface/block_middle"),
ARM_LOWER_BODY = get("mechanical_arm/lower_body"), ARM_UPPER_BODY = get("mechanical_arm/upper_body"), PORTABLE_FLUID_INTERFACE_MIDDLE_POWERED = block("portable_fluid_interface/block_middle_powered"),
ARM_HEAD = get("mechanical_arm/head"), ARM_CLAW_BASE = get("mechanical_arm/claw_base"), PORTABLE_FLUID_INTERFACE_TOP = block("portable_fluid_interface/block_top"),
ARM_CLAW_GRIP = get("mechanical_arm/claw_grip"),
FLAG_SHORT_IN = get("mechanical_arm/flag/short_in"), FLAG_SHORT_OUT = get("mechanical_arm/flag/short_out"), ARM_COG = block("mechanical_arm/cog"), ARM_BASE = block("mechanical_arm/base"),
FLAG_LONG_IN = get("mechanical_arm/flag/long_in"), FLAG_LONG_OUT = get("mechanical_arm/flag/long_out"), 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"), FLAG_SHORT_IN = block("mechanical_arm/flag/short_in"), FLAG_SHORT_OUT = block("mechanical_arm/flag/short_out"),
FLUID_PIPE_CASING = get("fluid_pipe/casing"), FLUID_VALVE_POINTER = get("fluid_valve/pointer"), 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"), EJECTOR_TOP = block("weighted_ejector/top"),
COPPER_BACKTANK_COGS = get("copper_backtank/block_cogs"),
CRAFTING_BLUEPRINT_1x1 = getEntity("crafting_blueprint_small"), COPPER_BACKTANK_SHAFT = block("copper_backtank/block_shaft_input"),
CRAFTING_BLUEPRINT_2x2 = getEntity("crafting_blueprint_medium"), COPPER_BACKTANK_COGS = block("copper_backtank/block_cogs"),
CRAFTING_BLUEPRINT_3x3 = getEntity("crafting_blueprint_large"),
COUPLING_ATTACHMENT = getEntity("minecart_coupling/attachment"), CRAFTING_BLUEPRINT_1x1 = entity("crafting_blueprint_small"),
COUPLING_RING = getEntity("minecart_coupling/ring"), CRAFTING_BLUEPRINT_2x2 = entity("crafting_blueprint_medium"),
COUPLING_CONNECTOR = getEntity("minecart_coupling/connector"); 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<FluidTransportBehaviour.AttachmentTypes, Map<Direction, PartialModel>> PIPE_ATTACHMENTS = public static final Map<FluidTransportBehaviour.AttachmentTypes, Map<Direction, PartialModel>> PIPE_ATTACHMENTS =
new HashMap<>(); new EnumMap<>(FluidTransportBehaviour.AttachmentTypes.class);
public static final Map<DyeColor, PartialModel> TOOLBOX_LIDS = new HashMap<>(); public static final Map<BlazeBurnerBlock.HeatLevel, PartialModel> BLAZES = new EnumMap<>(BlazeBurnerBlock.HeatLevel.class);
public static final Map<BlazeBurnerBlock.HeatLevel, PartialModel> BLAZES = new HashMap<>(); public static final Map<DyeColor, PartialModel> TOOLBOX_LIDS = new EnumMap<>(DyeColor.class);
static { static {
populateMaps();
}
static void populateMaps() {
for (FluidTransportBehaviour.AttachmentTypes type : FluidTransportBehaviour.AttachmentTypes.values()) { for (FluidTransportBehaviour.AttachmentTypes type : FluidTransportBehaviour.AttachmentTypes.values()) {
if (!type.hasModel()) if (!type.hasModel())
continue; continue;
Map<Direction, PartialModel> map = new HashMap<>(); Map<Direction, PartialModel> map = new HashMap<>();
for (Direction d : Iterate.directions) { for (Direction d : Iterate.directions) {
String asId = Lang.asId(type.name()); 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); PIPE_ATTACHMENTS.put(type, map);
} }
for (BlazeBurnerBlock.HeatLevel heat : BlazeBurnerBlock.HeatLevel.values()) { for (BlazeBurnerBlock.HeatLevel heat : BlazeBurnerBlock.HeatLevel.values()) {
if (heat == BlazeBurnerBlock.HeatLevel.NONE) if (heat == BlazeBurnerBlock.HeatLevel.NONE)
continue; continue;
BLAZES.put(heat, get("blaze_burner/blaze/" + heat.getSerializedName())); BLAZES.put(heat, block("blaze_burner/blaze/" + heat.getSerializedName()));
} }
for (DyeColor color : DyeColor.values()) 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) { private static PartialModel block(String path) {
return new PartialModel(Create.asResource("entity/" + path));
}
private static PartialModel get(String path) {
return new PartialModel(Create.asResource("block/" + 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() { public static void init() {
// init static fields // init static fields
} }

View file

@ -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.content.PonderIndex;
import com.simibubi.create.foundation.ponder.elements.WorldSectionElement; import com.simibubi.create.foundation.ponder.elements.WorldSectionElement;
import com.simibubi.create.foundation.render.AllMaterialSpecs; 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.CreateContexts;
import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.render.SuperByteBufferCache;
import com.simibubi.create.foundation.utility.ModelSwapper; import com.simibubi.create.foundation.utility.ModelSwapper;
@ -66,6 +67,9 @@ public class CreateClient {
} }
public static void clientInit(final FMLClientSetupEvent event) { 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(KineticTileEntityRenderer.KINETIC_TILE);
BUFFER_CACHE.registerCompartment(SBBContraptionManager.CONTRAPTION, 20); BUFFER_CACHE.registerCompartment(SBBContraptionManager.CONTRAPTION, 20);
BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20); BUFFER_CACHE.registerCompartment(WorldSectionElement.DOC_WORLD_SECTION, 20);

View file

@ -40,7 +40,7 @@ public class AnimatedItemDrain extends AnimatedKinetics {
ms.scale(scale, scale, scale); ms.scale(scale, scale, scale);
float from = 2/16f; float from = 2/16f;
float to = 1f - from; 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(); buffer.endBatch();
matrixStack.popPose(); matrixStack.popPose();

View file

@ -71,17 +71,19 @@ public class AnimatedSpout extends AnimatedKinetics {
matrixStack.pushPose(); matrixStack.pushPose();
UIRenderHelper.flipForGuiRender(matrixStack); UIRenderHelper.flipForGuiRender(matrixStack);
matrixStack.scale(16, 16, 16); matrixStack.scale(16, 16, 16);
float from = 2/16f; float from = 3f / 16f;
float to = 1f - from; float to = 17f / 16f;
FluidRenderer.renderTiledFluidBB(fluids.get(0), from, from, from, to, to, to, buffer, matrixStack, LightTexture.FULL_BRIGHT, false); FluidRenderer.renderFluidBox(fluids.get(0), from, from, from, to, to, to, buffer, matrixStack, LightTexture.FULL_BRIGHT, false);
matrixStack.popPose(); matrixStack.popPose();
float width = 1 / 128f * squeeze; float width = 1 / 128f * squeeze;
matrixStack.translate(scale / 2f, scale * 1.5f, scale / 2f); matrixStack.translate(scale / 2f, scale * 1.5f, scale / 2f);
UIRenderHelper.flipForGuiRender(matrixStack); UIRenderHelper.flipForGuiRender(matrixStack);
matrixStack.scale(16, 16, 16); matrixStack.scale(16, 16, 16);
matrixStack.translate(-width / 2, 0, -width / 2); matrixStack.translate(-0.5f, 0, -0.5f);
FluidRenderer.renderTiledFluidBB(fluids.get(0), 0, -0.001f, 0, width, 2.001f, width, buffer, matrixStack, LightTexture.FULL_BRIGHT, 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); false);
buffer.endBatch(); buffer.endBatch();
Lighting.setupFor3DItems(); Lighting.setupFor3DItems();

View file

@ -4,11 +4,11 @@ import com.jozufozu.flywheel.backend.Backend;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.content.contraptions.KineticDebugger;
import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel; 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.SuperByteBuffer;
import com.simibubi.create.foundation.render.SuperByteBufferCache;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Color;
@ -29,7 +29,7 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
@EventBusSubscriber(Dist.CLIENT) @EventBusSubscriber(Dist.CLIENT)
public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTileEntity> { public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTileEntity> {
public static final Compartment<BlockState> KINETIC_TILE = new Compartment<>(); public static final SuperByteBufferCache.Compartment<BlockState> KINETIC_TILE = new SuperByteBufferCache.Compartment<>();
public static boolean rainbowMode = false; public static boolean rainbowMode = false;
public KineticTileEntityRenderer(BlockEntityRendererProvider.Context context) { public KineticTileEntityRenderer(BlockEntityRendererProvider.Context context) {
@ -47,7 +47,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
public static void renderRotatingKineticBlock(KineticTileEntity te, BlockState renderedState, PoseStack ms, public static void renderRotatingKineticBlock(KineticTileEntity te, BlockState renderedState, PoseStack ms,
VertexConsumer buffer, int light) { VertexConsumer buffer, int light) {
SuperByteBuffer superByteBuffer = CreateClient.BUFFER_CACHE.renderBlockIn(KINETIC_TILE, renderedState); SuperByteBuffer superByteBuffer = CachedBufferer.block(KINETIC_TILE, renderedState);
renderRotatingBuffer(te, superByteBuffer, ms, buffer, light); renderRotatingBuffer(te, superByteBuffer, ms, buffer, light);
} }
@ -117,7 +117,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
} }
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return CreateClient.BUFFER_CACHE.renderBlockIn(KINETIC_TILE, getRenderedBlockState(te)); return CachedBufferer.block(KINETIC_TILE, getRenderedBlockState(te));
} }
} }

View file

@ -8,7 +8,7 @@ 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.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -29,13 +29,13 @@ public class DrillRenderer extends KineticTileEntityRenderer {
@Override @Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return PartialBufferer.getFacing(AllBlockPartials.DRILL_HEAD, te.getBlockState()); return CachedBufferer.partialFacing(AllBlockPartials.DRILL_HEAD, te.getBlockState());
} }
public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld, public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
ContraptionMatrices matrices, MultiBufferSource buffer) { ContraptionMatrices matrices, MultiBufferSource buffer) {
BlockState state = context.state; BlockState state = context.state;
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.DRILL_HEAD, state); SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.DRILL_HEAD, state);
Direction facing = state.getValue(DrillBlock.FACING); Direction facing = state.getValue(DrillBlock.FACING);
float speed = (float) (context.contraption.stalled float speed = (float) (context.contraption.stalled

View file

@ -7,7 +7,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; 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.ContraptionMatrices;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -33,7 +33,7 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
protected void renderSafe(HarvesterTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, protected void renderSafe(HarvesterTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer,
int light, int overlay) { int light, int overlay) {
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.HARVESTER_BLADE, blockState); SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.HARVESTER_BLADE, blockState);
transform(te.getLevel(), blockState.getValue(HarvesterBlock.FACING), superBuffer, transform(te.getLevel(), blockState.getValue(HarvesterBlock.FACING), superBuffer,
te.getAnimatedSpeed()); te.getAnimatedSpeed());
superBuffer.light(light) superBuffer.light(light)
@ -44,7 +44,7 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
ContraptionMatrices matrices, MultiBufferSource buffers) { ContraptionMatrices matrices, MultiBufferSource buffers) {
BlockState blockState = context.state; BlockState blockState = context.state;
Direction facing = blockState.getValue(HORIZONTAL_FACING); Direction facing = blockState.getValue(HORIZONTAL_FACING);
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.HARVESTER_BLADE, blockState); SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.HARVESTER_BLADE, blockState);
float speed = (float) (!VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite()) float speed = (float) (!VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite())
? context.getAnimationSpeed() ? context.getAnimationSpeed()
: 0); : 0);

View file

@ -10,7 +10,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; 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.ContraptionMatrices;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -62,8 +62,8 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
private static void render(BlockState blockState, boolean lit, float progress, private static void render(BlockState blockState, boolean lit, float progress,
PoseStack local, Consumer<SuperByteBuffer> drawCallback) { PoseStack local, Consumer<SuperByteBuffer> drawCallback) {
SuperByteBuffer middle = PartialBufferer.get(getMiddleForState(blockState, lit), blockState); SuperByteBuffer middle = CachedBufferer.partial(getMiddleForState(blockState, lit), blockState);
SuperByteBuffer top = PartialBufferer.get(getTopForState(blockState), blockState); SuperByteBuffer top = CachedBufferer.partial(getTopForState(blockState), blockState);
if (local != null) { if (local != null) {
middle.transform(local); middle.transform(local);

View file

@ -7,7 +7,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity.Animation; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -38,8 +38,8 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
VertexConsumer vb = buffer.getBuffer(RenderType.solid()); VertexConsumer vb = buffer.getBuffer(RenderType.solid());
// Render Hands // Render Hands
SuperByteBuffer hourHand = PartialBufferer.get(AllBlockPartials.CUCKOO_HOUR_HAND, blockState); SuperByteBuffer hourHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_HOUR_HAND, blockState);
SuperByteBuffer minuteHand = PartialBufferer.get(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState); SuperByteBuffer minuteHand = CachedBufferer.partial(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState);
float hourAngle = clock.hourHand.get(partialTicks); float hourAngle = clock.hourHand.get(partialTicks);
float minuteAngle = clock.minuteHand.get(partialTicks); float minuteAngle = clock.minuteHand.get(partialTicks);
rotateHand(hourHand, hourAngle, direction).light(light) rotateHand(hourHand, hourAngle, direction).light(light)
@ -48,8 +48,8 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
.renderInto(ms, vb); .renderInto(ms, vb);
// Doors // Doors
SuperByteBuffer leftDoor = PartialBufferer.get(AllBlockPartials.CUCKOO_LEFT_DOOR, blockState); SuperByteBuffer leftDoor = CachedBufferer.partial(AllBlockPartials.CUCKOO_LEFT_DOOR, blockState);
SuperByteBuffer rightDoor = PartialBufferer.get(AllBlockPartials.CUCKOO_RIGHT_DOOR, blockState); SuperByteBuffer rightDoor = CachedBufferer.partial(AllBlockPartials.CUCKOO_RIGHT_DOOR, blockState);
float angle = 0; float angle = 0;
float offset = 0; float offset = 0;
@ -80,7 +80,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
offset = -(angle / 135) * 1 / 2f + 10 / 16f; offset = -(angle / 135) * 1 / 2f + 10 / 16f;
PartialModel partialModel = (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER); PartialModel partialModel = (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER);
SuperByteBuffer figure = SuperByteBuffer figure =
PartialBufferer.get(partialModel, blockState); CachedBufferer.partial(partialModel, blockState);
figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.getCounterClockWise()))); figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.getCounterClockWise())));
figure.translate(offset, 0, 0); figure.translate(offset, 0, 0);
figure.light(light) figure.light(light)
@ -95,7 +95,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
} }
private SuperByteBuffer transform(PartialModel partial, KineticTileEntity te) { 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) .getValue(CuckooClockBlock.HORIZONTAL_FACING)
.getOpposite()); .getOpposite());
} }

View file

@ -13,7 +13,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllSpriteShifts; import com.simibubi.create.AllSpriteShifts;
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase; import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase;
import com.simibubi.create.content.contraptions.components.crafter.RecipeGridHandler.GroupedItems; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -171,7 +171,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
if (!Backend.getInstance() if (!Backend.getInstance()
.canUseInstancing(te.getLevel())) { .canUseInstancing(te.getLevel())) {
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState); SuperByteBuffer superBuffer = CachedBufferer.partial(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
standardKineticRotationTransform(superBuffer, te, light); standardKineticRotationTransform(superBuffer, te, light);
superBuffer.rotateCentered(Direction.UP, (float) (blockState.getValue(HORIZONTAL_FACING) superBuffer.rotateCentered(Direction.UP, (float) (blockState.getValue(HORIZONTAL_FACING)
.getAxis() != Direction.Axis.X ? 0 : Math.PI / 2)); .getAxis() != Direction.Axis.X ? 0 : Math.PI / 2));
@ -212,7 +212,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
} }
private SuperByteBuffer renderAndTransform(PartialModel renderBlock, BlockState crafterState) { private SuperByteBuffer renderAndTransform(PartialModel renderBlock, BlockState crafterState) {
SuperByteBuffer buffer = PartialBufferer.get(renderBlock, crafterState); SuperByteBuffer buffer = CachedBufferer.partial(renderBlock, crafterState);
float xRot = crafterState.getValue(MechanicalCrafterBlock.POINTING) float xRot = crafterState.getValue(MechanicalCrafterBlock.POINTING)
.getXRotation(); .getXRotation();
float yRot = AngleHelper.horizontalAngle(crafterState.getValue(HORIZONTAL_FACING)); float yRot = AngleHelper.horizontalAngle(crafterState.getValue(HORIZONTAL_FACING));

View file

@ -7,7 +7,7 @@ import com.jozufozu.flywheel.core.PartialModel;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
@ -39,7 +39,7 @@ public class HandCrankRenderer extends KineticTileEntityRenderer {
return; return;
Direction facing = state.getValue(FACING); Direction facing = state.getValue(FACING);
SuperByteBuffer handle = PartialBufferer.getFacing(renderedHandle, state, facing.getOpposite()); SuperByteBuffer handle = CachedBufferer.partialFacing(renderedHandle, state, facing.getOpposite());
HandCrankTileEntity crank = (HandCrankTileEntity) te; HandCrankTileEntity crank = (HandCrankTileEntity) te;
kineticRotationTransform(handle, te, facing.getAxis(), kineticRotationTransform(handle, te, facing.getAxis(),
(crank.independentAngle + partialTicks * crank.chasingVelocity) / 360, light); (crank.independentAngle + partialTicks * crank.chasingVelocity) / 360, light);

View file

@ -35,8 +35,8 @@ public class DeployerActorInstance extends ActorInstance {
boolean stationaryTimer; boolean stationaryTimer;
float yRot; float yRot;
float xRot;
float zRot; float zRot;
float zRotPole;
ModelData pole; ModelData pole;
ModelData hand; ModelData hand;
@ -57,8 +57,8 @@ public class DeployerActorInstance extends ActorInstance {
boolean rotatePole = state.getValue(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Direction.Axis.Z; boolean rotatePole = state.getValue(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Direction.Axis.Z;
yRot = AngleHelper.horizontalAngle(facing); yRot = AngleHelper.horizontalAngle(facing);
zRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; xRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0;
zRotPole = rotatePole ? 90 : 0; zRot = rotatePole ? 90 : 0;
pole = mat.getModel(AllBlockPartials.DEPLOYER_POLE, state).createInstance(); pole = mat.getModel(AllBlockPartials.DEPLOYER_POLE, state).createInstance();
hand = mat.getModel(handPose, state).createInstance(); hand = mat.getModel(handPose, state).createInstance();
@ -100,17 +100,17 @@ public class DeployerActorInstance extends ActorInstance {
msr.translate(context.localPos) msr.translate(context.localPos)
.translate(offset); .translate(offset);
transformModel(msr, pole, hand, yRot, zRot, zRotPole); transformModel(msr, pole, hand, yRot, xRot, zRot);
} }
static void transformModel(MatrixTransformStack msr, ModelData pole, ModelData hand, float yRot, float zRot, float zRotPole) { static void transformModel(MatrixTransformStack msr, ModelData pole, ModelData hand, float yRot, float xRot, float zRot) {
msr.centre(); msr.centre();
msr.rotate(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI));
msr.rotate(Direction.UP, (float) ((yRot) / 180 * Math.PI)); msr.rotate(Direction.UP, (float) ((yRot) / 180 * Math.PI));
msr.rotate(Direction.EAST, (float) ((xRot) / 180 * Math.PI));
msr.push(); msr.push();
msr.rotate(Direction.SOUTH, (float) ((zRotPole) / 180 * Math.PI)); msr.rotate(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI));
msr.unCentre(); msr.unCentre();
pole.setTransform(msr.unwrap()); pole.setTransform(msr.unwrap());
msr.pop(); msr.pop();

View file

@ -19,9 +19,9 @@ public class DeployerFilterSlot extends ValueBoxTransform {
Vec3 vec = VecHelper.voxelSpace(8f, 13.5f, 11.5f); Vec3 vec = VecHelper.voxelSpace(8f, 13.5f, 11.5f);
float yRot = AngleHelper.horizontalAngle(facing); float yRot = AngleHelper.horizontalAngle(facing);
float zRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; float xRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0;
vec = VecHelper.rotateCentered(vec, yRot, Axis.Y); vec = VecHelper.rotateCentered(vec, yRot, Axis.Y);
vec = VecHelper.rotateCentered(vec, zRot, Axis.Z); vec = VecHelper.rotateCentered(vec, xRot, Axis.X);
return vec; return vec;
} }

View file

@ -25,8 +25,8 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance,
final DeployerTileEntity tile; final DeployerTileEntity tile;
final Direction facing; final Direction facing;
final float yRot; final float yRot;
final float xRot;
final float zRot; final float zRot;
final float zRotPole;
protected final OrientedData pole; protected final OrientedData pole;
@ -45,8 +45,8 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance,
boolean rotatePole = blockState.getValue(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Direction.Axis.Z; boolean rotatePole = blockState.getValue(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Direction.Axis.Z;
yRot = AngleHelper.horizontalAngle(facing); yRot = AngleHelper.horizontalAngle(facing);
zRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; xRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0;
zRotPole = rotatePole ? 90 : 0; zRot = rotatePole ? 90 : 0;
pole = getOrientedMaterial().getModel(AllBlockPartials.DEPLOYER_POLE, blockState).createInstance(); pole = getOrientedMaterial().getModel(AllBlockPartials.DEPLOYER_POLE, blockState).createInstance();
@ -54,7 +54,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance,
relight(pos, pole); relight(pos, pole);
progress = getProgress(AnimationTickHolder.getPartialTicks()); progress = getProgress(AnimationTickHolder.getPartialTicks());
updateRotation(pole, hand, yRot, zRot, zRotPole); updateRotation(pole, hand, yRot, xRot, zRot);
updatePosition(); updatePosition();
} }
@ -100,7 +100,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance,
hand = getOrientedMaterial().getModel(currentHand, blockState).createInstance(); hand = getOrientedMaterial().getModel(currentHand, blockState).createInstance();
relight(pos, hand); relight(pos, hand);
updateRotation(pole, hand, yRot, zRot, zRotPole); updateRotation(pole, hand, yRot, xRot, zRot);
updatePosition(); updatePosition();
return true; return true;
@ -129,14 +129,14 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance,
hand.setPosition(x, y, z); hand.setPosition(x, y, z);
} }
static void updateRotation(OrientedData pole, OrientedData hand, float yRot, float zRot, float zRotPole) { static void updateRotation(OrientedData pole, OrientedData hand, float yRot, float xRot, float zRot) {
Quaternion q = Direction.SOUTH.step().rotationDegrees(zRot); Quaternion q = Direction.UP.step().rotationDegrees(yRot);
q.mul(Direction.UP.step().rotationDegrees(yRot)); q.mul(Direction.EAST.step().rotationDegrees(xRot));
hand.setRotation(q); hand.setRotation(q);
q.mul(Direction.SOUTH.step().rotationDegrees(zRotPole)); q.mul(Direction.SOUTH.step().rotationDegrees(zRot));
pole.setRotation(q); pole.setRotation(q);
} }

View file

@ -15,7 +15,7 @@ import com.simibubi.create.content.contraptions.components.deployer.DeployerTile
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; 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.ContraptionMatrices;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
@ -69,12 +69,12 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
boolean punching = te.mode == Mode.PUNCH; boolean punching = te.mode == Mode.PUNCH;
float yRot = AngleHelper.horizontalAngle(facing) + 180; 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; boolean displayMode = facing == Direction.UP && te.getSpeed() == 0 && !punching;
ms.mulPose(Vector3f.YP.rotationDegrees(yRot)); ms.mulPose(Vector3f.YP.rotationDegrees(yRot));
if (!displayMode) { if (!displayMode) {
ms.mulPose(Vector3f.XP.rotationDegrees(zRot)); ms.mulPose(Vector3f.XP.rotationDegrees(xRot));
ms.translate(0, 0, -11 / 16f); ms.translate(0, 0, -11 / 16f);
} }
@ -116,8 +116,8 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
Vec3 offset = getHandOffset(te, partialTicks, blockState); Vec3 offset = getHandOffset(te, partialTicks, blockState);
SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState); SuperByteBuffer pole = CachedBufferer.partial(AllBlockPartials.DEPLOYER_POLE, blockState);
SuperByteBuffer hand = PartialBufferer.get(te.getHandPose(), blockState); SuperByteBuffer hand = CachedBufferer.partial(te.getHandPose(), blockState);
transform(pole.translate(offset.x, offset.y, offset.z), blockState, true) transform(pole.translate(offset.x, offset.y, offset.z), blockState, true)
.light(light) .light(light)
@ -139,15 +139,15 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
private static SuperByteBuffer transform(SuperByteBuffer buffer, BlockState deployerState, boolean axisDirectionMatters) { private static SuperByteBuffer transform(SuperByteBuffer buffer, BlockState deployerState, boolean axisDirectionMatters) {
Direction facing = deployerState.getValue(FACING); 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 axisDirectionMatters && (deployerState.getValue(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Axis.Z) ? 90
: 0; : 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.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; return buffer;
} }
@ -158,8 +158,8 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
Mode mode = NBTHelper.readEnum(context.tileData, "Mode", Mode.class); Mode mode = NBTHelper.readEnum(context.tileData, "Mode", Mode.class);
PartialModel handPose = getHandPose(mode); PartialModel handPose = getHandPose(mode);
SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState); SuperByteBuffer pole = CachedBufferer.partial(AllBlockPartials.DEPLOYER_POLE, blockState);
SuperByteBuffer hand = PartialBufferer.get(handPose, blockState); SuperByteBuffer hand = CachedBufferer.partial(handPose, blockState);
double factor; double factor;
if (context.contraption.stalled || context.position == null || context.data.contains("StationaryTimer")) { if (context.contraption.stalled || context.position == null || context.data.contains("StationaryTimer")) {

View file

@ -8,7 +8,7 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; 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)); int lightInFront = LevelRenderer.getLightColor(te.getLevel(), te.getBlockPos().relative(direction));
SuperByteBuffer shaftHalf = SuperByteBuffer shaftHalf =
PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction.getOpposite()); CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction.getOpposite());
SuperByteBuffer fanInner = 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 time = AnimationTickHolder.getRenderTime(te.getLevel());
float speed = te.getSpeed() * 5; float speed = te.getSpeed() * 5;

View file

@ -25,7 +25,7 @@ import net.minecraft.world.level.block.state.properties.EnumProperty;
public class FlywheelBlock extends HorizontalKineticBlock implements ITE<FlywheelTileEntity> { public class FlywheelBlock extends HorizontalKineticBlock implements ITE<FlywheelTileEntity> {
public static EnumProperty<ConnectionState> CONNECTION = EnumProperty.create("connection", ConnectionState.class); public static final EnumProperty<ConnectionState> CONNECTION = EnumProperty.create("connection", ConnectionState.class);
public FlywheelBlock(Properties properties) { public FlywheelBlock(Properties properties) {
super(properties); super(properties);

View file

@ -9,7 +9,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock.ConnectionState; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -56,18 +56,18 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
boolean flip = blockState.getValue(FlywheelBlock.CONNECTION) == ConnectionState.LEFT; boolean flip = blockState.getValue(FlywheelBlock.CONNECTION) == ConnectionState.LEFT;
transformConnector( 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) rotation, flip).light(light)
.renderInto(ms, vb); .renderInto(ms, vb);
transformConnector( 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) rotation, flip).light(light)
.renderInto(ms, vb); .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) true, false, rotation, flip).light(light)
.renderInto(ms, vb); .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) false, false, rotation, flip).light(light)
.renderInto(ms, vb); .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) { private void renderFlywheel(KineticTileEntity te, PoseStack ms, int light, BlockState blockState, float angle, VertexConsumer vb) {
BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90); BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90);
Direction facing = referenceState.getValue(BlockStateProperties.HORIZONTAL_FACING); 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) kineticRotationTransform(wheel, te, blockState.getValue(HORIZONTAL_FACING)
.getAxis(), AngleHelper.rad(angle), light); .getAxis(), AngleHelper.rad(angle), light);
wheel.renderInto(ms, vb); wheel.renderInto(ms, vb);
@ -86,7 +86,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
@Override @Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { 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) .getValue(BlockStateProperties.HORIZONTAL_FACING)
.getOpposite()); .getOpposite());
} }

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine;
import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.core.PartialModel;
import com.mojang.blaze3d.vertex.PoseStack; 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.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -33,7 +33,7 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
Direction facing = te.getBlockState() Direction facing = te.getBlockState()
.getValue(EngineBlock.FACING); .getValue(EngineBlock.FACING);
float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing)); float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing));
PartialBufferer.get(frame, te.getBlockState()) CachedBufferer.partial(frame, te.getBlockState())
.rotateCentered(Direction.UP, angle) .rotateCentered(Direction.UP, angle)
.translate(0, 0, -1) .translate(0, 0, -1)
.light(light) .light(light)

View file

@ -1,9 +1,9 @@
package com.simibubi.create.content.contraptions.components.millstone; package com.simibubi.create.content.contraptions.components.millstone;
import com.simibubi.create.AllBlockPartials; 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.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
@ -16,7 +16,7 @@ public class MillstoneRenderer extends KineticTileEntityRenderer {
@Override @Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return CreateClient.BUFFER_CACHE.renderPartial(AllBlockPartials.MILLSTONE_COG, te.getBlockState()); return CachedBufferer.partial(AllBlockPartials.MILLSTONE_COG, te.getBlockState());
} }
} }

View file

@ -6,7 +6,7 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -38,7 +38,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
VertexConsumer vb = buffer.getBuffer(RenderType.solid()); 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); standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks); float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks);
@ -46,12 +46,12 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
float time = AnimationTickHolder.getRenderTime(te.getLevel()); float time = AnimationTickHolder.getRenderTime(te.getLevel());
float angle = ((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI; 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) poleRender.translate(0, -renderedHeadOffset, 0)
.light(light) .light(light)
.renderInto(ms, vb); .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) headRender.rotateCentered(Direction.UP, angle)
.translate(0, -renderedHeadOffset, 0) .translate(0, -renderedHeadOffset, 0)
.light(light) .light(light)

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.motor;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
@ -16,7 +16,7 @@ public class CreativeMotorRenderer extends KineticTileEntityRenderer {
@Override @Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState()); return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState());
} }
} }

View file

@ -7,7 +7,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
@ -36,7 +36,7 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer {
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks); 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) headRender.translate(0, -renderedHeadOffset, 0)
.light(light) .light(light)
.renderInto(ms, buffer.getBuffer(RenderType.solid())); .renderInto(ms, buffer.getBuffer(RenderType.solid()));

View file

@ -8,13 +8,12 @@ import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f; import com.mojang.math.Vector3f;
import com.simibubi.create.AllBlockPartials; 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.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.MovementContext;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer; import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
@ -82,7 +81,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
rotate = true; rotate = true;
} }
SuperByteBuffer superBuffer = PartialBufferer.getFacing(partial, blockState); SuperByteBuffer superBuffer = CachedBufferer.partialFacing(partial, blockState);
if (rotate) { if (rotate) {
superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(90)); superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(90));
} }
@ -150,9 +149,9 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
if (state.getValue(FACING) if (state.getValue(FACING)
.getAxis() .getAxis()
.isHorizontal()) .isHorizontal())
return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, return CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF,
state.rotate(te.getLevel(), te.getBlockPos(), Rotation.CLOCKWISE_180)); 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)); getRenderedBlockState(te));
} }
@ -181,14 +180,14 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
SuperByteBuffer superBuffer; SuperByteBuffer superBuffer;
if (SawBlock.isHorizontal(state)) { if (SawBlock.isHorizontal(state)) {
if (shouldAnimate) if (shouldAnimate)
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE, state); superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE, state);
else else
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE, state); superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE, state);
} else { } else {
if (shouldAnimate) if (shouldAnimate)
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE, state); superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE, state);
else else
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state); superBuffer = CachedBufferer.partial(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state);
} }
PoseStack m = matrices.getModel(); PoseStack m = matrices.getModel();
@ -199,7 +198,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
.rotateX(AngleHelper.verticalAngle(facing)); .rotateX(AngleHelper.verticalAngle(facing));
if (!SawBlock.isHorizontal(state)) if (!SawBlock.isHorizontal(state))
MatrixTransformStack.of(m) 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) MatrixTransformStack.of(m)
.unCentre(); .unCentre();

View file

@ -6,7 +6,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -35,7 +35,7 @@ public class BearingRenderer extends KineticTileEntityRenderer {
.getValue(BlockStateProperties.FACING); .getValue(BlockStateProperties.FACING);
PartialModel top = PartialModel top =
bearingTe.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_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); float interpolatedAngle = bearingTe.getInterpolatedAngle(partialTicks - 1);
kineticRotationTransform(superBuffer, te, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI), light); kineticRotationTransform(superBuffer, te, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI), light);
@ -50,7 +50,7 @@ public class BearingRenderer extends KineticTileEntityRenderer {
@Override @Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { 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) .getValue(BearingBlock.FACING)
.getOpposite()); .getOpposite());
} }

View file

@ -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.ActorInstance;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
@ -38,7 +38,7 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
Direction facing = context.state.getValue(BlockStateProperties.FACING); Direction facing = context.state.getValue(BlockStateProperties.FACING);
PartialModel top = AllBlockPartials.BEARING_TOP; PartialModel top = AllBlockPartials.BEARING_TOP;
SuperByteBuffer superBuffer = PartialBufferer.get(top, context.state); SuperByteBuffer superBuffer = CachedBufferer.partial(top, context.state);
float renderPartialTicks = AnimationTickHolder.getPartialTicks(); float renderPartialTicks = AnimationTickHolder.getPartialTicks();
// rotate to match blockstate // rotate to match blockstate

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch
import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.Backend;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -28,7 +28,7 @@ public class StickerRenderer extends SafeTileEntityRenderer<StickerTileEntity> {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return; if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
BlockState state = te.getBlockState(); 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())); float offset = te.piston.getValue(AnimationTickHolder.getPartialTicks(te.getLevel()));
if (te.getLevel() != Minecraft.getInstance().level && !te.isVirtual()) if (te.getLevel() != Minecraft.getInstance().level && !te.isVirtual())

View file

@ -5,7 +5,6 @@ import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.materials.model.ModelData; import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
@ -69,9 +68,9 @@ public class GantryCarriageInstance extends ShaftInstance implements IDynamicIns
.centre() .centre()
.rotateY(AngleHelper.horizontalAngle(facing)) .rotateY(AngleHelper.horizontalAngle(facing))
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) .rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90)
.rotateY(alongFirst ^ facing.getAxis() == Direction.Axis.Z ? 90 : 0) .rotateY(alongFirst ^ facing.getAxis() == Direction.Axis.X ? 0 : 90)
.translate(0, -9 / 16f, 0) .translate(0, -9 / 16f, 0)
.multiply(Vector3f.XP.rotation(-cogAngle)) .rotateX(-cogAngle)
.translate(0, 9 / 16f, 0) .translate(0, 9 / 16f, 0)
.unCentre(); .unCentre();
@ -80,8 +79,8 @@ public class GantryCarriageInstance extends ShaftInstance implements IDynamicIns
static float getRotationMultiplier(Direction.Axis gantryAxis, Direction facing) { static float getRotationMultiplier(Direction.Axis gantryAxis, Direction facing) {
float multiplier = 1; float multiplier = 1;
if (gantryAxis == Direction.Axis.Z) if (gantryAxis == Direction.Axis.X)
if (facing == Direction.DOWN) if (facing == Direction.UP)
multiplier *= -1; multiplier *= -1;
if (gantryAxis == Direction.Axis.Y) if (gantryAxis == Direction.Axis.Y)
if (facing == Direction.NORTH || facing == Direction.EAST) if (facing == Direction.NORTH || facing == Direction.EAST)

View file

@ -2,11 +2,10 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ga
import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.Backend;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -48,21 +47,21 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer {
if (axis != rotationAxis && axis != facing.getAxis()) if (axis != rotationAxis && axis != facing.getAxis())
gantryAxis = axis; gantryAxis = axis;
if (gantryAxis == Axis.Z) if (gantryAxis == Axis.X)
if (facing == Direction.DOWN) if (facing == Direction.UP)
angleForTe *= -1; angleForTe *= -1;
if (gantryAxis == Axis.Y) if (gantryAxis == Axis.Y)
if (facing == Direction.NORTH || facing == Direction.EAST) if (facing == Direction.NORTH || facing == Direction.EAST)
angleForTe *= -1; angleForTe *= -1;
SuperByteBuffer cogs = PartialBufferer.get(AllBlockPartials.GANTRY_COGS, state); SuperByteBuffer cogs = CachedBufferer.partial(AllBlockPartials.GANTRY_COGS, state);
cogs.matrixStacker() cogs.matrixStacker()
.centre() .centre()
.rotateY(AngleHelper.horizontalAngle(facing)) .rotateY(AngleHelper.horizontalAngle(facing))
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90) .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) .translate(0, -9 / 16f, 0)
.multiply(Vector3f.XP.rotation(-angleForTe)) .rotateX(-angleForTe)
.translate(0, 9 / 16f, 0) .translate(0, 9 / 16f, 0)
.unCentre(); .unCentre();
@ -74,7 +73,7 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer {
public static float getAngleForTe(KineticTileEntity te, final BlockPos pos, Axis axis) { public static float getAngleForTe(KineticTileEntity te, final BlockPos pos, Axis axis) {
float time = AnimationTickHolder.getRenderTime(te.getLevel()); float time = AnimationTickHolder.getRenderTime(te.getLevel());
float offset = getRotationOffsetForPosition(te, pos, axis); 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 @Override

View file

@ -43,7 +43,7 @@ public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITi
Instancer<OrientedData> instancer = getInstancer(materialManager, entity); Instancer<OrientedData> instancer = getInstancer(materialManager, entity);
Direction face = entity.getFacingDirection(); 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) model = new ConditionalInstance<>(instancer)
.withCondition(this::shouldShow) .withCondition(this::shouldShow)

View file

@ -70,7 +70,7 @@ public class SuperGlueRenderer extends EntityRenderer<SuperGlueEntity> {
ms.pushPose(); ms.pushPose();
MatrixTransformStack.of(ms) MatrixTransformStack.of(ms)
.rotateY(AngleHelper.horizontalAngleNew(face)) .rotateY(AngleHelper.horizontalAngle(face))
.rotateX(AngleHelper.verticalAngle(face)); .rotateX(AngleHelper.verticalAngle(face));
Pose peek = ms.last(); Pose peek = ms.last();

View file

@ -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.IRotate;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -61,8 +61,8 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
BlockPos pos = te.getBlockPos(); BlockPos pos = te.getBlockPos();
SuperByteBuffer halfMagnet = PartialBufferer.get(this.halfMagnet, blockState); SuperByteBuffer halfMagnet = CachedBufferer.partial(this.halfMagnet, blockState);
SuperByteBuffer halfRope = PartialBufferer.get(this.halfRope, blockState); SuperByteBuffer halfRope = CachedBufferer.partial(this.halfRope, blockState);
SuperByteBuffer magnet = renderMagnet(te); SuperByteBuffer magnet = renderMagnet(te);
SuperByteBuffer rope = renderRope(te); SuperByteBuffer rope = renderRope(te);
@ -109,7 +109,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
protected SuperByteBuffer getRotatedCoil(KineticTileEntity te) { protected SuperByteBuffer getRotatedCoil(KineticTileEntity te) {
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
return PartialBufferer.getFacing(getCoil(), blockState, return CachedBufferer.partialFacing(getCoil(), blockState,
Direction.get(AxisDirection.POSITIVE, getShaftAxis(te))); Direction.get(AxisDirection.POSITIVE, getShaftAxis(te)));
} }

View file

@ -8,7 +8,6 @@ import com.simibubi.create.foundation.block.ITE;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player; 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.BlockState;
import net.minecraft.world.level.block.state.StateDefinition.Builder; 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.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.PushReaction; 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<PulleyTileEntity> { public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE<PulleyTileEntity> {
public static EnumProperty<Axis> HORIZONTAL_AXIS = BlockStateProperties.HORIZONTAL_AXIS;
public PulleyBlock(Properties properties) { public PulleyBlock(Properties properties) {
super(properties); super(properties);
} }

View file

@ -3,9 +3,9 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pu
import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.core.PartialModel;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
@ -31,12 +31,12 @@ public class PulleyRenderer extends AbstractPulleyRenderer {
@Override @Override
protected SuperByteBuffer renderRope(KineticTileEntity te) { protected SuperByteBuffer renderRope(KineticTileEntity te) {
return CreateClient.BUFFER_CACHE.renderBlock(AllBlocks.ROPE.getDefaultState()); return CachedBufferer.block(AllBlocks.ROPE.getDefaultState());
} }
@Override @Override
protected SuperByteBuffer renderMagnet(KineticTileEntity te) { protected SuperByteBuffer renderMagnet(KineticTileEntity te) {
return CreateClient.BUFFER_CACHE.renderBlock(AllBlocks.PULLEY_MAGNET.getDefaultState()); return CachedBufferer.block(AllBlocks.PULLEY_MAGNET.getDefaultState());
} }
@Override @Override

View file

@ -1,12 +1,10 @@
package com.simibubi.create.content.contraptions.components.structureMovement.render; 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.jozufozu.flywheel.event.RenderLayerEvent;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; 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.SuperByteBuffer;
import com.simibubi.create.foundation.render.SuperByteBufferCache;
import com.simibubi.create.foundation.utility.Pair; import com.simibubi.create.foundation.utility.Pair;
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld; import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
@ -14,7 +12,7 @@ import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.LevelAccessor;
public class SBBContraptionManager extends ContraptionRenderManager<ContraptionRenderInfo> { public class SBBContraptionManager extends ContraptionRenderManager<ContraptionRenderInfo> {
public static final Compartment<Pair<Contraption, RenderType>> CONTRAPTION = new Compartment<>(); public static final SuperByteBufferCache.Compartment<Pair<Contraption, RenderType>> CONTRAPTION = new SuperByteBufferCache.Compartment<>();
public SBBContraptionManager(LevelAccessor world) { public SBBContraptionManager(LevelAccessor world) {
super(world); super(world);
@ -45,7 +43,7 @@ public class SBBContraptionManager extends ContraptionRenderManager<ContraptionR
if (!renderInfo.isVisible()) return; if (!renderInfo.isVisible()) return;
SuperByteBuffer contraptionBuffer = CreateClient.BUFFER_CACHE.get(CONTRAPTION, Pair.of(renderInfo.contraption, layer), () -> 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()) { if (!contraptionBuffer.isEmpty()) {
ContraptionMatrices matrices = renderInfo.getMatrices(); ContraptionMatrices matrices = renderInfo.getMatrices();

View file

@ -10,7 +10,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.content.contraptions.KineticDebugger;
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Color;
@ -66,9 +66,9 @@ public class CouplingRenderer {
BlockState renderState = Blocks.AIR.defaultBlockState(); BlockState renderState = Blocks.AIR.defaultBlockState();
VertexConsumer builder = buffer.getBuffer(RenderType.solid()); VertexConsumer builder = buffer.getBuffer(RenderType.solid());
SuperByteBuffer attachment = PartialBufferer.get(AllBlockPartials.COUPLING_ATTACHMENT, renderState); SuperByteBuffer attachment = CachedBufferer.partial(AllBlockPartials.COUPLING_ATTACHMENT, renderState);
SuperByteBuffer ring = PartialBufferer.get(AllBlockPartials.COUPLING_RING, renderState); SuperByteBuffer ring = CachedBufferer.partial(AllBlockPartials.COUPLING_RING, renderState);
SuperByteBuffer connector = PartialBufferer.get(AllBlockPartials.COUPLING_CONNECTOR, renderState); SuperByteBuffer connector = CachedBufferer.partial(AllBlockPartials.COUPLING_CONNECTOR, renderState);
Vec3 zero = Vec3.ZERO; Vec3 zero = Vec3.ZERO;
Vec3 firstEndpoint = transforms.getFirst() Vec3 firstEndpoint = transforms.getFirst()

View file

@ -5,7 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper; 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; float angle = Mth.lerp(pump.arrowDirection.getValue(partialTicks), 0, 90) - 90;
for (float yRot : new float[] { 0, 90 }) { for (float yRot : new float[] { 0, 90 }) {
ms.pushPose(); 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); Direction direction = blockState.getValue(PumpBlock.FACING);
MatrixTransformStack.of(ms) MatrixTransformStack.of(ms)
.centre() .centre()
@ -53,7 +53,7 @@ public class PumpRenderer extends KineticTileEntityRenderer {
@Override @Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return PartialBufferer.getFacing(AllBlockPartials.MECHANICAL_PUMP_COG, te.getBlockState()); return CachedBufferer.partialFacing(AllBlockPartials.MECHANICAL_PUMP_COG, te.getBlockState());
} }
} }

View file

@ -4,7 +4,7 @@ import com.jozufozu.flywheel.core.PartialModel;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.pulley.AbstractPulleyRenderer; 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 com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
@ -31,12 +31,12 @@ public class HosePulleyRenderer extends AbstractPulleyRenderer {
@Override @Override
protected SuperByteBuffer renderRope(KineticTileEntity te) { protected SuperByteBuffer renderRope(KineticTileEntity te) {
return PartialBufferer.get(AllBlockPartials.HOSE, te.getBlockState()); return CachedBufferer.partial(AllBlockPartials.HOSE, te.getBlockState());
} }
@Override @Override
protected SuperByteBuffer renderMagnet(KineticTileEntity te) { protected SuperByteBuffer renderMagnet(KineticTileEntity te) {
return PartialBufferer.get(AllBlockPartials.HOSE_MAGNET, te.getBlockState()); return CachedBufferer.partial(AllBlockPartials.HOSE_MAGNET, te.getBlockState());
} }
@Override @Override

View file

@ -149,7 +149,7 @@ public class ItemDrainRenderer extends SmartTileEntityRenderer<ItemDrainTileEnti
float yOffset = (7 / 16f) * level; float yOffset = (7 / 16f) * level;
ms.pushPose(); ms.pushPose();
ms.translate(0, yOffset, 0); ms.translate(0, yOffset, 0);
FluidRenderer.renderTiledFluidBB(fluidStack, min, yMin - yOffset, min, max, yMin, max, buffer, ms, light, FluidRenderer.renderFluidBox(fluidStack, min, yMin - yOffset, min, max, yMin, max, buffer, ms, light,
false); false);
ms.popPose(); ms.popPose();
} }
@ -174,7 +174,7 @@ public class ItemDrainRenderer extends SmartTileEntityRenderer<ItemDrainTileEnti
if (processingTicks != -1) { if (processingTicks != -1) {
radius = (float) (Math.pow(((2 * processingProgress) - 1), 2) - 1); radius = (float) (Math.pow(((2 * processingProgress) - 1), 2) - 1);
AABB bb = new AABB(0.5, 1.0, 0.5, 0.5, 0.25, 0.5).inflate(radius / 32f); AABB bb = new AABB(0.5, 1.0, 0.5, 0.5, 0.25, 0.5).inflate(radius / 32f);
FluidRenderer.renderTiledFluidBB(fluidStack2, (float) bb.minX, (float) bb.minY, (float) bb.minZ, FluidRenderer.renderFluidBox(fluidStack2, (float) bb.minX, (float) bb.minY, (float) bb.minZ,
(float) bb.maxX, (float) bb.maxY, (float) bb.maxZ, buffer, ms, light, true); (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ, buffer, ms, light, true);
} }

View file

@ -4,7 +4,7 @@ import com.jozufozu.flywheel.core.PartialModel;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.fluid.FluidRenderer; import com.simibubi.create.foundation.fluid.FluidRenderer;
import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment; import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
@ -44,7 +44,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer<SpoutTileEntity> {
float yOffset = (11 / 16f) * level; float yOffset = (11 / 16f) * level;
ms.pushPose(); ms.pushPose();
ms.translate(0, yOffset, 0); 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); false);
ms.popPose(); ms.popPose();
} }
@ -58,7 +58,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer<SpoutTileEntity> {
if (processingTicks != -1) { if (processingTicks != -1) {
radius = (float) (Math.pow(((2 * processingProgress) - 1), 2) - 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); 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); (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ, buffer, ms, light, true);
} }
@ -72,7 +72,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer<SpoutTileEntity> {
ms.pushPose(); ms.pushPose();
for (PartialModel bit : BITS) { for (PartialModel bit : BITS) {
PartialBufferer.get(bit, te.getBlockState()) CachedBufferer.partial(bit, te.getBlockState())
.light(light) .light(light)
.renderInto(ms, buffer.getBuffer(RenderType.solid())); .renderInto(ms, buffer.getBuffer(RenderType.solid()));
ms.translate(0, -3 * squeeze / 32f, 0); ms.translate(0, -3 * squeeze / 32f, 0);

View file

@ -35,7 +35,7 @@ public class FluidValveInstance extends ShaftInstance implements IDynamicInstanc
Direction.Axis pipeAxis = FluidValveBlock.getPipeAxis(blockState); Direction.Axis pipeAxis = FluidValveBlock.getPipeAxis(blockState);
Direction.Axis shaftAxis = KineticTileEntityRenderer.getRotationAxisOf(tile); 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; pointerRotationOffset = twist ? 90 : 0;
pointer = materialManager.defaultSolid() pointer = materialManager.defaultSolid()

View file

@ -6,7 +6,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -32,7 +32,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay); super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
BlockState blockState = te.getBlockState(); 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); Direction facing = blockState.getValue(FluidValveBlock.FACING);
if (!(te instanceof FluidValveTileEntity)) if (!(te instanceof FluidValveTileEntity))
@ -43,7 +43,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer {
Axis shaftAxis = KineticTileEntityRenderer.getRotationAxisOf(te); Axis shaftAxis = KineticTileEntityRenderer.getRotationAxisOf(te);
int pointerRotationOffset = 0; int pointerRotationOffset = 0;
if (pipeAxis.isHorizontal() && shaftAxis == Axis.Z || pipeAxis.isVertical()) if (pipeAxis.isHorizontal() && shaftAxis == Axis.X || pipeAxis.isVertical())
pointerRotationOffset = 90; pointerRotationOffset = 90;
MatrixTransformStack.of(ms) MatrixTransformStack.of(ms)

View file

@ -63,7 +63,7 @@ public class FluidTankRenderer extends SafeTileEntityRenderer<FluidTankTileEntit
ms.pushPose(); ms.pushPose();
ms.translate(0, clampedLevel - totalHeight, 0); ms.translate(0, clampedLevel - totalHeight, 0);
FluidRenderer.renderTiledFluidBB(fluidStack, xMin, yMin, zMin, xMax, yMax, zMax, buffer, ms, light, false); FluidRenderer.renderFluidBox(fluidStack, xMin, yMin, zMin, xMax, yMax, zMax, buffer, ms, light, false);
ms.popPose(); ms.popPose();
} }

View file

@ -170,7 +170,7 @@ public class BasinRenderer extends SmartTileEntityRenderer<BasinTileEntity> {
float partial = Mth.clamp(units / totalUnits, 0, 1); float partial = Mth.clamp(units / totalUnits, 0, 1);
xMax += partial * 12 / 16f; 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); false);
xMin = xMax; xMin = xMax;

View file

@ -4,7 +4,7 @@ import com.jozufozu.flywheel.core.PartialModel;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -33,7 +33,7 @@ public class BlazeBurnerRenderer extends SafeTileEntityRenderer<BlazeBurnerTileE
float offset = (Mth.sin((float) ((renderTick / 16f) % (2 * Math.PI))) + .5f) / 16f; float offset = (Mth.sin((float) ((renderTick / 16f) % (2 * Math.PI))) + .5f) / 16f;
PartialModel blazeModel = AllBlockPartials.BLAZES.get(heatLevel); PartialModel blazeModel = AllBlockPartials.BLAZES.get(heatLevel);
SuperByteBuffer blazeBuffer = PartialBufferer.get(blazeModel, te.getBlockState()); SuperByteBuffer blazeBuffer = CachedBufferer.partial(blazeModel, te.getBlockState());
blazeBuffer.rotateCentered(Direction.UP, AngleHelper.rad(te.headAngle.getValue(partialTicks))); blazeBuffer.rotateCentered(Direction.UP, AngleHelper.rad(te.headAngle.getValue(partialTicks)));
blazeBuffer.translate(0, offset, 0); blazeBuffer.translate(0, offset, 0);
blazeBuffer.light(LightTexture.FULL_BRIGHT) blazeBuffer.light(LightTexture.FULL_BRIGHT)

View file

@ -4,9 +4,8 @@ import com.jozufozu.flywheel.backend.Backend;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer;
@ -44,7 +43,7 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer<SpeedContro
BlockState blockState = tileEntityIn.getBlockState(); BlockState blockState = tileEntityIn.getBlockState();
boolean alongX = blockState.getValue(SpeedControllerBlock.HORIZONTAL_AXIS) == Axis.X; boolean alongX = blockState.getValue(SpeedControllerBlock.HORIZONTAL_AXIS) == Axis.X;
SuperByteBuffer bracket = PartialBufferer.get(AllBlockPartials.SPEED_CONTROLLER_BRACKET, blockState); SuperByteBuffer bracket = CachedBufferer.partial(AllBlockPartials.SPEED_CONTROLLER_BRACKET, blockState);
bracket.translate(0, 1, 0); bracket.translate(0, 1, 0);
bracket.rotateCentered(Direction.UP, bracket.rotateCentered(Direction.UP,
(float) (alongX ? Math.PI : Math.PI / 2)); (float) (alongX ? Math.PI : Math.PI / 2));
@ -53,7 +52,7 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer<SpeedContro
} }
private SuperByteBuffer getRotatedModel(SpeedControllerTileEntity te) { private SuperByteBuffer getRotatedModel(SpeedControllerTileEntity te) {
return CreateClient.BUFFER_CACHE.renderBlockIn(KineticTileEntityRenderer.KINETIC_TILE, return CachedBufferer.block(KineticTileEntityRenderer.KINETIC_TILE,
KineticTileEntityRenderer.shaft(KineticTileEntityRenderer.getRotationAxisOf(te))); KineticTileEntityRenderer.shaft(KineticTileEntityRenderer.getRotationAxisOf(te)));
} }

View file

@ -12,11 +12,10 @@ import com.mojang.math.Vector3f;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSpriteShifts; import com.simibubi.create.AllSpriteShifts;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack; import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
import com.simibubi.create.foundation.render.PartialBufferer; import com.simibubi.create.foundation.render.CachedBufferer;
import com.simibubi.create.foundation.render.ShadowRenderHelper; import com.simibubi.create.foundation.render.ShadowRenderHelper;
import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
@ -97,7 +96,7 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
PartialModel beltPartial = getBeltPartial(diagonal, start, end, bottom); PartialModel beltPartial = getBeltPartial(diagonal, start, end, bottom);
SuperByteBuffer beltBuffer = PartialBufferer.get(beltPartial, blockState) SuperByteBuffer beltBuffer = CachedBufferer.partial(beltPartial, blockState)
.light(light); .light(light);
SpriteShiftEntry spriteShift = getSpriteShiftEntry(color, diagonal, bottom); SpriteShiftEntry spriteShift = getSpriteShiftEntry(color, diagonal, bottom);
@ -142,7 +141,7 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
return stack; 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); KineticTileEntityRenderer.standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
} }
} }

View file

@ -6,7 +6,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -45,7 +45,7 @@ public class BracketedKineticTileRenderer extends KineticTileEntityRenderer {
Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE); Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE);
renderRotatingBuffer(te, 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); ms, buffer.getBuffer(RenderType.solid()), light);
float offset = getShaftAngleOffset(axis, pos); 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; float angle = ((time * te.getSpeed() * 3f / 10 + offset) % 360) / 180 * (float) Math.PI;
SuperByteBuffer shaft = SuperByteBuffer shaft =
PartialBufferer.getFacingVertical(AllBlockPartials.COGWHEEL_SHAFT, te.getBlockState(), facing); CachedBufferer.partialFacingVertical(AllBlockPartials.COGWHEEL_SHAFT, te.getBlockState(), facing);
kineticRotationTransform(shaft, te, axis, angle, light); kineticRotationTransform(shaft, te, axis, angle, light);
shaft.renderInto(ms, buffer.getBuffer(RenderType.solid())); shaft.renderInto(ms, buffer.getBuffer(RenderType.solid()));

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.relays.encased;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
@ -29,7 +29,7 @@ public class ShaftlessCogRenderer extends KineticTileEntityRenderer {
@Override @Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return PartialBufferer.getFacingVertical( return CachedBufferer.partialFacingVertical(
large ? AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL : AllBlockPartials.SHAFTLESS_COGWHEEL, te.getBlockState(), large ? AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL : AllBlockPartials.SHAFTLESS_COGWHEEL, te.getBlockState(),
Direction.fromAxisAndDirection(te.getBlockState() Direction.fromAxisAndDirection(te.getBlockState()
.getValue(EncasedCogwheelBlock.AXIS), AxisDirection.POSITIVE)); .getValue(EncasedCogwheelBlock.AXIS), AxisDirection.POSITIVE));

View file

@ -6,7 +6,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.IRotate;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
@ -52,7 +52,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer {
angle = angle / 180f * (float) Math.PI; angle = angle / 180f * (float) Math.PI;
SuperByteBuffer superByteBuffer = SuperByteBuffer superByteBuffer =
PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction); CachedBufferer.partialFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction);
kineticRotationTransform(superByteBuffer, te, axis, angle, light); kineticRotationTransform(superByteBuffer, te, axis, angle, light);
superByteBuffer.renderInto(ms, buffer.getBuffer(RenderType.solid())); superByteBuffer.renderInto(ms, buffer.getBuffer(RenderType.solid()));
} }

View file

@ -8,7 +8,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock.Type; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.Iterate; 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); PartialModel partialModel = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS);
SuperByteBuffer headBuffer = SuperByteBuffer headBuffer =
PartialBufferer.get(partialModel, gaugeState); CachedBufferer.partial(partialModel, gaugeState);
SuperByteBuffer dialBuffer = PartialBufferer.get(AllBlockPartials.GAUGE_DIAL, gaugeState); SuperByteBuffer dialBuffer = CachedBufferer.partial(AllBlockPartials.GAUGE_DIAL, gaugeState);
float dialPivot = 5.75f / 16; float dialPivot = 5.75f / 16;
float progress = Mth.lerp(partialTicks, gaugeTE.prevDialState, gaugeTE.dialState); float progress = Mth.lerp(partialTicks, gaugeTE.prevDialState, gaugeTE.dialState);

View file

@ -5,7 +5,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
@ -38,7 +38,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer {
if (boxAxis == axis) if (boxAxis == axis)
continue; 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 offset = getRotationOffsetForPosition(te, pos, axis);
float angle = (time * te.getSpeed() * 3f / 10) % 360; float angle = (time * te.getSpeed() * 3f / 10) % 360;

View file

@ -5,8 +5,8 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.gui.element.GuiGameElement; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -58,9 +58,8 @@ public class CopperBacktankArmorLayer<T extends LivingEntity, M extends EntityMo
RenderType renderType = Sheets.cutoutBlockSheet(); RenderType renderType = Sheets.cutoutBlockSheet();
BlockState renderedState = AllBlocks.COPPER_BACKTANK.getDefaultState() BlockState renderedState = AllBlocks.COPPER_BACKTANK.getDefaultState()
.setValue(CopperBacktankBlock.HORIZONTAL_FACING, Direction.SOUTH); .setValue(CopperBacktankBlock.HORIZONTAL_FACING, Direction.SOUTH);
SuperByteBuffer backtank = CreateClient.BUFFER_CACHE.renderBlock(renderedState); SuperByteBuffer backtank = CachedBufferer.block(renderedState);
SuperByteBuffer cogs = SuperByteBuffer cogs = CachedBufferer.partial(AllBlockPartials.COPPER_BACKTANK_COGS, renderedState);
CreateClient.BUFFER_CACHE.renderPartial(AllBlockPartials.COPPER_BACKTANK_COGS, renderedState);
ms.pushPose(); ms.pushPose();

View file

@ -2,10 +2,9 @@ package com.simibubi.create.content.curiosities.armor;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlockPartials; 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.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
@ -28,8 +27,7 @@ public class CopperBacktankRenderer extends KineticTileEntityRenderer {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay); super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
SuperByteBuffer cogs = SuperByteBuffer cogs = CachedBufferer.partial(AllBlockPartials.COPPER_BACKTANK_COGS, blockState);
CreateClient.BUFFER_CACHE.renderPartial(AllBlockPartials.COPPER_BACKTANK_COGS, blockState);
cogs.matrixStacker() cogs.matrixStacker()
.centre() .centre()
.rotateY(180 + AngleHelper.horizontalAngle(blockState.getValue(CopperBacktankBlock.HORIZONTAL_FACING))) .rotateY(180 + AngleHelper.horizontalAngle(blockState.getValue(CopperBacktankBlock.HORIZONTAL_FACING)))
@ -44,7 +42,7 @@ public class CopperBacktankRenderer extends KineticTileEntityRenderer {
@Override @Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return PartialBufferer.get(AllBlockPartials.COPPER_BACKTANK_SHAFT, te.getBlockState()); return CachedBufferer.partial(AllBlockPartials.COPPER_BACKTANK_SHAFT, te.getBlockState());
} }
} }

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.curiosities.bell; package com.simibubi.create.content.curiosities.bell;
import com.mojang.blaze3d.vertex.PoseStack; 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.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -26,7 +26,7 @@ public class BellRenderer<TE extends AbstractBellTileEntity> extends SafeTileEnt
Direction facing = state.getValue(BellBlock.FACING); Direction facing = state.getValue(BellBlock.FACING);
BellAttachType attachment = state.getValue(BellBlock.ATTACHMENT); BellAttachType attachment = state.getValue(BellBlock.ATTACHMENT);
SuperByteBuffer bell = PartialBufferer.get(te.getBellModel(), state); SuperByteBuffer bell = CachedBufferer.partial(te.getBellModel(), state);
if (te.isRinging) if (te.isRinging)
bell.rotateCentered(te.ringDirection.getCounterClockWise(), getSwingAngle(te.ringingTicks + partialTicks)); bell.rotateCentered(te.ringDirection.getCounterClockWise(), getSwingAngle(te.ringingTicks + partialTicks));

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.curiosities.toolbox;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.AllBlockPartials; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer;
import com.simibubi.create.foundation.utility.Iterate; import com.simibubi.create.foundation.utility.Iterate;
@ -28,8 +28,8 @@ public class ToolboxRenderer extends SmartTileEntityRenderer<ToolboxTileEntity>
Direction facing = blockState.getValue(ToolboxBlock.FACING) Direction facing = blockState.getValue(ToolboxBlock.FACING)
.getOpposite(); .getOpposite();
SuperByteBuffer lid = SuperByteBuffer lid =
PartialBufferer.get(AllBlockPartials.TOOLBOX_LIDS.get(tileEntityIn.getColor()), blockState); CachedBufferer.partial(AllBlockPartials.TOOLBOX_LIDS.get(tileEntityIn.getColor()), blockState);
SuperByteBuffer drawer = PartialBufferer.get(AllBlockPartials.TOOLBOX_DRAWER, blockState); SuperByteBuffer drawer = CachedBufferer.partial(AllBlockPartials.TOOLBOX_DRAWER, blockState);
float lidAngle = tileEntityIn.lid.getValue(partialTicks); float lidAngle = tileEntityIn.lid.getValue(partialTicks);
float drawerOffset = tileEntityIn.drawers.getValue(partialTicks); float drawerOffset = tileEntityIn.drawers.getValue(partialTicks);

View file

@ -6,7 +6,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix3f; import com.mojang.math.Matrix3f;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.curiosities.tools.BlueprintEntity.BlueprintSection; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
@ -33,7 +33,7 @@ public class BlueprintRenderer extends EntityRenderer<BlueprintEntity> {
int light) { int light) {
PartialModel partialModel = entity.size == 3 ? AllBlockPartials.CRAFTING_BLUEPRINT_3x3 PartialModel partialModel = entity.size == 3 ? AllBlockPartials.CRAFTING_BLUEPRINT_3x3
: entity.size == 2 ? AllBlockPartials.CRAFTING_BLUEPRINT_2x2 : AllBlockPartials.CRAFTING_BLUEPRINT_1x1; : 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() sbb.matrixStacker()
.rotateY(-yaw) .rotateY(-yaw)
.rotateX(90.0F + entity.getXRot()) .rotateX(90.0F + entity.getXRot())

View file

@ -5,7 +5,7 @@ import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.AllBlockPartials; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -33,7 +33,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer<BeltTunnelTileEn
if (Backend.getInstance().canUseInstancing(te.getLevel())) return; if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
SuperByteBuffer flapBuffer = PartialBufferer.get(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState()); SuperByteBuffer flapBuffer = CachedBufferer.partial(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState());
VertexConsumer vb = buffer.getBuffer(RenderType.solid()); VertexConsumer vb = buffer.getBuffer(RenderType.solid());
Vec3 pivot = VecHelper.voxelSpace(0, 10, 1f); Vec3 pivot = VecHelper.voxelSpace(0, 10, 1f);
MatrixTransformStack msr = MatrixTransformStack.of(ms); MatrixTransformStack msr = MatrixTransformStack.of(ms);

View file

@ -8,7 +8,7 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.IntAttached; import com.simibubi.create.foundation.utility.IntAttached;
@ -47,7 +47,7 @@ public class EjectorRenderer extends KineticTileEntityRenderer {
float angle = lidProgress * 70; float angle = lidProgress * 70;
if (!Backend.getInstance().canUseInstancing(te.getLevel())) { if (!Backend.getInstance().canUseInstancing(te.getLevel())) {
SuperByteBuffer model = PartialBufferer.get(AllBlockPartials.EJECTOR_TOP, te.getBlockState()); SuperByteBuffer model = CachedBufferer.partial(AllBlockPartials.EJECTOR_TOP, te.getBlockState());
applyLidAngle(te, angle, model.matrixStacker()); applyLidAngle(te, angle, model.matrixStacker());
model.light(light) model.light(light)
.renderInto(ms, vertexBuilder); .renderInto(ms, vertexBuilder);

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.logistics.block.diodes; package com.simibubi.create.content.logistics.block.diodes;
import com.simibubi.create.AllBlockPartials; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.ColoredOverlayTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.ColoredOverlayTileEntityRenderer;
import com.simibubi.create.foundation.utility.Color; import com.simibubi.create.foundation.utility.Color;
@ -21,7 +21,7 @@ public class BrassDiodeRenderer extends ColoredOverlayTileEntityRenderer<BrassDi
@Override @Override
protected SuperByteBuffer getOverlayBuffer(BrassDiodeTileEntity te) { protected SuperByteBuffer getOverlayBuffer(BrassDiodeTileEntity te) {
return PartialBufferer.get(AllBlockPartials.FLEXPEATER_INDICATOR, te.getBlockState()); return CachedBufferer.partial(AllBlockPartials.FLEXPEATER_INDICATOR, te.getBlockState());
} }
} }

View file

@ -6,7 +6,7 @@ import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.AllBlockPartials; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -37,7 +37,7 @@ public class FunnelRenderer extends SmartTileEntityRenderer<FunnelTileEntity> {
VertexConsumer vb = buffer.getBuffer(RenderType.solid()); VertexConsumer vb = buffer.getBuffer(RenderType.solid());
PartialModel partialModel = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP PartialModel partialModel = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP
: AllBlockPartials.BELT_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); Vec3 pivot = VecHelper.voxelSpace(0, 10, 9.5f);
MatrixTransformStack msr = MatrixTransformStack.of(ms); MatrixTransformStack msr = MatrixTransformStack.of(ms);

View file

@ -8,7 +8,7 @@ import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.content.logistics.block.mechanicalArm.ArmTileEntity.Phase; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Color; 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) { 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 base = CachedBufferer.partial(AllBlockPartials.ARM_BASE, blockState).light(light);
SuperByteBuffer lowerBody = PartialBufferer.get(AllBlockPartials.ARM_LOWER_BODY, blockState).light(light); SuperByteBuffer lowerBody = CachedBufferer.partial(AllBlockPartials.ARM_LOWER_BODY, blockState).light(light);
SuperByteBuffer upperBody = PartialBufferer.get(AllBlockPartials.ARM_UPPER_BODY, blockState).light(light); SuperByteBuffer upperBody = CachedBufferer.partial(AllBlockPartials.ARM_UPPER_BODY, blockState).light(light);
SuperByteBuffer head = PartialBufferer.get(AllBlockPartials.ARM_HEAD, blockState).light(light); SuperByteBuffer head = CachedBufferer.partial(AllBlockPartials.ARM_HEAD, blockState).light(light);
SuperByteBuffer claw = PartialBufferer.get(AllBlockPartials.ARM_CLAW_BASE, blockState).light(light); SuperByteBuffer claw = CachedBufferer.partial(AllBlockPartials.ARM_CLAW_BASE, blockState).light(light);
SuperByteBuffer clawGrip = PartialBufferer.get(AllBlockPartials.ARM_CLAW_GRIP, blockState); SuperByteBuffer clawGrip = CachedBufferer.partial(AllBlockPartials.ARM_CLAW_GRIP, blockState);
transformBase(msr, baseAngle); transformBase(msr, baseAngle);
base.transform(msLocal) base.transform(msLocal)
@ -188,7 +188,7 @@ public class ArmRenderer extends KineticTileEntityRenderer {
@Override @Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return PartialBufferer.get(AllBlockPartials.ARM_COG, te.getBlockState()); return CachedBufferer.partial(AllBlockPartials.ARM_COG, te.getBlockState());
} }
} }

View file

@ -527,7 +527,7 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE
private class SelectionModeValueBox extends CenteredSideValueBoxTransform { private class SelectionModeValueBox extends CenteredSideValueBoxTransform {
public SelectionModeValueBox() { public SelectionModeValueBox() {
super((blockState, direction) -> direction != Direction.DOWN && direction != Direction.UP); super((blockState, direction) -> !direction.getAxis().isVertical());
} }
@Override @Override

View file

@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.Backend;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.AllBlockPartials; 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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
@ -34,7 +34,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
VertexConsumer vb = buffer.getBuffer(RenderType.solid()); VertexConsumer vb = buffer.getBuffer(RenderType.solid());
// Handle // Handle
SuperByteBuffer handle = PartialBufferer.get(AllBlockPartials.ANALOG_LEVER_HANDLE, leverState); SuperByteBuffer handle = CachedBufferer.partial(AllBlockPartials.ANALOG_LEVER_HANDLE, leverState);
float angle = (float) ((state / 15) * 90 / 180 * Math.PI); float angle = (float) ((state / 15) * 90 / 180 * Math.PI);
transform(handle, leverState).translate(1 / 2f, 1 / 16f, 1 / 2f) transform(handle, leverState).translate(1 / 2f, 1 / 16f, 1 / 2f)
.rotate(Direction.EAST, angle) .rotate(Direction.EAST, angle)
@ -44,7 +44,7 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
// Indicator // Indicator
int color = Color.mixColors(0x2C0300, 0xCD0000, state / 15f); int color = Color.mixColors(0x2C0300, 0xCD0000, state / 15f);
SuperByteBuffer indicator = transform(PartialBufferer.get(AllBlockPartials.ANALOG_LEVER_INDICATOR, leverState), leverState); SuperByteBuffer indicator = transform(CachedBufferer.partial(AllBlockPartials.ANALOG_LEVER_INDICATOR, leverState), leverState);
indicator.light(light) indicator.light(light)
.color(color) .color(color)
.renderInto(ms, vb); .renderInto(ms, vb);

View file

@ -9,7 +9,7 @@ import com.mojang.math.Vector3f;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.schematics.block.LaunchedItem.ForBlockState; import com.simibubi.create.content.schematics.block.LaunchedItem.ForBlockState;
import com.simibubi.create.content.schematics.block.LaunchedItem.ForEntity; import com.simibubi.create.content.schematics.block.LaunchedItem.ForEntity;
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.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer; import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
@ -63,14 +63,14 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
VertexConsumer vb = buffer.getBuffer(RenderType.solid()); VertexConsumer vb = buffer.getBuffer(RenderType.solid());
SuperByteBuffer connector = PartialBufferer.get(AllBlockPartials.SCHEMATICANNON_CONNECTOR, state); SuperByteBuffer connector = CachedBufferer.partial(AllBlockPartials.SCHEMATICANNON_CONNECTOR, state);
connector.translate(.5f, 0, .5f); connector.translate(.5f, 0, .5f);
connector.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI)); connector.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
connector.translate(-.5f, 0, -.5f); connector.translate(-.5f, 0, -.5f);
connector.light(lightCoords) connector.light(lightCoords)
.renderInto(ms, vb); .renderInto(ms, vb);
SuperByteBuffer pipe = PartialBufferer.get(AllBlockPartials.SCHEMATICANNON_PIPE, state); SuperByteBuffer pipe = CachedBufferer.partial(AllBlockPartials.SCHEMATICANNON_PIPE, state);
pipe.translate(.5f, 15 / 16f, .5f); pipe.translate(.5f, 15 / 16f, .5f);
pipe.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI)); pipe.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
pipe.rotate(Direction.SOUTH, (float) (pitch / 180 * Math.PI)); pipe.rotate(Direction.SOUTH, (float) (pitch / 180 * Math.PI));

View file

@ -61,38 +61,38 @@ public class FluidRenderer {
ms.pushPose(); ms.pushPose();
msr.centre() msr.centre()
.rotateY(AngleHelper.horizontalAngle(direction)) .rotateY(AngleHelper.horizontalAngle(direction))
.rotateX(direction == Direction.UP ? 0 : direction == Direction.DOWN ? 180 : 90) .rotateX(direction == Direction.UP ? 180 : direction == Direction.DOWN ? 0 : 270)
.unCentre(); .unCentre();
ms.translate(.5, 0, .5); ms.translate(.5, 0, .5);
float h = (float) (radius); float h = radius;
float hMin = (float) (-radius); float hMin = -radius;
float hMax = (float) (radius); float hMax = radius;
float y = inbound ? 0 : .5f; float y = inbound ? 1 : .5f;
float yMin = y; float yMin = y - Mth.clamp(progress * .5f, 0, 1);
float yMax = y + Mth.clamp(progress * .5f - 1e-6f, 0, 1); float yMax = y;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
ms.pushPose(); ms.pushPose();
renderTiledHorizontalFace(h, Direction.SOUTH, hMin, yMin, hMax, yMax, builder, ms, light, color, renderFlowingTiledFace(Direction.SOUTH, hMin, yMin, hMax, yMax, h,
flowTexture); builder, ms, light, color, flowTexture);
ms.popPose(); ms.popPose();
msr.rotateY(90); msr.rotateY(90);
} }
if (progress != 1) if (progress != 1)
renderTiledVerticalFace(yMax, Direction.UP, hMin, hMin, hMax, hMax, builder, ms, light, color, renderStillTiledFace(Direction.DOWN, hMin, hMin, hMax, hMax, yMin,
stillTexture); builder, ms, light, color, stillTexture);
ms.popPose(); ms.popPose();
} }
public static void renderTiledFluidBB(FluidStack fluidStack, float xMin, float yMin, float zMin, float xMax, public static void renderFluidBox(FluidStack fluidStack, float xMin, float yMin, float zMin, float xMax,
float yMax, float zMax, MultiBufferSource buffer, PoseStack ms, int light, boolean renderBottom) { float yMax, float zMax, MultiBufferSource buffer, PoseStack ms, int light, boolean renderBottom) {
renderTiledFluidBB(fluidStack, xMin, yMin, zMin, xMax, yMax, zMax, getFluidBuilder(buffer), ms, light, renderBottom); renderFluidBox(fluidStack, xMin, yMin, zMin, xMax, yMax, zMax, getFluidBuilder(buffer), ms, light, renderBottom);
} }
public static void renderTiledFluidBB(FluidStack fluidStack, float xMin, float yMin, float zMin, float xMax, public static void renderFluidBox(FluidStack fluidStack, float xMin, float yMin, float zMin, float xMax,
float yMax, float zMax, VertexConsumer builder, PoseStack ms, int light, boolean renderBottom) { float yMax, float zMax, VertexConsumer builder, PoseStack ms, int light, boolean renderBottom) {
Fluid fluid = fluidStack.getFluid(); Fluid fluid = fluidStack.getFluid();
FluidAttributes fluidAttributes = fluid.getAttributes(); FluidAttributes fluidAttributes = fluid.getAttributes();
@ -122,77 +122,95 @@ public class FluidRenderer {
boolean positive = side.getAxisDirection() == AxisDirection.POSITIVE; boolean positive = side.getAxisDirection() == AxisDirection.POSITIVE;
if (side.getAxis() if (side.getAxis()
.isHorizontal()) { .isHorizontal()) {
boolean x = side.getAxis() == Axis.X; if (side.getAxis() == Axis.X) {
renderTiledHorizontalFace(positive ? (x ? xMax : zMax) : (x ? xMin : zMin), side, x ? zMin : xMin, yMin, x ? zMax : xMax, yMax, builder, renderStillTiledFace(side, zMin, yMin, zMax, yMax, positive ? xMax : xMin,
ms, light, color, fluidTexture); builder, ms, light, color, fluidTexture);
} else { } else {
renderTiledVerticalFace(positive ? yMax : yMin, side, xMin, zMin, xMax, zMax, builder, ms, renderStillTiledFace(side, xMin, yMin, xMax, yMax, positive ? zMax : zMin,
light, color, fluidTexture); builder, ms, light, color, fluidTexture);
}
} else {
renderStillTiledFace(side, xMin, zMin, xMax, zMax, positive ? yMax : yMin,
builder, ms, light, color, fluidTexture);
} }
} }
ms.popPose(); ms.popPose();
} }
private static void renderTiledVerticalFace(float y, Direction face, float xMin, float zMin, float xMax, float zMax, public static void renderStillTiledFace(Direction dir, float left, float down, float right, float up,
VertexConsumer builder, PoseStack ms, int light, int color, TextureAtlasSprite texture) { float depth, VertexConsumer builder, PoseStack ms, int light, int color, TextureAtlasSprite texture) {
boolean positive = face.getAxisDirection() == Direction.AxisDirection.POSITIVE; FluidRenderer.renderTiledFace(dir, left, down, right, up, depth, builder, ms, light, color, texture, 1);
}
public static void renderFlowingTiledFace(Direction dir, float left, float down, float right, float up,
float depth, VertexConsumer builder, PoseStack ms, int light, int color, TextureAtlasSprite texture) {
FluidRenderer.renderTiledFace(dir, left, down, right, up, depth, builder, ms, light, color, texture, 0.5f);
}
public static void renderTiledFace(Direction dir, float left, float down, float right, float up,
float depth, VertexConsumer builder, PoseStack ms, int light, int color, TextureAtlasSprite texture,
float textureScale) {
boolean positive = dir.getAxisDirection() == Direction.AxisDirection.POSITIVE;
boolean horizontal = dir.getAxis().isHorizontal();
boolean x = dir.getAxis() == Axis.X;
float shrink = texture.uvShrinkRatio() * 0.25f * textureScale;
float centerU = texture.getU0() + (texture.getU1() - texture.getU0()) * 0.5f * textureScale;
float centerV = texture.getV0() + (texture.getV1() - texture.getV0()) * 0.5f * textureScale;
float f;
float x2 = 0; float x2 = 0;
float z2 = 0;
for (float x1 = xMin; x1 < xMax; x1 = x2) {
x2 = Math.min((int) (x1 + 1), xMax);
for (float z1 = zMin; z1 < zMax; z1 = z2) {
z2 = Math.min((int) (z1 + 1), zMax);
float u1 = texture.getU(local(x1) * 16);
float v1 = texture.getV(local(z1) * 16);
float u2 = texture.getU(x2 == xMax ? local(x2) * 16 : 16);
float v2 = texture.getV(z2 == zMax ? local(z2) * 16 : 16);
putVertex(builder, ms, x1, y, positive ? z1 : z2, color, u1, v1, face, light);
putVertex(builder, ms, x1, y, positive ? z2 : z1, color, u1, v2, face, light);
putVertex(builder, ms, x2, y, positive ? z2 : z1, color, u2, v2, face, light);
putVertex(builder, ms, x2, y, positive ? z1 : z2, color, u2, v1, face, light);
}
}
}
private static void renderTiledHorizontalFace(float h, Direction face, float hMin, float yMin, float hMax,
float yMax, VertexConsumer builder, PoseStack ms, int light, int color, TextureAtlasSprite texture) {
boolean positive = face.getAxisDirection() == Direction.AxisDirection.POSITIVE;
boolean x = face.getAxis() == Axis.X;
float h2 = 0;
float y2 = 0; float y2 = 0;
for (float h1 = hMin; h1 < hMax; h1 = h2) { float u1, u2;
h2 = Math.min((int) (h1 + 1), hMax); float v1, v2;
for (float y1 = yMin; y1 < yMax; y1 = y2) { for (float x1 = left; x1 < right; x1 = x2) {
y2 = Math.min((int) (y1 + 1), yMax); f = Mth.floor(x1);
x2 = Math.min(f + 1, right);
if (dir == Direction.NORTH || dir == Direction.EAST) {
f = Mth.ceil(x2);
u1 = texture.getU((f - x2) * 16 * textureScale);
u2 = texture.getU((f - x1) * 16 * textureScale);
} else {
u1 = texture.getU((x1 - f) * 16 * textureScale);
u2 = texture.getU((x2 - f) * 16 * textureScale);
}
u1 = Mth.lerp(shrink, u1, centerU);
u2 = Mth.lerp(shrink, u2, centerU);
for (float y1 = down; y1 < up; y1 = y2) {
f = Mth.floor(y1);
y2 = Math.min(f + 1, up);
if (dir == Direction.UP) {
v1 = texture.getV((y1 - f) * 16 * textureScale);
v2 = texture.getV((y2 - f) * 16 * textureScale);
} else {
f = Mth.ceil(y2);
v1 = texture.getV((f - y2) * 16 * textureScale);
v2 = texture.getV((f - y1) * 16 * textureScale);
}
v1 = Mth.lerp(shrink, v1, centerV);
v2 = Mth.lerp(shrink, v2, centerV);
float u1 = texture.getU(local(h1) * 16); if (horizontal) {
float v1 = texture.getV(local(y1) * 16); if (x) {
float u2 = texture.getU(h2 == hMax ? local(h2) * 16 : 16); putVertex(builder, ms, depth, y2, positive ? x2 : x1, color, u1, v1, dir, light);
float v2 = texture.getV(y2 == yMax ? local(y2) * 16 : 16); putVertex(builder, ms, depth, y1, positive ? x2 : x1, color, u1, v2, dir, light);
putVertex(builder, ms, depth, y1, positive ? x1 : x2, color, u2, v2, dir, light);
float x1 = x ? h : (positive ? h1 : h2); putVertex(builder, ms, depth, y2, positive ? x1 : x2, color, u2, v1, dir, light);
float x2 = x ? h : (positive ? h2 : h1); } else {
float z1 = x ? (positive ? h1 : h2) : h; putVertex(builder, ms, positive ? x1 : x2, y2, depth, color, u1, v1, dir, light);
float z2 = x ? (positive ? h2 : h1) : h; putVertex(builder, ms, positive ? x1 : x2, y1, depth, color, u1, v2, dir, light);
putVertex(builder, ms, positive ? x2 : x1, y1, depth, color, u2, v2, dir, light);
putVertex(builder, ms, x1, y2, z2, color, u1, v1, face, light); putVertex(builder, ms, positive ? x2 : x1, y2, depth, color, u2, v1, dir, light);
putVertex(builder, ms, x1, y1, z2, color, u1, v2, face, light); }
putVertex(builder, ms, x2, y1, z1, color, u2, v2, face, light); } else {
putVertex(builder, ms, x2, y2, z1, color, u2, v1, face, light); putVertex(builder, ms, x1, depth, positive ? y1 : y2, color, u1, v1, dir, light);
putVertex(builder, ms, x1, depth, positive ? y2 : y1, color, u1, v2, dir, light);
putVertex(builder, ms, x2, depth, positive ? y2 : y1, color, u2, v2, dir, light);
putVertex(builder, ms, x2, depth, positive ? y1 : y2, color, u2, v1, dir, light);
} }
} }
} }
private static float local(float f) {
if (f < 0)
f += 10;
return f - ((int) f);
} }
private static void putVertex(VertexConsumer builder, PoseStack ms, float x, float y, float z, int color, float u, private static void putVertex(VertexConsumer builder, PoseStack ms, float x, float y, float z, int color, float u,

View file

@ -224,8 +224,8 @@ public class GuiGameElement {
.isEmpty()) .isEmpty())
return; return;
FluidRenderer.renderTiledFluidBB(new FluidStack(blockState.getFluidState() FluidRenderer.renderFluidBox(new FluidStack(blockState.getFluidState()
.getType(), 1000), 0, 0, 0, 1.0001f, 1.0001f, 1.0001f, buffer, ms, LightTexture.FULL_BRIGHT, false); .getType(), 1000), 0, 0, 0, 1, 1, 1, buffer, ms, LightTexture.FULL_BRIGHT, false);
buffer.endBatch(); buffer.endBatch();
} }
} }

View file

@ -19,7 +19,6 @@ import com.simibubi.create.CreateClient;
import com.simibubi.create.foundation.ponder.PonderScene; import com.simibubi.create.foundation.ponder.PonderScene;
import com.simibubi.create.foundation.ponder.PonderWorld; import com.simibubi.create.foundation.ponder.PonderWorld;
import com.simibubi.create.foundation.ponder.Selection; import com.simibubi.create.foundation.ponder.Selection;
import com.simibubi.create.foundation.render.Compartment;
import com.simibubi.create.foundation.render.SuperByteBuffer; import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.SuperByteBufferCache; import com.simibubi.create.foundation.render.SuperByteBufferCache;
import com.simibubi.create.foundation.render.TileEntityRenderHelper; import com.simibubi.create.foundation.render.TileEntityRenderHelper;
@ -33,7 +32,6 @@ import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.client.renderer.block.BlockRenderDispatcher;
import net.minecraft.client.renderer.block.ModelBlockRenderer;
import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
@ -41,7 +39,6 @@ import net.minecraft.util.Mth;
import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
@ -57,7 +54,7 @@ import net.minecraftforge.client.model.data.EmptyModelData;
public class WorldSectionElement extends AnimatedSceneElement { public class WorldSectionElement extends AnimatedSceneElement {
public static final Compartment<Pair<Integer, Integer>> DOC_WORLD_SECTION = new Compartment<>(); public static final SuperByteBufferCache.Compartment<Pair<Integer, Integer>> DOC_WORLD_SECTION = new SuperByteBufferCache.Compartment<>();
List<BlockEntity> renderedTileEntities; List<BlockEntity> renderedTileEntities;
List<Pair<BlockEntity, Consumer<Level>>> tickableTileEntities; List<Pair<BlockEntity, Consumer<Level>>> tickableTileEntities;
@ -396,12 +393,11 @@ public class WorldSectionElement extends AnimatedSceneElement {
private SuperByteBuffer buildStructureBuffer(PonderWorld world, RenderType layer) { private SuperByteBuffer buildStructureBuffer(PonderWorld world, RenderType layer) {
ForgeHooksClient.setRenderLayer(layer); ForgeHooksClient.setRenderLayer(layer);
PoseStack ms = new PoseStack();
BlockRenderDispatcher dispatcher = Minecraft.getInstance() BlockRenderDispatcher dispatcher = Minecraft.getInstance()
.getBlockRenderer(); .getBlockRenderer();
ModelBlockRenderer blockRenderer = dispatcher.getModelRenderer(); PoseStack ms = new PoseStack();
Random random = new Random(); Random random = new Random();
BufferBuilder builder = new BufferBuilder(DefaultVertexFormat.BLOCK.getIntegerSize()); BufferBuilder builder = new BufferBuilder(512);
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK); builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
world.setMask(this.section); world.setMask(this.section);
@ -412,8 +408,7 @@ public class WorldSectionElement extends AnimatedSceneElement {
ms.pushPose(); ms.pushPose();
ms.translate(pos.getX(), pos.getY(), pos.getZ()); ms.translate(pos.getX(), pos.getY(), pos.getZ());
if (state.getRenderShape() != RenderShape.ENTITYBLOCK_ANIMATED && state.getBlock() != Blocks.AIR if (state.getRenderShape() == RenderShape.MODEL && ItemBlockRenderTypes.canRenderInLayer(state, layer)) {
&& ItemBlockRenderTypes.canRenderInLayer(state, layer)) {
BlockEntity tileEntity = world.getBlockEntity(pos); BlockEntity tileEntity = world.getBlockEntity(pos);
dispatcher.renderBatched(state, pos, world, ms, builder, true, random, dispatcher.renderBatched(state, pos, world, ms, builder, true, random,
tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE); tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE);

View file

@ -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;
}
}

View file

@ -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<BlockState> GENERIC_TILE = new Compartment<>();
public static final Compartment<PartialModel> PARTIAL = new Compartment<>();
public static final Compartment<Pair<Direction, PartialModel>> DIRECTIONAL_PARTIAL = new Compartment<>();
public static SuperByteBuffer block(BlockState toRender) {
return block(GENERIC_TILE, toRender);
}
public static SuperByteBuffer block(Compartment<BlockState> 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<PoseStack> 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<PoseStack> modelTransform) {
return CreateClient.BUFFER_CACHE.get(DIRECTIONAL_PARTIAL, Pair.of(dir, partial),
() -> BakedModelRenderHelper.standardModelRender(partial.get(), referenceState, modelTransform.get()));
}
public static Supplier<PoseStack> 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<PoseStack> rotateToFaceVertical(Direction facing) {
return () -> {
PoseStack stack = new PoseStack();
MatrixTransformStack.of(stack)
.centre()
.rotateY(AngleHelper.horizontalAngle(facing))
.rotateX(AngleHelper.verticalAngle(facing) + 90)
.unCentre();
return stack;
};
}
}

View file

@ -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<T> {
public static final Compartment<BlockState> GENERIC_TILE = new Compartment<>();
public static final Compartment<PartialModel> PARTIAL = new Compartment<>();
public static final Compartment<Pair<Direction, PartialModel>> DIRECTIONAL_PARTIAL = new Compartment<>();
}

View file

@ -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<PoseStack> 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<PoseStack> rotateToFaceVertical(Direction facing) {
return () -> {
PoseStack stack = new PoseStack();
MatrixTransformStack.of(stack)
.centre()
.rotateY(AngleHelper.horizontalAngle(facing))
.rotateX(AngleHelper.verticalAngle(facing) + 90)
.unCentre();
return stack;
};
}
}

View file

@ -2,136 +2,53 @@ package com.simibubi.create.foundation.render;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; 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.Cache;
import com.google.common.cache.CacheBuilder; 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 { public class SuperByteBufferCache {
private Map<Compartment<?>, Cache<Object, SuperByteBuffer>> cache; protected final Map<Compartment<?>, Cache<Object, SuperByteBuffer>> caches = new HashMap<>();
public SuperByteBufferCache() { public synchronized void registerCompartment(Compartment<?> compartment) {
cache = new HashMap<>(); caches.put(compartment, CacheBuilder.newBuilder()
registerCompartment(Compartment.GENERIC_TILE);
registerCompartment(Compartment.PARTIAL);
registerCompartment(Compartment.DIRECTIONAL_PARTIAL);
}
public SuperByteBuffer renderBlock(BlockState toRender) {
return getGeneric(toRender, () -> standardBlockRender(toRender));
}
public SuperByteBuffer renderPartial(PartialModel partial, BlockState referenceState) {
return get(Compartment.PARTIAL, partial, () -> standardModelRender(partial.get(), referenceState));
}
public SuperByteBuffer renderPartial(PartialModel partial, BlockState referenceState,
Supplier<PoseStack> 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<PoseStack> modelTransform) {
return get(Compartment.DIRECTIONAL_PARTIAL, Pair.of(dir, partial),
() -> standardModelRender(partial.get(), referenceState, modelTransform.get()));
}
public SuperByteBuffer renderBlockIn(Compartment<BlockState> compartment, BlockState toRender) {
return get(compartment, toRender, () -> standardBlockRender(toRender));
}
SuperByteBuffer getGeneric(BlockState key, Supplier<SuperByteBuffer> supplier) {
return get(Compartment.GENERIC_TILE, key, supplier);
}
public <T> SuperByteBuffer get(Compartment<T> compartment, T key, Supplier<SuperByteBuffer> supplier) {
Cache<Object, SuperByteBuffer> compartmentCache = this.cache.get(compartment);
try {
return compartmentCache.get(key, supplier::get);
} catch (ExecutionException e) {
e.printStackTrace();
return null;
}
}
public <T> void invalidate(Compartment<T> compartment, T key) {
Cache<Object, SuperByteBuffer> compartmentCache = this.cache.get(compartment);
compartmentCache.invalidate(key);
}
public void registerCompartment(Compartment<?> instance) {
synchronized (cache) {
cache.put(instance, CacheBuilder.newBuilder()
.build()); .build());
} }
}
public void registerCompartment(Compartment<?> instance, long ticksUntilExpired) { public synchronized void registerCompartment(Compartment<?> compartment, long ticksUntilExpired) {
synchronized (cache) { caches.put(compartment, CacheBuilder.newBuilder()
cache.put(instance, CacheBuilder.newBuilder()
.expireAfterAccess(ticksUntilExpired * 50, TimeUnit.MILLISECONDS) .expireAfterAccess(ticksUntilExpired * 50, TimeUnit.MILLISECONDS)
.build()); .build());
} }
public <T> SuperByteBuffer get(Compartment<T> compartment, T key, Callable<SuperByteBuffer> callable) {
Cache<Object, SuperByteBuffer> cache = caches.get(compartment);
if (cache != null) {
try {
return cache.get(key, callable);
} catch (ExecutionException e) {
e.printStackTrace();
}
}
return null;
} }
private SuperByteBuffer standardBlockRender(BlockState renderedState) { public <T> void invalidate(Compartment<T> compartment, T key) {
BlockRenderDispatcher dispatcher = Minecraft.getInstance() caches.get(compartment).invalidate(key);
.getBlockRenderer();
return standardModelRender(dispatcher.getBlockModel(renderedState), renderedState);
} }
private SuperByteBuffer standardModelRender(BakedModel model, BlockState referenceState) { public <T> void invalidate(Compartment<?> compartment) {
return standardModelRender(model, referenceState, new PoseStack()); caches.get(compartment).invalidateAll();
}
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() { public void invalidate() {
cache.forEach((comp, cache) -> cache.invalidateAll()); caches.forEach((compartment, cache) -> cache.invalidateAll());
}
public static class Compartment<T> {
} }
} }

View file

@ -99,7 +99,7 @@ public abstract class ValueBoxTransform {
protected Vec3 getLocalOffset(BlockState state) { protected Vec3 getLocalOffset(BlockState state) {
Vec3 location = getSouthLocation(); Vec3 location = getSouthLocation();
location = VecHelper.rotateCentered(location, AngleHelper.horizontalAngle(getSide()), Axis.Y); 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; return location;
} }

View file

@ -30,12 +30,12 @@ public class ScrollValueHandler {
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public static boolean onScroll(double delta) { public static boolean onScroll(double delta) {
HitResult objectMouseOver = Minecraft.getInstance().hitResult; Minecraft mc = Minecraft.getInstance();
HitResult objectMouseOver = mc.hitResult;
if (!(objectMouseOver instanceof BlockHitResult)) if (!(objectMouseOver instanceof BlockHitResult))
return false; return false;
BlockHitResult result = (BlockHitResult) objectMouseOver; BlockHitResult result = (BlockHitResult) objectMouseOver;
Minecraft mc = Minecraft.getInstance();
ClientLevel world = mc.level; ClientLevel world = mc.level;
BlockPos blockPos = result.getBlockPos(); BlockPos blockPos = result.getBlockPos();
@ -46,13 +46,13 @@ public class ScrollValueHandler {
return false; return false;
if (!mc.player.mayBuild()) if (!mc.player.mayBuild())
return false; return false;
if (scrolling.needsWrench && !AllItems.WRENCH.isIn(mc.player.getMainHandItem()))
return false;
passiveScrollDirection = (float) -delta; passiveScrollDirection = (float) -delta;
wrenchCog.bump(3, -delta * 10); wrenchCog.bump(3, -delta * 10);
int prev = scrolling.scrollableValue; int prev = scrolling.scrollableValue;
if (scrolling.needsWrench && !AllItems.WRENCH.isIn(mc.player.getMainHandItem()))
return false;
if (scrolling.slotPositioning instanceof Sided) if (scrolling.slotPositioning instanceof Sided)
((Sided) scrolling.slotPositioning).fromSide(result.getDirection()); ((Sided) scrolling.slotPositioning).fromSide(result.getDirection());
if (!scrolling.testHit(objectMouseOver.getLocation())) if (!scrolling.testHit(objectMouseOver.getLocation()))

View file

@ -5,23 +5,9 @@ import net.minecraft.core.Direction.Axis;
public class AngleHelper { public class AngleHelper {
/**
* Legacy method. See {@link #horizontalAngleNew(Direction)} for new method.
*/
public static float horizontalAngle(Direction facing) { public static float horizontalAngle(Direction facing) {
float angle = facing.toYRot(); if (facing.getAxis().isVertical())
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()) {
return 0; return 0;
}
float angle = facing.toYRot(); float angle = facing.toYRot();
if (facing.getAxis() == Axis.X) if (facing.getAxis() == Axis.X)
angle = -angle; angle = -angle;

View file

@ -8,6 +8,7 @@ import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.util.Unit; import net.minecraft.util.Unit;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
// TODO 1.18: remove and replace all usages with ResourceManagerReloadListener
@FunctionalInterface @FunctionalInterface
public interface ISimpleReloadListener extends PreparableReloadListener { public interface ISimpleReloadListener extends PreparableReloadListener {

View file

@ -11,6 +11,7 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
import com.simibubi.create.AllSpecialTextures; import com.simibubi.create.AllSpecialTextures;
import com.simibubi.create.foundation.render.RenderTypes; import com.simibubi.create.foundation.render.RenderTypes;
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
@ -31,23 +32,12 @@ public class BlockClusterOutline extends Outline {
@Override @Override
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) { public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
for (MergeEntry edge : cluster.visibleEdges) { cluster.visibleEdges.forEach(edge -> {
Vec3 start = Vec3.atLowerCornerOf(edge.pos); Vec3 start = Vec3.atLowerCornerOf(edge.pos);
Direction direction = Direction.get(AxisDirection.POSITIVE, edge.axis); Direction direction = Direction.get(AxisDirection.POSITIVE, edge.axis);
renderAACuboidLine(ms, buffer, start, Vec3.atLowerCornerOf(edge.pos.relative(direction))); 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<AllSpecialTextures> faceTexture = params.faceTexture; Optional<AllSpecialTextures> faceTexture = params.faceTexture;
if (!faceTexture.isPresent()) if (!faceTexture.isPresent())
return; return;
@ -56,12 +46,22 @@ public class BlockClusterOutline extends Outline {
.getLocation(), true); .getLocation(), true);
VertexConsumer builder = buffer.getLateBuffer(translucentType); 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 center = VecHelper.getCenterOf(pos);
Vec3 offset = Vec3.atLowerCornerOf(face.getNormal()); Vec3 offset = Vec3.atLowerCornerOf(face.getNormal());
Vec3 plane = VecHelper.axisAlingedPlaneOf(offset); Vec3 plane = VecHelper.axisAlingedPlaneOf(offset);
Axis axis = face.getAxis(); Axis axis = face.getAxis();
offset = offset.scale(1 / 2f + 1 / 64d); offset = offset.scale(1 / 2f + 1 / 128d);
plane = plane.scale(1 / 2f) plane = plane.scale(1 / 2f)
.add(offset); .add(offset);
@ -80,8 +80,8 @@ public class BlockClusterOutline extends Outline {
private static class Cluster { private static class Cluster {
Map<MergeEntry, AxisDirection> visibleFaces; private Map<MergeEntry, AxisDirection> visibleFaces;
Set<MergeEntry> visibleEdges; private Set<MergeEntry> visibleEdges;
public Cluster() { public Cluster() {
visibleEdges = new HashSet<>(); visibleEdges = new HashSet<>();
@ -91,9 +91,9 @@ public class BlockClusterOutline extends Outline {
public void include(BlockPos pos) { public void include(BlockPos pos) {
// 6 FACES // 6 FACES
for (Axis axis : Axis.values()) { for (Axis axis : Iterate.axes) {
Direction direction = Direction.get(AxisDirection.POSITIVE, axis); 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)); MergeEntry entry = new MergeEntry(axis, pos.relative(direction, offset));
if (visibleFaces.remove(entry) == null) if (visibleFaces.remove(entry) == null)
visibleFaces.put(entry, offset == 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE); visibleFaces.put(entry, offset == 0 ? AxisDirection.NEGATIVE : AxisDirection.POSITIVE);
@ -101,11 +101,11 @@ public class BlockClusterOutline extends Outline {
} }
// 12 EDGES // 12 EDGES
for (Axis axis : Axis.values()) { for (Axis axis : Iterate.axes) {
for (Axis axis2 : Axis.values()) { for (Axis axis2 : Iterate.axes) {
if (axis == axis2) if (axis == axis2)
continue; continue;
for (Axis axis3 : Axis.values()) { for (Axis axis3 : Iterate.axes) {
if (axis == axis3) if (axis == axis3)
continue; continue;
if (axis2 == axis3) if (axis2 == axis3)
@ -114,9 +114,9 @@ public class BlockClusterOutline extends Outline {
Direction direction = Direction.get(AxisDirection.POSITIVE, axis2); Direction direction = Direction.get(AxisDirection.POSITIVE, axis2);
Direction direction2 = Direction.get(AxisDirection.POSITIVE, axis3); 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); BlockPos entryPos = pos.relative(direction, offset);
for (int offset2 : new int[] { 0, 1 }) { for (int offset2 : Iterate.zeroAndOne) {
entryPos = entryPos.relative(direction2, offset2); entryPos = entryPos.relative(direction2, offset2);
MergeEntry entry = new MergeEntry(axis, entryPos); MergeEntry entry = new MergeEntry(axis, entryPos);
if (!visibleEdges.remove(entry)) if (!visibleEdges.remove(entry))
@ -135,8 +135,8 @@ public class BlockClusterOutline extends Outline {
private static class MergeEntry { private static class MergeEntry {
Axis axis; private Axis axis;
BlockPos pos; private BlockPos pos;
public MergeEntry(Axis axis, BlockPos pos) { public MergeEntry(Axis axis, BlockPos pos) {
this.axis = axis; this.axis = axis;

View file

@ -6,7 +6,6 @@ import javax.annotation.Nullable;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.PoseStack.Pose;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix3f; import com.mojang.math.Matrix3f;
import com.simibubi.create.AllSpecialTextures; 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.Color;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
@ -25,7 +25,7 @@ import net.minecraft.world.phys.Vec3;
public abstract class Outline { public abstract class Outline {
protected OutlineParams params; protected OutlineParams params;
protected Matrix3f transformNormals; protected Matrix3f transformNormals; // TODO: not used?
public Outline() { public Outline() {
params = new OutlineParams(); params = new OutlineParams();
@ -33,6 +33,12 @@ public abstract class Outline {
public abstract void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt); 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) { public void renderCuboidLine(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 start, Vec3 end) {
Vec3 diff = end.subtract(start); Vec3 diff = end.subtract(start);
float hAngle = AngleHelper.deg(Mth.atan2(diff.x, diff.z)); 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) { protected void putVertex(PoseStack ms, VertexConsumer builder, Vec3 pos, float u, float v, Direction normal) {
int i = 15 << 20 | 15 << 4; putVertex(ms.last(), builder, (float) pos.x, (float) pos.y, (float) pos.z, u, v, normal);
int j = i >> 16 & '\uffff'; }
int k = i & '\uffff';
Pose peek = ms.last(); protected void putVertex(PoseStack.Pose pose, VertexConsumer builder, float x, float y, float z, float u, float v, Direction normal) {
Color rgb = params.rgb; Color rgb = params.rgb;
if (transformNormals == null) if (transformNormals == null)
transformNormals = peek.normal(); transformNormals = pose.normal();
int xOffset = 0; int xOffset = 0;
int yOffset = 0; int yOffset = 0;
@ -143,23 +149,17 @@ public abstract class Outline {
zOffset = normal.getStepZ(); 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) .color(rgb.getRedAsFloat(), rgb.getGreenAsFloat(), rgb.getBlueAsFloat(), rgb.getAlphaAsFloat() * params.alpha)
.uv(u, v) .uv(u, v)
.overlayCoords(OverlayTexture.NO_OVERLAY) .overlayCoords(OverlayTexture.NO_OVERLAY)
.uv2(j, k) .uv2(params.lightMap)
.normal(peek.normal(), xOffset, yOffset, zOffset) .normal(pose.normal(), xOffset, yOffset, zOffset)
.endVertex(); .endVertex();
transformNormals = null; transformNormals = null;
} }
public void tick() {}
public OutlineParams getParams() {
return params;
}
public static class OutlineParams { public static class OutlineParams {
protected Optional<AllSpecialTextures> faceTexture; protected Optional<AllSpecialTextures> faceTexture;
protected Optional<AllSpecialTextures> hightlightedFaceTexture; protected Optional<AllSpecialTextures> hightlightedFaceTexture;
@ -168,7 +168,7 @@ public abstract class Outline {
protected boolean disableCull; protected boolean disableCull;
protected boolean disableNormals; protected boolean disableNormals;
protected float alpha; protected float alpha;
protected int lightMapU, lightMapV; protected int lightMap;
protected Color rgb; protected Color rgb;
private float lineWidth; private float lineWidth;
@ -178,10 +178,7 @@ public abstract class Outline {
lineWidth = 1 / 32f; lineWidth = 1 / 32f;
fadeLineWidth = true; fadeLineWidth = true;
rgb = Color.WHITE; rgb = Color.WHITE;
lightMap = LightTexture.FULL_BRIGHT;
int i = 15 << 20 | 15 << 4;
lightMapU = i >> 16 & '\uffff';
lightMapV = i & '\uffff';
} }
// builder // builder
@ -196,6 +193,11 @@ public abstract class Outline {
return this; return this;
} }
public OutlineParams lightMap(int light) {
lightMap = light;
return this;
}
public OutlineParams lineWidth(float width) { public OutlineParams lineWidth(float width) {
this.lineWidth = width; this.lineWidth = width;
return this; return this;

View file

@ -2,10 +2,9 @@ package com.simibubi.create.foundation.utility.outliner;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
@ -20,11 +19,8 @@ import net.minecraft.world.phys.Vec3;
public class Outliner { public class Outliner {
final Map<Object, OutlineEntry> outlines; private final Map<Object, OutlineEntry> outlines = Collections.synchronizedMap(new HashMap<>());
private final Map<Object, OutlineEntry> outlinesView = Collections.unmodifiableMap(outlines);
public Map<Object, OutlineEntry> getOutlines() {
return Collections.unmodifiableMap(outlines);
}
// Facade // Facade
@ -103,6 +99,10 @@ public class Outliner {
return Optional.empty(); return Optional.empty();
} }
public Map<Object, OutlineEntry> getOutlines() {
return outlinesView;
}
// Utility // Utility
private void createAABBOutlineIfMissing(Object slot, AABB bb) { private void createAABBOutlineIfMissing(Object slot, AABB bb) {
@ -126,39 +126,30 @@ public class Outliner {
// Maintenance // Maintenance
public Outliner() {
outlines = Collections.synchronizedMap(new HashMap<>());
}
public void tickOutlines() { public void tickOutlines() {
Set<Object> toClear = new HashSet<>(); Iterator<OutlineEntry> iterator = outlines.values().iterator();
while (iterator.hasNext()) {
outlines.forEach((key, entry) -> { OutlineEntry entry = iterator.next();
entry.ticksTillRemoval--; entry.tick();
entry.getOutline() if (!entry.isAlive())
.tick(); iterator.remove();
if (entry.isAlive()) }
return;
toClear.add(key);
});
toClear.forEach(outlines::remove);
} }
public void renderOutlines(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) { public void renderOutlines(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
outlines.forEach((key, entry) -> { outlines.forEach((key, entry) -> {
Outline outline = entry.getOutline(); Outline outline = entry.getOutline();
outline.params.alpha = 1; OutlineParams params = outline.getParams();
if (entry.ticksTillRemoval < 0) { params.alpha = 1;
if (entry.isFading()) {
int prevTicks = entry.ticksTillRemoval + 1; int prevTicks = entry.ticksTillRemoval + 1;
float fadeticks = OutlineEntry.fadeTicks; float fadeticks = OutlineEntry.fadeTicks;
float lastAlpha = prevTicks >= 0 ? 1 : 1 + (prevTicks / fadeticks); float lastAlpha = prevTicks >= 0 ? 1 : 1 + (prevTicks / fadeticks);
float currentAlpha = 1 + (entry.ticksTillRemoval / fadeticks); float currentAlpha = 1 + (entry.ticksTillRemoval / fadeticks);
float alpha = Mth.lerp(pt, lastAlpha, currentAlpha); float alpha = Mth.lerp(pt, lastAlpha, currentAlpha);
outline.params.alpha = alpha * alpha * alpha; params.alpha = alpha * alpha * alpha;
if (outline.params.alpha < 1 / 8f) if (params.alpha < 1 / 8f)
return; return;
} }
outline.render(ms, buffer, pt); outline.render(ms, buffer, pt);
@ -176,10 +167,19 @@ public class Outliner {
ticksTillRemoval = 1; ticksTillRemoval = 1;
} }
public void tick() {
ticksTillRemoval--;
outline.tick();
}
public boolean isAlive() { public boolean isAlive() {
return ticksTillRemoval >= -fadeTicks; return ticksTillRemoval >= -fadeTicks;
} }
public boolean isFading() {
return ticksTillRemoval < 0;
}
public Outline getOutline() { public Outline getOutline() {
return outline; return outline;
} }