From f9fc00855a48ee62ac57a1e27573638b03252adf Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Mon, 25 May 2020 23:09:36 +0200 Subject: [PATCH] Reversed Simi's reverse-rendering - Fixed all TERs that had their transformations backwards - Fixed contraptions not rendering tileentities when not near world origin - Fixed Schematic table crashing on upload - Made more kinetic blocks non-opaque --- .../com/simibubi/create/AllBlockPartials.java | 25 ++--- .../java/com/simibubi/create/AllBlocks.java | 12 ++- .../com/simibubi/create/AllTileEntities.java | 94 +++++++++---------- .../base/KineticTileEntityRenderer.java | 4 +- .../actors/DrillMovementBehaviour.java | 2 +- ...EntityRenderer.java => DrillRenderer.java} | 4 +- .../components/clock/CuckooClockRenderer.java | 44 +++++---- ...er.java => MechanicalCrafterRenderer.java} | 81 ++++++++++------ ...tyRenderer.java => HandCrankRenderer.java} | 4 +- .../deployer/DeployerMovementBehaviour.java | 2 +- ...ityRenderer.java => DeployerRenderer.java} | 41 ++++---- ...yRenderer.java => EncasedFanRenderer.java} | 27 +++--- .../components/flywheel/FlywheelRenderer.java | 56 ++++++----- ...erer.java => MechanicalMixerRenderer.java} | 22 +++-- ...otorBlock.java => CreativeMotorBlock.java} | 6 +- ...rator.java => CreativeMotorGenerator.java} | 10 +- ...nderer.java => CreativeMotorRenderer.java} | 4 +- ...tity.java => CreativeMotorTileEntity.java} | 8 +- ...erer.java => MechanicalPressRenderer.java} | 4 +- ...leEntityRenderer.java => SawRenderer.java} | 4 +- ...tityRenderer.java => BearingRenderer.java} | 25 +++-- ...rer.java => MechanicalPistonRenderer.java} | 4 +- ...EntityRenderer.java => BasinRenderer.java} | 4 +- .../advanced/SpeedControllerTileEntity.java | 4 +- ...eEntityRenderer.java => BeltRenderer.java} | 4 +- ...enderer.java => EncasedShaftRenderer.java} | 4 +- ...yRenderer.java => SplitShaftRenderer.java} | 4 +- ...EntityRenderer.java => GaugeRenderer.java} | 27 +++--- ...tityRenderer.java => GearboxRenderer.java} | 4 +- ...enderer.java => BeltObserverRenderer.java} | 4 +- ...yRenderer.java => BeltTunnelRenderer.java} | 27 +++--- ...Renderer.java => AnalogLeverRenderer.java} | 22 +++-- .../schematics/ServerSchematicLoader.java | 3 +- .../block/SchematicannonRenderer.java | 12 +-- .../renderer/SafeTileEntityRenderer.java | 15 +-- .../utility/TileEntityRenderHelper.java | 58 +++--------- .../create/models/block/hand_crank/block.json | 19 ++-- 37 files changed, 367 insertions(+), 327 deletions(-) rename src/main/java/com/simibubi/create/content/contraptions/components/actors/{DrillTileEntityRenderer.java => DrillRenderer.java} (93%) rename src/main/java/com/simibubi/create/content/contraptions/components/crafter/{MechanicalCrafterTileEntityRenderer.java => MechanicalCrafterRenderer.java} (73%) rename src/main/java/com/simibubi/create/content/contraptions/components/crank/{HandCrankTileEntityRenderer.java => HandCrankRenderer.java} (90%) rename src/main/java/com/simibubi/create/content/contraptions/components/deployer/{DeployerTileEntityRenderer.java => DeployerRenderer.java} (86%) rename src/main/java/com/simibubi/create/content/contraptions/components/fan/{EncasedFanTileEntityRenderer.java => EncasedFanRenderer.java} (58%) rename src/main/java/com/simibubi/create/content/contraptions/components/mixer/{MechanicalMixerTileEntityRenderer.java => MechanicalMixerRenderer.java} (79%) rename src/main/java/com/simibubi/create/content/contraptions/components/motor/{MotorBlock.java => CreativeMotorBlock.java} (91%) rename src/main/java/com/simibubi/create/content/contraptions/components/motor/{MotorGenerator.java => CreativeMotorGenerator.java} (74%) rename src/main/java/com/simibubi/create/content/contraptions/components/motor/{MotorTileEntityRenderer.java => CreativeMotorRenderer.java} (80%) rename src/main/java/com/simibubi/create/content/contraptions/components/motor/{MotorTileEntity.java => CreativeMotorTileEntity.java} (90%) rename src/main/java/com/simibubi/create/content/contraptions/components/press/{MechanicalPressTileEntityRenderer.java => MechanicalPressRenderer.java} (90%) rename src/main/java/com/simibubi/create/content/contraptions/components/saw/{SawTileEntityRenderer.java => SawRenderer.java} (96%) rename src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/{BearingTileEntityRenderer.java => BearingRenderer.java} (70%) rename src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/{MechanicalPistonTileEntityRenderer.java => MechanicalPistonRenderer.java} (74%) rename src/main/java/com/simibubi/create/content/contraptions/processing/{BasinTileEntityRenderer.java => BasinRenderer.java} (91%) rename src/main/java/com/simibubi/create/content/contraptions/relays/belt/{BeltTileEntityRenderer.java => BeltRenderer.java} (97%) rename src/main/java/com/simibubi/create/content/contraptions/relays/encased/{EncasedShaftTileEntityRenderer.java => EncasedShaftRenderer.java} (75%) rename src/main/java/com/simibubi/create/content/contraptions/relays/encased/{SplitShaftTileEntityRenderer.java => SplitShaftRenderer.java} (92%) rename src/main/java/com/simibubi/create/content/contraptions/relays/gauge/{GaugeTileEntityRenderer.java => GaugeRenderer.java} (75%) rename src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/{GearboxTileEntityRenderer.java => GearboxRenderer.java} (93%) rename src/main/java/com/simibubi/create/content/logistics/block/belts/observer/{BeltObserverTileEntityRenderer.java => BeltObserverRenderer.java} (84%) rename src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/{BeltTunnelTileEntityRenderer.java => BeltTunnelRenderer.java} (81%) rename src/main/java/com/simibubi/create/content/logistics/block/redstone/{AnalogLeverTileEntityRenderer.java => AnalogLeverRenderer.java} (80%) diff --git a/src/main/java/com/simibubi/create/AllBlockPartials.java b/src/main/java/com/simibubi/create/AllBlockPartials.java index b249653fb..64466715d 100644 --- a/src/main/java/com/simibubi/create/AllBlockPartials.java +++ b/src/main/java/com/simibubi/create/AllBlockPartials.java @@ -8,10 +8,10 @@ import java.util.Map; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.Lang; +import com.simibubi.create.foundation.utility.MatrixStacker; import com.simibubi.create.foundation.utility.SuperByteBuffer; import net.minecraft.block.BlockState; -import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; @@ -69,18 +69,17 @@ public enum AllBlockPartials { ROPE_HALF("rope_pulley/rope_half"), ROPE_HALF_MAGNET("rope_pulley/rope_half_magnet"), MILLSTONE_COG("millstone/inner"), - + SYMMETRY_PLANE("symmetry_effect/plane"), SYMMETRY_CROSSPLANE("symmetry_effect/crossplane"), SYMMETRY_TRIPLEPLANE("symmetry_effect/tripleplane"), - + ; private ResourceLocation modelLocation; private IBakedModel bakedModel; - private AllBlockPartials() { - } + private AllBlockPartials() {} private AllBlockPartials(String path) { modelLocation = new ResourceLocation(Create.ID, "block/" + path); @@ -118,20 +117,22 @@ public enum AllBlockPartials { Direction facing = referenceState.get(FACING); return renderOnDirectional(referenceState, facing); } - + public SuperByteBuffer renderOnHorizontal(BlockState referenceState) { Direction facing = referenceState.get(HORIZONTAL_FACING); return renderOnDirectional(referenceState, facing); } - + public SuperByteBuffer renderOnDirectional(BlockState referenceState, Direction facing) { MatrixStack ms = new MatrixStack(); // TODO 1.15 find a way to cache this model matrix computation - ms.translate(0.5, 0.5, 0.5); - ms.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(AngleHelper.rad(AngleHelper.horizontalAngle(facing)))); - ms.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(AngleHelper.rad(AngleHelper.verticalAngle(facing)))); - ms.translate(-0.5, -0.5, -0.5); - SuperByteBuffer renderPartial = CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms); + MatrixStacker.of(ms) + .centre() + .rotateY(AngleHelper.horizontalAngle(facing)) + .rotateX(AngleHelper.verticalAngle(facing)) + .unCentre(); + SuperByteBuffer renderPartial = + CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms); return renderPartial; } diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 2a8e598bd..223d9ea7f 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -27,8 +27,8 @@ import com.simibubi.create.content.contraptions.components.flywheel.engine.Furna import com.simibubi.create.content.contraptions.components.millstone.MillstoneBlock; import com.simibubi.create.content.contraptions.components.mixer.BasinOperatorBlockItem; import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerBlock; -import com.simibubi.create.content.contraptions.components.motor.MotorBlock; -import com.simibubi.create.content.contraptions.components.motor.MotorGenerator; +import com.simibubi.create.content.contraptions.components.motor.CreativeMotorBlock; +import com.simibubi.create.content.contraptions.components.motor.CreativeMotorGenerator; import com.simibubi.create.content.contraptions.components.press.MechanicalPressBlock; import com.simibubi.create.content.contraptions.components.saw.SawBlock; import com.simibubi.create.content.contraptions.components.saw.SawGenerator; @@ -246,9 +246,9 @@ public class AllBlocks { .blockstate(new BeltGenerator()::generate) .register(); - public static final BlockEntry CREATIVE_MOTOR = REGISTRATE.block("creative_motor", MotorBlock::new) + public static final BlockEntry CREATIVE_MOTOR = REGISTRATE.block("creative_motor", CreativeMotorBlock::new) .initialProperties(SharedProperties::stone) - .blockstate(new MotorGenerator()::generate) + .blockstate(new CreativeMotorGenerator()::generate) .transform(StressConfigDefaults.setCapacity(16384.0)) .item() .transform(customItemModel()) @@ -256,6 +256,7 @@ public class AllBlocks { public static final BlockEntry WATER_WHEEL = REGISTRATE.block("water_wheel", WaterWheelBlock::new) .initialProperties(SharedProperties::wooden) + .properties(p -> p.nonOpaque()) .blockstate(BlockStateGen.horizontalWheelProvider(false)) .addLayer(() -> RenderType::getCutoutMipped) .transform(StressConfigDefaults.setCapacity(16.0)) @@ -317,6 +318,7 @@ public class AllBlocks { public static final BlockEntry CRUSHING_WHEEL = REGISTRATE.block("crushing_wheel", CrushingWheelBlock::new) .initialProperties(SharedProperties::stone) + .properties(p -> p.nonOpaque()) .blockstate(BlockStateGen.axisBlockProvider(false)) .addLayer(() -> RenderType::getCutoutMipped) .transform(StressConfigDefaults.setImpact(8.0)) @@ -552,6 +554,7 @@ public class AllBlocks { public static final BlockEntry MECHANICAL_CRAFTER = REGISTRATE.block("mechanical_crafter", MechanicalCrafterBlock::new) .initialProperties(SharedProperties::softMetal) + .properties(p -> p.nonOpaque()) .blockstate(BlockStateGen.horizontalBlockProvider(true)) .transform(StressConfigDefaults.setImpact(2.0)) .transform(CreateRegistrate.connectedTextures(new CrafterCTBehaviour())) @@ -571,6 +574,7 @@ public class AllBlocks { public static final BlockEntry FLYWHEEL = REGISTRATE.block("flywheel", FlywheelBlock::new) .initialProperties(SharedProperties::softMetal) + .properties(p -> p.nonOpaque()) .blockstate(new FlywheelGenerator()::generate) .item() .transform(customItemModel()) diff --git a/src/main/java/com/simibubi/create/AllTileEntities.java b/src/main/java/com/simibubi/create/AllTileEntities.java index 5aa7dcc48..d8dc5a1fb 100644 --- a/src/main/java/com/simibubi/create/AllTileEntities.java +++ b/src/main/java/com/simibubi/create/AllTileEntities.java @@ -5,21 +5,21 @@ import java.util.function.Supplier; import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import com.simibubi.create.content.contraptions.components.actors.DrillTileEntity; -import com.simibubi.create.content.contraptions.components.actors.DrillTileEntityRenderer; +import com.simibubi.create.content.contraptions.components.actors.DrillRenderer; import com.simibubi.create.content.contraptions.components.actors.HarvesterRenderer; import com.simibubi.create.content.contraptions.components.actors.HarvesterTileEntity; import com.simibubi.create.content.contraptions.components.clock.CuckooClockRenderer; import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity; import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity; -import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntityRenderer; +import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterRenderer; import com.simibubi.create.content.contraptions.components.crank.HandCrankTileEntity; -import com.simibubi.create.content.contraptions.components.crank.HandCrankTileEntityRenderer; +import com.simibubi.create.content.contraptions.components.crank.HandCrankRenderer; import com.simibubi.create.content.contraptions.components.crusher.CrushingWheelControllerTileEntity; import com.simibubi.create.content.contraptions.components.crusher.CrushingWheelTileEntity; import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity; -import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntityRenderer; +import com.simibubi.create.content.contraptions.components.deployer.DeployerRenderer; import com.simibubi.create.content.contraptions.components.fan.EncasedFanTileEntity; -import com.simibubi.create.content.contraptions.components.fan.EncasedFanTileEntityRenderer; +import com.simibubi.create.content.contraptions.components.fan.EncasedFanRenderer; import com.simibubi.create.content.contraptions.components.fan.NozzleTileEntity; import com.simibubi.create.content.contraptions.components.flywheel.FlywheelRenderer; import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity; @@ -28,48 +28,48 @@ import com.simibubi.create.content.contraptions.components.flywheel.engine.Furna import com.simibubi.create.content.contraptions.components.millstone.MillstoneRenderer; import com.simibubi.create.content.contraptions.components.millstone.MillstoneTileEntity; import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerTileEntity; -import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerTileEntityRenderer; -import com.simibubi.create.content.contraptions.components.motor.MotorTileEntity; -import com.simibubi.create.content.contraptions.components.motor.MotorTileEntityRenderer; +import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerRenderer; +import com.simibubi.create.content.contraptions.components.motor.CreativeMotorTileEntity; +import com.simibubi.create.content.contraptions.components.motor.CreativeMotorRenderer; import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity; -import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntityRenderer; +import com.simibubi.create.content.contraptions.components.press.MechanicalPressRenderer; import com.simibubi.create.content.contraptions.components.saw.SawTileEntity; -import com.simibubi.create.content.contraptions.components.saw.SawTileEntityRenderer; -import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingTileEntityRenderer; +import com.simibubi.create.content.contraptions.components.saw.SawRenderer; +import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.ClockworkBearingTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonTileEntity; -import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonTileEntityRenderer; +import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyRenderer; import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyTileEntity; import com.simibubi.create.content.contraptions.components.turntable.TurntableTileEntity; import com.simibubi.create.content.contraptions.components.waterwheel.WaterWheelTileEntity; import com.simibubi.create.content.contraptions.processing.BasinTileEntity; -import com.simibubi.create.content.contraptions.processing.BasinTileEntityRenderer; +import com.simibubi.create.content.contraptions.processing.BasinRenderer; import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerRenderer; import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerTileEntity; import com.simibubi.create.content.contraptions.relays.advanced.sequencer.SequencedGearshiftTileEntity; import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity; -import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntityRenderer; +import com.simibubi.create.content.contraptions.relays.belt.BeltRenderer; import com.simibubi.create.content.contraptions.relays.elementary.SimpleKineticTileEntity; import com.simibubi.create.content.contraptions.relays.encased.AdjustablePulleyTileEntity; import com.simibubi.create.content.contraptions.relays.encased.ClutchTileEntity; import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftTileEntity; -import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftTileEntityRenderer; -import com.simibubi.create.content.contraptions.relays.encased.SplitShaftTileEntityRenderer; +import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftRenderer; +import com.simibubi.create.content.contraptions.relays.encased.SplitShaftRenderer; import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock; -import com.simibubi.create.content.contraptions.relays.gauge.GaugeTileEntityRenderer; +import com.simibubi.create.content.contraptions.relays.gauge.GaugeRenderer; import com.simibubi.create.content.contraptions.relays.gauge.SpeedGaugeTileEntity; import com.simibubi.create.content.contraptions.relays.gauge.StressGaugeTileEntity; import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntity; -import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntityRenderer; +import com.simibubi.create.content.contraptions.relays.gearbox.GearboxRenderer; import com.simibubi.create.content.contraptions.relays.gearbox.GearshiftTileEntity; import com.simibubi.create.content.logistics.block.belts.observer.BeltObserverTileEntity; -import com.simibubi.create.content.logistics.block.belts.observer.BeltObserverTileEntityRenderer; +import com.simibubi.create.content.logistics.block.belts.observer.BeltObserverRenderer; import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelTileEntity; -import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelTileEntityRenderer; +import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelRenderer; import com.simibubi.create.content.logistics.block.diodes.AdjustablePulseRepeaterTileEntity; import com.simibubi.create.content.logistics.block.diodes.AdjustableRepeaterRenderer; import com.simibubi.create.content.logistics.block.diodes.AdjustableRepeaterTileEntity; @@ -79,7 +79,7 @@ import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateTileEntity; import com.simibubi.create.content.logistics.block.inventories.CreativeCrateTileEntity; import com.simibubi.create.content.logistics.block.redstone.AnalogLeverTileEntity; -import com.simibubi.create.content.logistics.block.redstone.AnalogLeverTileEntityRenderer; +import com.simibubi.create.content.logistics.block.redstone.AnalogLeverRenderer; import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkTileEntity; import com.simibubi.create.content.logistics.block.redstone.StockpileSwitchTileEntity; import com.simibubi.create.content.logistics.block.transposer.LinkedTransposerTileEntity; @@ -110,7 +110,7 @@ public enum AllTileEntities { // Kinetics SIMPLE_KINETIC(SimpleKineticTileEntity::new, AllBlocks.SHAFT, AllBlocks.COGWHEEL, AllBlocks.LARGE_COGWHEEL, AllBlocks.ENCASED_SHAFT), - MOTOR(MotorTileEntity::new, AllBlocks.CREATIVE_MOTOR), + MOTOR(CreativeMotorTileEntity::new, AllBlocks.CREATIVE_MOTOR), GEARBOX(GearboxTileEntity::new, AllBlocks.GEARBOX), ENCASED_SHAFT(EncasedShaftTileEntity::new, AllBlocks.ENCASED_SHAFT, AllBlocks.ENCASED_BELT), ADJUSTABLE_PULLEY(AdjustablePulleyTileEntity::new, AllBlocks.ADJUSTABLE_PULLEY), @@ -207,37 +207,37 @@ public enum AllTileEntities { bind(SIMPLE_KINETIC, KineticTileEntityRenderer::new); bind(TURNTABLE, KineticTileEntityRenderer::new); - bind(MOTOR, MotorTileEntityRenderer::new); - bind(ENCASED_SHAFT, EncasedShaftTileEntityRenderer::new); - bind(ADJUSTABLE_PULLEY, EncasedShaftTileEntityRenderer::new); - bind(DRILL, DrillTileEntityRenderer::new); - bind(SAW, SawTileEntityRenderer::new); - bind(ENCASED_FAN, EncasedFanTileEntityRenderer::new); - bind(GEARBOX, GearboxTileEntityRenderer::new); - bind(GEARSHIFT, SplitShaftTileEntityRenderer::new); - bind(CLUTCH, SplitShaftTileEntityRenderer::new); - bind(SEQUENCED_GEARSHIFT, SplitShaftTileEntityRenderer::new); - bind(BELT, BeltTileEntityRenderer::new); + bind(MOTOR, CreativeMotorRenderer::new); + bind(ENCASED_SHAFT, EncasedShaftRenderer::new); + bind(ADJUSTABLE_PULLEY, EncasedShaftRenderer::new); + bind(DRILL, DrillRenderer::new); + bind(SAW, SawRenderer::new); + bind(ENCASED_FAN, EncasedFanRenderer::new); + bind(GEARBOX, GearboxRenderer::new); + bind(GEARSHIFT, SplitShaftRenderer::new); + bind(CLUTCH, SplitShaftRenderer::new); + bind(SEQUENCED_GEARSHIFT, SplitShaftRenderer::new); + bind(BELT, BeltRenderer::new); bind(WATER_WHEEL, KineticTileEntityRenderer::new); - bind(HAND_CRANK, HandCrankTileEntityRenderer::new); + bind(HAND_CRANK, HandCrankRenderer::new); bind(CUCKOO_CLOCK, CuckooClockRenderer::new); - bind(ANALOG_LEVER, AnalogLeverTileEntityRenderer::new); + bind(ANALOG_LEVER, AnalogLeverRenderer::new); - bind(MECHANICAL_PISTON, MechanicalPistonTileEntityRenderer::new); - bind(MECHANICAL_BEARING, BearingTileEntityRenderer::new); - bind(CLOCKWORK_BEARING, BearingTileEntityRenderer::new); + bind(MECHANICAL_PISTON, MechanicalPistonRenderer::new); + bind(MECHANICAL_BEARING, BearingRenderer::new); + bind(CLOCKWORK_BEARING, BearingRenderer::new); bind(ROPE_PULLEY, PulleyRenderer::new); bind(HARVESTER, HarvesterRenderer::new); bind(MILLSTONE, MillstoneRenderer::new); bind(CRUSHING_WHEEL, KineticTileEntityRenderer::new); - bind(MECHANICAL_PRESS, MechanicalPressTileEntityRenderer::new); - bind(MECHANICAL_MIXER, MechanicalMixerTileEntityRenderer::new); - bind(MECHANICAL_CRAFTER, MechanicalCrafterTileEntityRenderer::new); - bind(SPEEDOMETER, disp -> new GaugeTileEntityRenderer(disp, GaugeBlock.Type.SPEED)); - bind(STRESSOMETER, disp -> new GaugeTileEntityRenderer(disp, GaugeBlock.Type.STRESS)); - bind(BASIN, BasinTileEntityRenderer::new); - bind(DEPLOYER, DeployerTileEntityRenderer::new); + bind(MECHANICAL_PRESS, MechanicalPressRenderer::new); + bind(MECHANICAL_MIXER, MechanicalMixerRenderer::new); + bind(MECHANICAL_CRAFTER, MechanicalCrafterRenderer::new); + bind(SPEEDOMETER, disp -> new GaugeRenderer(disp, GaugeBlock.Type.SPEED)); + bind(STRESSOMETER, disp -> new GaugeRenderer(disp, GaugeBlock.Type.STRESS)); + bind(BASIN, BasinRenderer::new); + bind(DEPLOYER, DeployerRenderer::new); bind(FLYWHEEL, FlywheelRenderer::new); bind(FURNACE_ENGINE, EngineRenderer::new); bind(ROTATION_SPEED_CONTROLLER, SpeedControllerRenderer::new); @@ -249,8 +249,8 @@ public enum AllTileEntities { bind(TRANSPOSER, SmartTileEntityRenderer::new); bind(LINKED_TRANSPOSER, SmartTileEntityRenderer::new); bind(FUNNEL, SmartTileEntityRenderer::new); - bind(BELT_TUNNEL, BeltTunnelTileEntityRenderer::new); - bind(BELT_OBSERVER, BeltObserverTileEntityRenderer::new); + bind(BELT_TUNNEL, BeltTunnelRenderer::new); + bind(BELT_OBSERVER, BeltObserverRenderer::new); bind(ADJUSTABLE_REPEATER, AdjustableRepeaterRenderer::new); bind(ADJUSTABLE_PULSE_REPEATER, AdjustableRepeaterRenderer::new); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java index acd0d6db6..5eb1aea7a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/base/KineticTileEntityRenderer.java @@ -18,7 +18,9 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; +import net.minecraft.util.Direction.AxisDirection; import net.minecraft.util.math.BlockPos; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; @@ -70,7 +72,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer { +public class MechanicalCrafterRenderer extends SafeTileEntityRenderer { - public MechanicalCrafterTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public MechanicalCrafterRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } @Override protected void renderSafe(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms, - IRenderTypeBuffer buffer, int light, int overlay) { + IRenderTypeBuffer buffer, int light, int overlay) { ms.push(); - Direction facing = te.getBlockState().get(HORIZONTAL_FACING); - Vec3d vec = new Vec3d(facing.getDirectionVec()).scale(.58).add(.5, .5, .5); + Direction facing = te.getBlockState() + .get(HORIZONTAL_FACING); + Vec3d vec = new Vec3d(facing.getDirectionVec()).scale(.58) + .add(.5, .5, .5); if (te.phase == Phase.EXPORTING) { Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(te.getBlockState()); @@ -59,16 +60,19 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer< ms.pop(); renderFast(te, partialTicks, ms, buffer, light); - //TessellatorHelper.draw(); + // TessellatorHelper.draw(); } - public void renderItems(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + public void renderItems(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms, + IRenderTypeBuffer buffer, int light, int overlay) { if (te.phase == Phase.IDLE) { ItemStack stack = te.inventory.getStackInSlot(0); if (!stack.isEmpty()) { ms.push(); ms.translate(0, 0, -1 / 256f); - Minecraft.getInstance().getItemRenderer().renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer); + Minecraft.getInstance() + .getItemRenderer() + .renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer); ms.pop(); } } else { @@ -89,7 +93,7 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer< ms.scale(1 - lateProgress, 1 - lateProgress, 1 - lateProgress); Vec3d centering = new Vec3d(-items.minX + (-items.width + 1) / 2f, -items.minY + (-items.height + 1) / 2f, 0) - .scale(earlyProgress); + .scale(earlyProgress); ms.translate(centering.x * .5f, centering.y * .5f, 0); distance += (-4 * (progress - .5f) * (progress - .5f) + 1) * .25f; } @@ -97,13 +101,22 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer< boolean onlyRenderFirst = te.phase == Phase.INSERTING || te.phase == Phase.CRAFTING && te.countDown < 1000; final float spacing = distance; items.grid.forEach((pair, stack) -> { - if (onlyRenderFirst && (pair.getLeft().intValue() != 0 || pair.getRight().intValue() != 0)) + if (onlyRenderFirst && (pair.getLeft() + .intValue() != 0 + || pair.getRight() + .intValue() != 0)) return; ms.push(); - ms.translate(pair.getKey() * spacing, pair.getValue() * spacing, 0); - TessellatorHelper.fightZFighting(pair.hashCode() + te.getPos().hashCode()); - Minecraft.getInstance().getItemRenderer().renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer); + Integer x = pair.getKey(); + Integer y = pair.getValue(); + ms.translate(x * spacing, y * spacing, 0); + MatrixStacker.of(ms) + .nudge(x * 13 + y + te.getPos() + .hashCode()); + Minecraft.getInstance() + .getItemRenderer() + .renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer); ms.pop(); }); @@ -123,36 +136,44 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer< ms.scale(downScaling, downScaling, downScaling); items.grid.forEach((pair, stack) -> { - if (pair.getLeft().intValue() != 0 || pair.getRight().intValue() != 0) + if (pair.getLeft() + .intValue() != 0 + || pair.getRight() + .intValue() != 0) return; - Minecraft.getInstance().getItemRenderer().renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer); + Minecraft.getInstance() + .getItemRenderer() + .renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer); }); } } } - public void renderFast(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light) { + public void renderFast(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, + int light) { BlockState blockState = te.getBlockState(); - IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState); - superBuffer.rotateCentered(Axis.X, (float) (Math.PI / 2)); - superBuffer.rotateCentered(Axis.Y, - (float) (blockState.get(HORIZONTAL_FACING).getAxis() != Axis.X ? 0 : Math.PI / 2)); - standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb); + standardKineticRotationTransform(superBuffer, te, light); + superBuffer.rotateCentered(Direction.UP, (float) (blockState.get(HORIZONTAL_FACING) + .getAxis() != Axis.X ? 0 : Math.PI / 2)); + superBuffer.rotateCentered(Direction.EAST, (float) (Math.PI / 2)); + superBuffer.renderInto(ms, vb); Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(blockState); BlockPos pos = te.getPos(); if ((te.covered || te.phase != Phase.IDLE) && te.phase != Phase.CRAFTING && te.phase != Phase.INSERTING) { - SuperByteBuffer lidBuffer = renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_LID, blockState, pos); + SuperByteBuffer lidBuffer = + renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_LID, blockState, pos); lidBuffer.renderInto(ms, vb); } if (MechanicalCrafterBlock.isValidTarget(te.getWorld(), pos.offset(targetDirection), blockState)) { - SuperByteBuffer beltBuffer = renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT, blockState, pos); + SuperByteBuffer beltBuffer = + renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT, blockState, pos); SuperByteBuffer beltFrameBuffer = renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT_FRAME, blockState, pos); @@ -174,12 +195,14 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer< } - private SuperByteBuffer renderAndTransform(MechanicalCrafterTileEntity te, AllBlockPartials renderBlock, BlockState crafterState, BlockPos pos) { + private SuperByteBuffer renderAndTransform(MechanicalCrafterTileEntity te, AllBlockPartials renderBlock, + BlockState crafterState, BlockPos pos) { SuperByteBuffer buffer = renderBlock.renderOn(crafterState); - float xRot = crafterState.get(MechanicalCrafterBlock.POINTING).getXRotation(); + float xRot = crafterState.get(MechanicalCrafterBlock.POINTING) + .getXRotation(); float yRot = AngleHelper.horizontalAngle(crafterState.get(HORIZONTAL_FACING)); - buffer.rotateCentered(Axis.X, (float) ((xRot) / 180 * Math.PI)); - buffer.rotateCentered(Axis.Y, (float) ((yRot + 90) / 180 * Math.PI)); + buffer.rotateCentered(Direction.UP, (float) ((yRot + 90) / 180 * Math.PI)); + buffer.rotateCentered(Direction.EAST, (float) ((xRot) / 180 * Math.PI)); buffer.light(WorldRenderer.getLightmapCoordinates(te.getWorld(), crafterState, pos)); return buffer; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java similarity index 90% rename from src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java index 9a692d807..fe26150be 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crank/HandCrankRenderer.java @@ -14,9 +14,9 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.Direction; -public class HandCrankTileEntityRenderer extends KineticTileEntityRenderer { +public class HandCrankRenderer extends KineticTileEntityRenderer { - public HandCrankTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public HandCrankRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java index 5f93fcb88..7f315c3bb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerMovementBehaviour.java @@ -168,7 +168,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour { @Override public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffers) { - DeployerTileEntityRenderer.renderInContraption(context, ms, msLocal, buffers); + DeployerRenderer.renderInContraption(context, ms, msLocal, buffers); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java similarity index 86% rename from src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java index 53c1809bc..c9cf85bec 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/deployer/DeployerRenderer.java @@ -37,10 +37,9 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -@SuppressWarnings("deprecation") -public class DeployerTileEntityRenderer extends SafeTileEntityRenderer { +public class DeployerRenderer extends SafeTileEntityRenderer { - public DeployerTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public DeployerRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } @@ -107,15 +106,16 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer 0) @@ -40,10 +47,8 @@ public class EncasedFanTileEntityRenderer extends KineticTileEntityRenderer { float angle = (time * speed * 3 / 10f) % 360; angle = angle / 180f * (float) Math.PI; - SuperByteBuffer superByteBuffer = AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectional(te.getBlockState(), - direction.getOpposite()); - kineticRotationTransform(superByteBuffer, te, direction.getAxis(), angle, light); - superByteBuffer.renderInto(ms, vb); + standardKineticRotationTransform(shaftHalf, te, lightBehind).renderInto(ms, vb); + kineticRotationTransform(fanInner, te, direction.getAxis(), angle, lightInFront).renderInto(ms, vb); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java index 5fdb16608..9b25502b2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/flywheel/FlywheelRenderer.java @@ -30,7 +30,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { @Override protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, - int light, int overlay) { + int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); BlockState blockState = te.getBlockState(); @@ -39,39 +39,49 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { SuperByteBuffer wheel = AllBlockPartials.FLYWHEEL.renderOnHorizontal(blockState.rotate(Rotation.CLOCKWISE_90)); float speed = wte.visualSpeed.get(partialTicks) * 3 / 10f; float angle = wte.angle + speed * partialTicks; - + IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); if (FlywheelBlock.isConnected(blockState)) { Direction connection = FlywheelBlock.getConnection(blockState); - light = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, te.getPos().offset(connection)); - float rotation = connection.getAxis() == Axis.X ^ connection.getAxisDirection() == AxisDirection.NEGATIVE - ? -angle + light = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, te.getPos() + .offset(connection)); + float rotation = + connection.getAxis() == Axis.X ^ connection.getAxisDirection() == AxisDirection.NEGATIVE ? -angle : angle; boolean flip = blockState.get(FlywheelBlock.CONNECTION) == ConnectionState.LEFT; - rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_UPPER_ROTATING.renderOn(blockState), true, true, - rotation, flip), connection).light(light).renderInto(ms, vb); - rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_LOWER_ROTATING.renderOn(blockState), false, - true, rotation, flip), connection).light(light).renderInto(ms, vb); - rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_UPPER_SLIDING.renderOn(blockState), true, false, - rotation, flip), connection).light(light).renderInto(ms, vb); - rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_LOWER_SLIDING.renderOn(blockState), false, - false, rotation, flip), connection).light(light).renderInto(ms, vb); + transformConnector( + rotateToFacing(AllBlockPartials.FLYWHEEL_UPPER_ROTATING.renderOn(blockState), connection), true, true, + rotation, flip).light(light) + .renderInto(ms, vb); + transformConnector( + rotateToFacing(AllBlockPartials.FLYWHEEL_LOWER_ROTATING.renderOn(blockState), connection), false, true, + rotation, flip).light(light) + .renderInto(ms, vb); + + transformConnector(rotateToFacing(AllBlockPartials.FLYWHEEL_UPPER_SLIDING.renderOn(blockState), connection), + true, false, rotation, flip).light(light) + .renderInto(ms, vb); + transformConnector(rotateToFacing(AllBlockPartials.FLYWHEEL_LOWER_SLIDING.renderOn(blockState), connection), + false, false, rotation, flip).light(light) + .renderInto(ms, vb); } - kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING).getAxis(), AngleHelper.rad(angle), light); + kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING) + .getAxis(), AngleHelper.rad(angle), light); wheel.renderInto(ms, vb); } @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), - te.getBlockState().get(HORIZONTAL_FACING).getOpposite()); + return AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), te.getBlockState() + .get(HORIZONTAL_FACING) + .getOpposite()); } protected SuperByteBuffer transformConnector(SuperByteBuffer buffer, boolean upper, boolean rotating, float angle, - boolean flip) { + boolean flip) { float shift = upper ? 1 / 4f : -1 / 8f; float offset = upper ? 1 / 4f : 1 / 4f; @@ -89,19 +99,19 @@ public class FlywheelRenderer extends KineticTileEntityRenderer { float pivotY = (upper ? 8f : 2f) / 16; float pivotZ = (upper ? 23f : 21.5f) / 16f; + buffer.translate(pivotX, pivotY, pivotZ + shifting); + if (rotating) + buffer.rotate(Direction.EAST, AngleHelper.rad(barAngle)); + buffer.translate(-pivotX, -pivotY, -pivotZ); + if (flip && !upper) buffer.translate(9 / 16f, 0, 0); - buffer.translate(-pivotX, -pivotY, -pivotZ); - if (rotating) - buffer.rotate(Axis.X, AngleHelper.rad(barAngle)); - buffer.translate(pivotX, pivotY, pivotZ + shifting); - return buffer; } protected SuperByteBuffer rotateToFacing(SuperByteBuffer buffer, Direction facing) { - buffer.rotateCentered(Axis.Y, AngleHelper.rad(AngleHelper.horizontalAngle(facing))); + buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing))); return buffer; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java similarity index 79% rename from src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java index 262dcc604..da84d012f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/mixer/MechanicalMixerRenderer.java @@ -13,24 +13,24 @@ import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.util.Direction.Axis; +import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -public class MechanicalMixerTileEntityRenderer extends KineticTileEntityRenderer { +public class MechanicalMixerRenderer extends KineticTileEntityRenderer { - public MechanicalMixerTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public MechanicalMixerRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } @Override protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, - int light, int overlay) { + int light, int overlay) { BlockState blockState = te.getBlockState(); MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te; BlockPos pos = te.getPos(); - + IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); - + SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState); standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb); @@ -41,11 +41,15 @@ public class MechanicalMixerTileEntityRenderer extends KineticTileEntityRenderer float angle = (float) (((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI); SuperByteBuffer poleRender = AllBlockPartials.MECHANICAL_MIXER_POLE.renderOn(blockState); - poleRender.translate(0, -renderedHeadOffset, 0).light(packedLightmapCoords).renderInto(ms, vb); + poleRender.translate(0, -renderedHeadOffset, 0) + .light(packedLightmapCoords) + .renderInto(ms, vb); SuperByteBuffer headRender = AllBlockPartials.MECHANICAL_MIXER_HEAD.renderOn(blockState); - headRender.rotateCentered(Axis.Y, angle).translate(0, -renderedHeadOffset, 0).light(packedLightmapCoords) - .renderInto(ms, vb); + headRender.rotateCentered(Direction.UP, angle) + .translate(0, -renderedHeadOffset, 0) + .light(packedLightmapCoords) + .renderInto(ms, vb); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/motor/MotorBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorBlock.java similarity index 91% rename from src/main/java/com/simibubi/create/content/contraptions/components/motor/MotorBlock.java rename to src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorBlock.java index 34b14f5a5..c67338988 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/motor/MotorBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorBlock.java @@ -14,9 +14,9 @@ import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; -public class MotorBlock extends DirectionalKineticBlock { +public class CreativeMotorBlock extends DirectionalKineticBlock { - public MotorBlock(Properties properties) { + public CreativeMotorBlock(Properties properties) { super(properties); } @@ -27,7 +27,7 @@ public class MotorBlock extends DirectionalKineticBlock { @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return new MotorTileEntity(); + return new CreativeMotorTileEntity(); } @Override diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/motor/MotorGenerator.java b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorGenerator.java similarity index 74% rename from src/main/java/com/simibubi/create/content/contraptions/components/motor/MotorGenerator.java rename to src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorGenerator.java index a7c196bec..a26c54d41 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/motor/MotorGenerator.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorGenerator.java @@ -10,24 +10,24 @@ import net.minecraft.block.BlockState; import net.minecraft.util.Direction; import net.minecraftforge.client.model.generators.ModelFile; -public class MotorGenerator extends SpecialBlockStateGen { +public class CreativeMotorGenerator extends SpecialBlockStateGen { @Override protected int getXRotation(BlockState state) { - return state.get(MotorBlock.FACING) == Direction.DOWN ? 180 : 0; + return state.get(CreativeMotorBlock.FACING) == Direction.DOWN ? 180 : 0; } @Override protected int getYRotation(BlockState state) { - return state.get(MotorBlock.FACING) + return state.get(CreativeMotorBlock.FACING) .getAxis() - .isVertical() ? 0 : horizontalAngle(state.get(MotorBlock.FACING)); + .isVertical() ? 0 : horizontalAngle(state.get(CreativeMotorBlock.FACING)); } @Override public ModelFile getModel(DataGenContext ctx, RegistrateBlockstateProvider prov, BlockState state) { - return state.get(MotorBlock.FACING) + return state.get(CreativeMotorBlock.FACING) .getAxis() .isVertical() ? AssetLookup.partialBaseModel(ctx, prov, "vertical") : AssetLookup.partialBaseModel(ctx, prov); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/motor/MotorTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorRenderer.java similarity index 80% rename from src/main/java/com/simibubi/create/content/contraptions/components/motor/MotorTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorRenderer.java index f0a73a192..937e7558b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/motor/MotorTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorRenderer.java @@ -7,9 +7,9 @@ import com.simibubi.create.foundation.utility.SuperByteBuffer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -public class MotorTileEntityRenderer extends KineticTileEntityRenderer { +public class CreativeMotorRenderer extends KineticTileEntityRenderer { - public MotorTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public CreativeMotorRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/motor/MotorTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorTileEntity.java similarity index 90% rename from src/main/java/com/simibubi/create/content/contraptions/components/motor/MotorTileEntity.java rename to src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorTileEntity.java index bac057005..1a2a66f7a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/motor/MotorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/motor/CreativeMotorTileEntity.java @@ -11,12 +11,12 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollVal import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour.StepContext; import com.simibubi.create.foundation.utility.Lang; -public class MotorTileEntity extends GeneratingKineticTileEntity { +public class CreativeMotorTileEntity extends GeneratingKineticTileEntity { public static final int DEFAULT_SPEED = 16; protected ScrollValueBehaviour generatedSpeed; - public MotorTileEntity() { + public CreativeMotorTileEntity() { super(AllTileEntities.MOTOR.type); } @@ -26,7 +26,7 @@ public class MotorTileEntity extends GeneratingKineticTileEntity { Integer max = AllConfigs.SERVER.kinetics.maxMotorSpeed.get(); CenteredSideValueBoxTransform slot = - new CenteredSideValueBoxTransform((motor, side) -> motor.get(MotorBlock.FACING) == side.getOpposite()); + new CenteredSideValueBoxTransform((motor, side) -> motor.get(CreativeMotorBlock.FACING) == side.getOpposite()); generatedSpeed = new ScrollValueBehaviour(Lang.translate("generic.speed"), this, slot); generatedSpeed.between(-max, max); @@ -34,7 +34,7 @@ public class MotorTileEntity extends GeneratingKineticTileEntity { generatedSpeed.scrollableValue = DEFAULT_SPEED; generatedSpeed.withUnit(i -> Lang.translate("generic.unit.rpm")); generatedSpeed.withCallback(i -> this.updateGeneratedRotation()); - generatedSpeed.withStepFunction(MotorTileEntity::step); + generatedSpeed.withStepFunction(CreativeMotorTileEntity::step); behaviours.add(generatedSpeed); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java similarity index 90% rename from src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java index db0371d7d..1a721bac8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/press/MechanicalPressRenderer.java @@ -13,9 +13,9 @@ import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.math.BlockPos; -public class MechanicalPressTileEntityRenderer extends KineticTileEntityRenderer { +public class MechanicalPressRenderer extends KineticTileEntityRenderer { - public MechanicalPressTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public MechanicalPressRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java similarity index 96% rename from src/main/java/com/simibubi/create/content/contraptions/components/saw/SawTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java index a65c592d9..705fb5c6c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/saw/SawRenderer.java @@ -25,9 +25,9 @@ import net.minecraft.util.Direction; import net.minecraft.util.Rotation; import net.minecraft.util.math.MathHelper; -public class SawTileEntityRenderer extends SafeTileEntityRenderer { +public class SawRenderer extends SafeTileEntityRenderer { - public SawTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public SawRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java similarity index 70% rename from src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java index 84c19b603..eb3584ff4 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/bearing/BearingRenderer.java @@ -12,34 +12,39 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; -public class BearingTileEntityRenderer extends KineticTileEntityRenderer { +public class BearingRenderer extends KineticTileEntityRenderer { - public BearingTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public BearingRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } @Override protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, - int light, int overlay) { + int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); IBearingTileEntity bearingTe = (IBearingTileEntity) te; - final Direction facing = te.getBlockState().get(BlockStateProperties.FACING); + final Direction facing = te.getBlockState() + .get(BlockStateProperties.FACING); SuperByteBuffer superBuffer = AllBlockPartials.BEARING_TOP.renderOn(te.getBlockState()); - superBuffer.rotateCentered(Axis.X, AngleHelper.rad(-90 - AngleHelper.verticalAngle(facing))); - if (facing.getAxis().isHorizontal()) - superBuffer.rotateCentered(Axis.Y, AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite()))); + float interpolatedAngle = bearingTe.getInterpolatedAngle(partialTicks - 1); kineticRotationTransform(superBuffer, te, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI), light); + + if (facing.getAxis() + .isHorizontal()) + superBuffer.rotateCentered(Direction.UP, + AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite()))); + superBuffer.rotateCentered(Direction.EAST, AngleHelper.rad(-90 - AngleHelper.verticalAngle(facing))); superBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid())); } @Override protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { - return AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), - te.getBlockState().get(BearingBlock.FACING).getOpposite()); + return AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), te.getBlockState() + .get(BearingBlock.FACING) + .getOpposite()); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonRenderer.java similarity index 74% rename from src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonRenderer.java index e93fadd01..ae6114f31 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/MechanicalPistonRenderer.java @@ -6,9 +6,9 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -public class MechanicalPistonTileEntityRenderer extends KineticTileEntityRenderer { +public class MechanicalPistonRenderer extends KineticTileEntityRenderer { - public MechanicalPistonTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public MechanicalPistonRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java similarity index 91% rename from src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java index cc7781d40..899b3e7d7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinRenderer.java @@ -17,9 +17,9 @@ import net.minecraft.util.math.Vec3d; import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.ItemStackHandler; -public class BasinTileEntityRenderer extends SafeTileEntityRenderer { +public class BasinRenderer extends SafeTileEntityRenderer { - public BasinTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public BasinRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerTileEntity.java index 36b3d9fe5..96f72698f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/advanced/SpeedControllerTileEntity.java @@ -5,7 +5,7 @@ import java.util.List; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.RotationPropagator; import com.simibubi.create.content.contraptions.base.KineticTileEntity; -import com.simibubi.create.content.contraptions.components.motor.MotorTileEntity; +import com.simibubi.create.content.contraptions.components.motor.CreativeMotorTileEntity; import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; @@ -38,7 +38,7 @@ public class SpeedControllerTileEntity extends KineticTileEntity { targetSpeed.moveText(new Vec3d(9, 0, 10)); targetSpeed.withUnit(i -> Lang.translate("generic.unit.rpm")); targetSpeed.withCallback(i -> this.updateTargetRotation()); - targetSpeed.withStepFunction(MotorTileEntity::step); + targetSpeed.withStepFunction(CreativeMotorTileEntity::step); behaviours.add(targetSpeed); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java similarity index 97% rename from src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java index 8a22ae299..fbe8d5b3f 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltRenderer.java @@ -37,9 +37,9 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3i; @SuppressWarnings("deprecation") -public class BeltTileEntityRenderer extends SafeTileEntityRenderer { +public class BeltRenderer extends SafeTileEntityRenderer { - public BeltTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public BeltRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftRenderer.java similarity index 75% rename from src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftRenderer.java index 6f63dda62..0c4541743 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/EncasedShaftRenderer.java @@ -6,9 +6,9 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; import net.minecraft.block.BlockState; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -public class EncasedShaftTileEntityRenderer extends KineticTileEntityRenderer { +public class EncasedShaftRenderer extends KineticTileEntityRenderer { - public EncasedShaftTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public EncasedShaftRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java similarity index 92% rename from src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java index daa1543b2..6d04e0b0e 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/encased/SplitShaftRenderer.java @@ -16,9 +16,9 @@ import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; -public class SplitShaftTileEntityRenderer extends KineticTileEntityRenderer { +public class SplitShaftRenderer extends KineticTileEntityRenderer { - public SplitShaftTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public SplitShaftRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java similarity index 75% rename from src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java index 67a47d24b..edebd9556 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gauge/GaugeRenderer.java @@ -14,21 +14,20 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.util.Direction; -import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.MathHelper; -public class GaugeTileEntityRenderer extends KineticTileEntityRenderer { +public class GaugeRenderer extends KineticTileEntityRenderer { protected GaugeBlock.Type type; - public GaugeTileEntityRenderer(TileEntityRendererDispatcher dispatcher, GaugeBlock.Type type) { + public GaugeRenderer(TileEntityRendererDispatcher dispatcher, GaugeBlock.Type type) { super(dispatcher); this.type = type; } @Override protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, - int light, int overlay) { + int light, int overlay) { super.renderSafe(te, partialTicks, ms, buffer, light, overlay); BlockState gaugeState = te.getBlockState(); GaugeTileEntity gaugeTE = (GaugeTileEntity) te; @@ -36,25 +35,25 @@ public class GaugeTileEntityRenderer extends KineticTileEntityRenderer { SuperByteBuffer headBuffer = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS) - .renderOn(gaugeState); + .renderOn(gaugeState); SuperByteBuffer dialBuffer = AllBlockPartials.GAUGE_DIAL.renderOn(gaugeState); for (Direction facing : Direction.values()) { if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(te.getWorld(), te.getPos(), gaugeState, - facing)) + facing)) continue; - float dialPivot = -5.75f / 16; + float dialPivot = 5.75f / 16; float progress = MathHelper.lerp(partialTicks, gaugeTE.prevDialState, gaugeTE.dialState); - dialBuffer.translate(0, dialPivot, dialPivot) - .rotate(Axis.X, (float) (Math.PI / 2 * -progress)) - .translate(0, -dialPivot, -dialPivot); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); - rotateBufferTowards(dialBuffer, facing).light(lightCoords) - .renderInto(ms, vb); + rotateBufferTowards(dialBuffer, facing).translate(0, dialPivot, dialPivot) + .rotate(Direction.EAST, (float) (Math.PI / 2 * -progress)) + .translate(0, -dialPivot, -dialPivot) + .light(lightCoords) + .renderInto(ms, vb); rotateBufferTowards(headBuffer, facing).light(lightCoords) - .renderInto(ms, vb); + .renderInto(ms, vb); } } @@ -65,7 +64,7 @@ public class GaugeTileEntityRenderer extends KineticTileEntityRenderer { } protected SuperByteBuffer rotateBufferTowards(SuperByteBuffer buffer, Direction target) { - return buffer.rotateCentered(Axis.Y, (float) ((-target.getHorizontalAngle() - 90) / 180 * Math.PI)); + return buffer.rotateCentered(Direction.UP, (float) ((-target.getHorizontalAngle() - 90) / 180 * Math.PI)); } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java similarity index 93% rename from src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java index 9ba04ebff..2983b8673 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/gearbox/GearboxRenderer.java @@ -15,9 +15,9 @@ import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; -public class GearboxTileEntityRenderer extends KineticTileEntityRenderer { +public class GearboxRenderer extends KineticTileEntityRenderer { - public GearboxTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public GearboxRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/observer/BeltObserverTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/observer/BeltObserverRenderer.java similarity index 84% rename from src/main/java/com/simibubi/create/content/logistics/block/belts/observer/BeltObserverTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/logistics/block/belts/observer/BeltObserverRenderer.java index 2d8056012..0461fd6cd 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/observer/BeltObserverTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/observer/BeltObserverRenderer.java @@ -9,9 +9,9 @@ import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.state.properties.BlockStateProperties; -public class BeltObserverTileEntityRenderer extends SafeTileEntityRenderer { +public class BeltObserverRenderer extends SafeTileEntityRenderer { - public BeltObserverTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public BeltObserverRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntityRenderer.java b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java similarity index 81% rename from src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntityRenderer.java rename to src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java index dfb1e3a68..d728b837a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/belts/tunnel/BeltTunnelRenderer.java @@ -18,15 +18,15 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -public class BeltTunnelTileEntityRenderer extends SafeTileEntityRenderer { +public class BeltTunnelRenderer extends SafeTileEntityRenderer { - public BeltTunnelTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public BeltTunnelRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } @Override protected void renderSafe(BeltTunnelTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, - int light, int overlay) { + int light, int overlay) { SuperByteBuffer flapBuffer = AllBlockPartials.BELT_TUNNEL_FLAP.renderOn(te.getBlockState()); SuperByteBuffer indicatorBuffer = AllBlockPartials.BELT_TUNNEL_INDICATOR.renderOn(te.getBlockState()); BlockPos pos = te.getPos(); @@ -45,7 +45,8 @@ public class BeltTunnelTileEntityRenderer extends SafeTileEntityRenderer { +public class AnalogLeverRenderer extends SafeTileEntityRenderer { - public AnalogLeverTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { + public AnalogLeverRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } @Override protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, - int light, int overlay) { + int light, int overlay) { BlockState leverState = te.getBlockState(); int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), leverState, te.getPos()); float state = te.clientState.get(partialTicks); - + IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); // Handle SuperByteBuffer handle = AllBlockPartials.ANALOG_LEVER_HANDLE.renderOn(leverState); float angle = (float) ((state / 15) * 90 / 180 * Math.PI); - handle.translate(-1 / 2f, -1 / 16f, -1 / 2f).rotate(Axis.X, angle).translate(1 / 2f, 1 / 16f, 1 / 2f); - transform(handle, leverState).light(lightCoords).renderInto(ms, vb); + transform(handle, leverState).translate(1 / 2f, 1 / 16f, 1 / 2f) + .rotate(Direction.EAST, angle) + .translate(-1 / 2f, -1 / 16f, -1 / 2f); + handle.light(lightCoords) + .renderInto(ms, vb); // Indicator int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f); SuperByteBuffer indicator = transform(AllBlockPartials.ANALOG_LEVER_INDICATOR.renderOn(leverState), leverState); - indicator.light(lightCoords).color(color).renderInto(ms, vb); + indicator.light(lightCoords) + .color(color) + .renderInto(ms, vb); } private SuperByteBuffer transform(SuperByteBuffer buffer, BlockState leverState) { AttachFace face = leverState.get(AnalogLeverBlock.FACE); float rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180; float rY = AngleHelper.horizontalAngle(leverState.get(AnalogLeverBlock.HORIZONTAL_FACING)); - buffer.rotateCentered(Direction.EAST, (float) (rX / 180 * Math.PI)); buffer.rotateCentered(Direction.UP, (float) (rY / 180 * Math.PI)); + buffer.rotateCentered(Direction.EAST, (float) (rX / 180 * Math.PI)); return buffer; } diff --git a/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java b/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java index 735c8ec6d..3755dff63 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java +++ b/src/main/java/com/simibubi/create/content/schematics/ServerSchematicLoader.java @@ -46,6 +46,7 @@ public class ServerSchematicLoader { this.stream = stream; this.totalBytes = totalBytes; this.tablePos = tablePos; + this.world = world; this.bytesUploaded = 0; this.idleTime = 0; } @@ -134,7 +135,7 @@ public class ServerSchematicLoader { OutputStream writer = Files.newOutputStream(Paths.get(getSchematicPath(), playerSchematicId), StandardOpenOption.CREATE_NEW); activeUploads.put(playerSchematicId, - new SchematicUploadEntry(writer, size, player.getEntityWorld(), pos)); + new SchematicUploadEntry(writer, size, player.getServerWorld(), pos)); // Notify Tile Entity table.startUpload(schematic); diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java index 20ee72ab3..bcda5b31b 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonRenderer.java @@ -148,17 +148,17 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer extends TileEntityRenderer { - + public SafeTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } @Override - public final void render(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) { + public final void render(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, + int overlay) { if (isInvalid(te)) return; renderSafe(te, partialTicks, ms, buffer, light, overlay); } - - protected abstract void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay); - + + protected abstract void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, + int overlay); + public boolean isInvalid(T te) { - return te.getBlockState().getBlock() == Blocks.AIR; + return !te.hasWorld() || te.getBlockState() + .getBlock() == Blocks.AIR; } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/TileEntityRenderHelper.java b/src/main/java/com/simibubi/create/foundation/utility/TileEntityRenderHelper.java index 288093507..e20c7791d 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/TileEntityRenderHelper.java +++ b/src/main/java/com/simibubi/create/foundation/utility/TileEntityRenderHelper.java @@ -5,51 +5,48 @@ import java.util.Iterator; import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.Create; import com.simibubi.create.foundation.config.AllConfigs; -import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.Vector4f; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.crash.ReportedException; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.LightType; import net.minecraft.world.World; public class TileEntityRenderHelper { - protected static LightingWorld lightingWorld; - public static void renderTileEntities(World world, Iterable customRenderTEs, MatrixStack ms, MatrixStack localTransform, IRenderTypeBuffer buffer) { float pt = Minecraft.getInstance() .getRenderPartialTicks(); - - if (lightingWorld == null) - lightingWorld = new LightingWorld(world); - lightingWorld.setWorld(world); - lightingWorld.setTransform(localTransform.peek() - .getModel()); + Matrix4f matrix = localTransform.peek() + .getModel(); for (Iterator iterator = customRenderTEs.iterator(); iterator.hasNext();) { TileEntity tileEntity = iterator.next(); - if (TileEntityRendererDispatcher.instance.getRenderer(tileEntity) == null) { + TileEntityRenderer renderer = TileEntityRendererDispatcher.instance.getRenderer(tileEntity); + if (renderer == null) { iterator.remove(); continue; } try { - BlockPos pos = tileEntity.getPos(); - World prevTileWorld = tileEntity.getWorld(); ms.push(); MatrixStacker.of(ms) .translate(pos); - tileEntity.setLocation(lightingWorld, pos); - TileEntityRendererDispatcher.instance.render(tileEntity, pt, ms, buffer); - tileEntity.setLocation(prevTileWorld, pos); + + Vector4f vec = new Vector4f(pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, 1); + vec.transform(matrix); + BlockPos lightPos = new BlockPos(vec.getX(), vec.getY(), vec.getZ()); + renderer.render(tileEntity, pt, ms, buffer, WorldRenderer.getLightmapCoordinates(world, lightPos), + OverlayTexture.DEFAULT_UV); ms.pop(); } catch (ReportedException e) { @@ -68,33 +65,4 @@ public class TileEntityRenderHelper { } } - private static class LightingWorld extends WrappedWorld { - - private Matrix4f matrix; - - public LightingWorld(World world) { - super(world); - } - - void setWorld(World world) { - this.world = world; - } - - void setTransform(Matrix4f matrix) { - this.matrix = matrix; - } - - @Override - public int getLightLevel(LightType p_226658_1_, BlockPos p_226658_2_) { - return super.getLightLevel(p_226658_1_, transformPos(p_226658_2_)); - } - - private BlockPos transformPos(BlockPos pos) { - Vector4f vec = new Vector4f(pos.getX(), pos.getY(), pos.getZ(), 1); - vec.transform(matrix); - return new BlockPos(vec.getX(), vec.getY(), vec.getZ()); - } - - } - } diff --git a/src/main/resources/assets/create/models/block/hand_crank/block.json b/src/main/resources/assets/create/models/block/hand_crank/block.json index 748bb6b34..04ef87a0b 100644 --- a/src/main/resources/assets/create/models/block/hand_crank/block.json +++ b/src/main/resources/assets/create/models/block/hand_crank/block.json @@ -4,22 +4,20 @@ "textures": { "0": "create:block/axis", "1": "create:block/axis_top", - "2": "create:block/andesite_casing_short", - "3": "block/spruce_log", "particle": "create:block/axis" }, "elements": [ { "name": "Axis", - "from": [6, 6, 11], - "to": [10, 10, 16], + "from": [6, 0, 6], + "to": [10, 5, 10], "shade": false, "faces": { - "east": {"uv": [6, 0, 10, 5], "rotation": 270, "texture": "#0"}, - "south": {"uv": [6, 6, 10, 10], "texture": "#1"}, - "west": {"uv": [6, 0, 10, 5], "rotation": 90, "texture": "#0"}, - "up": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"}, - "down": {"uv": [6, 0, 10, 5], "texture": "#0"} + "north": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"}, + "east": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"}, + "south": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"}, + "west": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"}, + "down": {"uv": [6, 6, 10, 10], "texture": "#1"} } } ], @@ -28,5 +26,6 @@ "name": "shaft_half", "origin": [8, 8, 8], "children": [0] - }, 1, 2, 3, 4] + } + ] } \ No newline at end of file