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
This commit is contained in:
simibubi 2020-05-25 23:09:36 +02:00
parent 4e8a72be8b
commit f9fc00855a
37 changed files with 367 additions and 327 deletions

View File

@ -8,10 +8,10 @@ import java.util.Map;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.utility.AngleHelper; import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.SuperByteBuffer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -79,8 +79,7 @@ public enum AllBlockPartials {
private ResourceLocation modelLocation; private ResourceLocation modelLocation;
private IBakedModel bakedModel; private IBakedModel bakedModel;
private AllBlockPartials() { private AllBlockPartials() {}
}
private AllBlockPartials(String path) { private AllBlockPartials(String path) {
modelLocation = new ResourceLocation(Create.ID, "block/" + path); modelLocation = new ResourceLocation(Create.ID, "block/" + path);
@ -127,11 +126,13 @@ public enum AllBlockPartials {
public SuperByteBuffer renderOnDirectional(BlockState referenceState, Direction facing) { public SuperByteBuffer renderOnDirectional(BlockState referenceState, Direction facing) {
MatrixStack ms = new MatrixStack(); MatrixStack ms = new MatrixStack();
// TODO 1.15 find a way to cache this model matrix computation // TODO 1.15 find a way to cache this model matrix computation
ms.translate(0.5, 0.5, 0.5); MatrixStacker.of(ms)
ms.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(AngleHelper.rad(AngleHelper.horizontalAngle(facing)))); .centre()
ms.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(AngleHelper.rad(AngleHelper.verticalAngle(facing)))); .rotateY(AngleHelper.horizontalAngle(facing))
ms.translate(-0.5, -0.5, -0.5); .rotateX(AngleHelper.verticalAngle(facing))
SuperByteBuffer renderPartial = CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms); .unCentre();
SuperByteBuffer renderPartial =
CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms);
return renderPartial; return renderPartial;
} }

View File

@ -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.millstone.MillstoneBlock;
import com.simibubi.create.content.contraptions.components.mixer.BasinOperatorBlockItem; 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.mixer.MechanicalMixerBlock;
import com.simibubi.create.content.contraptions.components.motor.MotorBlock; import com.simibubi.create.content.contraptions.components.motor.CreativeMotorBlock;
import com.simibubi.create.content.contraptions.components.motor.MotorGenerator; 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.press.MechanicalPressBlock;
import com.simibubi.create.content.contraptions.components.saw.SawBlock; import com.simibubi.create.content.contraptions.components.saw.SawBlock;
import com.simibubi.create.content.contraptions.components.saw.SawGenerator; import com.simibubi.create.content.contraptions.components.saw.SawGenerator;
@ -246,9 +246,9 @@ public class AllBlocks {
.blockstate(new BeltGenerator()::generate) .blockstate(new BeltGenerator()::generate)
.register(); .register();
public static final BlockEntry<MotorBlock> CREATIVE_MOTOR = REGISTRATE.block("creative_motor", MotorBlock::new) public static final BlockEntry<CreativeMotorBlock> CREATIVE_MOTOR = REGISTRATE.block("creative_motor", CreativeMotorBlock::new)
.initialProperties(SharedProperties::stone) .initialProperties(SharedProperties::stone)
.blockstate(new MotorGenerator()::generate) .blockstate(new CreativeMotorGenerator()::generate)
.transform(StressConfigDefaults.setCapacity(16384.0)) .transform(StressConfigDefaults.setCapacity(16384.0))
.item() .item()
.transform(customItemModel()) .transform(customItemModel())
@ -256,6 +256,7 @@ public class AllBlocks {
public static final BlockEntry<WaterWheelBlock> WATER_WHEEL = REGISTRATE.block("water_wheel", WaterWheelBlock::new) public static final BlockEntry<WaterWheelBlock> WATER_WHEEL = REGISTRATE.block("water_wheel", WaterWheelBlock::new)
.initialProperties(SharedProperties::wooden) .initialProperties(SharedProperties::wooden)
.properties(p -> p.nonOpaque())
.blockstate(BlockStateGen.horizontalWheelProvider(false)) .blockstate(BlockStateGen.horizontalWheelProvider(false))
.addLayer(() -> RenderType::getCutoutMipped) .addLayer(() -> RenderType::getCutoutMipped)
.transform(StressConfigDefaults.setCapacity(16.0)) .transform(StressConfigDefaults.setCapacity(16.0))
@ -317,6 +318,7 @@ public class AllBlocks {
public static final BlockEntry<CrushingWheelBlock> CRUSHING_WHEEL = public static final BlockEntry<CrushingWheelBlock> CRUSHING_WHEEL =
REGISTRATE.block("crushing_wheel", CrushingWheelBlock::new) REGISTRATE.block("crushing_wheel", CrushingWheelBlock::new)
.initialProperties(SharedProperties::stone) .initialProperties(SharedProperties::stone)
.properties(p -> p.nonOpaque())
.blockstate(BlockStateGen.axisBlockProvider(false)) .blockstate(BlockStateGen.axisBlockProvider(false))
.addLayer(() -> RenderType::getCutoutMipped) .addLayer(() -> RenderType::getCutoutMipped)
.transform(StressConfigDefaults.setImpact(8.0)) .transform(StressConfigDefaults.setImpact(8.0))
@ -552,6 +554,7 @@ public class AllBlocks {
public static final BlockEntry<MechanicalCrafterBlock> MECHANICAL_CRAFTER = public static final BlockEntry<MechanicalCrafterBlock> MECHANICAL_CRAFTER =
REGISTRATE.block("mechanical_crafter", MechanicalCrafterBlock::new) REGISTRATE.block("mechanical_crafter", MechanicalCrafterBlock::new)
.initialProperties(SharedProperties::softMetal) .initialProperties(SharedProperties::softMetal)
.properties(p -> p.nonOpaque())
.blockstate(BlockStateGen.horizontalBlockProvider(true)) .blockstate(BlockStateGen.horizontalBlockProvider(true))
.transform(StressConfigDefaults.setImpact(2.0)) .transform(StressConfigDefaults.setImpact(2.0))
.transform(CreateRegistrate.connectedTextures(new CrafterCTBehaviour())) .transform(CreateRegistrate.connectedTextures(new CrafterCTBehaviour()))
@ -571,6 +574,7 @@ public class AllBlocks {
public static final BlockEntry<FlywheelBlock> FLYWHEEL = REGISTRATE.block("flywheel", FlywheelBlock::new) public static final BlockEntry<FlywheelBlock> FLYWHEEL = REGISTRATE.block("flywheel", FlywheelBlock::new)
.initialProperties(SharedProperties::softMetal) .initialProperties(SharedProperties::softMetal)
.properties(p -> p.nonOpaque())
.blockstate(new FlywheelGenerator()::generate) .blockstate(new FlywheelGenerator()::generate)
.item() .item()
.transform(customItemModel()) .transform(customItemModel())

View File

@ -5,21 +5,21 @@ import java.util.function.Supplier;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer; 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.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.HarvesterRenderer;
import com.simibubi.create.content.contraptions.components.actors.HarvesterTileEntity; 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.CuckooClockRenderer;
import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity; 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.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.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.CrushingWheelControllerTileEntity;
import com.simibubi.create.content.contraptions.components.crusher.CrushingWheelTileEntity; 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.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.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.fan.NozzleTileEntity;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelRenderer; import com.simibubi.create.content.contraptions.components.flywheel.FlywheelRenderer;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity; 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.MillstoneRenderer;
import com.simibubi.create.content.contraptions.components.millstone.MillstoneTileEntity; 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.MechanicalMixerTileEntity;
import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerTileEntityRenderer; import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerRenderer;
import com.simibubi.create.content.contraptions.components.motor.MotorTileEntity; import com.simibubi.create.content.contraptions.components.motor.CreativeMotorTileEntity;
import com.simibubi.create.content.contraptions.components.motor.MotorTileEntityRenderer; 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.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.SawTileEntity;
import com.simibubi.create.content.contraptions.components.saw.SawTileEntityRenderer; import com.simibubi.create.content.contraptions.components.saw.SawRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingTileEntityRenderer; 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.ClockworkBearingTileEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingTileEntity; 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.chassis.ChassisTileEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerTileEntity; 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.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.PulleyRenderer;
import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyTileEntity; 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.turntable.TurntableTileEntity;
import com.simibubi.create.content.contraptions.components.waterwheel.WaterWheelTileEntity; import com.simibubi.create.content.contraptions.components.waterwheel.WaterWheelTileEntity;
import com.simibubi.create.content.contraptions.processing.BasinTileEntity; 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.SpeedControllerRenderer;
import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerTileEntity; 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.advanced.sequencer.SequencedGearshiftTileEntity;
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity; 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.elementary.SimpleKineticTileEntity;
import com.simibubi.create.content.contraptions.relays.encased.AdjustablePulleyTileEntity; 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.ClutchTileEntity;
import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftTileEntity; 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.EncasedShaftRenderer;
import com.simibubi.create.content.contraptions.relays.encased.SplitShaftTileEntityRenderer; 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.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.SpeedGaugeTileEntity;
import com.simibubi.create.content.contraptions.relays.gauge.StressGaugeTileEntity; 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.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.contraptions.relays.gearbox.GearshiftTileEntity;
import com.simibubi.create.content.logistics.block.belts.observer.BeltObserverTileEntity; 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.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.AdjustablePulseRepeaterTileEntity;
import com.simibubi.create.content.logistics.block.diodes.AdjustableRepeaterRenderer; import com.simibubi.create.content.logistics.block.diodes.AdjustableRepeaterRenderer;
import com.simibubi.create.content.logistics.block.diodes.AdjustableRepeaterTileEntity; 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.AdjustableCrateTileEntity;
import com.simibubi.create.content.logistics.block.inventories.CreativeCrateTileEntity; 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.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.RedstoneLinkTileEntity;
import com.simibubi.create.content.logistics.block.redstone.StockpileSwitchTileEntity; import com.simibubi.create.content.logistics.block.redstone.StockpileSwitchTileEntity;
import com.simibubi.create.content.logistics.block.transposer.LinkedTransposerTileEntity; import com.simibubi.create.content.logistics.block.transposer.LinkedTransposerTileEntity;
@ -110,7 +110,7 @@ public enum AllTileEntities {
// Kinetics // Kinetics
SIMPLE_KINETIC(SimpleKineticTileEntity::new, AllBlocks.SHAFT, AllBlocks.COGWHEEL, AllBlocks.LARGE_COGWHEEL, SIMPLE_KINETIC(SimpleKineticTileEntity::new, AllBlocks.SHAFT, AllBlocks.COGWHEEL, AllBlocks.LARGE_COGWHEEL,
AllBlocks.ENCASED_SHAFT), AllBlocks.ENCASED_SHAFT),
MOTOR(MotorTileEntity::new, AllBlocks.CREATIVE_MOTOR), MOTOR(CreativeMotorTileEntity::new, AllBlocks.CREATIVE_MOTOR),
GEARBOX(GearboxTileEntity::new, AllBlocks.GEARBOX), GEARBOX(GearboxTileEntity::new, AllBlocks.GEARBOX),
ENCASED_SHAFT(EncasedShaftTileEntity::new, AllBlocks.ENCASED_SHAFT, AllBlocks.ENCASED_BELT), ENCASED_SHAFT(EncasedShaftTileEntity::new, AllBlocks.ENCASED_SHAFT, AllBlocks.ENCASED_BELT),
ADJUSTABLE_PULLEY(AdjustablePulleyTileEntity::new, AllBlocks.ADJUSTABLE_PULLEY), ADJUSTABLE_PULLEY(AdjustablePulleyTileEntity::new, AllBlocks.ADJUSTABLE_PULLEY),
@ -207,37 +207,37 @@ public enum AllTileEntities {
bind(SIMPLE_KINETIC, KineticTileEntityRenderer::new); bind(SIMPLE_KINETIC, KineticTileEntityRenderer::new);
bind(TURNTABLE, KineticTileEntityRenderer::new); bind(TURNTABLE, KineticTileEntityRenderer::new);
bind(MOTOR, MotorTileEntityRenderer::new); bind(MOTOR, CreativeMotorRenderer::new);
bind(ENCASED_SHAFT, EncasedShaftTileEntityRenderer::new); bind(ENCASED_SHAFT, EncasedShaftRenderer::new);
bind(ADJUSTABLE_PULLEY, EncasedShaftTileEntityRenderer::new); bind(ADJUSTABLE_PULLEY, EncasedShaftRenderer::new);
bind(DRILL, DrillTileEntityRenderer::new); bind(DRILL, DrillRenderer::new);
bind(SAW, SawTileEntityRenderer::new); bind(SAW, SawRenderer::new);
bind(ENCASED_FAN, EncasedFanTileEntityRenderer::new); bind(ENCASED_FAN, EncasedFanRenderer::new);
bind(GEARBOX, GearboxTileEntityRenderer::new); bind(GEARBOX, GearboxRenderer::new);
bind(GEARSHIFT, SplitShaftTileEntityRenderer::new); bind(GEARSHIFT, SplitShaftRenderer::new);
bind(CLUTCH, SplitShaftTileEntityRenderer::new); bind(CLUTCH, SplitShaftRenderer::new);
bind(SEQUENCED_GEARSHIFT, SplitShaftTileEntityRenderer::new); bind(SEQUENCED_GEARSHIFT, SplitShaftRenderer::new);
bind(BELT, BeltTileEntityRenderer::new); bind(BELT, BeltRenderer::new);
bind(WATER_WHEEL, KineticTileEntityRenderer::new); bind(WATER_WHEEL, KineticTileEntityRenderer::new);
bind(HAND_CRANK, HandCrankTileEntityRenderer::new); bind(HAND_CRANK, HandCrankRenderer::new);
bind(CUCKOO_CLOCK, CuckooClockRenderer::new); bind(CUCKOO_CLOCK, CuckooClockRenderer::new);
bind(ANALOG_LEVER, AnalogLeverTileEntityRenderer::new); bind(ANALOG_LEVER, AnalogLeverRenderer::new);
bind(MECHANICAL_PISTON, MechanicalPistonTileEntityRenderer::new); bind(MECHANICAL_PISTON, MechanicalPistonRenderer::new);
bind(MECHANICAL_BEARING, BearingTileEntityRenderer::new); bind(MECHANICAL_BEARING, BearingRenderer::new);
bind(CLOCKWORK_BEARING, BearingTileEntityRenderer::new); bind(CLOCKWORK_BEARING, BearingRenderer::new);
bind(ROPE_PULLEY, PulleyRenderer::new); bind(ROPE_PULLEY, PulleyRenderer::new);
bind(HARVESTER, HarvesterRenderer::new); bind(HARVESTER, HarvesterRenderer::new);
bind(MILLSTONE, MillstoneRenderer::new); bind(MILLSTONE, MillstoneRenderer::new);
bind(CRUSHING_WHEEL, KineticTileEntityRenderer::new); bind(CRUSHING_WHEEL, KineticTileEntityRenderer::new);
bind(MECHANICAL_PRESS, MechanicalPressTileEntityRenderer::new); bind(MECHANICAL_PRESS, MechanicalPressRenderer::new);
bind(MECHANICAL_MIXER, MechanicalMixerTileEntityRenderer::new); bind(MECHANICAL_MIXER, MechanicalMixerRenderer::new);
bind(MECHANICAL_CRAFTER, MechanicalCrafterTileEntityRenderer::new); bind(MECHANICAL_CRAFTER, MechanicalCrafterRenderer::new);
bind(SPEEDOMETER, disp -> new GaugeTileEntityRenderer(disp, GaugeBlock.Type.SPEED)); bind(SPEEDOMETER, disp -> new GaugeRenderer(disp, GaugeBlock.Type.SPEED));
bind(STRESSOMETER, disp -> new GaugeTileEntityRenderer(disp, GaugeBlock.Type.STRESS)); bind(STRESSOMETER, disp -> new GaugeRenderer(disp, GaugeBlock.Type.STRESS));
bind(BASIN, BasinTileEntityRenderer::new); bind(BASIN, BasinRenderer::new);
bind(DEPLOYER, DeployerTileEntityRenderer::new); bind(DEPLOYER, DeployerRenderer::new);
bind(FLYWHEEL, FlywheelRenderer::new); bind(FLYWHEEL, FlywheelRenderer::new);
bind(FURNACE_ENGINE, EngineRenderer::new); bind(FURNACE_ENGINE, EngineRenderer::new);
bind(ROTATION_SPEED_CONTROLLER, SpeedControllerRenderer::new); bind(ROTATION_SPEED_CONTROLLER, SpeedControllerRenderer::new);
@ -249,8 +249,8 @@ public enum AllTileEntities {
bind(TRANSPOSER, SmartTileEntityRenderer::new); bind(TRANSPOSER, SmartTileEntityRenderer::new);
bind(LINKED_TRANSPOSER, SmartTileEntityRenderer::new); bind(LINKED_TRANSPOSER, SmartTileEntityRenderer::new);
bind(FUNNEL, SmartTileEntityRenderer::new); bind(FUNNEL, SmartTileEntityRenderer::new);
bind(BELT_TUNNEL, BeltTunnelTileEntityRenderer::new); bind(BELT_TUNNEL, BeltTunnelRenderer::new);
bind(BELT_OBSERVER, BeltObserverTileEntityRenderer::new); bind(BELT_OBSERVER, BeltObserverRenderer::new);
bind(ADJUSTABLE_REPEATER, AdjustableRepeaterRenderer::new); bind(ADJUSTABLE_REPEATER, AdjustableRepeaterRenderer::new);
bind(ADJUSTABLE_PULSE_REPEATER, AdjustableRepeaterRenderer::new); bind(ADJUSTABLE_PULSE_REPEATER, AdjustableRepeaterRenderer::new);
} }

View File

@ -18,7 +18,9 @@ import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup; import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Direction.AxisDirection;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
@ -70,7 +72,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
public static SuperByteBuffer kineticRotationTransform(SuperByteBuffer buffer, KineticTileEntity te, Axis axis, public static SuperByteBuffer kineticRotationTransform(SuperByteBuffer buffer, KineticTileEntity te, Axis axis,
float angle, int light) { float angle, int light) {
buffer.light(light); buffer.light(light);
buffer.rotateCentered(axis, angle); buffer.rotateCentered(Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis), angle);
int white = 0xFFFFFF; int white = 0xFFFFFF;
if (KineticDebugger.isActive()) { if (KineticDebugger.isActive()) {

View File

@ -31,7 +31,7 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
@OnlyIn(value = Dist.CLIENT) @OnlyIn(value = Dist.CLIENT)
public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffer) { IRenderTypeBuffer buffer) {
DrillTileEntityRenderer.renderInContraption(context, ms, msLocal, buffer); DrillRenderer.renderInContraption(context, ms, msLocal, buffer);
} }
@Override @Override

View File

@ -17,9 +17,9 @@ import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
public class DrillTileEntityRenderer extends KineticTileEntityRenderer { public class DrillRenderer extends KineticTileEntityRenderer {
public DrillTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { public DrillRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }

View File

@ -15,7 +15,6 @@ import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
public class CuckooClockRenderer extends KineticTileEntityRenderer { public class CuckooClockRenderer extends KineticTileEntityRenderer {
@ -26,7 +25,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
@Override @Override
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, 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); super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (!(te instanceof CuckooClockTileEntity)) if (!(te instanceof CuckooClockTileEntity))
return; return;
@ -43,8 +42,10 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
SuperByteBuffer minuteHand = AllBlockPartials.CUCKOO_MINUTE_HAND.renderOn(blockState); SuperByteBuffer minuteHand = AllBlockPartials.CUCKOO_MINUTE_HAND.renderOn(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(packedLightmapCoords).renderInto(ms, vb); rotateHand(hourHand, hourAngle, direction).light(packedLightmapCoords)
rotateHand(minuteHand, minuteAngle, direction).light(packedLightmapCoords).renderInto(ms, vb); .renderInto(ms, vb);
rotateHand(minuteHand, minuteAngle, direction).light(packedLightmapCoords)
.renderInto(ms, vb);
// Doors // Doors
SuperByteBuffer leftDoor = AllBlockPartials.CUCKOO_LEFT_DOOR.renderOn(blockState); SuperByteBuffer leftDoor = AllBlockPartials.CUCKOO_LEFT_DOOR.renderOn(blockState);
@ -69,17 +70,21 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
} }
} }
rotateDoor(leftDoor, angle, true, direction).light(packedLightmapCoords).renderInto(ms, vb); rotateDoor(leftDoor, angle, true, direction).light(packedLightmapCoords)
rotateDoor(rightDoor, angle, false, direction).light(packedLightmapCoords).renderInto(ms, vb); .renderInto(ms, vb);
rotateDoor(rightDoor, angle, false, direction).light(packedLightmapCoords)
.renderInto(ms, vb);
// Figure // Figure
if (clock.animationType != null) { if (clock.animationType != null) {
offset = -(angle / 135) * 1 / 2f + 10 / 16f; offset = -(angle / 135) * 1 / 2f + 10 / 16f;
SuperByteBuffer figure = (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG SuperByteBuffer figure =
: AllBlockPartials.CUCKOO_CREEPER).renderOn(blockState); (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER)
.renderOn(blockState);
figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.rotateYCCW())));
figure.translate(offset, 0, 0); figure.translate(offset, 0, 0);
figure.rotateCentered(Axis.Y, AngleHelper.rad(AngleHelper.horizontalAngle(direction.rotateYCCW()))); figure.light(packedLightmapCoords)
figure.light(packedLightmapCoords).renderInto(ms, vb); .renderInto(ms, vb);
} }
} }
@ -90,18 +95,19 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
} }
private SuperByteBuffer transform(AllBlockPartials partial, KineticTileEntity te) { private SuperByteBuffer transform(AllBlockPartials partial, KineticTileEntity te) {
return partial.renderOnDirectional(te.getBlockState(), return partial.renderOnDirectional(te.getBlockState(), te.getBlockState()
te.getBlockState().get(CuckooClockBlock.HORIZONTAL_FACING).getOpposite()); .get(CuckooClockBlock.HORIZONTAL_FACING)
.getOpposite());
} }
private SuperByteBuffer rotateHand(SuperByteBuffer buffer, float angle, Direction facing) { private SuperByteBuffer rotateHand(SuperByteBuffer buffer, float angle, Direction facing) {
float pivotX = 2 / 16f; float pivotX = 2 / 16f;
float pivotY = 6 / 16f; float pivotY = 6 / 16f;
float pivotZ = 8 / 16f; float pivotZ = 8 / 16f;
buffer.translate(-pivotX, -pivotY, -pivotZ); buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.rotateYCCW())));
buffer.rotate(Axis.X, angle);
buffer.translate(pivotX, pivotY, pivotZ); buffer.translate(pivotX, pivotY, pivotZ);
buffer.rotateCentered(Axis.Y, AngleHelper.rad(AngleHelper.horizontalAngle(facing.rotateYCCW()))); buffer.rotate(Direction.EAST, angle);
buffer.translate(-pivotX, -pivotY, -pivotZ);
return buffer; return buffer;
} }
@ -109,10 +115,10 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
float pivotX = 2 / 16f; float pivotX = 2 / 16f;
float pivotY = 0; float pivotY = 0;
float pivotZ = (left ? 6 : 10) / 16f; float pivotZ = (left ? 6 : 10) / 16f;
buffer.translate(-pivotX, -pivotY, -pivotZ); buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.rotateYCCW())));
buffer.rotate(Axis.Y, AngleHelper.rad(angle) * (left ? -1 : 1));
buffer.translate(pivotX, pivotY, pivotZ); buffer.translate(pivotX, pivotY, pivotZ);
buffer.rotateCentered(Axis.Y, AngleHelper.rad(AngleHelper.horizontalAngle(facing.rotateYCCW()))); buffer.rotate(Direction.UP, AngleHelper.rad(angle) * (left ? -1 : 1));
buffer.translate(-pivotX, -pivotY, -pivotZ);
return buffer; return buffer;
} }

View File

@ -12,8 +12,8 @@ import com.simibubi.create.content.contraptions.components.crafter.RecipeGridHan
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;
import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.SuperByteBuffer;
import com.simibubi.create.foundation.utility.TessellatorHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -30,19 +30,20 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@SuppressWarnings("deprecation") public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<MechanicalCrafterTileEntity> {
public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer<MechanicalCrafterTileEntity> {
public MechanicalCrafterTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { public MechanicalCrafterRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }
@Override @Override
protected void renderSafe(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms, protected void renderSafe(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms,
IRenderTypeBuffer buffer, int light, int overlay) { IRenderTypeBuffer buffer, int light, int overlay) {
ms.push(); ms.push();
Direction facing = te.getBlockState().get(HORIZONTAL_FACING); Direction facing = te.getBlockState()
Vec3d vec = new Vec3d(facing.getDirectionVec()).scale(.58).add(.5, .5, .5); .get(HORIZONTAL_FACING);
Vec3d vec = new Vec3d(facing.getDirectionVec()).scale(.58)
.add(.5, .5, .5);
if (te.phase == Phase.EXPORTING) { if (te.phase == Phase.EXPORTING) {
Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(te.getBlockState()); Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(te.getBlockState());
@ -59,16 +60,19 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer<
ms.pop(); ms.pop();
renderFast(te, partialTicks, ms, buffer, light); 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) { if (te.phase == Phase.IDLE) {
ItemStack stack = te.inventory.getStackInSlot(0); ItemStack stack = te.inventory.getStackInSlot(0);
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
ms.push(); ms.push();
ms.translate(0, 0, -1 / 256f); 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(); ms.pop();
} }
} else { } else {
@ -89,7 +93,7 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer<
ms.scale(1 - lateProgress, 1 - lateProgress, 1 - lateProgress); ms.scale(1 - lateProgress, 1 - lateProgress, 1 - lateProgress);
Vec3d centering = Vec3d centering =
new Vec3d(-items.minX + (-items.width + 1) / 2f, -items.minY + (-items.height + 1) / 2f, 0) 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); ms.translate(centering.x * .5f, centering.y * .5f, 0);
distance += (-4 * (progress - .5f) * (progress - .5f) + 1) * .25f; 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; boolean onlyRenderFirst = te.phase == Phase.INSERTING || te.phase == Phase.CRAFTING && te.countDown < 1000;
final float spacing = distance; final float spacing = distance;
items.grid.forEach((pair, stack) -> { 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; return;
ms.push(); ms.push();
ms.translate(pair.getKey() * spacing, pair.getValue() * spacing, 0); Integer x = pair.getKey();
TessellatorHelper.fightZFighting(pair.hashCode() + te.getPos().hashCode()); Integer y = pair.getValue();
Minecraft.getInstance().getItemRenderer().renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer); 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(); ms.pop();
}); });
@ -123,36 +136,44 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer<
ms.scale(downScaling, downScaling, downScaling); ms.scale(downScaling, downScaling, downScaling);
items.grid.forEach((pair, stack) -> { items.grid.forEach((pair, stack) -> {
if (pair.getLeft().intValue() != 0 || pair.getRight().intValue() != 0) if (pair.getLeft()
.intValue() != 0
|| pair.getRight()
.intValue() != 0)
return; 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(); BlockState blockState = te.getBlockState();
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState); SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
superBuffer.rotateCentered(Axis.X, (float) (Math.PI / 2)); standardKineticRotationTransform(superBuffer, te, light);
superBuffer.rotateCentered(Axis.Y, superBuffer.rotateCentered(Direction.UP, (float) (blockState.get(HORIZONTAL_FACING)
(float) (blockState.get(HORIZONTAL_FACING).getAxis() != Axis.X ? 0 : Math.PI / 2)); .getAxis() != Axis.X ? 0 : Math.PI / 2));
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb); superBuffer.rotateCentered(Direction.EAST, (float) (Math.PI / 2));
superBuffer.renderInto(ms, vb);
Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(blockState); Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(blockState);
BlockPos pos = te.getPos(); BlockPos pos = te.getPos();
if ((te.covered || te.phase != Phase.IDLE) && te.phase != Phase.CRAFTING && te.phase != Phase.INSERTING) { 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); lidBuffer.renderInto(ms, vb);
} }
if (MechanicalCrafterBlock.isValidTarget(te.getWorld(), pos.offset(targetDirection), blockState)) { 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 = SuperByteBuffer beltFrameBuffer =
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT_FRAME, blockState, pos); 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); 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)); float yRot = AngleHelper.horizontalAngle(crafterState.get(HORIZONTAL_FACING));
buffer.rotateCentered(Axis.X, (float) ((xRot) / 180 * Math.PI)); buffer.rotateCentered(Direction.UP, (float) ((yRot + 90) / 180 * Math.PI));
buffer.rotateCentered(Axis.Y, (float) ((yRot + 90) / 180 * Math.PI)); buffer.rotateCentered(Direction.EAST, (float) ((xRot) / 180 * Math.PI));
buffer.light(WorldRenderer.getLightmapCoordinates(te.getWorld(), crafterState, pos)); buffer.light(WorldRenderer.getLightmapCoordinates(te.getWorld(), crafterState, pos));
return buffer; return buffer;
} }

