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:
parent
4e8a72be8b
commit
f9fc00855a
37 changed files with 367 additions and 327 deletions
|
@ -8,10 +8,10 @@ import java.util.Map;
|
|||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -69,18 +69,17 @@ public enum AllBlockPartials {
|
|||
ROPE_HALF("rope_pulley/rope_half"),
|
||||
ROPE_HALF_MAGNET("rope_pulley/rope_half_magnet"),
|
||||
MILLSTONE_COG("millstone/inner"),
|
||||
|
||||
|
||||
SYMMETRY_PLANE("symmetry_effect/plane"),
|
||||
SYMMETRY_CROSSPLANE("symmetry_effect/crossplane"),
|
||||
SYMMETRY_TRIPLEPLANE("symmetry_effect/tripleplane"),
|
||||
|
||||
|
||||
;
|
||||
|
||||
private ResourceLocation modelLocation;
|
||||
private IBakedModel bakedModel;
|
||||
|
||||
private AllBlockPartials() {
|
||||
}
|
||||
private AllBlockPartials() {}
|
||||
|
||||
private AllBlockPartials(String path) {
|
||||
modelLocation = new ResourceLocation(Create.ID, "block/" + path);
|
||||
|
@ -118,20 +117,22 @@ public enum AllBlockPartials {
|
|||
Direction facing = referenceState.get(FACING);
|
||||
return renderOnDirectional(referenceState, facing);
|
||||
}
|
||||
|
||||
|
||||
public SuperByteBuffer renderOnHorizontal(BlockState referenceState) {
|
||||
Direction facing = referenceState.get(HORIZONTAL_FACING);
|
||||
return renderOnDirectional(referenceState, facing);
|
||||
}
|
||||
|
||||
|
||||
public SuperByteBuffer renderOnDirectional(BlockState referenceState, Direction facing) {
|
||||
MatrixStack ms = new MatrixStack();
|
||||
// TODO 1.15 find a way to cache this model matrix computation
|
||||
ms.translate(0.5, 0.5, 0.5);
|
||||
ms.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(AngleHelper.rad(AngleHelper.horizontalAngle(facing))));
|
||||
ms.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(AngleHelper.rad(AngleHelper.verticalAngle(facing))));
|
||||
ms.translate(-0.5, -0.5, -0.5);
|
||||
SuperByteBuffer renderPartial = CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms);
|
||||
MatrixStacker.of(ms)
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(AngleHelper.verticalAngle(facing))
|
||||
.unCentre();
|
||||
SuperByteBuffer renderPartial =
|
||||
CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms);
|
||||
return renderPartial;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ import com.simibubi.create.content.contraptions.components.flywheel.engine.Furna
|
|||
import com.simibubi.create.content.contraptions.components.millstone.MillstoneBlock;
|
||||
import com.simibubi.create.content.contraptions.components.mixer.BasinOperatorBlockItem;
|
||||
import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerBlock;
|
||||
import com.simibubi.create.content.contraptions.components.motor.MotorBlock;
|
||||
import com.simibubi.create.content.contraptions.components.motor.MotorGenerator;
|
||||
import com.simibubi.create.content.contraptions.components.motor.CreativeMotorBlock;
|
||||
import com.simibubi.create.content.contraptions.components.motor.CreativeMotorGenerator;
|
||||
import com.simibubi.create.content.contraptions.components.press.MechanicalPressBlock;
|
||||
import com.simibubi.create.content.contraptions.components.saw.SawBlock;
|
||||
import com.simibubi.create.content.contraptions.components.saw.SawGenerator;
|
||||
|
@ -246,9 +246,9 @@ public class AllBlocks {
|
|||
.blockstate(new BeltGenerator()::generate)
|
||||
.register();
|
||||
|
||||
public static final BlockEntry<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)
|
||||
.blockstate(new MotorGenerator()::generate)
|
||||
.blockstate(new CreativeMotorGenerator()::generate)
|
||||
.transform(StressConfigDefaults.setCapacity(16384.0))
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
|
@ -256,6 +256,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<WaterWheelBlock> WATER_WHEEL = REGISTRATE.block("water_wheel", WaterWheelBlock::new)
|
||||
.initialProperties(SharedProperties::wooden)
|
||||
.properties(p -> p.nonOpaque())
|
||||
.blockstate(BlockStateGen.horizontalWheelProvider(false))
|
||||
.addLayer(() -> RenderType::getCutoutMipped)
|
||||
.transform(StressConfigDefaults.setCapacity(16.0))
|
||||
|
@ -317,6 +318,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<CrushingWheelBlock> CRUSHING_WHEEL =
|
||||
REGISTRATE.block("crushing_wheel", CrushingWheelBlock::new)
|
||||
.initialProperties(SharedProperties::stone)
|
||||
.properties(p -> p.nonOpaque())
|
||||
.blockstate(BlockStateGen.axisBlockProvider(false))
|
||||
.addLayer(() -> RenderType::getCutoutMipped)
|
||||
.transform(StressConfigDefaults.setImpact(8.0))
|
||||
|
@ -552,6 +554,7 @@ public class AllBlocks {
|
|||
public static final BlockEntry<MechanicalCrafterBlock> MECHANICAL_CRAFTER =
|
||||
REGISTRATE.block("mechanical_crafter", MechanicalCrafterBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(p -> p.nonOpaque())
|
||||
.blockstate(BlockStateGen.horizontalBlockProvider(true))
|
||||
.transform(StressConfigDefaults.setImpact(2.0))
|
||||
.transform(CreateRegistrate.connectedTextures(new CrafterCTBehaviour()))
|
||||
|
@ -571,6 +574,7 @@ public class AllBlocks {
|
|||
|
||||
public static final BlockEntry<FlywheelBlock> FLYWHEEL = REGISTRATE.block("flywheel", FlywheelBlock::new)
|
||||
.initialProperties(SharedProperties::softMetal)
|
||||
.properties(p -> p.nonOpaque())
|
||||
.blockstate(new FlywheelGenerator()::generate)
|
||||
.item()
|
||||
.transform(customItemModel())
|
||||
|
|
|
@ -5,21 +5,21 @@ import java.util.function.Supplier;
|
|||
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.actors.DrillTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.actors.DrillTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.actors.DrillRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.actors.HarvesterRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.actors.HarvesterTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.clock.CuckooClockRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.crank.HandCrankTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.crank.HandCrankTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.crank.HandCrankRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.crusher.CrushingWheelControllerTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.crusher.CrushingWheelTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.deployer.DeployerRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.fan.EncasedFanTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.fan.EncasedFanTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.fan.EncasedFanRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.fan.NozzleTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
|
||||
|
@ -28,48 +28,48 @@ import com.simibubi.create.content.contraptions.components.flywheel.engine.Furna
|
|||
import com.simibubi.create.content.contraptions.components.millstone.MillstoneRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.millstone.MillstoneTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.motor.MotorTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.motor.MotorTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.mixer.MechanicalMixerRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.motor.CreativeMotorTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.motor.CreativeMotorRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.press.MechanicalPressRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.saw.SawTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.saw.SawTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.saw.SawRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.ClockworkBearingTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.turntable.TurntableTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.waterwheel.WaterWheelTileEntity;
|
||||
import com.simibubi.create.content.contraptions.processing.BasinTileEntity;
|
||||
import com.simibubi.create.content.contraptions.processing.BasinTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.processing.BasinRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.advanced.SpeedControllerTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.advanced.sequencer.SequencedGearshiftTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.belt.BeltRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.elementary.SimpleKineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.AdjustablePulleyTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ClutchTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.SplitShaftTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.SplitShaftRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock;
|
||||
import com.simibubi.create.content.contraptions.relays.gauge.GaugeTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.gauge.GaugeRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.gauge.SpeedGaugeTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.gauge.StressGaugeTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.gearbox.GearboxTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.gearbox.GearboxRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.gearbox.GearshiftTileEntity;
|
||||
import com.simibubi.create.content.logistics.block.belts.observer.BeltObserverTileEntity;
|
||||
import com.simibubi.create.content.logistics.block.belts.observer.BeltObserverTileEntityRenderer;
|
||||
import com.simibubi.create.content.logistics.block.belts.observer.BeltObserverRenderer;
|
||||
import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelTileEntity;
|
||||
import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelTileEntityRenderer;
|
||||
import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelRenderer;
|
||||
import com.simibubi.create.content.logistics.block.diodes.AdjustablePulseRepeaterTileEntity;
|
||||
import com.simibubi.create.content.logistics.block.diodes.AdjustableRepeaterRenderer;
|
||||
import com.simibubi.create.content.logistics.block.diodes.AdjustableRepeaterTileEntity;
|
||||
|
@ -79,7 +79,7 @@ import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity;
|
|||
import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateTileEntity;
|
||||
import com.simibubi.create.content.logistics.block.inventories.CreativeCrateTileEntity;
|
||||
import com.simibubi.create.content.logistics.block.redstone.AnalogLeverTileEntity;
|
||||
import com.simibubi.create.content.logistics.block.redstone.AnalogLeverTileEntityRenderer;
|
||||
import com.simibubi.create.content.logistics.block.redstone.AnalogLeverRenderer;
|
||||
import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkTileEntity;
|
||||
import com.simibubi.create.content.logistics.block.redstone.StockpileSwitchTileEntity;
|
||||
import com.simibubi.create.content.logistics.block.transposer.LinkedTransposerTileEntity;
|
||||
|
@ -110,7 +110,7 @@ public enum AllTileEntities {
|
|||
// Kinetics
|
||||
SIMPLE_KINETIC(SimpleKineticTileEntity::new, AllBlocks.SHAFT, AllBlocks.COGWHEEL, AllBlocks.LARGE_COGWHEEL,
|
||||
AllBlocks.ENCASED_SHAFT),
|
||||
MOTOR(MotorTileEntity::new, AllBlocks.CREATIVE_MOTOR),
|
||||
MOTOR(CreativeMotorTileEntity::new, AllBlocks.CREATIVE_MOTOR),
|
||||
GEARBOX(GearboxTileEntity::new, AllBlocks.GEARBOX),
|
||||
ENCASED_SHAFT(EncasedShaftTileEntity::new, AllBlocks.ENCASED_SHAFT, AllBlocks.ENCASED_BELT),
|
||||
ADJUSTABLE_PULLEY(AdjustablePulleyTileEntity::new, AllBlocks.ADJUSTABLE_PULLEY),
|
||||
|
@ -207,37 +207,37 @@ public enum AllTileEntities {
|
|||
|
||||
bind(SIMPLE_KINETIC, KineticTileEntityRenderer::new);
|
||||
bind(TURNTABLE, KineticTileEntityRenderer::new);
|
||||
bind(MOTOR, MotorTileEntityRenderer::new);
|
||||
bind(ENCASED_SHAFT, EncasedShaftTileEntityRenderer::new);
|
||||
bind(ADJUSTABLE_PULLEY, EncasedShaftTileEntityRenderer::new);
|
||||
bind(DRILL, DrillTileEntityRenderer::new);
|
||||
bind(SAW, SawTileEntityRenderer::new);
|
||||
bind(ENCASED_FAN, EncasedFanTileEntityRenderer::new);
|
||||
bind(GEARBOX, GearboxTileEntityRenderer::new);
|
||||
bind(GEARSHIFT, SplitShaftTileEntityRenderer::new);
|
||||
bind(CLUTCH, SplitShaftTileEntityRenderer::new);
|
||||
bind(SEQUENCED_GEARSHIFT, SplitShaftTileEntityRenderer::new);
|
||||
bind(BELT, BeltTileEntityRenderer::new);
|
||||
bind(MOTOR, CreativeMotorRenderer::new);
|
||||
bind(ENCASED_SHAFT, EncasedShaftRenderer::new);
|
||||
bind(ADJUSTABLE_PULLEY, EncasedShaftRenderer::new);
|
||||
bind(DRILL, DrillRenderer::new);
|
||||
bind(SAW, SawRenderer::new);
|
||||
bind(ENCASED_FAN, EncasedFanRenderer::new);
|
||||
bind(GEARBOX, GearboxRenderer::new);
|
||||
bind(GEARSHIFT, SplitShaftRenderer::new);
|
||||
bind(CLUTCH, SplitShaftRenderer::new);
|
||||
bind(SEQUENCED_GEARSHIFT, SplitShaftRenderer::new);
|
||||
bind(BELT, BeltRenderer::new);
|
||||
bind(WATER_WHEEL, KineticTileEntityRenderer::new);
|
||||
bind(HAND_CRANK, HandCrankTileEntityRenderer::new);
|
||||
bind(HAND_CRANK, HandCrankRenderer::new);
|
||||
bind(CUCKOO_CLOCK, CuckooClockRenderer::new);
|
||||
bind(ANALOG_LEVER, AnalogLeverTileEntityRenderer::new);
|
||||
bind(ANALOG_LEVER, AnalogLeverRenderer::new);
|
||||
|
||||
bind(MECHANICAL_PISTON, MechanicalPistonTileEntityRenderer::new);
|
||||
bind(MECHANICAL_BEARING, BearingTileEntityRenderer::new);
|
||||
bind(CLOCKWORK_BEARING, BearingTileEntityRenderer::new);
|
||||
bind(MECHANICAL_PISTON, MechanicalPistonRenderer::new);
|
||||
bind(MECHANICAL_BEARING, BearingRenderer::new);
|
||||
bind(CLOCKWORK_BEARING, BearingRenderer::new);
|
||||
bind(ROPE_PULLEY, PulleyRenderer::new);
|
||||
bind(HARVESTER, HarvesterRenderer::new);
|
||||
|
||||
bind(MILLSTONE, MillstoneRenderer::new);
|
||||
bind(CRUSHING_WHEEL, KineticTileEntityRenderer::new);
|
||||
bind(MECHANICAL_PRESS, MechanicalPressTileEntityRenderer::new);
|
||||
bind(MECHANICAL_MIXER, MechanicalMixerTileEntityRenderer::new);
|
||||
bind(MECHANICAL_CRAFTER, MechanicalCrafterTileEntityRenderer::new);
|
||||
bind(SPEEDOMETER, disp -> new GaugeTileEntityRenderer(disp, GaugeBlock.Type.SPEED));
|
||||
bind(STRESSOMETER, disp -> new GaugeTileEntityRenderer(disp, GaugeBlock.Type.STRESS));
|
||||
bind(BASIN, BasinTileEntityRenderer::new);
|
||||
bind(DEPLOYER, DeployerTileEntityRenderer::new);
|
||||
bind(MECHANICAL_PRESS, MechanicalPressRenderer::new);
|
||||
bind(MECHANICAL_MIXER, MechanicalMixerRenderer::new);
|
||||
bind(MECHANICAL_CRAFTER, MechanicalCrafterRenderer::new);
|
||||
bind(SPEEDOMETER, disp -> new GaugeRenderer(disp, GaugeBlock.Type.SPEED));
|
||||
bind(STRESSOMETER, disp -> new GaugeRenderer(disp, GaugeBlock.Type.STRESS));
|
||||
bind(BASIN, BasinRenderer::new);
|
||||
bind(DEPLOYER, DeployerRenderer::new);
|
||||
bind(FLYWHEEL, FlywheelRenderer::new);
|
||||
bind(FURNACE_ENGINE, EngineRenderer::new);
|
||||
bind(ROTATION_SPEED_CONTROLLER, SpeedControllerRenderer::new);
|
||||
|
@ -249,8 +249,8 @@ public enum AllTileEntities {
|
|||
bind(TRANSPOSER, SmartTileEntityRenderer::new);
|
||||
bind(LINKED_TRANSPOSER, SmartTileEntityRenderer::new);
|
||||
bind(FUNNEL, SmartTileEntityRenderer::new);
|
||||
bind(BELT_TUNNEL, BeltTunnelTileEntityRenderer::new);
|
||||
bind(BELT_OBSERVER, BeltObserverTileEntityRenderer::new);
|
||||
bind(BELT_TUNNEL, BeltTunnelRenderer::new);
|
||||
bind(BELT_OBSERVER, BeltObserverRenderer::new);
|
||||
bind(ADJUSTABLE_REPEATER, AdjustableRepeaterRenderer::new);
|
||||
bind(ADJUSTABLE_PULSE_REPEATER, AdjustableRepeaterRenderer::new);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,9 @@ import net.minecraft.client.renderer.RenderType;
|
|||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.Direction.AxisDirection;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
@ -70,7 +72,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
|
|||
public static SuperByteBuffer kineticRotationTransform(SuperByteBuffer buffer, KineticTileEntity te, Axis axis,
|
||||
float angle, int light) {
|
||||
buffer.light(light);
|
||||
buffer.rotateCentered(axis, angle);
|
||||
buffer.rotateCentered(Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis), angle);
|
||||
|
||||
int white = 0xFFFFFF;
|
||||
if (KineticDebugger.isActive()) {
|
||||
|
|
|
@ -31,7 +31,7 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
|
|||
@OnlyIn(value = Dist.CLIENT)
|
||||
public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
DrillTileEntityRenderer.renderInContraption(context, ms, msLocal, buffer);
|
||||
DrillRenderer.renderInContraption(context, ms, msLocal, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,9 +17,9 @@ import net.minecraft.client.renderer.IRenderTypeBuffer;
|
|||
import net.minecraft.client.renderer.RenderType;
|
||||
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);
|
||||
}
|
||||
|
|
@ -15,7 +15,6 @@ import net.minecraft.client.renderer.RenderType;
|
|||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
||||
|
@ -26,7 +25,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
int light, int overlay) {
|
||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||
if (!(te instanceof CuckooClockTileEntity))
|
||||
return;
|
||||
|
@ -35,7 +34,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
|||
BlockState blockState = te.getBlockState();
|
||||
int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, te.getPos());
|
||||
Direction direction = blockState.get(CuckooClockBlock.HORIZONTAL_FACING);
|
||||
|
||||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
// Render Hands
|
||||
|
@ -43,8 +42,10 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
|||
SuperByteBuffer minuteHand = AllBlockPartials.CUCKOO_MINUTE_HAND.renderOn(blockState);
|
||||
float hourAngle = clock.hourHand.get(partialTicks);
|
||||
float minuteAngle = clock.minuteHand.get(partialTicks);
|
||||
rotateHand(hourHand, hourAngle, direction).light(packedLightmapCoords).renderInto(ms, vb);
|
||||
rotateHand(minuteHand, minuteAngle, direction).light(packedLightmapCoords).renderInto(ms, vb);
|
||||
rotateHand(hourHand, hourAngle, direction).light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
rotateHand(minuteHand, minuteAngle, direction).light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
// Doors
|
||||
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(rightDoor, angle, false, direction).light(packedLightmapCoords).renderInto(ms, vb);
|
||||
rotateDoor(leftDoor, angle, true, direction).light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
rotateDoor(rightDoor, angle, false, direction).light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
// Figure
|
||||
if (clock.animationType != null) {
|
||||
offset = -(angle / 135) * 1 / 2f + 10 / 16f;
|
||||
SuperByteBuffer figure = (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG
|
||||
: AllBlockPartials.CUCKOO_CREEPER).renderOn(blockState);
|
||||
SuperByteBuffer figure =
|
||||
(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.rotateCentered(Axis.Y, AngleHelper.rad(AngleHelper.horizontalAngle(direction.rotateYCCW())));
|
||||
figure.light(packedLightmapCoords).renderInto(ms, vb);
|
||||
figure.light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -90,18 +95,19 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
|||
}
|
||||
|
||||
private SuperByteBuffer transform(AllBlockPartials partial, KineticTileEntity te) {
|
||||
return partial.renderOnDirectional(te.getBlockState(),
|
||||
te.getBlockState().get(CuckooClockBlock.HORIZONTAL_FACING).getOpposite());
|
||||
return partial.renderOnDirectional(te.getBlockState(), te.getBlockState()
|
||||
.get(CuckooClockBlock.HORIZONTAL_FACING)
|
||||
.getOpposite());
|
||||
}
|
||||
|
||||
private SuperByteBuffer rotateHand(SuperByteBuffer buffer, float angle, Direction facing) {
|
||||
float pivotX = 2 / 16f;
|
||||
float pivotY = 6 / 16f;
|
||||
float pivotZ = 8 / 16f;
|
||||
buffer.translate(-pivotX, -pivotY, -pivotZ);
|
||||
buffer.rotate(Axis.X, angle);
|
||||
buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.rotateYCCW())));
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -109,10 +115,10 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
|||
float pivotX = 2 / 16f;
|
||||
float pivotY = 0;
|
||||
float pivotZ = (left ? 6 : 10) / 16f;
|
||||
buffer.translate(-pivotX, -pivotY, -pivotZ);
|
||||
buffer.rotate(Axis.Y, AngleHelper.rad(angle) * (left ? -1 : 1));
|
||||
buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing.rotateYCCW())));
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.utility.AngleHelper;
|
||||
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.TessellatorHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
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.Vec3d;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer<MechanicalCrafterTileEntity> {
|
||||
public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<MechanicalCrafterTileEntity> {
|
||||
|
||||
public MechanicalCrafterTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public MechanicalCrafterRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms,
|
||||
IRenderTypeBuffer buffer, int light, int overlay) {
|
||||
IRenderTypeBuffer buffer, int light, int overlay) {
|
||||
ms.push();
|
||||
Direction facing = te.getBlockState().get(HORIZONTAL_FACING);
|
||||
Vec3d vec = new Vec3d(facing.getDirectionVec()).scale(.58).add(.5, .5, .5);
|
||||
Direction facing = te.getBlockState()
|
||||
.get(HORIZONTAL_FACING);
|
||||
Vec3d vec = new Vec3d(facing.getDirectionVec()).scale(.58)
|
||||
.add(.5, .5, .5);
|
||||
|
||||
if (te.phase == Phase.EXPORTING) {
|
||||
Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(te.getBlockState());
|
||||
|
@ -59,16 +60,19 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer<
|
|||
ms.pop();
|
||||
|
||||
renderFast(te, partialTicks, ms, buffer, light);
|
||||
//TessellatorHelper.draw();
|
||||
// TessellatorHelper.draw();
|
||||
}
|
||||
|
||||
public void renderItems(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||
public void renderItems(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms,
|
||||
IRenderTypeBuffer buffer, int light, int overlay) {
|
||||
if (te.phase == Phase.IDLE) {
|
||||
ItemStack stack = te.inventory.getStackInSlot(0);
|
||||
if (!stack.isEmpty()) {
|
||||
ms.push();
|
||||
ms.translate(0, 0, -1 / 256f);
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
||||
Minecraft.getInstance()
|
||||
.getItemRenderer()
|
||||
.renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
||||
ms.pop();
|
||||
}
|
||||
} else {
|
||||
|
@ -89,7 +93,7 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer<
|
|||
ms.scale(1 - lateProgress, 1 - lateProgress, 1 - lateProgress);
|
||||
Vec3d centering =
|
||||
new Vec3d(-items.minX + (-items.width + 1) / 2f, -items.minY + (-items.height + 1) / 2f, 0)
|
||||
.scale(earlyProgress);
|
||||
.scale(earlyProgress);
|
||||
ms.translate(centering.x * .5f, centering.y * .5f, 0);
|
||||
distance += (-4 * (progress - .5f) * (progress - .5f) + 1) * .25f;
|
||||
}
|
||||
|
@ -97,13 +101,22 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer<
|
|||
boolean onlyRenderFirst = te.phase == Phase.INSERTING || te.phase == Phase.CRAFTING && te.countDown < 1000;
|
||||
final float spacing = distance;
|
||||
items.grid.forEach((pair, stack) -> {
|
||||
if (onlyRenderFirst && (pair.getLeft().intValue() != 0 || pair.getRight().intValue() != 0))
|
||||
if (onlyRenderFirst && (pair.getLeft()
|
||||
.intValue() != 0
|
||||
|| pair.getRight()
|
||||
.intValue() != 0))
|
||||
return;
|
||||
|
||||
ms.push();
|
||||
ms.translate(pair.getKey() * spacing, pair.getValue() * spacing, 0);
|
||||
TessellatorHelper.fightZFighting(pair.hashCode() + te.getPos().hashCode());
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
||||
Integer x = pair.getKey();
|
||||
Integer y = pair.getValue();
|
||||
ms.translate(x * spacing, y * spacing, 0);
|
||||
MatrixStacker.of(ms)
|
||||
.nudge(x * 13 + y + te.getPos()
|
||||
.hashCode());
|
||||
Minecraft.getInstance()
|
||||
.getItemRenderer()
|
||||
.renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
||||
ms.pop();
|
||||
});
|
||||
|
||||
|
@ -123,36 +136,44 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer<
|
|||
ms.scale(downScaling, downScaling, downScaling);
|
||||
|
||||
items.grid.forEach((pair, stack) -> {
|
||||
if (pair.getLeft().intValue() != 0 || pair.getRight().intValue() != 0)
|
||||
if (pair.getLeft()
|
||||
.intValue() != 0
|
||||
|| pair.getRight()
|
||||
.intValue() != 0)
|
||||
return;
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
||||
Minecraft.getInstance()
|
||||
.getItemRenderer()
|
||||
.renderItem(stack, TransformType.FIXED, light, overlay, ms, buffer);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void renderFast(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light) {
|
||||
public void renderFast(MechanicalCrafterTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light) {
|
||||
BlockState blockState = te.getBlockState();
|
||||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
|
||||
superBuffer.rotateCentered(Axis.X, (float) (Math.PI / 2));
|
||||
superBuffer.rotateCentered(Axis.Y,
|
||||
(float) (blockState.get(HORIZONTAL_FACING).getAxis() != Axis.X ? 0 : Math.PI / 2));
|
||||
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
|
||||
standardKineticRotationTransform(superBuffer, te, light);
|
||||
superBuffer.rotateCentered(Direction.UP, (float) (blockState.get(HORIZONTAL_FACING)
|
||||
.getAxis() != Axis.X ? 0 : Math.PI / 2));
|
||||
superBuffer.rotateCentered(Direction.EAST, (float) (Math.PI / 2));
|
||||
superBuffer.renderInto(ms, vb);
|
||||
|
||||
Direction targetDirection = MechanicalCrafterBlock.getTargetDirection(blockState);
|
||||
BlockPos pos = te.getPos();
|
||||
|
||||
if ((te.covered || te.phase != Phase.IDLE) && te.phase != Phase.CRAFTING && te.phase != Phase.INSERTING) {
|
||||
SuperByteBuffer lidBuffer = renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_LID, blockState, pos);
|
||||
SuperByteBuffer lidBuffer =
|
||||
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_LID, blockState, pos);
|
||||
lidBuffer.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
if (MechanicalCrafterBlock.isValidTarget(te.getWorld(), pos.offset(targetDirection), blockState)) {
|
||||
SuperByteBuffer beltBuffer = renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT, blockState, pos);
|
||||
SuperByteBuffer beltBuffer =
|
||||
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT, blockState, pos);
|
||||
SuperByteBuffer beltFrameBuffer =
|
||||
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT_FRAME, blockState, pos);
|
||||
|
||||
|
@ -174,12 +195,14 @@ public class MechanicalCrafterTileEntityRenderer extends SafeTileEntityRenderer<
|
|||
|
||||
}
|
||||
|
||||
private SuperByteBuffer renderAndTransform(MechanicalCrafterTileEntity te, AllBlockPartials renderBlock, BlockState crafterState, BlockPos pos) {
|
||||
private SuperByteBuffer renderAndTransform(MechanicalCrafterTileEntity te, AllBlockPartials renderBlock,
|
||||
BlockState crafterState, BlockPos pos) {
|
||||
SuperByteBuffer buffer = renderBlock.renderOn(crafterState);
|
||||
float xRot = crafterState.get(MechanicalCrafterBlock.POINTING).getXRotation();
|
||||
float xRot = crafterState.get(MechanicalCrafterBlock.POINTING)
|
||||
.getXRotation();
|
||||
float yRot = AngleHelper.horizontalAngle(crafterState.get(HORIZONTAL_FACING));
|
||||
buffer.rotateCentered(Axis.X, (float) ((xRot) / 180 * Math.PI));
|
||||
buffer.rotateCentered(Axis.Y, (float) ((yRot + 90) / 180 * Math.PI));
|
||||
buffer.rotateCentered(Direction.UP, (float) ((yRot + 90) / 180 * Math.PI));
|
||||
buffer.rotateCentered(Direction.EAST, (float) ((xRot) / 180 * Math.PI));
|
||||
buffer.light(WorldRenderer.getLightmapCoordinates(te.getWorld(), crafterState, pos));
|
||||
return buffer;
|
||||
}
|
|
@ -14,9 +14,9 @@ import net.minecraft.client.renderer.RenderType;
|
|||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class HandCrankTileEntityRenderer extends KineticTileEntityRenderer {
|
||||
public class HandCrankRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
public HandCrankTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public HandCrankRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
|
@ -168,7 +168,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
|
|||
@Override
|
||||
public void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffers) {
|
||||
DeployerTileEntityRenderer.renderInContraption(context, ms, msLocal, buffers);
|
||||
DeployerRenderer.renderInContraption(context, ms, msLocal, buffers);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,10 +37,9 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DeployerTileEntityRenderer extends SafeTileEntityRenderer<DeployerTileEntity> {
|
||||
public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity> {
|
||||
|
||||
public DeployerTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public DeployerRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
|
@ -107,15 +106,16 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer<DeployerT
|
|||
|
||||
BlockState blockState = te.getBlockState();
|
||||
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);
|
||||
pole.translate(offset.x, offset.y, offset.z)
|
||||
.renderInto(ms, vb);
|
||||
hand.translate(offset.x, offset.y, offset.z)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
SuperByteBuffer pole = AllBlockPartials.DEPLOYER_POLE.renderOn(blockState);
|
||||
SuperByteBuffer hand = te.getHandPose()
|
||||
.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) {
|
||||
|
@ -137,20 +137,19 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer<DeployerT
|
|||
return KineticTileEntityRenderer.shaft(KineticTileEntityRenderer.getRotationAxisOf(te));
|
||||
}
|
||||
|
||||
private static SuperByteBuffer renderAndTransform(World world, AllBlockPartials renderBlock,
|
||||
BlockState deployerState, BlockPos pos, boolean axisDirectionMatters) {
|
||||
SuperByteBuffer buffer = renderBlock.renderOn(deployerState);
|
||||
private static SuperByteBuffer transform(World world, SuperByteBuffer buffer, BlockState deployerState,
|
||||
BlockPos pos, boolean axisDirectionMatters) {
|
||||
Direction facing = deployerState.get(FACING);
|
||||
|
||||
float zRotFirst =
|
||||
float zRotLast =
|
||||
axisDirectionMatters && (deployerState.get(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Axis.Z) ? 90
|
||||
: 0;
|
||||
float yRot = AngleHelper.horizontalAngle(facing);
|
||||
float zRot = facing == Direction.UP ? 270 : facing == Direction.DOWN ? 90 : 0;
|
||||
|
||||
buffer.rotateCentered(Axis.Z, (float) ((zRotFirst) / 180 * Math.PI));
|
||||
buffer.rotateCentered(Axis.Y, (float) ((yRot) / 180 * Math.PI));
|
||||
buffer.rotateCentered(Axis.Z, (float) ((zRot) / 180 * Math.PI));
|
||||
buffer.rotateCentered(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI));
|
||||
buffer.rotateCentered(Direction.UP, (float) ((yRot) / 180 * Math.PI));
|
||||
buffer.rotateCentered(Direction.SOUTH, (float) ((zRotLast) / 180 * Math.PI));
|
||||
buffer.light(WorldRenderer.getLightmapCoordinates(world, deployerState, pos));
|
||||
return buffer;
|
||||
}
|
||||
|
@ -166,8 +165,10 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer<DeployerT
|
|||
AllBlockPartials handPose =
|
||||
mode == Mode.PUNCH ? AllBlockPartials.DEPLOYER_HAND_PUNCHING : AllBlockPartials.DEPLOYER_HAND_POINTING;
|
||||
|
||||
SuperByteBuffer pole = renderAndTransform(world, AllBlockPartials.DEPLOYER_POLE, blockState, pos, true);
|
||||
SuperByteBuffer hand = renderAndTransform(world, handPose, blockState, pos, false);
|
||||
SuperByteBuffer pole = AllBlockPartials.DEPLOYER_POLE.renderOn(blockState);
|
||||
SuperByteBuffer hand = handPose.renderOn(blockState);
|
||||
pole = transform(world, pole, blockState, pos, true);
|
||||
hand = transform(world, hand, blockState, pos, false);
|
||||
|
||||
double factor;
|
||||
if (context.contraption.stalled || context.position == null || context.data.contains("StationaryTimer")) {
|
|
@ -12,25 +12,32 @@ import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
|||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
Direction direction = te.getBlockState().get(FACING);
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(),
|
||||
direction.getOpposite());
|
||||
int light, int overlay) {
|
||||
Direction direction = te.getBlockState()
|
||||
.get(FACING);
|
||||
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 speed = te.getSpeed() * 5;
|
||||
if (speed > 0)
|
||||
|
@ -40,10 +47,8 @@ public class EncasedFanTileEntityRenderer extends KineticTileEntityRenderer {
|
|||
float angle = (time * speed * 3 / 10f) % 360;
|
||||
angle = angle / 180f * (float) Math.PI;
|
||||
|
||||
SuperByteBuffer superByteBuffer = AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectional(te.getBlockState(),
|
||||
direction.getOpposite());
|
||||
kineticRotationTransform(superByteBuffer, te, direction.getAxis(), angle, light);
|
||||
superByteBuffer.renderInto(ms, vb);
|
||||
standardKineticRotationTransform(shaftHalf, te, lightBehind).renderInto(ms, vb);
|
||||
kineticRotationTransform(fanInner, te, direction.getAxis(), angle, lightInFront).renderInto(ms, vb);
|
||||
}
|
||||
|
||||
}
|
|
@ -30,7 +30,7 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
int light, int overlay) {
|
||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
BlockState blockState = te.getBlockState();
|
||||
|
@ -39,39 +39,49 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
|
|||
SuperByteBuffer wheel = AllBlockPartials.FLYWHEEL.renderOnHorizontal(blockState.rotate(Rotation.CLOCKWISE_90));
|
||||
float speed = wte.visualSpeed.get(partialTicks) * 3 / 10f;
|
||||
float angle = wte.angle + speed * partialTicks;
|
||||
|
||||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
if (FlywheelBlock.isConnected(blockState)) {
|
||||
Direction connection = FlywheelBlock.getConnection(blockState);
|
||||
light = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, te.getPos().offset(connection));
|
||||
float rotation = connection.getAxis() == Axis.X ^ connection.getAxisDirection() == AxisDirection.NEGATIVE
|
||||
? -angle
|
||||
light = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, te.getPos()
|
||||
.offset(connection));
|
||||
float rotation =
|
||||
connection.getAxis() == Axis.X ^ connection.getAxisDirection() == AxisDirection.NEGATIVE ? -angle
|
||||
: angle;
|
||||
boolean flip = blockState.get(FlywheelBlock.CONNECTION) == ConnectionState.LEFT;
|
||||
|
||||
rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_UPPER_ROTATING.renderOn(blockState), true, true,
|
||||
rotation, flip), connection).light(light).renderInto(ms, vb);
|
||||
rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_LOWER_ROTATING.renderOn(blockState), false,
|
||||
true, rotation, flip), connection).light(light).renderInto(ms, vb);
|
||||
rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_UPPER_SLIDING.renderOn(blockState), true, false,
|
||||
rotation, flip), connection).light(light).renderInto(ms, vb);
|
||||
rotateToFacing(transformConnector(AllBlockPartials.FLYWHEEL_LOWER_SLIDING.renderOn(blockState), false,
|
||||
false, rotation, flip), connection).light(light).renderInto(ms, vb);
|
||||
transformConnector(
|
||||
rotateToFacing(AllBlockPartials.FLYWHEEL_UPPER_ROTATING.renderOn(blockState), connection), true, true,
|
||||
rotation, flip).light(light)
|
||||
.renderInto(ms, vb);
|
||||
transformConnector(
|
||||
rotateToFacing(AllBlockPartials.FLYWHEEL_LOWER_ROTATING.renderOn(blockState), connection), false, true,
|
||||
rotation, flip).light(light)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
transformConnector(rotateToFacing(AllBlockPartials.FLYWHEEL_UPPER_SLIDING.renderOn(blockState), connection),
|
||||
true, false, rotation, flip).light(light)
|
||||
.renderInto(ms, vb);
|
||||
transformConnector(rotateToFacing(AllBlockPartials.FLYWHEEL_LOWER_SLIDING.renderOn(blockState), connection),
|
||||
false, false, rotation, flip).light(light)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING).getAxis(), AngleHelper.rad(angle), light);
|
||||
kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING)
|
||||
.getAxis(), AngleHelper.rad(angle), light);
|
||||
wheel.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(),
|
||||
te.getBlockState().get(HORIZONTAL_FACING).getOpposite());
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), te.getBlockState()
|
||||
.get(HORIZONTAL_FACING)
|
||||
.getOpposite());
|
||||
}
|
||||
|
||||
protected SuperByteBuffer transformConnector(SuperByteBuffer buffer, boolean upper, boolean rotating, float angle,
|
||||
boolean flip) {
|
||||
boolean flip) {
|
||||
|
||||
float shift = upper ? 1 / 4f : -1 / 8f;
|
||||
float offset = upper ? 1 / 4f : 1 / 4f;
|
||||
|
@ -89,19 +99,19 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
|
|||
float pivotY = (upper ? 8f : 2f) / 16;
|
||||
float pivotZ = (upper ? 23f : 21.5f) / 16f;
|
||||
|
||||
buffer.translate(pivotX, pivotY, pivotZ + shifting);
|
||||
if (rotating)
|
||||
buffer.rotate(Direction.EAST, AngleHelper.rad(barAngle));
|
||||
buffer.translate(-pivotX, -pivotY, -pivotZ);
|
||||
|
||||
if (flip && !upper)
|
||||
buffer.translate(9 / 16f, 0, 0);
|
||||
|
||||
buffer.translate(-pivotX, -pivotY, -pivotZ);
|
||||
if (rotating)
|
||||
buffer.rotate(Axis.X, AngleHelper.rad(barAngle));
|
||||
buffer.translate(pivotX, pivotY, pivotZ + shifting);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
protected SuperByteBuffer rotateToFacing(SuperByteBuffer buffer, Direction facing) {
|
||||
buffer.rotateCentered(Axis.Y, AngleHelper.rad(AngleHelper.horizontalAngle(facing)));
|
||||
buffer.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(facing)));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,24 +13,24 @@ import net.minecraft.client.renderer.IRenderTypeBuffer;
|
|||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class MechanicalMixerTileEntityRenderer extends KineticTileEntityRenderer {
|
||||
public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
public MechanicalMixerTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public MechanicalMixerRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
int light, int overlay) {
|
||||
BlockState blockState = te.getBlockState();
|
||||
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te;
|
||||
BlockPos pos = te.getPos();
|
||||
|
||||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
|
||||
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
|
||||
|
||||
|
@ -41,11 +41,15 @@ public class MechanicalMixerTileEntityRenderer extends KineticTileEntityRenderer
|
|||
float angle = (float) (((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI);
|
||||
|
||||
SuperByteBuffer poleRender = AllBlockPartials.MECHANICAL_MIXER_POLE.renderOn(blockState);
|
||||
poleRender.translate(0, -renderedHeadOffset, 0).light(packedLightmapCoords).renderInto(ms, vb);
|
||||
poleRender.translate(0, -renderedHeadOffset, 0)
|
||||
.light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
SuperByteBuffer headRender = AllBlockPartials.MECHANICAL_MIXER_HEAD.renderOn(blockState);
|
||||
headRender.rotateCentered(Axis.Y, angle).translate(0, -renderedHeadOffset, 0).light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
headRender.rotateCentered(Direction.UP, angle)
|
||||
.translate(0, -renderedHeadOffset, 0)
|
||||
.light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
}
|
|
@ -14,9 +14,9 @@ import net.minecraft.util.math.shapes.VoxelShape;
|
|||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
|
||||
public class MotorBlock extends DirectionalKineticBlock {
|
||||
public class CreativeMotorBlock extends DirectionalKineticBlock {
|
||||
|
||||
public MotorBlock(Properties properties) {
|
||||
public CreativeMotorBlock(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class MotorBlock extends DirectionalKineticBlock {
|
|||
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return new MotorTileEntity();
|
||||
return new CreativeMotorTileEntity();
|
||||
}
|
||||
|
||||
@Override
|
|
@ -10,24 +10,24 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.generators.ModelFile;
|
||||
|
||||
public class MotorGenerator extends SpecialBlockStateGen {
|
||||
public class CreativeMotorGenerator extends SpecialBlockStateGen {
|
||||
|
||||
@Override
|
||||
protected int getXRotation(BlockState state) {
|
||||
return state.get(MotorBlock.FACING) == Direction.DOWN ? 180 : 0;
|
||||
return state.get(CreativeMotorBlock.FACING) == Direction.DOWN ? 180 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getYRotation(BlockState state) {
|
||||
return state.get(MotorBlock.FACING)
|
||||
return state.get(CreativeMotorBlock.FACING)
|
||||
.getAxis()
|
||||
.isVertical() ? 0 : horizontalAngle(state.get(MotorBlock.FACING));
|
||||
.isVertical() ? 0 : horizontalAngle(state.get(CreativeMotorBlock.FACING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Block> ModelFile getModel(DataGenContext<Block, T> ctx, RegistrateBlockstateProvider prov,
|
||||
BlockState state) {
|
||||
return state.get(MotorBlock.FACING)
|
||||
return state.get(CreativeMotorBlock.FACING)
|
||||
.getAxis()
|
||||
.isVertical() ? AssetLookup.partialBaseModel(ctx, prov, "vertical")
|
||||
: AssetLookup.partialBaseModel(ctx, prov);
|
|
@ -7,9 +7,9 @@ import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
|||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
|
||||
public class MotorTileEntityRenderer extends KineticTileEntityRenderer {
|
||||
public class CreativeMotorRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
public MotorTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public CreativeMotorRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
|
@ -11,12 +11,12 @@ import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollVal
|
|||
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour.StepContext;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
public class MotorTileEntity extends GeneratingKineticTileEntity {
|
||||
public class CreativeMotorTileEntity extends GeneratingKineticTileEntity {
|
||||
|
||||
public static final int DEFAULT_SPEED = 16;
|
||||
protected ScrollValueBehaviour generatedSpeed;
|
||||
|
||||
public MotorTileEntity() {
|
||||
public CreativeMotorTileEntity() {
|
||||
super(AllTileEntities.MOTOR.type);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class MotorTileEntity extends GeneratingKineticTileEntity {
|
|||
Integer max = AllConfigs.SERVER.kinetics.maxMotorSpeed.get();
|
||||
|
||||
CenteredSideValueBoxTransform slot =
|
||||
new CenteredSideValueBoxTransform((motor, side) -> motor.get(MotorBlock.FACING) == side.getOpposite());
|
||||
new CenteredSideValueBoxTransform((motor, side) -> motor.get(CreativeMotorBlock.FACING) == side.getOpposite());
|
||||
|
||||
generatedSpeed = new ScrollValueBehaviour(Lang.translate("generic.speed"), this, slot);
|
||||
generatedSpeed.between(-max, max);
|
||||
|
@ -34,7 +34,7 @@ public class MotorTileEntity extends GeneratingKineticTileEntity {
|
|||
generatedSpeed.scrollableValue = DEFAULT_SPEED;
|
||||
generatedSpeed.withUnit(i -> Lang.translate("generic.unit.rpm"));
|
||||
generatedSpeed.withCallback(i -> this.updateGeneratedRotation());
|
||||
generatedSpeed.withStepFunction(MotorTileEntity::step);
|
||||
generatedSpeed.withStepFunction(CreativeMotorTileEntity::step);
|
||||
behaviours.add(generatedSpeed);
|
||||
}
|
||||
|
|
@ -13,9 +13,9 @@ import net.minecraft.client.renderer.WorldRenderer;
|
|||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class MechanicalPressTileEntityRenderer extends KineticTileEntityRenderer {
|
||||
public class MechanicalPressRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
public MechanicalPressTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public MechanicalPressRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
|
@ -25,9 +25,9 @@ import net.minecraft.util.Direction;
|
|||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class SawTileEntityRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
||||
public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
||||
|
||||
public SawTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public SawRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
|
@ -12,34 +12,39 @@ import net.minecraft.client.renderer.RenderType;
|
|||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
|
||||
public class BearingTileEntityRenderer extends KineticTileEntityRenderer {
|
||||
public class BearingRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
public BearingTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public BearingRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
int light, int overlay) {
|
||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
IBearingTileEntity bearingTe = (IBearingTileEntity) te;
|
||||
final Direction facing = te.getBlockState().get(BlockStateProperties.FACING);
|
||||
final Direction facing = te.getBlockState()
|
||||
.get(BlockStateProperties.FACING);
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.BEARING_TOP.renderOn(te.getBlockState());
|
||||
superBuffer.rotateCentered(Axis.X, AngleHelper.rad(-90 - AngleHelper.verticalAngle(facing)));
|
||||
if (facing.getAxis().isHorizontal())
|
||||
superBuffer.rotateCentered(Axis.Y, AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite())));
|
||||
|
||||
float interpolatedAngle = bearingTe.getInterpolatedAngle(partialTicks - 1);
|
||||
kineticRotationTransform(superBuffer, te, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI), light);
|
||||
|
||||
if (facing.getAxis()
|
||||
.isHorizontal())
|
||||
superBuffer.rotateCentered(Direction.UP,
|
||||
AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite())));
|
||||
superBuffer.rotateCentered(Direction.EAST, AngleHelper.rad(-90 - AngleHelper.verticalAngle(facing)));
|
||||
superBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(),
|
||||
te.getBlockState().get(BearingBlock.FACING).getOpposite());
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectional(te.getBlockState(), te.getBlockState()
|
||||
.get(BearingBlock.FACING)
|
||||
.getOpposite());
|
||||
}
|
||||
|
||||
}
|
|
@ -6,9 +6,9 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
|
||||
public class MechanicalPistonTileEntityRenderer extends KineticTileEntityRenderer {
|
||||
public class MechanicalPistonRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
public MechanicalPistonTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public MechanicalPistonRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
|
@ -17,9 +17,9 @@ import net.minecraft.util.math.Vec3d;
|
|||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class BasinTileEntityRenderer extends SafeTileEntityRenderer<BasinTileEntity> {
|
||||
public class BasinRenderer extends SafeTileEntityRenderer<BasinTileEntity> {
|
||||
|
||||
public BasinTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public BasinRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.content.contraptions.RotationPropagator;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.motor.MotorTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.motor.CreativeMotorTileEntity;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform;
|
||||
|
@ -38,7 +38,7 @@ public class SpeedControllerTileEntity extends KineticTileEntity {
|
|||
targetSpeed.moveText(new Vec3d(9, 0, 10));
|
||||
targetSpeed.withUnit(i -> Lang.translate("generic.unit.rpm"));
|
||||
targetSpeed.withCallback(i -> this.updateTargetRotation());
|
||||
targetSpeed.withStepFunction(MotorTileEntity::step);
|
||||
targetSpeed.withStepFunction(CreativeMotorTileEntity::step);
|
||||
behaviours.add(targetSpeed);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,9 @@ import net.minecraft.util.math.Vec3d;
|
|||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BeltTileEntityRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
||||
public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
||||
|
||||
public BeltTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public BeltRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
|
@ -6,9 +6,9 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
|
||||
public class EncasedShaftTileEntityRenderer extends KineticTileEntityRenderer {
|
||||
public class EncasedShaftRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
public EncasedShaftTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public EncasedShaftRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
|
@ -16,9 +16,9 @@ import net.minecraft.util.Direction;
|
|||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class SplitShaftTileEntityRenderer extends KineticTileEntityRenderer {
|
||||
public class SplitShaftRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
public SplitShaftTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public SplitShaftRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
|
@ -14,21 +14,20 @@ import net.minecraft.client.renderer.RenderType;
|
|||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class GaugeTileEntityRenderer extends KineticTileEntityRenderer {
|
||||
public class GaugeRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
protected GaugeBlock.Type type;
|
||||
|
||||
public GaugeTileEntityRenderer(TileEntityRendererDispatcher dispatcher, GaugeBlock.Type type) {
|
||||
public GaugeRenderer(TileEntityRendererDispatcher dispatcher, GaugeBlock.Type type) {
|
||||
super(dispatcher);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
int light, int overlay) {
|
||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||
BlockState gaugeState = te.getBlockState();
|
||||
GaugeTileEntity gaugeTE = (GaugeTileEntity) te;
|
||||
|
@ -36,25 +35,25 @@ public class GaugeTileEntityRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
SuperByteBuffer headBuffer =
|
||||
(type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS)
|
||||
.renderOn(gaugeState);
|
||||
.renderOn(gaugeState);
|
||||
SuperByteBuffer dialBuffer = AllBlockPartials.GAUGE_DIAL.renderOn(gaugeState);
|
||||
|
||||
for (Direction facing : Direction.values()) {
|
||||
if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(te.getWorld(), te.getPos(), gaugeState,
|
||||
facing))
|
||||
facing))
|
||||
continue;
|
||||
|
||||
float dialPivot = -5.75f / 16;
|
||||
float dialPivot = 5.75f / 16;
|
||||
float progress = MathHelper.lerp(partialTicks, gaugeTE.prevDialState, gaugeTE.dialState);
|
||||
dialBuffer.translate(0, dialPivot, dialPivot)
|
||||
.rotate(Axis.X, (float) (Math.PI / 2 * -progress))
|
||||
.translate(0, -dialPivot, -dialPivot);
|
||||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
rotateBufferTowards(dialBuffer, facing).light(lightCoords)
|
||||
.renderInto(ms, vb);
|
||||
rotateBufferTowards(dialBuffer, facing).translate(0, dialPivot, dialPivot)
|
||||
.rotate(Direction.EAST, (float) (Math.PI / 2 * -progress))
|
||||
.translate(0, -dialPivot, -dialPivot)
|
||||
.light(lightCoords)
|
||||
.renderInto(ms, vb);
|
||||
rotateBufferTowards(headBuffer, facing).light(lightCoords)
|
||||
.renderInto(ms, vb);
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -65,7 +64,7 @@ public class GaugeTileEntityRenderer extends KineticTileEntityRenderer {
|
|||
}
|
||||
|
||||
protected SuperByteBuffer rotateBufferTowards(SuperByteBuffer buffer, Direction target) {
|
||||
return buffer.rotateCentered(Axis.Y, (float) ((-target.getHorizontalAngle() - 90) / 180 * Math.PI));
|
||||
return buffer.rotateCentered(Direction.UP, (float) ((-target.getHorizontalAngle() - 90) / 180 * Math.PI));
|
||||
}
|
||||
|
||||
}
|
|
@ -15,9 +15,9 @@ import net.minecraft.util.Direction;
|
|||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class GearboxTileEntityRenderer extends KineticTileEntityRenderer {
|
||||
public class GearboxRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
public GearboxTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public GearboxRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
|
@ -9,9 +9,9 @@ import net.minecraft.client.renderer.WorldRenderer;
|
|||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
|
||||
public class BeltObserverTileEntityRenderer extends SafeTileEntityRenderer<BeltObserverTileEntity> {
|
||||
public class BeltObserverRenderer extends SafeTileEntityRenderer<BeltObserverTileEntity> {
|
||||
|
||||
public BeltObserverTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public BeltObserverRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
|
@ -18,15 +18,15 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BeltTunnelTileEntityRenderer extends SafeTileEntityRenderer<BeltTunnelTileEntity> {
|
||||
public class BeltTunnelRenderer extends SafeTileEntityRenderer<BeltTunnelTileEntity> {
|
||||
|
||||
public BeltTunnelTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
public BeltTunnelRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(BeltTunnelTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
int light, int overlay) {
|
||||
SuperByteBuffer flapBuffer = AllBlockPartials.BELT_TUNNEL_FLAP.renderOn(te.getBlockState());
|
||||
SuperByteBuffer indicatorBuffer = AllBlockPartials.BELT_TUNNEL_INDICATOR.renderOn(te.getBlockState());
|
||||
BlockPos pos = te.getPos();
|
||||
|
@ -45,7 +45,8 @@ public class BeltTunnelTileEntityRenderer extends SafeTileEntityRenderer<BeltTun
|
|||
float flapPivotZ = 0;
|
||||
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)
|
||||
f *= -1;
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class BeltTunnelTileEntityRenderer extends SafeTileEntityRenderer<BeltTun
|
|||
float abs = Math.abs(f);
|
||||
float flapAngle = MathHelper.sin((float) ((1 - abs) * Math.PI * intensity)) * 30 * -f;
|
||||
flapAngle = (float) (flapAngle / 180 * Math.PI);
|
||||
|
||||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
if (te.syncedFlaps.containsKey(direction)) {
|
||||
|
@ -64,15 +65,19 @@ public class BeltTunnelTileEntityRenderer extends SafeTileEntityRenderer<BeltTun
|
|||
indicatorBlockLight = Math.max(indicatorBlockLight, (int) (12 * lightIntensity));
|
||||
indicatorLight = LightTexture.pack(indicatorBlockLight, indicatorSkyLight);
|
||||
int color = ColorHelper.mixColors(0x808080, 0xFFFFFF, lightIntensity);
|
||||
indicatorBuffer.rotateCentered(Axis.Y, (float) ((horizontalAngle + 90) / 180f * Math.PI))
|
||||
.color(color).light(indicatorLight).renderInto(ms, vb);
|
||||
indicatorBuffer.rotateCentered(Direction.UP, (float) ((horizontalAngle + 90) / 180f * Math.PI))
|
||||
.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.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);
|
||||
}
|
||||
}
|
||||
|
|
@ -15,41 +15,45 @@ import net.minecraft.client.renderer.WorldRenderer;
|
|||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.state.properties.AttachFace;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
int light, int overlay) {
|
||||
BlockState leverState = te.getBlockState();
|
||||
int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), leverState, te.getPos());
|
||||
float state = te.clientState.get(partialTicks);
|
||||
|
||||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
// Handle
|
||||
SuperByteBuffer handle = AllBlockPartials.ANALOG_LEVER_HANDLE.renderOn(leverState);
|
||||
float angle = (float) ((state / 15) * 90 / 180 * Math.PI);
|
||||
handle.translate(-1 / 2f, -1 / 16f, -1 / 2f).rotate(Axis.X, angle).translate(1 / 2f, 1 / 16f, 1 / 2f);
|
||||
transform(handle, leverState).light(lightCoords).renderInto(ms, vb);
|
||||
transform(handle, leverState).translate(1 / 2f, 1 / 16f, 1 / 2f)
|
||||
.rotate(Direction.EAST, angle)
|
||||
.translate(-1 / 2f, -1 / 16f, -1 / 2f);
|
||||
handle.light(lightCoords)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
// Indicator
|
||||
int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f);
|
||||
SuperByteBuffer indicator = transform(AllBlockPartials.ANALOG_LEVER_INDICATOR.renderOn(leverState), leverState);
|
||||
indicator.light(lightCoords).color(color).renderInto(ms, vb);
|
||||
indicator.light(lightCoords)
|
||||
.color(color)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
private SuperByteBuffer transform(SuperByteBuffer buffer, BlockState leverState) {
|
||||
AttachFace face = leverState.get(AnalogLeverBlock.FACE);
|
||||
float rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180;
|
||||
float rY = AngleHelper.horizontalAngle(leverState.get(AnalogLeverBlock.HORIZONTAL_FACING));
|
||||
buffer.rotateCentered(Direction.EAST, (float) (rX / 180 * Math.PI));
|
||||
buffer.rotateCentered(Direction.UP, (float) (rY / 180 * Math.PI));
|
||||
buffer.rotateCentered(Direction.EAST, (float) (rX / 180 * Math.PI));
|
||||
return buffer;
|
||||
}
|
||||
|
|
@ -46,6 +46,7 @@ public class ServerSchematicLoader {
|
|||
this.stream = stream;
|
||||
this.totalBytes = totalBytes;
|
||||
this.tablePos = tablePos;
|
||||
this.world = world;
|
||||
this.bytesUploaded = 0;
|
||||
this.idleTime = 0;
|
||||
}
|
||||
|
@ -134,7 +135,7 @@ public class ServerSchematicLoader {
|
|||
OutputStream writer =
|
||||
Files.newOutputStream(Paths.get(getSchematicPath(), playerSchematicId), StandardOpenOption.CREATE_NEW);
|
||||
activeUploads.put(playerSchematicId,
|
||||
new SchematicUploadEntry(writer, size, player.getEntityWorld(), pos));
|
||||
new SchematicUploadEntry(writer, size, player.getServerWorld(), pos));
|
||||
|
||||
// Notify Tile Entity
|
||||
table.startUpload(schematic);
|
||||
|
|
|
@ -148,17 +148,17 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
|
|||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
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.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
|
||||
connector.translate(-.5f, 0, -.5f);
|
||||
connector.light(lightCoords).renderInto(ms, vb);
|
||||
|
||||
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.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);
|
||||
|
||||
ms.pop();
|
||||
|
|
|
@ -9,21 +9,24 @@ import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public abstract class SafeTileEntityRenderer<T extends TileEntity> extends TileEntityRenderer<T> {
|
||||
|
||||
|
||||
public SafeTileEntityRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void render(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||
public final void render(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light,
|
||||
int overlay) {
|
||||
if (isInvalid(te))
|
||||
return;
|
||||
renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||
}
|
||||
|
||||
protected abstract void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay);
|
||||
|
||||
|
||||
protected abstract void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light,
|
||||
int overlay);
|
||||
|
||||
public boolean isInvalid(T te) {
|
||||
return te.getBlockState().getBlock() == Blocks.AIR;
|
||||
return !te.hasWorld() || te.getBlockState()
|
||||
.getBlock() == Blocks.AIR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,51 +5,48 @@ import java.util.Iterator;
|
|||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.crash.ReportedException;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityRenderHelper {
|
||||
|
||||
protected static LightingWorld lightingWorld;
|
||||
|
||||
public static void renderTileEntities(World world, Iterable<TileEntity> customRenderTEs, MatrixStack ms,
|
||||
MatrixStack localTransform, IRenderTypeBuffer buffer) {
|
||||
float pt = Minecraft.getInstance()
|
||||
.getRenderPartialTicks();
|
||||
|
||||
if (lightingWorld == null)
|
||||
lightingWorld = new LightingWorld(world);
|
||||
lightingWorld.setWorld(world);
|
||||
lightingWorld.setTransform(localTransform.peek()
|
||||
.getModel());
|
||||
Matrix4f matrix = localTransform.peek()
|
||||
.getModel();
|
||||
|
||||
for (Iterator<TileEntity> iterator = customRenderTEs.iterator(); iterator.hasNext();) {
|
||||
TileEntity tileEntity = iterator.next();
|
||||
if (TileEntityRendererDispatcher.instance.getRenderer(tileEntity) == null) {
|
||||
TileEntityRenderer<TileEntity> renderer = TileEntityRendererDispatcher.instance.getRenderer(tileEntity);
|
||||
if (renderer == null) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
BlockPos pos = tileEntity.getPos();
|
||||
World prevTileWorld = tileEntity.getWorld();
|
||||
ms.push();
|
||||
MatrixStacker.of(ms)
|
||||
.translate(pos);
|
||||
tileEntity.setLocation(lightingWorld, pos);
|
||||
TileEntityRendererDispatcher.instance.render(tileEntity, pt, ms, buffer);
|
||||
tileEntity.setLocation(prevTileWorld, pos);
|
||||
|
||||
Vector4f vec = new Vector4f(pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, 1);
|
||||
vec.transform(matrix);
|
||||
BlockPos lightPos = new BlockPos(vec.getX(), vec.getY(), vec.getZ());
|
||||
renderer.render(tileEntity, pt, ms, buffer, WorldRenderer.getLightmapCoordinates(world, lightPos),
|
||||
OverlayTexture.DEFAULT_UV);
|
||||
ms.pop();
|
||||
|
||||
} catch (ReportedException e) {
|
||||
|
@ -68,33 +65,4 @@ public class TileEntityRenderHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private static class LightingWorld extends WrappedWorld {
|
||||
|
||||
private Matrix4f matrix;
|
||||
|
||||
public LightingWorld(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
void setWorld(World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
void setTransform(Matrix4f matrix) {
|
||||
this.matrix = matrix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightLevel(LightType p_226658_1_, BlockPos p_226658_2_) {
|
||||
return super.getLightLevel(p_226658_1_, transformPos(p_226658_2_));
|
||||
}
|
||||
|
||||
private BlockPos transformPos(BlockPos pos) {
|
||||
Vector4f vec = new Vector4f(pos.getX(), pos.getY(), pos.getZ(), 1);
|
||||
vec.transform(matrix);
|
||||
return new BlockPos(vec.getX(), vec.getY(), vec.getZ());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,22 +4,20 @@
|
|||
"textures": {
|
||||
"0": "create:block/axis",
|
||||
"1": "create:block/axis_top",
|
||||
"2": "create:block/andesite_casing_short",
|
||||
"3": "block/spruce_log",
|
||||
"particle": "create:block/axis"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"name": "Axis",
|
||||
"from": [6, 6, 11],
|
||||
"to": [10, 10, 16],
|
||||
"from": [6, 0, 6],
|
||||
"to": [10, 5, 10],
|
||||
"shade": false,
|
||||
"faces": {
|
||||
"east": {"uv": [6, 0, 10, 5], "rotation": 270, "texture": "#0"},
|
||||
"south": {"uv": [6, 6, 10, 10], "texture": "#1"},
|
||||
"west": {"uv": [6, 0, 10, 5], "rotation": 90, "texture": "#0"},
|
||||
"up": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"},
|
||||
"down": {"uv": [6, 0, 10, 5], "texture": "#0"}
|
||||
"north": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"},
|
||||
"east": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"},
|
||||
"south": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"},
|
||||
"west": {"uv": [6, 0, 10, 5], "rotation": 180, "texture": "#0"},
|
||||
"down": {"uv": [6, 6, 10, 10], "texture": "#1"}
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -28,5 +26,6 @@
|
|||
"name": "shaft_half",
|
||||
"origin": [8, 8, 8],
|
||||
"children": [0]
|
||||
}, 1, 2, 3, 4]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue