Merge branch 'mc1.15/dev' of https://github.com/Creators-of-Create/Create into mc1.15/dev

This commit is contained in:
simibubi 2021-03-14 21:12:04 +01:00
commit dac1cf0303
73 changed files with 558 additions and 406 deletions

View file

@ -7,6 +7,7 @@ import com.simibubi.create.content.contraptions.components.clock.CuckooClockTile
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterInstance;
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterRenderer;
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity;
import com.simibubi.create.content.contraptions.components.crank.HandCrankInstance;
import com.simibubi.create.content.contraptions.components.crank.HandCrankRenderer;
import com.simibubi.create.content.contraptions.components.crank.HandCrankTileEntity;
import com.simibubi.create.content.contraptions.components.crusher.CrushingWheelControllerTileEntity;
@ -119,9 +120,9 @@ public class AllTileEntities {
// Schematics
public static final TileEntityEntry<SchematicannonTileEntity> SCHEMATICANNON = Create.registrate()
.tileEntity("schematicannon", SchematicannonTileEntity::new)
.instance(() -> SchematicannonInstance::new)
.validBlocks(AllBlocks.SCHEMATICANNON)
.renderer(() -> SchematicannonRenderer::new)
.onRegister(SchematicannonInstance::register)
.register();
public static final TileEntityEntry<SchematicTableTileEntity> SCHEMATIC_TABLE = Create.registrate()
@ -132,44 +133,44 @@ public class AllTileEntities {
// Kinetics
public static final TileEntityEntry<SimpleKineticTileEntity> SIMPLE_KINETIC = Create.registrate()
.tileEntity("simple_kinetic", SimpleKineticTileEntity::new)
.instance(() -> SingleRotatingInstance::new)
.validBlocks(AllBlocks.SHAFT, AllBlocks.COGWHEEL, AllBlocks.LARGE_COGWHEEL)
.renderer(() -> KineticTileEntityRenderer::new)
.onRegister(SingleRotatingInstance::register)
.register();
public static final TileEntityEntry<CreativeMotorTileEntity> MOTOR = Create.registrate()
.tileEntity("motor", CreativeMotorTileEntity::new)
.instance(() -> HalfShaftInstance::new)
.validBlocks(AllBlocks.CREATIVE_MOTOR)
.renderer(() -> CreativeMotorRenderer::new)
.onRegister(HalfShaftInstance::register)
.register();
public static final TileEntityEntry<GearboxTileEntity> GEARBOX = Create.registrate()
.tileEntity("gearbox", GearboxTileEntity::new)
.instance(() -> GearboxInstance::new)
.validBlocks(AllBlocks.GEARBOX)
.renderer(() -> GearboxRenderer::new)
.onRegister(GearboxInstance::register)
.register();
public static final TileEntityEntry<EncasedShaftTileEntity> ENCASED_SHAFT = Create.registrate()
.tileEntity("encased_shaft", EncasedShaftTileEntity::new)
.instance(() -> ShaftInstance::new)
.validBlocks(AllBlocks.ANDESITE_ENCASED_SHAFT, AllBlocks.BRASS_ENCASED_SHAFT, AllBlocks.ENCASED_CHAIN_DRIVE)
.renderer(() -> EncasedShaftRenderer::new)
.onRegister(ShaftInstance::register)
.register();
public static final TileEntityEntry<AdjustablePulleyTileEntity> ADJUSTABLE_PULLEY = Create.registrate()
.tileEntity("adjustable_pulley", AdjustablePulleyTileEntity::new)
.instance(() -> ShaftInstance::new)
.validBlocks(AllBlocks.ADJUSTABLE_CHAIN_GEARSHIFT)
.renderer(() -> EncasedShaftRenderer::new)
.onRegister(ShaftInstance::register)
.register();
public static final TileEntityEntry<EncasedFanTileEntity> ENCASED_FAN = Create.registrate()
.tileEntity("encased_fan", EncasedFanTileEntity::new)
.instance(() -> FanInstance::new)
.validBlocks(AllBlocks.ENCASED_FAN)
.renderer(() -> EncasedFanRenderer::new)
.onRegister(FanInstance::register)
.register();
public static final TileEntityEntry<NozzleTileEntity> NOZZLE = Create.registrate()
@ -180,59 +181,59 @@ public class AllTileEntities {
public static final TileEntityEntry<ClutchTileEntity> CLUTCH = Create.registrate()
.tileEntity("clutch", ClutchTileEntity::new)
.instance(() -> SplitShaftInstance::new)
.validBlocks(AllBlocks.CLUTCH)
.renderer(() -> SplitShaftRenderer::new)
.onRegister(SplitShaftInstance::register)
.register();
public static final TileEntityEntry<GearshiftTileEntity> GEARSHIFT = Create.registrate()
.tileEntity("gearshift", GearshiftTileEntity::new)
.instance(() -> SplitShaftInstance::new)
.validBlocks(AllBlocks.GEARSHIFT)
.renderer(() -> SplitShaftRenderer::new)
.onRegister(SplitShaftInstance::register)
.register();
public static final TileEntityEntry<TurntableTileEntity> TURNTABLE = Create.registrate()
.tileEntity("turntable", TurntableTileEntity::new)
.instance(() -> SingleRotatingInstance::new)
.validBlocks(AllBlocks.TURNTABLE)
.renderer(() -> KineticTileEntityRenderer::new)
.onRegister(SingleRotatingInstance::register)
.register();
public static final TileEntityEntry<HandCrankTileEntity> HAND_CRANK = Create.registrate()
.tileEntity("hand_crank", HandCrankTileEntity::new)
.instance(() -> HandCrankInstance::new)
.validBlocks(AllBlocks.HAND_CRANK, AllBlocks.COPPER_VALVE_HANDLE)
.validBlocks(AllBlocks.DYED_VALVE_HANDLES)
.renderer(() -> HandCrankRenderer::new)
.onRegister(SingleRotatingInstance::register)
.register();
public static final TileEntityEntry<CuckooClockTileEntity> CUCKOO_CLOCK = Create.registrate()
.tileEntity("cuckoo_clock", CuckooClockTileEntity::new)
.instance(() -> HorizontalHalfShaftInstance::new)
.validBlocks(AllBlocks.CUCKOO_CLOCK, AllBlocks.MYSTERIOUS_CUCKOO_CLOCK)
.renderer(() -> CuckooClockRenderer::new)
.onRegister(HorizontalHalfShaftInstance::register)
.register();
public static final TileEntityEntry<GantryShaftTileEntity> GANTRY_SHAFT = Create.registrate()
.tileEntity("gantry_shaft", GantryShaftTileEntity::new)
.instance(() -> SingleRotatingInstance::new)
.validBlocks(AllBlocks.GANTRY_SHAFT)
.renderer(() -> KineticTileEntityRenderer::new)
.onRegister(SingleRotatingInstance::register)
.register();
public static final TileEntityEntry<GantryCarriageTileEntity> GANTRY_PINION = Create.registrate()
.tileEntity("gantry_pinion", GantryCarriageTileEntity::new)
.instance(() -> GantryCarriageInstance::new)
.validBlocks(AllBlocks.GANTRY_CARRIAGE)
.renderer(() -> GantryCarriageRenderer::new)
.onRegister(GantryCarriageInstance::register)
.register();
public static final TileEntityEntry<PumpTileEntity> MECHANICAL_PUMP = Create.registrate()
.tileEntity("mechanical_pump", PumpTileEntity::new)
.instance(() -> PumpCogInstance::new)
.validBlocks(AllBlocks.MECHANICAL_PUMP)
.renderer(() -> PumpRenderer::new)
.onRegister(PumpCogInstance::register)
.register();
public static final TileEntityEntry<SmartFluidPipeTileEntity> SMART_FLUID_PIPE = Create.registrate()
@ -259,9 +260,9 @@ public class AllTileEntities {
public static final TileEntityEntry<FluidValveTileEntity> FLUID_VALVE = Create.registrate()
.tileEntity("fluid_valve", FluidValveTileEntity::new)
.instance(() -> ShaftInstance::new)
.validBlocks(AllBlocks.FLUID_VALVE)
.renderer(() -> FluidValveRenderer::new)
.onRegister(ShaftInstance::register)
.register();
public static final TileEntityEntry<FluidTankTileEntity> FLUID_TANK = Create.registrate()
@ -278,9 +279,9 @@ public class AllTileEntities {
public static final TileEntityEntry<HosePulleyTileEntity> HOSE_PULLEY = Create.registrate()
.tileEntity("hose_pulley", HosePulleyTileEntity::new)
.instance(() -> ShaftInstance::new)
.validBlocks(AllBlocks.HOSE_PULLEY)
.renderer(() -> HosePulleyRenderer::new)
.onRegister(ShaftInstance::register)
.register();
public static final TileEntityEntry<SpoutTileEntity> SPOUT = Create.registrate()
@ -297,9 +298,9 @@ public class AllTileEntities {
public static final TileEntityEntry<BeltTileEntity> BELT = Create.registrate()
.tileEntity("belt", BeltTileEntity::new)
.instance(() -> BeltInstance::new)
.validBlocks(AllBlocks.BELT)
.renderer(() -> BeltRenderer::new)
.onRegister(BeltInstance::register)
.register();
public static final TileEntityEntry<ChuteTileEntity> CHUTE = Create.registrate()
@ -316,58 +317,58 @@ public class AllTileEntities {
public static final TileEntityEntry<BeltTunnelTileEntity> ANDESITE_TUNNEL = Create.registrate()
.tileEntity("andesite_tunnel", BeltTunnelTileEntity::new)
.instance(() -> BeltTunnelInstance::new)
.validBlocks(AllBlocks.ANDESITE_TUNNEL)
.renderer(() -> BeltTunnelRenderer::new)
.onRegister(BeltTunnelInstance::register)
.register();
public static final TileEntityEntry<BrassTunnelTileEntity> BRASS_TUNNEL = Create.registrate()
.tileEntity("brass_tunnel", BrassTunnelTileEntity::new)
.instance(() -> BeltTunnelInstance::new)
.validBlocks(AllBlocks.BRASS_TUNNEL)
.renderer(() -> BeltTunnelRenderer::new)
.onRegister(BeltTunnelInstance::register)
.register();
public static final TileEntityEntry<ArmTileEntity> MECHANICAL_ARM = Create.registrate()
.tileEntity("mechanical_arm", ArmTileEntity::new)
.instance(() -> ArmInstance::new)
.validBlocks(AllBlocks.MECHANICAL_ARM)
.renderer(() -> ArmRenderer::new)
.onRegister((type) -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> ArmInstance.register(type)))//ArmInstance line 142 -> Minecraft.getInstance().world causes ClientWorld to get loaded on the server
.register();
public static final TileEntityEntry<MechanicalPistonTileEntity> MECHANICAL_PISTON = Create.registrate()
.tileEntity("mechanical_piston", MechanicalPistonTileEntity::new)
.instance(() -> ShaftInstance::new)
.validBlocks(AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON)
.renderer(() -> MechanicalPistonRenderer::new)
.onRegister(ShaftInstance::register)
.register();
public static final TileEntityEntry<WindmillBearingTileEntity> WINDMILL_BEARING = Create.registrate()
.tileEntity("windmill_bearing", WindmillBearingTileEntity::new)
.instance(() -> BackHalfShaftInstance::new)
.validBlocks(AllBlocks.WINDMILL_BEARING)
.renderer(() -> BearingRenderer::new)
.onRegister(BackHalfShaftInstance::register)
.register();
public static final TileEntityEntry<MechanicalBearingTileEntity> MECHANICAL_BEARING = Create.registrate()
.tileEntity("mechanical_bearing", MechanicalBearingTileEntity::new)
.instance(() -> BackHalfShaftInstance::new)
.validBlocks(AllBlocks.MECHANICAL_BEARING)
.renderer(() -> BearingRenderer::new)
.onRegister(BackHalfShaftInstance::register)
.register();
public static final TileEntityEntry<ClockworkBearingTileEntity> CLOCKWORK_BEARING = Create.registrate()
.tileEntity("clockwork_bearing", ClockworkBearingTileEntity::new)
.instance(() -> BackHalfShaftInstance::new)
.validBlocks(AllBlocks.CLOCKWORK_BEARING)
.renderer(() -> BearingRenderer::new)
.onRegister(BackHalfShaftInstance::register)
.register();
public static final TileEntityEntry<PulleyTileEntity> ROPE_PULLEY = Create.registrate()
.tileEntity("rope_pulley", PulleyTileEntity::new)
.instance(() -> ShaftInstance::new)
.validBlocks(AllBlocks.ROPE_PULLEY)
.renderer(() -> PulleyRenderer::new)
.onRegister(ShaftInstance::register)
.register();
public static final TileEntityEntry<ChassisTileEntity> CHASSIS = Create.registrate()
@ -378,23 +379,23 @@ public class AllTileEntities {
public static final TileEntityEntry<StickerTileEntity> STICKER = Create.registrate()
.tileEntity("sticker", StickerTileEntity::new)
.instance(() -> StickerInstance::new)
.validBlocks(AllBlocks.STICKER)
.renderer(() -> StickerRenderer::new)
.onRegister(StickerInstance::register)
.register();
public static final TileEntityEntry<DrillTileEntity> DRILL = Create.registrate()
.tileEntity("drill", DrillTileEntity::new)
.instance(() -> DrillInstance::new)
.validBlocks(AllBlocks.MECHANICAL_DRILL)
.renderer(() -> DrillRenderer::new)
.onRegister(DrillInstance::register)
.register();
public static final TileEntityEntry<SawTileEntity> SAW = Create.registrate()
.tileEntity("saw", SawTileEntity::new)
.instance(() -> SawInstance::new)
.validBlocks(AllBlocks.MECHANICAL_SAW)
.renderer(() -> SawRenderer::new)
.onRegister(SawInstance::register)
.register();
public static final TileEntityEntry<HarvesterTileEntity> HARVESTER = Create.registrate()
@ -418,30 +419,30 @@ public class AllTileEntities {
public static final TileEntityEntry<FlywheelTileEntity> FLYWHEEL = Create.registrate()
.tileEntity("flywheel", FlywheelTileEntity::new)
.instance(() -> FlyWheelInstance::new)
.validBlocks(AllBlocks.FLYWHEEL)
.renderer(() -> FlywheelRenderer::new)
.onRegister(FlyWheelInstance::register)
.register();
public static final TileEntityEntry<FurnaceEngineTileEntity> FURNACE_ENGINE = Create.registrate()
.tileEntity("furnace_engine", FurnaceEngineTileEntity::new)
.instance(() -> EngineInstance::new)
.validBlocks(AllBlocks.FURNACE_ENGINE)
.renderer(() -> EngineRenderer::new)
.onRegister(EngineInstance::register)
.register();
public static final TileEntityEntry<MillstoneTileEntity> MILLSTONE = Create.registrate()
.tileEntity("millstone", MillstoneTileEntity::new)
.instance(() -> MillStoneCogInstance::new)
.validBlocks(AllBlocks.MILLSTONE)
.renderer(() -> MillstoneRenderer::new)
.onRegister(MillStoneCogInstance::register)
.register();
public static final TileEntityEntry<CrushingWheelTileEntity> CRUSHING_WHEEL = Create.registrate()
.tileEntity("crushing_wheel", CrushingWheelTileEntity::new)
.instance(() -> SingleRotatingInstance::new)
.validBlocks(AllBlocks.CRUSHING_WHEEL)
.renderer(() -> KineticTileEntityRenderer::new)
.onRegister(SingleRotatingInstance::register)
.register();
public static final TileEntityEntry<CrushingWheelControllerTileEntity> CRUSHING_WHEEL_CONTROLLER =
@ -453,30 +454,30 @@ public class AllTileEntities {
public static final TileEntityEntry<WaterWheelTileEntity> WATER_WHEEL = Create.registrate()
.tileEntity("water_wheel", WaterWheelTileEntity::new)
.instance(() -> SingleRotatingInstance::new)
.validBlocks(AllBlocks.WATER_WHEEL)
.renderer(() -> KineticTileEntityRenderer::new)
.onRegister(SingleRotatingInstance::register)
.register();
public static final TileEntityEntry<MechanicalPressTileEntity> MECHANICAL_PRESS = Create.registrate()
.tileEntity("mechanical_press", MechanicalPressTileEntity::new)
.instance(() -> PressInstance::new)
.validBlocks(AllBlocks.MECHANICAL_PRESS)
.renderer(() -> MechanicalPressRenderer::new)
.onRegister(PressInstance::register)
.register();
public static final TileEntityEntry<MechanicalMixerTileEntity> MECHANICAL_MIXER = Create.registrate()
.tileEntity("mechanical_mixer", MechanicalMixerTileEntity::new)
.instance(() -> MixerInstance::new)
.validBlocks(AllBlocks.MECHANICAL_MIXER)
.renderer(() -> MechanicalMixerRenderer::new)
.onRegister(MixerInstance::register)
.register();
public static final TileEntityEntry<DeployerTileEntity> DEPLOYER = Create.registrate()
.tileEntity("deployer", DeployerTileEntity::new)
.instance(() -> ShaftInstance::new)
.validBlocks(AllBlocks.DEPLOYER)
.renderer(() -> DeployerRenderer::new)
.onRegister(ShaftInstance::register)
.register();
public static final TileEntityEntry<BasinTileEntity> BASIN = Create.registrate()
@ -493,41 +494,42 @@ public class AllTileEntities {
public static final TileEntityEntry<MechanicalCrafterTileEntity> MECHANICAL_CRAFTER = Create.registrate()
.tileEntity("mechanical_crafter", MechanicalCrafterTileEntity::new)
.instance(() -> MechanicalCrafterInstance::new)
.validBlocks(AllBlocks.MECHANICAL_CRAFTER)
.renderer(() -> MechanicalCrafterRenderer::new)
.onRegister(MechanicalCrafterInstance::register)
.register();
public static final TileEntityEntry<SequencedGearshiftTileEntity> SEQUENCED_GEARSHIFT = Create.registrate()
.tileEntity("sequenced_gearshift", SequencedGearshiftTileEntity::new)
.instance(() -> SplitShaftInstance::new)
.validBlocks(AllBlocks.SEQUENCED_GEARSHIFT)
.renderer(() -> SplitShaftRenderer::new)
.onRegister(SplitShaftInstance::register)
.register();
public static final TileEntityEntry<SpeedControllerTileEntity> ROTATION_SPEED_CONTROLLER = Create.registrate()
.tileEntity("rotation_speed_controller", SpeedControllerTileEntity::new)
.instance(() -> ShaftInstance::new)
.validBlocks(AllBlocks.ROTATION_SPEED_CONTROLLER)
.renderer(() -> SpeedControllerRenderer::new)
.onRegister(ShaftInstance::register)
.register();
public static final TileEntityEntry<SpeedGaugeTileEntity> SPEEDOMETER = Create.registrate()
.tileEntity("speedometer", SpeedGaugeTileEntity::new)
.instance(() -> ShaftInstance::new)
.validBlocks(AllBlocks.SPEEDOMETER)
.renderer(() -> GaugeRenderer::speed)
.onRegister(ShaftInstance::register)
.register();
public static final TileEntityEntry<StressGaugeTileEntity> STRESSOMETER = Create.registrate()
.tileEntity("stressometer", StressGaugeTileEntity::new)
.instance(() -> ShaftInstance::new)
.validBlocks(AllBlocks.STRESSOMETER)
.renderer(() -> GaugeRenderer::stress)
.onRegister(ShaftInstance::register)
.register();
public static final TileEntityEntry<AnalogLeverTileEntity> ANALOG_LEVER = Create.registrate()
.tileEntity("analog_lever", AnalogLeverTileEntity::new)
.instance(() -> AnalogLeverInstance::new)
.validBlocks(AllBlocks.ANALOG_LEVER)
.renderer(() -> AnalogLeverRenderer::new)
.register();
@ -577,10 +579,10 @@ public class AllTileEntities {
public static final TileEntityEntry<FunnelTileEntity> FUNNEL = Create.registrate()
.tileEntity("funnel", FunnelTileEntity::new)
.instance(() -> FunnelInstance::new)
.validBlocks(AllBlocks.BRASS_FUNNEL, AllBlocks.BRASS_BELT_FUNNEL, AllBlocks.ANDESITE_FUNNEL,
AllBlocks.ANDESITE_BELT_FUNNEL)
.renderer(() -> FunnelRenderer::new)
.onRegister(FunnelInstance::register)
.register();
public static final TileEntityEntry<ContentObserverTileEntity> CONTENT_OBSERVER = Create.registrate()

View file

@ -10,11 +10,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class BackHalfShaftInstance extends HalfShaftInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, BackHalfShaftInstance::new));
}
public BackHalfShaftInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}

View file

@ -12,11 +12,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class HalfShaftInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, HalfShaftInstance::new));
}
public HalfShaftInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}

View file

@ -10,10 +10,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class HorizontalHalfShaftInstance extends HalfShaftInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, HorizontalHalfShaftInstance::new));
}
public HorizontalHalfShaftInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);