View File

@ -14,9 +14,9 @@ import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; 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); super(dispatcher);
} }

View File

@ -168,7 +168,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
@Override @Override
public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal, public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
IRenderTypeBuffer buffers) { IRenderTypeBuffer buffers) {
DeployerTileEntityRenderer.renderInContraption(context, ms, msLocal, buffers); DeployerRenderer.renderInContraption(context, ms, msLocal, buffers);
} }
} }

View File

@ -37,10 +37,9 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
@SuppressWarnings("deprecation") public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity> {
public class DeployerTileEntityRenderer extends SafeTileEntityRenderer<DeployerTileEntity> {
public DeployerTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { public DeployerRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }
@ -107,15 +106,16 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer<DeployerT
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
BlockPos pos = te.getPos(); BlockPos pos = te.getPos();
SuperByteBuffer pole = renderAndTransform(te.getWorld(), AllBlockPartials.DEPLOYER_POLE, blockState, pos, true);
SuperByteBuffer hand = renderAndTransform(te.getWorld(), te.getHandPose(), blockState, pos, false);
Vec3d offset = getHandOffset(te, partialTicks, blockState); Vec3d offset = getHandOffset(te, partialTicks, blockState);
pole.translate(offset.x, offset.y, offset.z)
.renderInto(ms, vb); SuperByteBuffer pole = AllBlockPartials.DEPLOYER_POLE.renderOn(blockState);
hand.translate(offset.x, offset.y, offset.z) SuperByteBuffer hand = te.getHandPose()
.renderInto(ms, vb); .renderOn(blockState);
transform(te.getWorld(), pole.translate(offset.x, offset.y, offset.z), blockState, pos, true).renderInto(ms,
vb);
transform(te.getWorld(), hand.translate(offset.x, offset.y, offset.z), blockState, pos, false).renderInto(ms,
vb);
} }
protected Vec3d getHandOffset(DeployerTileEntity te, float partialTicks, BlockState blockState) { protected Vec3d getHandOffset(DeployerTileEntity te, float partialTicks, BlockState blockState) {
@ -137,20 +137,19 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer<DeployerT
return KineticTileEntityRenderer.shaft(KineticTileEntityRenderer.getRotationAxisOf(te)); return KineticTileEntityRenderer.shaft(KineticTileEntityRenderer.getRotationAxisOf(te));
} }
private static SuperByteBuffer renderAndTransform(World world, AllBlockPartials renderBlock, private static SuperByteBuffer transform(World world, SuperByteBuffer buffer, BlockState deployerState,
BlockState deployerState, BlockPos pos, boolean axisDirectionMatters) { BlockPos pos, boolean axisDirectionMatters) {
SuperByteBuffer buffer = renderBlock.renderOn(deployerState);
Direction facing = deployerState.get(FACING); Direction facing = deployerState.get(FACING);
float zRotFirst = float zRotLast =
axisDirectionMatters && (deployerState.get(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Axis.Z) ? 90 axisDirectionMatters && (deployerState.get(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Axis.Z) ? 90
: 0; : 0;
float yRot = AngleHelper.horizontalAngle(facing); float yRot = AngleHelper.horizontalAngle(facing);
float zRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0; float zRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0;
buffer.rotateCentered(Axis.Z, (float) ((zRotFirst) / 180 * Math.PI)); buffer.rotateCentered(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI));
buffer.rotateCentered(Axis.Y, (float) ((yRot) / 180 * Math.PI)); buffer.rotateCentered(Direction.UP, (float) ((yRot) / 180 * Math.PI));
buffer.rotateCentered(Axis.Z, (float) ((zRot) / 180 * Math.PI)); buffer.rotateCentered(Direction.SOUTH, (float) ((zRotLast) / 180 * Math.PI));
buffer.light(WorldRenderer.getLightmapCoordinates(world, deployerState, pos)); buffer.light(WorldRenderer.getLightmapCoordinates(world, deployerState, pos));
return buffer; return buffer;
} }
@ -166,8 +165,10 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer<DeployerT
AllBlockPartials handPose = AllBlockPartials handPose =
mode == Mode.PUNCH ? AllBlockPartials.DEPLOYER_HAND_PUNCHING : AllBlockPartials.DEPLOYER_HAND_POINTING; mode == Mode.PUNCH ? AllBlockPartials.DEPLOYER_HAND_PUNCHING : AllBlockPartials.DEPLOYER_HAND_POINTING;
SuperByteBuffer pole = renderAndTransform(world, AllBlockPartials.DEPLOYER_POLE, blockState, pos, true); SuperByteBuffer pole = AllBlockPartials.DEPLOYER_POLE.renderOn(blockState);
SuperByteBuffer hand = renderAndTransform(world, handPose, blockState, pos, false); SuperByteBuffer hand = handPose.renderOn(blockState);
pole = transform(world, pole, blockState, pos, true);
hand = transform(world, hand, blockState, pos, false);
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

@ -12,24 +12,31 @@ import com.simibubi.create.foundation.utility.SuperByteBuffer;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
public class EncasedFanTileEntityRenderer extends KineticTileEntityRenderer { public class EncasedFanRenderer extends KineticTileEntityRenderer {
public EncasedFanTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { public EncasedFanRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }
@Override @Override
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int light, int overlay) { int light, int overlay) {
Direction direction = te.getBlockState().get(FACING); Direction direction = te.getBlockState()
SuperByteBuffer superBuffer = AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), .get(FACING);
direction.getOpposite());
IVertexBuilder vb = buffer.getBuffer(RenderType.getCutoutMipped()); IVertexBuilder vb = buffer.getBuffer(RenderType.getCutoutMipped());
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
int lightBehind = WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getPos().offset(direction.getOpposite()));
int lightInFront = WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getPos().offset(direction));
SuperByteBuffer shaftHalf =
AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), direction.getOpposite());
SuperByteBuffer fanInner =
AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectional(te.getBlockState(), direction.getOpposite());
float time = AnimationTickHolder.getRenderTick(); float time = AnimationTickHolder.getRenderTick();
float speed = te.getSpeed() * 5; float speed = te.getSpeed() * 5;
@ -40,10 +47,8 @@ public class EncasedFanTileEntityRenderer extends KineticTileEntityRenderer {
float angle = (time * speed * 3 / 10f) % 360; float angle = (time * speed * 3 / 10f) % 360;
angle = angle / 180f * (float) Math.PI; angle = angle / 180f * (float) Math.PI;
SuperByteBuffer superByteBuffer = AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectional(te.getBlockState(), standardKineticRotationTransform(shaftHalf, te, lightBehind).renderInto(ms, vb);
direction.getOpposite()); kineticRotationTransform(fanInner, te, direction.getAxis(), angle, lightInFront).renderInto(ms, vb);
kineticRotationTransform(superByteBuffer, te, direction.getAxis(), angle, light);
superByteBuffer.renderInto(ms, vb);
} }
} }

View File

@ -30,7 +30,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
@Override @Override
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, 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); super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
@ -44,34 +44,44 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
if (FlywheelBlock.isConnected(blockState)) { if (FlywheelBlock.isConnected(blockState)) {
Direction connection = FlywheelBlock.getConnection(blockState); Direction connection = FlywheelBlock.getConnection(blockState);
light = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, te.getPos().offset(connection)); light = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, te.getPos()
float rotation = connection.getAxis() == Axis.X ^ connection.getAxisDirection() == AxisDirection.NEGATIVE .offset(connection));
? -angle float rotation =
connection.getAxis() == Axis.X ^ connection.getAxisDirection() == AxisDirection.NEGATIVE ? -angle
: angle; : angle;
boolean flip = blockState.get(FlywheelBlock.CONNECTION) == ConnectionState.LEFT; boolean flip = blockState.get(FlywheelBlock.CONNECTION) == ConnectionState.LEFT;
rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_UPPER_ROTATING.renderOn(blockState), true, true, transformConnector(
rotation, flip), connection).light(light).renderInto(ms, vb); rotateToFacing(AllBlockPartials.FLYWHEEL_UPPER_ROTATING.renderOn(blockState), connection), true, true,
rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_LOWER_ROTATING.renderOn(blockState), false, rotation, flip).light(light)
true, rotation, flip), connection).light(light).renderInto(ms, vb); .renderInto(ms, vb);
rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_UPPER_SLIDING.renderOn(blockState), true, false, transformConnector(
rotation, flip), connection).light(light).renderInto(ms, vb); rotateToFacing(AllBlockPartials.FLYWHEEL_LOWER_ROTATING.renderOn(blockState), connection), false, true,
rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_LOWER_SLIDING.renderOn(blockState), false, rotation, flip).light(light)
false, rotation, flip), connection).light(light).renderInto(ms, vb); .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); wheel.renderInto(ms, vb);
} }
@Override @Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), return AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), te.getBlockState()
te.getBlockState().get(HORIZONTAL_FACING).getOpposite()); .get(HORIZONTAL_FACING)
.getOpposite());
} }
protected SuperByteBuffer transformConnector(SuperByteBuffer buffer, boolean upper, boolean rotating, float angle, protected SuperByteBuffer transformConnector(SuperByteBuffer buffer, boolean upper, boolean rotating, float angle,
boolean flip) { boolean flip) {
float shift = upper ? 1 / 4f : -1 / 8f; float shift = upper ? 1 / 4f : -1 / 8f;
float offset = upper ? 1 / 4f : 1 / 4f; float offset = upper ? 1 / 4f : 1 / 4f;
@ -89,19 +99,19 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
float pivotY = (upper ? 8f : 2f) / 16; float pivotY = (upper ? 8f : 2f) / 16;
float pivotZ = (upper ? 23f : 21.5f) / 16f; 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) if (flip && !upper)
buffer.translate(9 / 16f, 0, 0); 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; return buffer;
} }
protected SuperByteBuffer rotateToFacing(SuperByteBuffer buffer, Direction facing) { 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; return buffer;
} }