View file

@ -80,9 +80,6 @@ public abstract class KineticTileEntity extends SmartTileEntity
}
super.initialize();
if (world != null && world.isRemote)
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> CreateClient.kineticRenderer.add(this));
}
@Override
@ -551,11 +548,6 @@ public abstract class KineticTileEntity extends SmartTileEntity
}
}
@Override
public void onChunkLightUpdate() {
CreateClient.kineticRenderer.onLightUpdate(this);
}
protected AxisAlignedBB cachedBoundingBox;
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {

View file

@ -10,10 +10,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class ShaftlessCogInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, ShaftlessCogInstance::new));
}
public ShaftlessCogInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);

View file

@ -14,10 +14,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class SingleRotatingInstance extends KineticTileInstance<KineticTileEntity> {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, SingleRotatingInstance::new));
}
protected InstanceKey<RotatingData> rotatingModelKey;

View file

@ -17,9 +17,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class DrillInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, DrillInstance::new)); }
public DrillInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);

View file

@ -6,7 +6,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompoundNBT;

View file

@ -18,10 +18,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class MechanicalCrafterInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, MechanicalCrafterInstance::new));
}
public MechanicalCrafterInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);

View file

@ -0,0 +1,78 @@
package com.simibubi.create.content.contraptions.components.crank;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
import com.simibubi.create.content.logistics.block.redstone.AnalogLeverInstance;
import com.simibubi.create.content.logistics.block.redstone.AnalogLeverTileEntity;
import com.simibubi.create.foundation.render.backend.RenderMaterials;
import com.simibubi.create.foundation.render.backend.instancing.*;
import com.simibubi.create.foundation.render.backend.instancing.impl.ModelData;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.MatrixStacker;
import net.minecraft.block.Block;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class HandCrankInstance extends SingleRotatingInstance implements ITickableInstance {
private InstanceKey<ModelData> crank;
private Direction facing;
public HandCrankInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);
}
@Override
protected void init() {
super.init();
Block block = lastState.getBlock();
AllBlockPartials renderedHandle = null;
if (block instanceof HandCrankBlock)
renderedHandle = ((HandCrankBlock) block).getRenderedHandle();
if (renderedHandle == null)
return;
facing = lastState.get(BlockStateProperties.FACING);
InstancedModel<ModelData> model = renderedHandle.renderOnDirectionalSouthModel(modelManager, lastState, facing.getOpposite());
crank = model.createInstance();
updateLight();
}
@Override
public void tick() {
if (crank == null) return;
HandCrankTileEntity crankTile = (HandCrankTileEntity) tile;
Direction.Axis axis = facing.getAxis();
float angle = (crankTile.independentAngle + AnimationTickHolder.getPartialTicks() * crankTile.chasingVelocity) / 360;
MatrixStack ms = new MatrixStack();
MatrixStacker.of(ms)
.translate(getFloatingPos())
.centre()
.rotate(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis), angle)
.unCentre();
crank.getInstance().setTransformNoCopy(ms);
}
@Override
public void remove() {
super.remove();
if (crank != null) crank.delete();
}
@Override
public void updateLight() {
super.updateLight();
if (crank != null) relight(pos, crank.getInstance());
}
}

View file

@ -8,6 +8,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer;
@ -26,6 +27,8 @@ public class HandCrankRenderer extends KineticTileEntityRenderer {
int light, int overlay) {
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
if (FastRenderDispatcher.available(te.getWorld())) return;
BlockState state = te.getBlockState();
Block block = state.getBlock();
AllBlockPartials renderedHandle = null;

View file

@ -20,10 +20,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class FanInstance extends KineticTileInstance<EncasedFanTileEntity> {
public static void register(TileEntityType<? extends EncasedFanTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, FanInstance::new));
}
protected InstanceKey<RotatingData> shaft;
protected InstanceKey<RotatingData> fan;

View file

@ -30,10 +30,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> implements ITickableInstance {
public static void register(TileEntityType<? extends FlywheelTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, FlyWheelInstance::new));
}
protected Direction facing;
protected boolean connectedLeft;

View file

@ -20,10 +20,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class EngineInstance extends TileEntityInstance<EngineTileEntity> {
public static void register(TileEntityType<? extends EngineTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, EngineInstance::new));
}
protected InstanceKey<ModelData> frame;

View file

@ -104,16 +104,4 @@ public class EngineTileEntity extends SmartTileEntity implements IInstanceRender
poweredWheel.setRotation(appliedSpeed, appliedCapacity);
}
@Override
public void onChunkLightUpdate() {
CreateClient.kineticRenderer.onLightUpdate(this);
}
@Override
public void initialize() {
super.initialize();
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> CreateClient.kineticRenderer.add(this));
}
}