View File

@ -13,18 +13,18 @@ import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; 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); super(dispatcher);
} }
@Override @Override
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int light, int overlay) { int light, int overlay) {
BlockState blockState = te.getBlockState(); BlockState blockState = te.getBlockState();
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te; MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te;
BlockPos pos = te.getPos(); BlockPos pos = te.getPos();
@ -41,11 +41,15 @@ public class MechanicalMixerTileEntityRenderer extends KineticTileEntityRenderer
float angle = (float) (((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI); float angle = (float) (((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI);
SuperByteBuffer poleRender = AllBlockPartials.MECHANICAL_MIXER_POLE.renderOn(blockState); 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); SuperByteBuffer headRender = AllBlockPartials.MECHANICAL_MIXER_HEAD.renderOn(blockState);
headRender.rotateCentered(Axis.Y, angle).translate(0, -renderedHeadOffset, 0).light(packedLightmapCoords) headRender.rotateCentered(Direction.UP, angle)
.renderInto(ms, vb); .translate(0, -renderedHeadOffset, 0)
.light(packedLightmapCoords)
.renderInto(ms, vb);
} }
} }

View File

@ -14,9 +14,9 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader; 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); super(properties);
} }
@ -27,7 +27,7 @@ public class MotorBlock extends DirectionalKineticBlock {
@Override @Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) { public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new MotorTileEntity(); return new CreativeMotorTileEntity();
} }
@Override @Override

View File

@ -10,24 +10,24 @@ import net.minecraft.block.BlockState;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.client.model.generators.ModelFile;
public class MotorGenerator extends SpecialBlockStateGen { public class CreativeMotorGenerator extends SpecialBlockStateGen {
@Override @Override
protected int getXRotation(BlockState state) { protected int getXRotation(BlockState state) {
return state.get(MotorBlock.FACING) == Direction.DOWN ? 180 : 0; return state.get(CreativeMotorBlock.FACING) == Direction.DOWN ? 180 : 0;
} }
@Override @Override
protected int getYRotation(BlockState state) { protected int getYRotation(BlockState state) {
return state.get(MotorBlock.FACING) return state.get(CreativeMotorBlock.FACING)
.getAxis() .getAxis()
.isVertical() ? 0 : horizontalAngle(state.get(MotorBlock.FACING)); .isVertical() ? 0 : horizontalAngle(state.get(CreativeMotorBlock.FACING));
} }
@Override @Override
public <T extends Block> ModelFile getModel(DataGenContext<Block, T> ctx, RegistrateBlockstateProvider prov, public <T extends Block> ModelFile getModel(DataGenContext<Block, T> ctx, RegistrateBlockstateProvider prov,
BlockState state) { BlockState state) {
return state.get(MotorBlock.FACING) return state.get(CreativeMotorBlock.FACING)
.getAxis() .getAxis()
.isVertical() ? AssetLookup.partialBaseModel(ctx, prov, "vertical") .isVertical() ? AssetLookup.partialBaseModel(ctx, prov, "vertical")
: AssetLookup.partialBaseModel(ctx, prov); : AssetLookup.partialBaseModel(ctx, prov);

View File

@ -7,9 +7,9 @@ import com.simibubi.create.foundation.utility.SuperByteBuffer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; 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); super(dispatcher);
} }

View File

@ -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.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour.StepContext;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
public class MotorTileEntity extends GeneratingKineticTileEntity { public class CreativeMotorTileEntity extends GeneratingKineticTileEntity {
public static final int DEFAULT_SPEED = 16; public static final int DEFAULT_SPEED = 16;
protected ScrollValueBehaviour generatedSpeed; protected ScrollValueBehaviour generatedSpeed;
public MotorTileEntity() { public CreativeMotorTileEntity() {
super(AllTileEntities.MOTOR.type); super(AllTileEntities.MOTOR.type);
} }
@ -26,7 +26,7 @@ public class MotorTileEntity extends GeneratingKineticTileEntity {
Integer max = AllConfigs.SERVER.kinetics.maxMotorSpeed.get(); Integer max = AllConfigs.SERVER.kinetics.maxMotorSpeed.get();
CenteredSideValueBoxTransform slot = 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 = new ScrollValueBehaviour(Lang.translate("generic.speed"), this, slot);
generatedSpeed.between(-max, max); generatedSpeed.between(-max, max);
@ -34,7 +34,7 @@ public class MotorTileEntity extends GeneratingKineticTileEntity {
generatedSpeed.scrollableValue = DEFAULT_SPEED; generatedSpeed.scrollableValue = DEFAULT_SPEED;
generatedSpeed.withUnit(i -> Lang.translate("generic.unit.rpm")); generatedSpeed.withUnit(i -> Lang.translate("generic.unit.rpm"));
generatedSpeed.withCallback(i -> this.updateGeneratedRotation()); generatedSpeed.withCallback(i -> this.updateGeneratedRotation());
generatedSpeed.withStepFunction(MotorTileEntity::step); generatedSpeed.withStepFunction(CreativeMotorTileEntity::step);
behaviours.add(generatedSpeed); behaviours.add(generatedSpeed);
} }

View File

@ -13,9 +13,9 @@ import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.math.BlockPos; 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); super(dispatcher);
} }

View File

@ -25,9 +25,9 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Rotation; import net.minecraft.util.Rotation;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
public class SawTileEntityRenderer extends SafeTileEntityRenderer<SawTileEntity> { public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
public SawTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { public SawRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }

View File

@ -12,34 +12,39 @@ import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction; 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); super(dispatcher);
} }
@Override @Override
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, 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); super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
IBearingTileEntity bearingTe = (IBearingTileEntity) te; 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()); 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); 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);
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())); superBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
} }
@Override @Override
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) { protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
return AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), return AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), te.getBlockState()
te.getBlockState().get(BearingBlock.FACING).getOpposite()); .get(BearingBlock.FACING)
.getOpposite());
} }
} }

View File

@ -6,9 +6,9 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; 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); super(dispatcher);
} }

View File

@ -17,9 +17,9 @@ import net.minecraft.util.math.Vec3d;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.ItemStackHandler;
public class BasinTileEntityRenderer extends SafeTileEntityRenderer<BasinTileEntity> { public class BasinRenderer extends SafeTileEntityRenderer<BasinTileEntity> {
public BasinTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { public BasinRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }

View File

@ -5,7 +5,7 @@ import java.util.List;
import com.simibubi.create.AllTileEntities; import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.RotationPropagator; import com.simibubi.create.content.contraptions.RotationPropagator;
import com.simibubi.create.content.contraptions.base.KineticTileEntity; 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.config.AllConfigs;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform; 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.moveText(new Vec3d(9, 0, 10));
targetSpeed.withUnit(i -> Lang.translate("generic.unit.rpm")); targetSpeed.withUnit(i -> Lang.translate("generic.unit.rpm"));
targetSpeed.withCallback(i -> this.updateTargetRotation()); targetSpeed.withCallback(i -> this.updateTargetRotation());
targetSpeed.withStepFunction(MotorTileEntity::step); targetSpeed.withStepFunction(CreativeMotorTileEntity::step);
behaviours.add(targetSpeed); behaviours.add(targetSpeed);
} }

View File