View file

@ -13,9 +13,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class MillStoneCogInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, MillStoneCogInstance::new)); }
public MillStoneCogInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);

View file

@ -21,10 +21,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class MixerInstance extends ShaftlessCogInstance implements ITickableInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, MixerInstance::new));
}
private InstanceKey<RotatingData> mixerHead;
private InstanceKey<ModelData> mixerPole;

View file

@ -18,10 +18,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class PressInstance extends ShaftInstance implements ITickableInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, PressInstance::new));
}
private InstanceKey<ModelData> pressHead;

View file

@ -17,10 +17,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class SawInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, SawInstance::new));
}
public SawInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);

View file

@ -16,10 +16,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class StickerInstance extends TileEntityInstance<StickerTileEntity> implements ITickableInstance {
public static void register(TileEntityType<? extends StickerTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, StickerInstance::new));
}
float lastOffset = Float.NaN;

View file

@ -10,8 +10,8 @@ import com.simibubi.create.content.contraptions.components.structureMovement.glu
import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
@ -43,7 +43,6 @@ public class StickerTileEntity extends SmartTileEntity implements IInstanceRende
if (!world.isRemote)
return;
piston.startWithValue(isBlockStateExtended() ? 1 : 0);
CreateClient.kineticRenderer.add(this);
}
public boolean isBlockStateExtended() {
@ -94,8 +93,4 @@ public class StickerTileEntity extends SmartTileEntity implements IInstanceRende
0.35F, attach ? 0.75F : 0.2f);
}
@Override
public void onChunkLightUpdate() {
CreateClient.kineticRenderer.onLightUpdate(this);
}
}

View file

@ -23,10 +23,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class GantryCarriageInstance extends ShaftInstance implements ITickableInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, GantryCarriageInstance::new));
}
private InstanceKey<ModelData> gantryCogs;

View file

@ -10,7 +10,7 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.BlockFace;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.client.Minecraft;

View file

@ -13,10 +13,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class PumpCogInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, PumpCogInstance::new));
}
public PumpCogInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
super(modelManager, tile);

View file

@ -19,8 +19,8 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.BlockFace;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.Pair;
import net.minecraft.block.BlockState;

View file

@ -6,7 +6,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.foundation.fluid.SmartFluidTank;
import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
import net.minecraft.nbt.CompoundNBT;

View file

@ -6,8 +6,8 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.fluids.pipes.StraightPipeTileEntity.StraightPipeFluidTransportBehaviour;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT;

View file

@ -7,7 +7,7 @@ import com.simibubi.create.foundation.fluid.FluidRenderer;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;

View file

@ -30,8 +30,8 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.IntAttached;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.NBTHelper;
import com.simibubi.create.foundation.utility.VecHelper;

View file

@ -10,8 +10,8 @@ import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;

View file

@ -26,10 +26,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
public static void register(TileEntityType<? extends BeltTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, BeltInstance::new));
}
private boolean upward;
private boolean diagonal;

View file

@ -23,6 +23,7 @@ import com.simibubi.create.content.contraptions.relays.belt.transport.ItemHandle
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
import com.simibubi.create.content.logistics.block.belts.tunnel.BrassTunnelTileEntity;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.render.backend.light.ILightListener;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour;
@ -56,7 +57,7 @@ import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
public class BeltTileEntity extends KineticTileEntity {
public class BeltTileEntity extends KineticTileEntity implements ILightListener {
public Map<Entity, TransportedEntityInfo> passengers;
public Optional<DyeColor> color;
@ -515,7 +516,6 @@ public class BeltTileEntity extends KineticTileEntity {
@Override
public void onChunkLightUpdate() {
super.onChunkLightUpdate();
updateLight();
}

View file

@ -133,11 +133,12 @@ public class BeltMovementHandler {
movement = movement.add(0, -Math.abs(axis.getCoordinate(movement.x, movement.y, movement.z)), 0);
Vec3d centering = new Vec3d(centeringDirection).scale(diffCenter * Math.min(Math.abs(movementSpeed), .1f) * 4);
movement = movement.add(centering);
float step = entityIn.stepHeight;
if (!isPlayer)
if (!isPlayer) {
movement = movement.add(centering);
entityIn.stepHeight = 1;
}
// Entity Collisions
if (Math.abs(movementSpeed) < .5f) {

View file

@ -12,11 +12,6 @@ import net.minecraftforge.fml.DistExecutor;
public class ShaftInstance extends SingleRotatingInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, ShaftInstance::new));
}
public ShaftInstance(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
super(dispatcher, tile);
}

View file

@ -19,10 +19,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class SplitShaftInstance extends KineticTileInstance<SplitShaftTileEntity> {
public static void register(TileEntityType<? extends SplitShaftTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, SplitShaftInstance::new));
}
protected ArrayList<InstanceKey<RotatingData>> keys;

View file

@ -21,10 +21,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
public static void register(TileEntityType<? extends GearboxTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, GearboxInstance::new));
}
protected EnumMap<Direction, InstanceKey<RotatingData>> keys;
protected Direction sourceFacing;

View file

@ -18,10 +18,7 @@ import java.util.EnumMap;
import java.util.Map;
public class BeltTunnelInstance extends TileEntityInstance<BeltTunnelTileEntity> implements ITickableInstance {
public static void register(TileEntityType<? extends BeltTunnelTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, BeltTunnelInstance::new));
}
private Map<Direction, ArrayList<InstanceKey<FlapData>>> tunnelFlaps;

View file

@ -154,8 +154,6 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe
public void initialize() {
super.initialize();
updateTunnelConnections();
if (world != null && world.isRemote)
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> CreateClient.kineticRenderer.add(this));
}
@Override
@ -198,9 +196,4 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements IInstanceRe
}
return this.cap.cast();
}
@Override
public void onChunkLightUpdate() {
CreateClient.kineticRenderer.onLightUpdate(this);
}
}

View file

@ -14,10 +14,6 @@ import net.minecraftforge.fml.DistExecutor;
import java.util.ArrayList;
public class FunnelInstance extends TileEntityInstance<FunnelTileEntity> implements ITickableInstance {
public static void register(TileEntityType<? extends FunnelTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, FunnelInstance::new));
}
private ArrayList<InstanceKey<FlapData>> flaps;

View file

@ -386,16 +386,4 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn
TooltipHelper.addHint(tooltip, "hint.horizontal_funnel");
return true;
}
@Override
public void initialize() {
super.initialize();
if (world != null && world.isRemote)
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> CreateClient.kineticRenderer.add(this));
}
@Override
public void onChunkLightUpdate() {
CreateClient.kineticRenderer.onLightUpdate(this);
}
}

View file

@ -29,10 +29,7 @@ import java.util.ArrayList;
import java.util.stream.Stream;
public class ArmInstance extends SingleRotatingInstance implements ITickableInstance {
public static void register(TileEntityType<? extends KineticTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, ArmInstance::new));
}
private InstanceKey<ModelData> base;
private InstanceKey<ModelData> lowerBody;
private InstanceKey<ModelData> upperBody;
@ -67,6 +64,7 @@ public class ArmInstance extends SingleRotatingInstance implements ITickableInst
clawGrips = Lists.newArrayList(clawGrip1, clawGrip2);
models = Lists.newArrayList(base, lowerBody, upperBody, head, claw, clawGrip1, clawGrip2);
firstTick = true;
tick();
updateLight();
}

View file