@ -37,9 +37,9 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i; import net.minecraft.util.math.Vec3i;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class BeltTileEntityRenderer extends SafeTileEntityRenderer<BeltTileEntity> { public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
public BeltTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { public BeltRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }

View File

@ -6,9 +6,9 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; 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); super(dispatcher);
} }

View File

@ -16,9 +16,9 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; 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); super(dispatcher);
} }

View File

@ -14,21 +14,20 @@ import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
public class GaugeTileEntityRenderer extends KineticTileEntityRenderer { public class GaugeRenderer extends KineticTileEntityRenderer {
protected GaugeBlock.Type type; protected GaugeBlock.Type type;
public GaugeTileEntityRenderer(TileEntityRendererDispatcher dispatcher, GaugeBlock.Type type) { public GaugeRenderer(TileEntityRendererDispatcher dispatcher, GaugeBlock.Type type) {
super(dispatcher); super(dispatcher);
this.type = type; this.type = type;
} }
@Override @Override
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, 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); super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
BlockState gaugeState = te.getBlockState(); BlockState gaugeState = te.getBlockState();
GaugeTileEntity gaugeTE = (GaugeTileEntity) te; GaugeTileEntity gaugeTE = (GaugeTileEntity) te;
@ -36,25 +35,25 @@ public class GaugeTileEntityRenderer extends KineticTileEntityRenderer {
SuperByteBuffer headBuffer = SuperByteBuffer headBuffer =
(type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS) (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS)
.renderOn(gaugeState); .renderOn(gaugeState);
SuperByteBuffer dialBuffer = AllBlockPartials.GAUGE_DIAL.renderOn(gaugeState); SuperByteBuffer dialBuffer = AllBlockPartials.GAUGE_DIAL.renderOn(gaugeState);
for (Direction facing : Direction.values()) { for (Direction facing : Direction.values()) {
if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(te.getWorld(), te.getPos(), gaugeState, if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(te.getWorld(), te.getPos(), gaugeState,
facing)) facing))
continue; continue;
float dialPivot = -5.75f / 16; float dialPivot = 5.75f / 16;
float progress = MathHelper.lerp(partialTicks, gaugeTE.prevDialState, gaugeTE.dialState); 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()); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
rotateBufferTowards(dialBuffer, facing).light(lightCoords) rotateBufferTowards(dialBuffer, facing).translate(0, dialPivot, dialPivot)
.renderInto(ms, vb); .rotate(Direction.EAST, (float) (Math.PI / 2 * -progress))
.translate(0, -dialPivot, -dialPivot)
.light(lightCoords)
.renderInto(ms, vb);
rotateBufferTowards(headBuffer, facing).light(lightCoords) 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) { 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));
} }
} }

View File

@ -15,9 +15,9 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; 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); super(dispatcher);
} }

View File

@ -9,9 +9,9 @@ import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
public class BeltObserverTileEntityRenderer extends SafeTileEntityRenderer<BeltObserverTileEntity> { public class BeltObserverRenderer extends SafeTileEntityRenderer<BeltObserverTileEntity> {
public BeltObserverTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { public BeltObserverRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }

View File

@ -18,15 +18,15 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BeltTunnelTileEntityRenderer extends SafeTileEntityRenderer<BeltTunnelTileEntity> { public class BeltTunnelRenderer extends SafeTileEntityRenderer<BeltTunnelTileEntity> {
public BeltTunnelTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { public BeltTunnelRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }
@Override @Override
protected void renderSafe(BeltTunnelTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, 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 flapBuffer = AllBlockPartials.BELT_TUNNEL_FLAP.renderOn(te.getBlockState());
SuperByteBuffer indicatorBuffer = AllBlockPartials.BELT_TUNNEL_INDICATOR.renderOn(te.getBlockState()); SuperByteBuffer indicatorBuffer = AllBlockPartials.BELT_TUNNEL_INDICATOR.renderOn(te.getBlockState());
BlockPos pos = te.getPos(); BlockPos pos = te.getPos();
@ -45,7 +45,8 @@ public class BeltTunnelTileEntityRenderer extends SafeTileEntityRenderer<BeltTun
float flapPivotZ = 0; float flapPivotZ = 0;
for (int segment = 0; segment <= 3; segment++) { for (int segment = 0; segment <= 3; segment++) {
float f = te.flaps.get(direction).get(partialTicks); float f = te.flaps.get(direction)
.get(partialTicks);
if (direction.getAxis() == Axis.X) if (direction.getAxis() == Axis.X)
f *= -1; f *= -1;
@ -64,15 +65,19 @@ public class BeltTunnelTileEntityRenderer extends SafeTileEntityRenderer<BeltTun
indicatorBlockLight = Math.max(indicatorBlockLight, (int) (12 * lightIntensity)); indicatorBlockLight = Math.max(indicatorBlockLight, (int) (12 * lightIntensity));
indicatorLight = LightTexture.pack(indicatorBlockLight, indicatorSkyLight); indicatorLight = LightTexture.pack(indicatorBlockLight, indicatorSkyLight);
int color = ColorHelper.mixColors(0x808080, 0xFFFFFF, lightIntensity); int color = ColorHelper.mixColors(0x808080, 0xFFFFFF, lightIntensity);
indicatorBuffer.rotateCentered(Axis.Y, (float) ((horizontalAngle + 90) / 180f * Math.PI)) indicatorBuffer.rotateCentered(Direction.UP, (float) ((horizontalAngle + 90) / 180f * Math.PI))
.color(color).light(indicatorLight).renderInto(ms, vb); .color(color)
.light(indicatorLight)
.renderInto(ms, vb);
} }
flapBuffer.translate(0, 0, -segment * 3 / 16f);
flapBuffer.translate(flapPivotX, flapPivotY, flapPivotZ).rotate(Axis.Z, flapAngle)
.translate(-flapPivotX, -flapPivotY, -flapPivotZ);
flapBuffer.rotateCentered(Direction.UP, (float) (horizontalAngle / 180f * Math.PI)); flapBuffer.rotateCentered(Direction.UP, (float) (horizontalAngle / 180f * Math.PI));
flapBuffer.light(WorldRenderer.getLightmapCoordinates(world, te.getBlockState(), pos)).renderInto(ms, vb); flapBuffer.translate(-flapPivotX, -flapPivotY, -flapPivotZ)
.rotate(Direction.SOUTH, flapAngle)
.translate(flapPivotX, flapPivotY, flapPivotZ);
flapBuffer.translate(0, 0, -segment * 3 / 16f);
flapBuffer.light(WorldRenderer.getLightmapCoordinates(world, te.getBlockState(), pos))
.renderInto(ms, vb);
} }
} }

View File

@ -15,17 +15,16 @@ import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.state.properties.AttachFace; import net.minecraft.state.properties.AttachFace;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
public class AnalogLeverTileEntityRenderer extends SafeTileEntityRenderer<AnalogLeverTileEntity> { public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileEntity> {
public AnalogLeverTileEntityRenderer(TileEntityRendererDispatcher dispatcher) { public AnalogLeverRenderer(TileEntityRendererDispatcher dispatcher) {
super(dispatcher); super(dispatcher);
} }
@Override @Override
protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int light, int overlay) { int light, int overlay) {
BlockState leverState = te.getBlockState(); BlockState leverState = te.getBlockState();
int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), leverState, te.getPos()); int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), leverState, te.getPos());
float state = te.clientState.get(partialTicks); float state = te.clientState.get(partialTicks);
@ -35,21 +34,26 @@ public class AnalogLeverTileEntityRenderer extends SafeTileEntityRenderer<Analog
// Handle // Handle
SuperByteBuffer handle = AllBlockPartials.ANALOG_LEVER_HANDLE.renderOn(leverState); SuperByteBuffer handle = AllBlockPartials.ANALOG_LEVER_HANDLE.renderOn(leverState);
float angle = (float) ((state / 15) * 90 / 180 * Math.PI); 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).translate(1 / 2f, 1 / 16f, 1 / 2f)
transform(handle, leverState).light(lightCoords).renderInto(ms, vb); .rotate(Direction.EAST, angle)
.translate(-1 / 2f, -1 / 16f, -1 / 2f);
handle.light(lightCoords)
.renderInto(ms, vb);
// Indicator // Indicator
int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f); int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f);
SuperByteBuffer indicator = transform(AllBlockPartials.ANALOG_LEVER_INDICATOR.renderOn(leverState), leverState); 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) { private SuperByteBuffer transform(SuperByteBuffer buffer, BlockState leverState) {
AttachFace face = leverState.get(AnalogLeverBlock.FACE); AttachFace face = leverState.get(AnalogLeverBlock.FACE);
float rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180; float rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180;
float rY = AngleHelper.horizontalAngle(leverState.get(AnalogLeverBlock.HORIZONTAL_FACING)); 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.UP, (float) (rY / 180 * Math.PI));
buffer.rotateCentered(Direction.EAST, (float) (rX / 180 * Math.PI));
return buffer; return buffer;
} }