@ -77,12 +77,16 @@ public class ArmTileEntity extends KineticTileEntity {
interactionPointTag = new ListNBT();
heldItem = ItemStack.EMPTY;
phase = Phase.SEARCH_INPUTS;
baseAngle = new InterpolatedAngle();
lowerArmAngle = new InterpolatedAngle();
upperArmAngle = new InterpolatedAngle();
headAngle = new InterpolatedAngle();
clawAngle = new InterpolatedAngle();
previousTarget = ArmAngleTarget.NO_TARGET;
baseAngle = new InterpolatedAngle();
baseAngle.set(previousTarget.baseAngle);
lowerArmAngle = new InterpolatedAngle();
lowerArmAngle.set(previousTarget.lowerArmAngle);
upperArmAngle = new InterpolatedAngle();
upperArmAngle.set(previousTarget.upperArmAngle);
headAngle = new InterpolatedAngle();
headAngle.set(previousTarget.headAngle);
clawAngle = new InterpolatedAngle();
previousBaseAngle = previousTarget.baseAngle;
updateInteractionPoints = true;
redstoneLocked = false;

View file

@ -0,0 +1,93 @@
package com.simibubi.create.content.logistics.block.redstone;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.flywheel.FlyWheelInstance;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
import com.simibubi.create.foundation.render.backend.RenderMaterials;
import com.simibubi.create.foundation.render.backend.instancing.*;
import com.simibubi.create.foundation.render.backend.instancing.impl.ModelData;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.MatrixStacker;
import net.minecraft.state.properties.AttachFace;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class AnalogLeverInstance extends TileEntityInstance<AnalogLeverTileEntity> implements ITickableInstance {
protected InstanceKey<ModelData> handle;
protected InstanceKey<ModelData> indicator;
private float rX;
private float rY;
public AnalogLeverInstance(InstancedTileRenderer<?> modelManager, AnalogLeverTileEntity tile) {
super(modelManager, tile);
}
@Override
protected void init() {
RenderMaterial<?, InstancedModel<ModelData>> mat = modelManager.getMaterial(RenderMaterials.MODELS);
handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE, lastState).createInstance();
indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR, lastState).createInstance();
AttachFace face = lastState.get(AnalogLeverBlock.FACE);
rX = face == AttachFace.FLOOR ? 0 : face == AttachFace.WALL ? 90 : 180;
rY = AngleHelper.horizontalAngle(lastState.get(AnalogLeverBlock.HORIZONTAL_FACING));
setupModel();
updateLight();
}
@Override
public void tick() {
if (!tile.clientState.settled())
setupModel();
}
protected void setupModel() {
MatrixStack ms = new MatrixStack();
MatrixStacker msr = MatrixStacker.of(ms);
msr.translate(getFloatingPos());
transform(msr);
float state = tile.clientState.get(AnimationTickHolder.getPartialTicks());
int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f);
indicator.getInstance()
.setTransform(ms)
.setColor(color);
float angle = (float) ((state / 15) * 90 / 180 * Math.PI);
msr.translate(1 / 2f, 1 / 16f, 1 / 2f)
.rotate(Direction.EAST, angle)
.translate(-1 / 2f, -1 / 16f, -1 / 2f);
handle.getInstance()
.setTransformNoCopy(ms);
}
@Override
public void remove() {
handle.delete();
indicator.delete();
}
@Override
public void updateLight() {
relight(pos, handle.getInstance(), indicator.getInstance());
}
private void transform(MatrixStacker msr) {
msr.centre()
.rotate(Direction.UP, (float) (rY / 180 * Math.PI))
.rotate(Direction.EAST, (float) (rX / 180 * Math.PI))
.unCentre();
}
}

View file

@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.ColorHelper;
@ -25,6 +26,9 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
@Override
protected void renderSafe(AnalogLeverTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
int light, int overlay) {
if (FastRenderDispatcher.available(te.getWorld())) return;
BlockState leverState = te.getBlockState();
int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), leverState, te.getPos());
float state = te.clientState.get(partialTicks);

View file

@ -2,8 +2,10 @@ package com.simibubi.create.content.logistics.block.redstone;
import java.util.List;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.foundation.gui.widgets.InterpolatedChasingValue;
import com.simibubi.create.foundation.render.backend.instancing.IInstanceRendered;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.utility.Lang;
@ -12,7 +14,7 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.math.MathHelper;
public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggleInformation {
public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggleInformation, IInstanceRendered {
int state = 0;
int lastChange;
@ -49,6 +51,12 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl
clientState.tick();
}
@Override
public void initialize() {
super.initialize();
}
private void updateOutput() {
AnalogLeverBlock.updateNeighbors(getBlockState(), world, pos);
}

View file

@ -13,8 +13,8 @@ import com.simibubi.create.foundation.gui.widgets.IconButton;
import com.simibubi.create.foundation.gui.widgets.ScrollInput;
import com.simibubi.create.foundation.networking.AllPackets;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;

View file

@ -22,10 +22,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class SchematicannonInstance extends TileEntityInstance<SchematicannonTileEntity> implements ITickableInstance {
public static void register(TileEntityType<? extends SchematicannonTileEntity> type) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () ->
InstancedTileRenderRegistry.instance.register(type, SchematicannonInstance::new));
}
private InstanceKey<ModelData> connector;
private InstanceKey<ModelData> pipe;

View file

@ -937,18 +937,6 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
findInventories();
}
@Override
public void initialize() {
super.initialize();
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> CreateClient.kineticRenderer.add(this));
}
@Override
public void onChunkLightUpdate() {
CreateClient.kineticRenderer.onLightUpdate(this);
}
@Override
public boolean shouldRenderAsTE() {
return true;

View file

@ -19,10 +19,7 @@ import com.simibubi.create.foundation.block.connected.CTModel;
import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour;
import com.simibubi.create.foundation.block.render.CustomRenderedItemModel;
import com.tterrag.registrate.AbstractRegistrate;
import com.tterrag.registrate.builders.BlockBuilder;
import com.tterrag.registrate.builders.Builder;
import com.tterrag.registrate.builders.FluidBuilder;
import com.tterrag.registrate.builders.ItemBuilder;
import com.tterrag.registrate.builders.*;
import com.tterrag.registrate.util.NonNullLazyValue;
import com.tterrag.registrate.util.entry.RegistryEntry;
import com.tterrag.registrate.util.nullness.NonNullBiFunction;
@ -38,6 +35,8 @@ import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.IItemProvider;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@ -109,6 +108,17 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
.collect(Collectors.toList());
}
public <T extends TileEntity> CreateTileEntityBuilder<T, CreateRegistrate> tileEntity(String name, NonNullFunction<TileEntityType<T>, ? extends T> factory) {
return this.tileEntity(this.self(), name, (NonNullFunction)factory);
}
@Override
public <T extends TileEntity, P> CreateTileEntityBuilder<T, P> tileEntity(P parent, String name, NonNullFunction<TileEntityType<T>, ? extends T> factory) {
return (CreateTileEntityBuilder<T, P>) this.entry(name, (callback) -> {
return CreateTileEntityBuilder.create(this, parent, name, callback, factory);
});
}
/* Palettes */
public <T extends Block> BlockBuilder<T, CreateRegistrate> baseBlock(String name,

View file

@ -0,0 +1,57 @@
package com.simibubi.create.foundation.data;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.logistics.block.redstone.AnalogLeverInstance;
import com.simibubi.create.foundation.render.backend.instancing.IRendererFactory;
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderRegistry;
import com.tterrag.registrate.AbstractRegistrate;
import com.tterrag.registrate.builders.BuilderCallback;
import com.tterrag.registrate.builders.TileEntityBuilder;
import com.tterrag.registrate.util.OneTimeEventReceiver;
import com.tterrag.registrate.util.nullness.NonNullFunction;
import com.tterrag.registrate.util.nullness.NonNullSupplier;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import javax.annotation.Nullable;
import java.util.function.Function;
public class CreateTileEntityBuilder<T extends TileEntity, P> extends TileEntityBuilder<T, P> {
@Nullable
private NonNullSupplier<IRendererFactory<? super T>> instanceFactory;
public static <T extends TileEntity, P> TileEntityBuilder<T, P> create(AbstractRegistrate<?> owner, P parent, String name, BuilderCallback callback, NonNullFunction<TileEntityType<T>, ? extends T> factory) {
return new CreateTileEntityBuilder<>(owner, parent, name, callback, factory);
}
protected CreateTileEntityBuilder(AbstractRegistrate<?> owner, P parent, String name, BuilderCallback callback, NonNullFunction<TileEntityType<T>, ? extends T> factory) {
super(owner, parent, name, callback, factory);
}
public CreateTileEntityBuilder<T, P> instance(NonNullSupplier<IRendererFactory<? super T>> instanceFactory) {
if (this.instanceFactory == null) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> this::registerInstance);
}
this.instanceFactory = instanceFactory;
return this;
}
protected void registerInstance() {
OneTimeEventReceiver.addModListener(FMLClientSetupEvent.class, ($) -> {
NonNullSupplier<IRendererFactory<? super T>> instanceFactory = this.instanceFactory;
if (instanceFactory != null) {
InstancedTileRenderRegistry.instance.register(getEntry(), instanceFactory.get());
}
});
}
}