View File

@ -46,6 +46,7 @@ public class ServerSchematicLoader {
this.stream = stream; this.stream = stream;
this.totalBytes = totalBytes; this.totalBytes = totalBytes;
this.tablePos = tablePos; this.tablePos = tablePos;
this.world = world;
this.bytesUploaded = 0; this.bytesUploaded = 0;
this.idleTime = 0; this.idleTime = 0;
} }
@ -134,7 +135,7 @@ public class ServerSchematicLoader {
OutputStream writer = OutputStream writer =
Files.newOutputStream(Paths.get(getSchematicPath(), playerSchematicId), StandardOpenOption.CREATE_NEW); Files.newOutputStream(Paths.get(getSchematicPath(), playerSchematicId), StandardOpenOption.CREATE_NEW);
activeUploads.put(playerSchematicId, activeUploads.put(playerSchematicId,
new SchematicUploadEntry(writer, size, player.getEntityWorld(), pos)); new SchematicUploadEntry(writer, size, player.getServerWorld(), pos));
// Notify Tile Entity // Notify Tile Entity
table.startUpload(schematic); table.startUpload(schematic);

View File

@ -148,17 +148,17 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid()); IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
SuperByteBuffer connector = AllBlockPartials.SCHEMATICANNON_CONNECTOR.renderOn(state); SuperByteBuffer connector = AllBlockPartials.SCHEMATICANNON_CONNECTOR.renderOn(state);
connector.translate(-.5f, 0, -.5f);
connector.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
connector.translate(.5f, 0, .5f); connector.translate(.5f, 0, .5f);
connector.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
connector.translate(-.5f, 0, -.5f);
connector.light(lightCoords).renderInto(ms, vb); connector.light(lightCoords).renderInto(ms, vb);
SuperByteBuffer pipe = AllBlockPartials.SCHEMATICANNON_PIPE.renderOn(state); SuperByteBuffer pipe = AllBlockPartials.SCHEMATICANNON_PIPE.renderOn(state);
pipe.translate(0, -recoil / 100, 0);
pipe.translate(-.5f, -15 / 16f, -.5f);
pipe.rotate(Direction.SOUTH, (float) (pitch / 180 * Math.PI));
pipe.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
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.SOUTH, (float) (pitch / 180 * Math.PI));
pipe.translate(-.5f, -15 / 16f, -.5f);
pipe.translate(0, -recoil / 100, 0);
pipe.light(lightCoords).renderInto(ms, vb); pipe.light(lightCoords).renderInto(ms, vb);
ms.pop(); ms.pop();

View File

@ -15,15 +15,18 @@ public abstract class SafeTileEntityRenderer<T extends TileEntity> extends TileE
} }
@Override @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)) if (isInvalid(te))
return; return;
renderSafe(te, partialTicks, ms, buffer, light, overlay); 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) { public boolean isInvalid(T te) {
return te.getBlockState().getBlock() == Blocks.AIR; return !te.hasWorld() || te.getBlockState()
.getBlock() == Blocks.AIR;
} }
} }

View File

@ -5,51 +5,48 @@ import java.util.Iterator;
import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.Matrix4f; import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.client.renderer.Vector4f; 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.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.crash.ReportedException; import net.minecraft.crash.ReportedException;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.LightType;
import net.minecraft.world.World; import net.minecraft.world.World;
public class TileEntityRenderHelper { public class TileEntityRenderHelper {
protected static LightingWorld lightingWorld;
public static void renderTileEntities(World world, Iterable<TileEntity> customRenderTEs, MatrixStack ms, public static void renderTileEntities(World world, Iterable<TileEntity> customRenderTEs, MatrixStack ms,
MatrixStack localTransform, IRenderTypeBuffer buffer) { MatrixStack localTransform, IRenderTypeBuffer buffer) {
float pt = Minecraft.getInstance() float pt = Minecraft.getInstance()
.getRenderPartialTicks(); .getRenderPartialTicks();
Matrix4f matrix = localTransform.peek()
if (lightingWorld == null) .getModel();
lightingWorld = new LightingWorld(world);
lightingWorld.setWorld(world);
lightingWorld.setTransform(localTransform.peek()
.getModel());
for (Iterator<TileEntity> iterator = customRenderTEs.iterator(); iterator.hasNext();) { for (Iterator<TileEntity> iterator = customRenderTEs.iterator(); iterator.hasNext();) {
TileEntity tileEntity = iterator.next(); TileEntity tileEntity = iterator.next();
if (TileEntityRendererDispatcher.instance.getRenderer(tileEntity) == null) { TileEntityRenderer<TileEntity> renderer = TileEntityRendererDispatcher.instance.getRenderer(tileEntity);
if (renderer == null) {
iterator.remove(); iterator.remove();
continue; continue;
} }
try { try {
BlockPos pos = tileEntity.getPos(); BlockPos pos = tileEntity.getPos();
World prevTileWorld = tileEntity.getWorld();
ms.push(); ms.push();
MatrixStacker.of(ms) MatrixStacker.of(ms)
.translate(pos); .translate(pos);
tileEntity.setLocation(lightingWorld, pos);
TileEntityRendererDispatcher.instance.render(tileEntity, pt, ms, buffer); Vector4f vec = new Vector4f(pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, 1);
tileEntity.setLocation(prevTileWorld, pos); 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(); ms.pop();
} catch (ReportedException e) { } 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());
}
}
} }

View File

@ -4,22 +4,20 @@
"textures": { "textures": {
"0": "create:block/axis", "0": "create:block/axis",
"1": "create:block/axis_top", "1": "create:block/axis_top",
"2": "create:block/andesite_casing_short",
"3": "block/spruce_log",
"particle": "create:block/axis" "particle": "create:block/axis"
}, },
"elements": [ "elements": [
{ {
"name": "Axis", "name": "Axis",
"from": [6, 6, 11], "from": [6, 0, 6],
"to": [10, 10, 16], "to": [10, 5, 10],
"shade": false, "shade": false,
"faces": { "faces": {
"east": {"uv": [6, 0, 10, 5], "rotation": 270, "texture": "#0"}, "north": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"},
"south": {"uv": [6, 6, 10, 10], "texture": "#1"}, "east": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"},
"west": {"uv": [6, 0, 10, 5], "rotation": 90, "texture": "#0"}, "south": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"},
"up": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"}, "west": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"},
"down": {"uv": [6, 0, 10, 5], "texture": "#0"} "down": {"uv": [6, 6, 10, 10], "texture": "#1"}
} }
} }
], ],
@ -28,5 +26,6 @@
"name": "shaft_half", "name": "shaft_half",
"origin": [8, 8, 8], "origin": [8, 8, 8],
"children": [0] "children": [0]
}, 1, 2, 3, 4] }
]
} }