View file

@ -11,7 +11,7 @@ import org.lwjgl.glfw.GLFW;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import net.minecraft.client.MainWindow;
import net.minecraft.client.Minecraft;

View file

@ -8,7 +8,7 @@ import java.util.Optional;
import javax.annotation.Nullable;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;

View file

@ -6,6 +6,7 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import com.simibubi.create.CreateClient;
@ -18,7 +19,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
@Mixin(World.class)
public class OnRemoveTileMixin {
public class AddRemoveTileMixin {
@Shadow @Final public boolean isRemote;
@ -31,4 +32,9 @@ public class OnRemoveTileMixin {
private void onRemoveTile(BlockPos pos, CallbackInfo ci, TileEntity te) {
if (isRemote) CreateClient.kineticRenderer.remove(te);
}
@Inject(at = @At("TAIL"), method = "addTileEntity")
private void onAddTile(TileEntity te, CallbackInfoReturnable<Boolean> cir) {
if (isRemote) CreateClient.kineticRenderer.queueAdd(te);
}
}

View file

@ -2,6 +2,7 @@ package com.simibubi.create.foundation.mixin;
import java.util.Map;
import com.simibubi.create.CreateClient;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -42,10 +43,12 @@ public abstract class LightUpdateMixin extends AbstractChunkProvider {
.entrySet()
.stream()
.filter(entry -> SectionPos.toChunk(entry.getKey().getY()) == sectionY)
.map(Map.Entry::getValue)
.filter(tile -> tile instanceof ILightListener)
.map(tile -> (ILightListener) tile)
.forEach(ILightListener::onChunkLightUpdate);
.map(Map.Entry::getValue).forEach(tile -> {
CreateClient.kineticRenderer.onLightUpdate(tile);
if (tile instanceof ILightListener)
((ILightListener) tile).onChunkLightUpdate();
});
}
ContraptionRenderDispatcher.notifyLightUpdate((ILightReader) thi.getWorld(), type, pos);

View file

@ -4,7 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SoundHandler;

View file

@ -26,7 +26,7 @@ import com.simibubi.create.foundation.ponder.elements.WorldSectionElement;
import com.simibubi.create.foundation.ponder.instructions.HideAllInstruction;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.MatrixStacker;
import com.simibubi.create.foundation.utility.Pair;
import com.simibubi.create.foundation.utility.VecHelper;

View file

@ -7,10 +7,9 @@ import com.simibubi.create.foundation.gui.AbstractSimiScreen;
import com.simibubi.create.foundation.gui.ScreenOpener;
import com.simibubi.create.foundation.ponder.content.PonderIndexScreen;
import com.simibubi.create.foundation.ponder.content.PonderTagScreen;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;

View file

@ -27,8 +27,8 @@ import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Iterate;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.Pair;
import com.simibubi.create.foundation.utility.Pointing;

View file

@ -3,7 +3,7 @@ package com.simibubi.create.foundation.ponder.elements;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.ponder.PonderScene;
import com.simibubi.create.foundation.ponder.PonderUI;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
public abstract class AnimatedOverlayElement extends PonderOverlayElement {

View file

@ -2,7 +2,7 @@ package com.simibubi.create.foundation.ponder.elements;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.foundation.ponder.PonderWorld;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.MatrixStacker;
import net.minecraft.client.renderer.IRenderTypeBuffer;

View file

@ -3,7 +3,7 @@ package com.simibubi.create.foundation.ponder.instructions;
import com.simibubi.create.foundation.ponder.PonderInstruction;
import com.simibubi.create.foundation.ponder.PonderScene;
import com.simibubi.create.foundation.ponder.PonderScene.SceneTransform;
import com.simibubi.create.foundation.utility.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
public class RotateSceneInstruction extends PonderInstruction {

View file

@ -8,7 +8,7 @@ import com.simibubi.create.foundation.gui.IScreenRenderable;
import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget;
import com.simibubi.create.foundation.ponder.PonderUI;
import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;

View file

@ -1,8 +1,6 @@
package com.simibubi.create.foundation.render.backend.instancing;
import com.simibubi.create.foundation.render.backend.light.ILightListener;
public interface IInstanceRendered extends ILightListener {
public interface IInstanceRendered {
default boolean shouldRenderAsTE() {
return false;
}

View file

@ -19,6 +19,8 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
public abstract class InstancedTileRenderer<P extends BasicProgram> {
protected ArrayList<TileEntity> queuedAdditions = new ArrayList<>(64);
protected Map<TileEntity, TileEntityInstance<?>> instances = new HashMap<>();
protected Map<TileEntity, ITickableInstance> tickableInstances = new HashMap<>();
@ -44,6 +46,8 @@ public abstract class InstancedTileRenderer<P extends BasicProgram> {
}
public void beginFrame(double cameraX, double cameraY, double cameraZ) {
queuedAdditions.forEach(this::add);
queuedAdditions.clear();
tickableInstances.values().forEach(ITickableInstance::tick);
}
@ -112,6 +116,12 @@ public abstract class InstancedTileRenderer<P extends BasicProgram> {
}
}
public <T extends TileEntity> void queueAdd(T tile) {
if (!Backend.canUseInstancing()) return;
queuedAdditions.add(tile);
}
public <T extends TileEntity> void update(T tile) {
if (!Backend.canUseInstancing()) return;

View file

@ -1,8 +1,10 @@
package com.simibubi.create.foundation.render.backend.instancing;
import com.simibubi.create.foundation.render.backend.instancing.impl.ModelData;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
public abstract class TileEntityInstance<T extends TileEntity> {
@ -57,4 +59,14 @@ public abstract class TileEntityInstance<T extends TileEntity> {
public BlockPos getFloatingPos() {
return pos.subtract(modelManager.getOriginCoordinate());
}
protected void relight(BlockPos pos, ModelData... models) {
relight(world.getLightLevel(LightType.BLOCK, pos), world.getLightLevel(LightType.SKY, pos), models);
}
protected void relight(int block, int sky, ModelData... models) {
for (ModelData model : models) {
model.setBlockLight(block).setSkyLight(sky);
}
}
}

View file

@ -9,8 +9,8 @@ import com.simibubi.create.foundation.fluid.SmartFluidTank;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType;
import com.simibubi.create.foundation.utility.LerpedFloat;
import com.simibubi.create.foundation.utility.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
import com.simibubi.create.foundation.utility.NBTHelper;
import net.minecraft.nbt.CompoundNBT;

View file

@ -7,7 +7,7 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform.Sided;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour.StepContext;
import com.simibubi.create.foundation.utility.PhysicalFloat;
import com.simibubi.create.foundation.utility.animation.PhysicalFloat;
import net.minecraft.client.Minecraft;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.BlockPos;
@ -24,7 +24,7 @@ public class ScrollValueHandler {
private static float lastPassiveScroll = 0.0f;
private static float passiveScroll = 0.0f;
private static float passiveScrollDirection = 1f;
private static final PhysicalFloat wrenchCog = PhysicalFloat.create().withDrag(0.7);
private static final PhysicalFloat wrenchCog = PhysicalFloat.create().withDrag(0.3);
@OnlyIn(Dist.CLIENT)
public static boolean onScroll(double delta) {
@ -43,8 +43,8 @@ public class ScrollValueHandler {
if (!mc.player.isAllowEdit())
return false;
passiveScrollDirection = (float) delta;
wrenchCog.bump(3, delta * 10);
passiveScrollDirection = (float) -delta;
wrenchCog.bump(3, -delta * 10);
if (scrolling.needsWrench && !AllItems.WRENCH.isIn(mc.player.getHeldItemMainhand()))
return false;

View file

@ -1,147 +0,0 @@
package com.simibubi.create.foundation.utility;
import net.minecraft.util.math.MathHelper;
import java.util.ArrayList;
public class PhysicalFloat {
float previousValue;
float value;
float speed;
private final ArrayList<Force> forces = new ArrayList<>();
public static PhysicalFloat create() {
return new PhysicalFloat();
}
public PhysicalFloat startAt(double value) {
previousValue = this.value = (float) value;
return this;
}
public PhysicalFloat withDrag(double drag) {
return addForce(new DragForce((float) drag));
}
public PhysicalFloat zeroing(double g) {
return addForce(new ZeroingForce((float) g));
}
public void tick() {
previousValue = value;
for (Force force : forces)
speed = force.apply(speed, value);
forces.removeIf(Force::finished);
value += speed;
}
public PhysicalFloat addForce(Force f) {
forces.add(f);
return this;
}
public PhysicalFloat bump(double force) {
return addForce(new Impulse((float) force));
}
public PhysicalFloat bump(int time, double force) {
return addForce(new ForceOverTime(time, (float) force));
}
public float getValue() {
return getValue(1);
}
public float getValue(float partialTicks) {
return MathHelper.lerp(partialTicks, previousValue, value);
}
public interface Force {
float apply(float speed, float value);
boolean finished();
}
public static class DragForce implements Force {
final float dragFactor;
public DragForce(float dragFactor) {
this.dragFactor = dragFactor;
}
@Override
public float apply(float speed, float value) {
return speed * dragFactor;
}
@Override
public boolean finished() {
return false;
}
}
public static class ZeroingForce implements Force {
final float g;
public ZeroingForce(float g) {
this.g = g;
}
@Override
public float apply(float speed, float value) {
return speed - MathHelper.clamp(g * Math.signum(value), -speed, speed);
}
@Override
public boolean finished() {
return false;
}
}
public static class Impulse implements Force {
float force;
public Impulse(float force) {
this.force = force;
}
@Override
public float apply(float speed, float value) {
return speed + force;
}
@Override
public boolean finished() {
return true;
}
}
public static class ForceOverTime implements Force {
int timeRemaining;
float accel;
public ForceOverTime(int time, float totalAcceleration) {
this.timeRemaining = time;
this.accel = totalAcceleration / (float) time;
}
@Override
public float apply(float speed, float value) {
timeRemaining--;
return speed + accel;
}
@Override
public boolean finished() {
return timeRemaining <= 0;
}
}
}

View file

@ -0,0 +1,84 @@
package com.simibubi.create.foundation.utility.animation;
public interface Force {
float get(float mass, float value, float speed);
boolean finished();
class Drag implements Force {
final float dragFactor;
public Drag(float dragFactor) {
this.dragFactor = dragFactor;
}
@Override
public float get(float mass, float value, float speed) {
return -speed * dragFactor;
}
@Override
public boolean finished() {
return false;
}
}
class Zeroing implements Force {
final float g;
public Zeroing(float g) {
this.g = g / 20;
}
@Override
public float get(float mass, float value, float speed) {
return -Math.signum(value) * g * mass;
}
@Override
public boolean finished() {
return false;
}
}
class Impulse implements Force {
float force;
public Impulse(float force) {
this.force = force;
}
@Override
public float get(float mass, float value, float speed) {
return force;
}
@Override
public boolean finished() {
return true;
}
}
class OverTime implements Force {
int timeRemaining;
float f;
public OverTime(int time, float totalAcceleration) {
this.timeRemaining = time;
this.f = totalAcceleration / (float) time;
}
@Override
public float get(float mass, float value, float speed) {
timeRemaining--;
return f;
}
@Override
public boolean finished() {
return timeRemaining <= 0;
}
}
}

View file

@ -1,5 +1,6 @@
package com.simibubi.create.foundation.utility;
package com.simibubi.create.foundation.utility.animation;
import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.MathHelper;

View file

@ -0,0 +1,80 @@
package com.simibubi.create.foundation.utility.animation;
import net.minecraft.util.math.MathHelper;
import java.util.ArrayList;
public class PhysicalFloat {
float previousValue;
float value;
float previousSpeed;
float speed;
float mass;
private final ArrayList<Force> forces = new ArrayList<>();
public static PhysicalFloat create() {
return new PhysicalFloat(1);
}
public static PhysicalFloat create(float mass) {
return new PhysicalFloat(mass);
}
public PhysicalFloat(float mass) {
this.mass = mass;
}
public PhysicalFloat startAt(double value) {
previousValue = this.value = (float) value;
return this;
}
public PhysicalFloat withDrag(double drag) {
return addForce(new Force.Drag((float) drag));
}
public PhysicalFloat zeroing(double g) {
return addForce(new Force.Zeroing((float) g));
}
public void tick() {
previousSpeed = speed;
previousValue = value;
float totalImpulse = 0;
for (Force force : forces)
totalImpulse += force.get(mass, value, speed) / mass;
speed += totalImpulse;
forces.removeIf(Force::finished);
value += speed;
}
public PhysicalFloat addForce(Force f) {
forces.add(f);
return this;
}
public PhysicalFloat bump(double force) {
return addForce(new Force.Impulse((float) force));
}
public PhysicalFloat bump(int time, double force) {
return addForce(new Force.OverTime(time, (float) force));
}
public float getValue() {
return getValue(1);
}
public float getValue(float partialTicks) {
return MathHelper.lerp(partialTicks, previousValue, value);
}
}

View file

@ -4,7 +4,7 @@
"compatibilityLevel": "JAVA_8",
"refmap": "create.refmap.json",
"client": [
"OnRemoveTileMixin",
"AddRemoveTileMixin",
"ShaderCloseMixin",
"CancelTileEntityRenderMixin",
"LightUpdateMixin",