Update to Flywheel 0.5.1

This commit is contained in:
PepperCode1 2022-01-03 23:52:36 -08:00
parent cf3dac6ad0
commit c8ba7b88cc
75 changed files with 199 additions and 284 deletions

View file

@ -19,7 +19,7 @@ parchment_version = 2021.12.19
# dependency versions
registrate_version = MC1.18-1.0.21
flywheel_version = 1.18-0.5.0.33
flywheel_version = 1.18-0.5.1.38
jei_minecraft_version = 1.18
jei_version = 9.0.0.40

View file

@ -40,7 +40,7 @@ public class AllEntityTypes {
public static final EntityEntry<SuperGlueEntity> SUPER_GLUE =
register("super_glue", SuperGlueEntity::new, () -> SuperGlueRenderer::new, MobCategory.MISC, 10,
Integer.MAX_VALUE, false, true, SuperGlueEntity::build).instance(() -> GlueInstance::new)
Integer.MAX_VALUE, false, true, SuperGlueEntity::build).instance(() -> GlueInstance::new, false)
.register();
public static final EntityEntry<BlueprintEntity> CRAFTING_BLUEPRINT =

View file

@ -191,56 +191,56 @@ public class AllTileEntities {
// Kinetics
public static final BlockEntityEntry<BracketedKineticTileEntity> BRACKETED_KINETIC = Create.registrate()
.tileEntity("simple_kinetic", BracketedKineticTileEntity::new)
.instance(() -> BracketedKineticTileInstance::new)
.instance(() -> BracketedKineticTileInstance::new, false)
.validBlocks(AllBlocks.SHAFT, AllBlocks.COGWHEEL, AllBlocks.LARGE_COGWHEEL)
.renderer(() -> BracketedKineticTileRenderer::new)
.register();
public static final BlockEntityEntry<CreativeMotorTileEntity> MOTOR = Create.registrate()
.tileEntity("motor", CreativeMotorTileEntity::new)
.instance(() -> HalfShaftInstance::new)
.instance(() -> HalfShaftInstance::new, false)
.validBlocks(AllBlocks.CREATIVE_MOTOR)
.renderer(() -> CreativeMotorRenderer::new)
.register();
public static final BlockEntityEntry<GearboxTileEntity> GEARBOX = Create.registrate()
.tileEntity("gearbox", GearboxTileEntity::new)
.instance(() -> GearboxInstance::new)
.instance(() -> GearboxInstance::new, false)
.validBlocks(AllBlocks.GEARBOX)
.renderer(() -> GearboxRenderer::new)
.register();
public static final BlockEntityEntry<KineticTileEntity> ENCASED_SHAFT = Create.registrate()
.tileEntity("encased_shaft", KineticTileEntity::new)
.instance(() -> ShaftInstance::new)
.instance(() -> ShaftInstance::new, false)
.validBlocks(AllBlocks.ANDESITE_ENCASED_SHAFT, AllBlocks.BRASS_ENCASED_SHAFT, AllBlocks.ENCASED_CHAIN_DRIVE)
.renderer(() -> ShaftRenderer::new)
.register();
public static final BlockEntityEntry<SimpleKineticTileEntity> ENCASED_COGWHEEL = Create.registrate()
.tileEntity("encased_cogwheel", SimpleKineticTileEntity::new)
.instance(() -> EncasedCogInstance::small)
.instance(() -> EncasedCogInstance::small, false)
.validBlocks(AllBlocks.ANDESITE_ENCASED_COGWHEEL, AllBlocks.BRASS_ENCASED_COGWHEEL)
.renderer(() -> EncasedCogRenderer::small)
.register();
public static final BlockEntityEntry<SimpleKineticTileEntity> ENCASED_LARGE_COGWHEEL = Create.registrate()
.tileEntity("encased_large_cogwheel", SimpleKineticTileEntity::new)
.instance(() -> EncasedCogInstance::large)
.instance(() -> EncasedCogInstance::large, false)
.validBlocks(AllBlocks.ANDESITE_ENCASED_LARGE_COGWHEEL, AllBlocks.BRASS_ENCASED_LARGE_COGWHEEL)
.renderer(() -> EncasedCogRenderer::large)
.register();
public static final BlockEntityEntry<AdjustablePulleyTileEntity> ADJUSTABLE_PULLEY = Create.registrate()
.tileEntity("adjustable_pulley", AdjustablePulleyTileEntity::new)
.instance(() -> ShaftInstance::new)
.instance(() -> ShaftInstance::new, false)
.validBlocks(AllBlocks.ADJUSTABLE_CHAIN_GEARSHIFT)
.renderer(() -> ShaftRenderer::new)
.register();
public static final BlockEntityEntry<EncasedFanTileEntity> ENCASED_FAN = Create.registrate()
.tileEntity("encased_fan", EncasedFanTileEntity::new)
.instance(() -> FanInstance::new)
.instance(() -> FanInstance::new, false)
.validBlocks(AllBlocks.ENCASED_FAN)
.renderer(() -> EncasedFanRenderer::new)
.register();
@ -253,21 +253,21 @@ public class AllTileEntities {
public static final BlockEntityEntry<ClutchTileEntity> CLUTCH = Create.registrate()
.tileEntity("clutch", ClutchTileEntity::new)
.instance(() -> SplitShaftInstance::new)
.instance(() -> SplitShaftInstance::new, false)
.validBlocks(AllBlocks.CLUTCH)
.renderer(() -> SplitShaftRenderer::new)
.register();
public static final BlockEntityEntry<GearshiftTileEntity> GEARSHIFT = Create.registrate()
.tileEntity("gearshift", GearshiftTileEntity::new)
.instance(() -> SplitShaftInstance::new)
.instance(() -> SplitShaftInstance::new, false)
.validBlocks(AllBlocks.GEARSHIFT)
.renderer(() -> SplitShaftRenderer::new)
.register();
public static final BlockEntityEntry<TurntableTileEntity> TURNTABLE = Create.registrate()
.tileEntity("turntable", TurntableTileEntity::new)
.instance(() -> SingleRotatingInstance::new)
.instance(() -> SingleRotatingInstance::new, false)
.validBlocks(AllBlocks.TURNTABLE)
.renderer(() -> KineticTileEntityRenderer::new)
.register();
@ -289,7 +289,7 @@ public class AllTileEntities {
public static final BlockEntityEntry<GantryShaftTileEntity> GANTRY_SHAFT = Create.registrate()
.tileEntity("gantry_shaft", GantryShaftTileEntity::new)
.instance(() -> SingleRotatingInstance::new)
.instance(() -> SingleRotatingInstance::new, false)
.validBlocks(AllBlocks.GANTRY_SHAFT)
.renderer(() -> KineticTileEntityRenderer::new)
.register();
@ -370,7 +370,7 @@ public class AllTileEntities {
public static final BlockEntityEntry<BeltTileEntity> BELT = Create.registrate()
.tileEntity("belt", BeltTileEntity::new)
.instance(() -> BeltInstance::new)
.instance(() -> BeltInstance::new, BeltTileEntity::shouldRenderNormally)
.validBlocks(AllBlocks.BELT)
.renderer(() -> BeltRenderer::new)
.register();
@ -415,7 +415,7 @@ public class AllTileEntities {
public static final BlockEntityEntry<MechanicalPistonTileEntity> MECHANICAL_PISTON = Create.registrate()
.tileEntity("mechanical_piston", MechanicalPistonTileEntity::new)
.instance(() -> ShaftInstance::new)
.instance(() -> ShaftInstance::new, false)
.validBlocks(AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON)
.renderer(() -> MechanicalPistonRenderer::new)
.register();
@ -443,7 +443,7 @@ public class AllTileEntities {
public static final BlockEntityEntry<PulleyTileEntity> ROPE_PULLEY = Create.registrate()
.tileEntity("rope_pulley", PulleyTileEntity::new)
.instance(() -> RopePulleyInstance::new)
.instance(() -> RopePulleyInstance::new, false)
.validBlocks(AllBlocks.ROPE_PULLEY)
.renderer(() -> PulleyRenderer::new)
.register();
@ -456,14 +456,14 @@ public class AllTileEntities {
public static final BlockEntityEntry<StickerTileEntity> STICKER = Create.registrate()
.tileEntity("sticker", StickerTileEntity::new)
.instance(() -> StickerInstance::new)
.instance(() -> StickerInstance::new, false)
.validBlocks(AllBlocks.STICKER)
.renderer(() -> StickerRenderer::new)
.register();
public static final BlockEntityEntry<DrillTileEntity> DRILL = Create.registrate()
.tileEntity("drill", DrillTileEntity::new)
.instance(() -> DrillInstance::new)
.instance(() -> DrillInstance::new, false)
.validBlocks(AllBlocks.MECHANICAL_DRILL)
.renderer(() -> DrillRenderer::new)
.register();
@ -496,28 +496,28 @@ public class AllTileEntities {
public static final BlockEntityEntry<FlywheelTileEntity> FLYWHEEL = Create.registrate()
.tileEntity("flywheel", FlywheelTileEntity::new)
.instance(() -> FlyWheelInstance::new)
.instance(() -> FlyWheelInstance::new, false)
.validBlocks(AllBlocks.FLYWHEEL)
.renderer(() -> FlywheelRenderer::new)
.register();
public static final BlockEntityEntry<FurnaceEngineTileEntity> FURNACE_ENGINE = Create.registrate()
.tileEntity("furnace_engine", FurnaceEngineTileEntity::new)
.instance(() -> EngineInstance::new)
.instance(() -> EngineInstance::new, false)
.validBlocks(AllBlocks.FURNACE_ENGINE)
.renderer(() -> EngineRenderer::new)
.register();
public static final BlockEntityEntry<MillstoneTileEntity> MILLSTONE = Create.registrate()
.tileEntity("millstone", MillstoneTileEntity::new)
.instance(() -> MillStoneCogInstance::new)
.instance(() -> MillStoneCogInstance::new, false)
.validBlocks(AllBlocks.MILLSTONE)
.renderer(() -> MillstoneRenderer::new)
.register();
public static final BlockEntityEntry<CrushingWheelTileEntity> CRUSHING_WHEEL = Create.registrate()
.tileEntity("crushing_wheel", CrushingWheelTileEntity::new)
.instance(() -> CutoutRotatingInstance::new)
.instance(() -> CutoutRotatingInstance::new, false)
.validBlocks(AllBlocks.CRUSHING_WHEEL)
.renderer(() -> KineticTileEntityRenderer::new)
.register();
@ -531,7 +531,7 @@ public class AllTileEntities {
public static final BlockEntityEntry<WaterWheelTileEntity> WATER_WHEEL = Create.registrate()
.tileEntity("water_wheel", WaterWheelTileEntity::new)
.instance(() -> CutoutRotatingInstance::new)
.instance(() -> CutoutRotatingInstance::new, false)
.validBlocks(AllBlocks.WATER_WHEEL)
.renderer(() -> KineticTileEntityRenderer::new)
.register();
@ -578,7 +578,7 @@ public class AllTileEntities {
public static final BlockEntityEntry<SequencedGearshiftTileEntity> SEQUENCED_GEARSHIFT = Create.registrate()
.tileEntity("sequenced_gearshift", SequencedGearshiftTileEntity::new)
.instance(() -> SplitShaftInstance::new)
.instance(() -> SplitShaftInstance::new, false)
.validBlocks(AllBlocks.SEQUENCED_GEARSHIFT)
.renderer(() -> SplitShaftRenderer::new)
.register();
@ -606,7 +606,7 @@ public class AllTileEntities {
public static final BlockEntityEntry<AnalogLeverTileEntity> ANALOG_LEVER = Create.registrate()
.tileEntity("analog_lever", AnalogLeverTileEntity::new)
.instance(() -> AnalogLeverInstance::new)
.instance(() -> AnalogLeverInstance::new, false)
.validBlocks(AllBlocks.ANALOG_LEVER)
.renderer(() -> AnalogLeverRenderer::new)
.register();
@ -672,7 +672,7 @@ public class AllTileEntities {
public static final BlockEntityEntry<PulseExtenderTileEntity> PULSE_EXTENDER = Create.registrate()
.tileEntity("pulse_extender", PulseExtenderTileEntity::new)
.instance(() -> BrassDiodeInstance::new)
.instance(() -> BrassDiodeInstance::new, false)
.validBlocks(AllBlocks.PULSE_EXTENDER)
.renderer(() -> BrassDiodeRenderer::new)
.register();
@ -680,7 +680,7 @@ public class AllTileEntities {
public static final BlockEntityEntry<PulseRepeaterTileEntity> PULSE_REPEATER =
Create.registrate()
.tileEntity("pulse_repeater", PulseRepeaterTileEntity::new)
.instance(() -> BrassDiodeInstance::new)
.instance(() -> BrassDiodeInstance::new, false)
.validBlocks(AllBlocks.PULSE_REPEATER)
.renderer(() -> BrassDiodeRenderer::new)
.register();
@ -714,7 +714,7 @@ public class AllTileEntities {
public static final BlockEntityEntry<ToolboxTileEntity> TOOLBOX = Create.registrate()
.tileEntity("toolbox", ToolboxTileEntity::new)
.instance(() -> ToolBoxInstance::new)
.instance(() -> ToolBoxInstance::new, false)
.validBlocks(AllBlocks.TOOLBOXES.toArray())
.renderer(() -> ToolboxRenderer::new)
.register();

View file

@ -12,6 +12,6 @@ public class BackHalfShaftInstance extends HalfShaftInstance {
@Override
protected Direction getShaftDirection() {
return tile.getBlockState().getValue(BlockStateProperties.FACING).getOpposite();
return blockEntity.getBlockState().getValue(BlockStateProperties.FACING).getOpposite();
}
}

View file

@ -7,7 +7,6 @@ import java.util.List;
import javax.annotation.Nullable;
import com.jozufozu.flywheel.api.FlywheelRendered;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.KineticNetwork;
@ -49,7 +48,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor;
public class KineticTileEntity extends SmartTileEntity
implements IHaveGoggleInformation, IHaveHoveringInformation, FlywheelRendered {
implements IHaveGoggleInformation, IHaveHoveringInformation {
public @Nullable Long network;
public @Nullable BlockPos source;

View file

@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.base;
import com.jozufozu.flywheel.api.Material;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel;
@ -12,7 +12,7 @@ import com.simibubi.create.foundation.render.AllMaterialSpecs;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
public abstract class KineticTileInstance<T extends KineticTileEntity> extends TileEntityInstance<T> {
public abstract class KineticTileInstance<T extends KineticTileEntity> extends BlockEntityInstance<T> {
protected final Direction.Axis axis;
@ -38,7 +38,7 @@ public abstract class KineticTileInstance<T extends KineticTileEntity> extends T
instance.setRotationAxis(axis)
.setRotationOffset(getRotationOffset(axis))
.setRotationalSpeed(speed)
.setColor(tile);
.setColor(blockEntity);
}
protected final RotatingData setup(RotatingData key) {
@ -57,7 +57,7 @@ public abstract class KineticTileInstance<T extends KineticTileEntity> extends T
key.setRotationAxis(axis)
.setRotationalSpeed(speed)
.setRotationOffset(getRotationOffset(axis))
.setColor(tile)
.setColor(blockEntity)
.setPosition(getInstancePosition());
return key;
@ -78,7 +78,7 @@ public abstract class KineticTileInstance<T extends KineticTileEntity> extends T
}
protected float getTileSpeed() {
return tile.getSpeed();
return blockEntity.getSpeed();
}
protected BlockState shaft() {

View file

@ -19,7 +19,7 @@ public class DrillInstance extends SingleRotatingInstance {
@Override
protected Instancer<RotatingData> getModel() {
BlockState referenceState = tile.getBlockState();
BlockState referenceState = blockEntity.getBlockState();
Direction facing = referenceState.getValue(BlockStateProperties.FACING);
return getRotatingMaterial().getModel(AllBlockPartials.DRILL_HEAD, referenceState, facing);
}

View file

@ -187,9 +187,4 @@ public class CuckooClockTileEntity extends KineticTileEntity {
Vec3 vec = VecHelper.getCenterOf(worldPosition);
level.playLocalSound(vec.x, vec.y, vec.z, sound, SoundSource.BLOCKS, volume, pitch, false);
}
@Override
public boolean shouldRenderNormally() {
return true;
}
}

View file

@ -523,11 +523,6 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity {
return inventory;
}
@Override
public boolean shouldRenderNormally() {
return true;
}
public void setScriptedResult(ItemStack scriptedResult) {
this.scriptedResult = scriptedResult;
}

View file

@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.crank;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
@ -12,7 +12,7 @@ import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
public class HandCrankInstance extends SingleRotatingInstance implements IDynamicInstance {
public class HandCrankInstance extends SingleRotatingInstance implements DynamicInstance {
private final HandCrankTileEntity tile;
private ModelData crank;

View file

@ -79,11 +79,6 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity {
return AllBlocks.HAND_CRANK.get();
}
@Override
public boolean shouldRenderNormally() {
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public void tickAudio() {

View file

@ -4,8 +4,8 @@ import static com.simibubi.create.content.contraptions.base.DirectionalAxisKinet
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.ITickableInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.api.instance.TickableInstance;
import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
import com.mojang.math.Quaternion;
@ -20,7 +20,7 @@ import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
import net.minecraft.util.Mth;
public class DeployerInstance extends ShaftInstance implements IDynamicInstance, ITickableInstance {
public class DeployerInstance extends ShaftInstance implements DynamicInstance, TickableInstance {
final DeployerTileEntity tile;
final Direction facing;
@ -39,7 +39,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance,
public DeployerInstance(MaterialManager dispatcher, KineticTileEntity tile) {
super(dispatcher, tile);
this.tile = (DeployerTileEntity) super.tile;
this.tile = (DeployerTileEntity) super.blockEntity;
facing = blockState.getValue(FACING);
boolean rotatePole = blockState.getValue(AXIS_ALONG_FIRST_COORDINATE) ^ facing.getAxis() == Direction.Axis.Z;

View file

@ -424,11 +424,6 @@ public class DeployerTileEntity extends KineticTileEntity {
return true;
}
@Override
public boolean shouldRenderNormally() {
return true;
}
public float getHandOffset(float partialTicks) {
if (isVirtual())
return animatedOffset.getValue(partialTicks);

View file

@ -36,7 +36,7 @@ public class FanInstance extends KineticTileInstance<EncasedFanTileEntity> {
}
private float getFanSpeed() {
float speed = tile.getSpeed() * 5;
float speed = blockEntity.getSpeed() * 5;
if (speed > 0)
speed = Mth.clamp(speed, 80, 64 * 20);
if (speed < 0)

View file

@ -10,7 +10,7 @@ import com.jozufozu.flywheel.api.InstanceData;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.Material;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
@ -25,7 +25,7 @@ import net.minecraft.util.Mth;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> implements IDynamicInstance {
public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> implements DynamicInstance {
protected final Direction facing;
protected final Direction connection;
@ -90,8 +90,8 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
float partialTicks = AnimationTickHolder.getPartialTicks();
float speed = tile.visualSpeed.get(partialTicks) * 3 / 10f;
float angle = tile.angle + speed * partialTicks;
float speed = blockEntity.visualSpeed.get(partialTicks) * 3 / 10f;
float angle = blockEntity.angle + speed * partialTicks;
if (Math.abs(angle - lastAngle) < 0.001)
return;

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.contraptions.components.flywheel.engine;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance;
import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -10,7 +10,7 @@ import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
public class EngineInstance extends TileEntityInstance<EngineTileEntity> {
public class EngineInstance extends BlockEntityInstance<EngineTileEntity> {
protected ModelData frame;

View file

@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine;
import java.util.List;
import com.jozufozu.flywheel.api.FlywheelRendered;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock;
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
@ -18,7 +17,7 @@ import net.minecraft.world.phys.AABB;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class EngineTileEntity extends SmartTileEntity implements FlywheelRendered {
public class EngineTileEntity extends SmartTileEntity {
public float appliedCapacity;
public float appliedSpeed;

View file

@ -15,6 +15,6 @@ public class MillStoneCogInstance extends SingleRotatingInstance {
@Override
protected Instancer<RotatingData> getModel() {
return getRotatingMaterial().getModel(AllBlockPartials.MILLSTONE_COG, tile.getBlockState());
return getRotatingMaterial().getModel(AllBlockPartials.MILLSTONE_COG, blockEntity.getBlockState());
}
}

View file

@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.mixer;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.flwdata.RotatingData;
@ -12,7 +12,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.core.Direction;
public class MixerInstance extends EncasedCogInstance implements IDynamicInstance {
public class MixerInstance extends EncasedCogInstance implements DynamicInstance {
private final RotatingData mixerHead;
private final OrientedData mixerPole;
@ -42,7 +42,7 @@ public class MixerInstance extends EncasedCogInstance implements IDynamicInstanc
protected Instancer<RotatingData> getCogModel() {
return materialManager.defaultSolid()
.material(AllMaterialSpecs.ROTATING)
.getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, tile.getBlockState());
.getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, blockEntity.getBlockState());
}
@Override

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.contraptions.components.press;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
import com.mojang.math.Quaternion;
@ -11,7 +11,7 @@ import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
public class PressInstance extends ShaftInstance implements IDynamicInstance {
public class PressInstance extends ShaftInstance implements DynamicInstance {
private final OrientedData pressHead;
private final MechanicalPressTileEntity press;

View file

@ -23,7 +23,7 @@ public class SawInstance extends SingleRotatingInstance {
if (blockState.getValue(BlockStateProperties.FACING)
.getAxis()
.isHorizontal()) {
BlockState referenceState = blockState.rotate(tile.getLevel(), tile.getBlockPos(), Rotation.CLOCKWISE_180);
BlockState referenceState = blockState.rotate(blockEntity.getLevel(), blockEntity.getBlockPos(), Rotation.CLOCKWISE_180);
Direction facing = referenceState.getValue(BlockStateProperties.FACING);
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, referenceState, facing);
} else {

View file

@ -499,9 +499,4 @@ public class SawTileEntity extends BlockBreakingKineticTileEntity {
return false;
}
@Override
public boolean shouldRenderNormally() {
return true;
}
}

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.contraptions.components.structureMovement.bearing;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.core.PartialModel;
import com.jozufozu.flywheel.core.materials.oriented.OrientedData;
import com.mojang.math.Quaternion;
@ -15,7 +15,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
public class BearingInstance<B extends KineticTileEntity & IBearingTileEntity> extends BackHalfShaftInstance implements IDynamicInstance {
public class BearingInstance<B extends KineticTileEntity & IBearingTileEntity> extends BackHalfShaftInstance implements DynamicInstance {
final B bearing;
final OrientedData topInstance;

View file

@ -420,11 +420,6 @@ public class ClockworkBearingTileEntity extends KineticTileEntity
return worldPosition;
}
@Override
public boolean shouldRenderNormally() {
return true;
}
public void setAngle(float forcedAngle) {
hourAngle = forcedAngle;
}

View file

@ -321,11 +321,6 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity
return true;
}
@Override
public boolean shouldRenderNormally() {
return true;
}
public void setAngle(float forcedAngle) {
angle = forcedAngle;
}

View file

@ -1,8 +1,8 @@
package com.simibubi.create.content.contraptions.components.structureMovement.chassis;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.utility.AngleHelper;
@ -12,7 +12,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
public class StickerInstance extends TileEntityInstance<StickerTileEntity> implements IDynamicInstance {
public class StickerInstance extends BlockEntityInstance<StickerTileEntity> implements DynamicInstance {
float lastOffset = Float.NaN;
final Direction facing;
@ -35,7 +35,7 @@ public class StickerInstance extends TileEntityInstance<StickerTileEntity> imple
@Override
public void beginFrame() {
float offset = tile.piston.getValue(AnimationTickHolder.getPartialTicks());
float offset = blockEntity.piston.getValue(AnimationTickHolder.getPartialTicks());
if (fakeWorld)
offset = this.offset;
@ -51,7 +51,7 @@ public class StickerInstance extends TileEntityInstance<StickerTileEntity> imple
private void animateHead(float offset) {
head.loadIdentity()
.translate(getInstancePosition())
.nudge(tile.hashCode())
.nudge(blockEntity.hashCode())
.centre()
.rotateY(AngleHelper.horizontalAngle(facing))
.rotateX(AngleHelper.verticalAngle(facing) + 90)

View file

@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch
import java.util.List;
import com.jozufozu.flywheel.api.FlywheelRendered;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSoundEvents;
@ -23,7 +22,7 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor;
public class StickerTileEntity extends SmartTileEntity implements FlywheelRendered {
public class StickerTileEntity extends SmartTileEntity {
LerpedFloat piston;
boolean update;

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.contraptions.components.structureMovement.gantry;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
@ -14,7 +14,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
public class GantryCarriageInstance extends ShaftInstance implements IDynamicInstance {
public class GantryCarriageInstance extends ShaftInstance implements DynamicInstance {
private final ModelData gantryCogs;
@ -56,7 +56,7 @@ public class GantryCarriageInstance extends ShaftInstance implements IDynamicIns
}
private float getCogAngle() {
return GantryCarriageRenderer.getAngleForTe(tile, visualPos, rotationAxis) * rotationMult;
return GantryCarriageRenderer.getAngleForTe(blockEntity, visualPos, rotationAxis) * rotationMult;
}
private void animateCogs(float cogAngle) {

View file

@ -171,9 +171,4 @@ public class GantryCarriageTileEntity extends KineticTileEntity implements IDisp
BlockEntity te = level.getBlockEntity(worldPosition.relative(facing));
return te instanceof GantryShaftTileEntity && ((GantryShaftTileEntity) te).canAssembleOn();
}
@Override
public boolean shouldRenderNormally() {
return true;
}
}

View file

@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.gl
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.MaterialGroup;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.ITickableInstance;
import com.jozufozu.flywheel.api.instance.TickableInstance;
import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.instancing.ConditionalInstance;
@ -21,7 +21,7 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.LightLayer;
public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITickableInstance {
public class GlueInstance extends EntityInstance<SuperGlueEntity> implements TickableInstance {
private static final ResourceLocation TEXTURE = Create.asResource("textures/entity/super_glue/slime.png");

View file

@ -4,7 +4,6 @@ import javax.annotation.Nullable;
import org.apache.commons.lang3.Validate;
import com.jozufozu.flywheel.api.FlywheelRendered;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllEntityTypes;
import com.simibubi.create.AllItems;
@ -68,7 +67,7 @@ import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.network.PacketDistributor;
public class SuperGlueEntity extends Entity
implements IEntityAdditionalSpawnData, ISpecialEntityItemRequirement, FlywheelRendered {
implements IEntityAdditionalSpawnData, ISpecialEntityItemRequirement {
private int validationTimer;
protected BlockPos hangingPosition;

View file

@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pu
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.core.instancing.ConditionalInstance;
import com.jozufozu.flywheel.core.instancing.GroupInstance;
import com.jozufozu.flywheel.core.instancing.SelectInstance;
@ -22,7 +22,7 @@ import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
import net.minecraft.world.level.LightLayer;
public abstract class AbstractPulleyInstance extends ShaftInstance implements IDynamicInstance, MovingListener {
public abstract class AbstractPulleyInstance extends ShaftInstance implements DynamicInstance, MovingListener {
final OrientedData coil;
final SelectInstance<OrientedData> magnet;

View file

@ -39,7 +39,7 @@ public class HosePulleyInstance extends AbstractPulleyInstance {
}
protected float getOffset() {
return ((HosePulleyTileEntity) tile).getInterpolatedOffset(AnimationTickHolder.getPartialTicks());
return ((HosePulleyTileEntity) blockEntity).getInterpolatedOffset(AnimationTickHolder.getPartialTicks());
}
protected boolean isRunning() {

View file

@ -236,9 +236,4 @@ public class PulleyTileEntity extends LinearActuatorTileEntity {
public void animateOffset(float forcedOffset) {
offset = forcedOffset;
}
@Override
public boolean shouldRenderNormally() {
return false;
}
}

View file

@ -35,10 +35,10 @@ public class RopePulleyInstance extends AbstractPulleyInstance {
protected float getOffset() {
float partialTicks = AnimationTickHolder.getPartialTicks();
return PulleyRenderer.getTileOffset(partialTicks, (PulleyTileEntity) tile);
return PulleyRenderer.getTileOffset(partialTicks, (PulleyTileEntity) blockEntity);
}
protected boolean isRunning() {
return ((PulleyTileEntity) tile).running || tile.isVirtual();
return ((PulleyTileEntity) blockEntity).running || blockEntity.isVirtual();
}
}

View file

@ -8,7 +8,7 @@ import org.apache.commons.lang3.tuple.Pair;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.instancing.TaskEngine;
import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstanceManager;
import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld;
import com.simibubi.create.AllMovementBehaviours;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
@ -18,7 +18,7 @@ import net.minecraft.client.Camera;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
public class ContraptionInstanceManager extends TileInstanceManager {
public class ContraptionInstanceManager extends BlockEntityInstanceManager {
protected ArrayList<ActorInstance> actors = new ArrayList<>();

View file

@ -108,7 +108,7 @@ public class ContraptionRenderDispatcher {
ContraptionWorld contraptionWorld = c.getContraptionWorld();
VirtualRenderWorld renderWorld = new VirtualRenderWorld(world, contraptionWorld.getHeight(), contraptionWorld.getMinBuildHeight());
renderWorld.setTileEntities(c.presentTileEntities.values());
renderWorld.setBlockEntities(c.presentTileEntities.values());
for (StructureTemplate.StructureBlockInfo info : c.getBlocks()
.values())

View file

@ -147,8 +147,7 @@ public class FlwContraption extends ContraptionRenderInfo {
Collection<BlockEntity> tileEntities = contraption.maybeInstancedTileEntities;
if (!tileEntities.isEmpty()) {
for (BlockEntity te : tileEntities) {
if (InstancedRenderRegistry.getInstance()
.canInstance(te.getType())) {
if (InstancedRenderRegistry.canInstance(te.getType())) {
Level world = te.getLevel();
te.setLevel(renderWorld);
instanceWorld.tileInstanceManager.add(te);

View file

@ -19,7 +19,7 @@ public class PumpCogInstance extends SingleRotatingInstance {
@Override
protected Instancer<RotatingData> getModel() {
BlockState referenceState = tile.getBlockState();
BlockState referenceState = blockEntity.getBlockState();
Direction facing = referenceState.getValue(BlockStateProperties.FACING);
return getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_PUMP_COG, referenceState, facing);
}

View file

@ -389,9 +389,4 @@ public class PumpTileEntity extends KineticTileEntity {
}
}
@Override
public boolean shouldRenderNormally() {
return true;
}
}

View file

@ -187,9 +187,4 @@ public class HosePulleyTileEntity extends KineticTileEntity {
return this.capability.cast();
return super.getCapability(cap, side);
}
@Override
public boolean shouldRenderNormally() {
return true;
}
}

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.contraptions.fluids.pipes;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.simibubi.create.AllBlockPartials;
@ -14,7 +14,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
public class FluidValveInstance extends ShaftInstance implements IDynamicInstance {
public class FluidValveInstance extends ShaftInstance implements DynamicInstance {
private final FluidValveTileEntity tile;
protected ModelData pointer;

View file

@ -80,11 +80,6 @@ public class FluidValveTileEntity extends KineticTileEntity {
behaviours.add(new ValvePipeBehaviour(this));
}
@Override
public boolean shouldRenderNormally() {
return true;
}
class ValvePipeBehaviour extends StraightPipeFluidTransportBehaviour {
public ValvePipeBehaviour(SmartTileEntity te) {

View file

@ -149,9 +149,4 @@ public abstract class BasinOperatingTileEntity extends KineticTileEntity {
protected abstract <C extends Container> boolean matchStaticFilters(Recipe<C> recipe);
protected abstract Object getRecipeCacheKey();
@Override
public boolean shouldRenderNormally() {
return true;
}
}

View file

@ -118,11 +118,6 @@ public class SpeedControllerTileEntity extends KineticTileEntity {
&& stateAbove.getValue(CogWheelBlock.AXIS).isHorizontal();
}
@Override
public boolean shouldRenderNormally() {
return true;
}
private class ControllerValueBoxTransform extends ValueBoxTransform.Sided {
@Override

View file

@ -80,14 +80,14 @@ public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
@Override
public void update() {
DyeColor color = tile.color.orElse(null);
DyeColor color = blockEntity.color.orElse(null);
boolean bottom = true;
for (BeltData key : keys) {
SpriteShiftEntry spriteShiftEntry = BeltRenderer.getSpriteShiftEntry(color, diagonal, bottom);
key.setScrollTexture(spriteShiftEntry)
.setColor(tile)
.setColor(blockEntity)
.setRotationalSpeed(getScrollSpeed());
bottom = false;
}
@ -113,7 +113,7 @@ public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
}
private float getScrollSpeed() {
float speed = tile.getSpeed();
float speed = blockEntity.getSpeed();
if (((facing.getAxisDirection() == Direction.AxisDirection.NEGATIVE) ^ upward) ^
((alongX && !diagonal) || (alongZ && diagonal))) {
speed = -speed;
@ -168,7 +168,7 @@ public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
.setRotation(q)
.setRotationalSpeed(getScrollSpeed())
.setRotationOffset(bottom ? 0.5f : 0f)
.setColor(tile)
.setColor(blockEntity)
.setPosition(getInstancePosition())
.setBlockLight(world.getBrightness(LightLayer.BLOCK, pos))
.setSkyLight(world.getBrightness(LightLayer.SKY, pos));

View file

@ -528,7 +528,6 @@ public class BeltTileEntity extends KineticTileEntity implements LightListener {
itemHandler.invalidate();
}
@Override
public boolean shouldRenderNormally() {
if (level == null)
return isController();

View file

@ -27,15 +27,15 @@ public class BracketedKineticTileInstance extends SingleRotatingInstance {
@Override
public void init() {
super.init();
if (!ICogWheel.isLargeCog(tile.getBlockState()))
if (!ICogWheel.isLargeCog(blockEntity.getBlockState()))
return;
// Large cogs sometimes have to offset their teeth by 11.25 degrees in order to
// mesh properly
float speed = tile.getSpeed();
Axis axis = KineticTileEntityRenderer.getRotationAxisOf(tile);
BlockPos pos = tile.getBlockPos();
float speed = blockEntity.getSpeed();
Axis axis = KineticTileEntityRenderer.getRotationAxisOf(blockEntity);
BlockPos pos = blockEntity.getBlockPos();
float offset = BracketedKineticTileRenderer.getShaftAngleOffset(axis, pos);
Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE);
Instancer<RotatingData> half = getRotatingMaterial().getModel(AllBlockPartials.COGWHEEL_SHAFT, blockState,
@ -47,10 +47,10 @@ public class BracketedKineticTileInstance extends SingleRotatingInstance {
@Override
protected Instancer<RotatingData> getModel() {
if (!ICogWheel.isLargeCog(tile.getBlockState()))
if (!ICogWheel.isLargeCog(blockEntity.getBlockState()))
return super.getModel();
Axis axis = KineticTileEntityRenderer.getRotationAxisOf(tile);
Axis axis = KineticTileEntityRenderer.getRotationAxisOf(blockEntity);
Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE);
return getRotatingMaterial().getModel(AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL, blockState, facing,
() -> this.rotateToAxis(axis));

View file

@ -56,7 +56,7 @@ public class EncasedCogInstance extends KineticTileInstance<KineticTileEntity> {
rotatingBottomShaft = Optional.empty();
for (Direction d : Iterate.directionsInAxis(axis)) {
if (!def.hasShaftTowards(tile.getLevel(), tile.getBlockPos(), blockState, d))
if (!def.hasShaftTowards(blockEntity.getLevel(), blockEntity.getBlockPos(), blockState, d))
continue;
RotatingData data = setup(getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, d)
.createInstance());
@ -89,7 +89,7 @@ public class EncasedCogInstance extends KineticTileInstance<KineticTileEntity> {
}
protected Instancer<RotatingData> getCogModel() {
BlockState referenceState = tile.getBlockState();
BlockState referenceState = blockEntity.getBlockState();
Direction facing =
Direction.fromAxisAndDirection(referenceState.getValue(BlockStateProperties.AXIS), AxisDirection.POSITIVE);
PartialModel partial = large ? AllBlockPartials.SHAFTLESS_LARGE_COGWHEEL : AllBlockPartials.SHAFTLESS_COGWHEEL;

View file

@ -46,7 +46,7 @@ public class SplitShaftInstance extends KineticTileInstance<SplitShaftTileEntity
Direction[] directions = Iterate.directionsInAxis(boxAxis);
for (int i : Iterate.zeroAndOne) {
updateRotation(keys.get(i), tile.getSpeed() * tile.getRotationSpeedModifier(directions[i]));
updateRotation(keys.get(i), blockEntity.getSpeed() * blockEntity.getRotationSpeedModifier(directions[i]));
}
}

View file

@ -4,7 +4,7 @@ import java.util.ArrayList;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
@ -18,7 +18,7 @@ import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.core.Direction;
import net.minecraft.util.Mth;
public abstract class GaugeInstance extends ShaftInstance implements IDynamicInstance {
public abstract class GaugeInstance extends ShaftInstance implements DynamicInstance {
protected final ArrayList<DialFace> faces;
@ -59,7 +59,7 @@ public abstract class GaugeInstance extends ShaftInstance implements IDynamicIns
@Override
public void beginFrame() {
GaugeTileEntity gaugeTile = (GaugeTileEntity) tile;
GaugeTileEntity gaugeTile = (GaugeTileEntity) blockEntity;
if (Mth.equal(gaugeTile.prevDialState, gaugeTile.dialState))
return;

View file

@ -52,9 +52,4 @@ public class GaugeTileEntity extends KineticTileEntity implements IHaveGoggleInf
return true;
}
@Override
public boolean shouldRenderNormally() {
return true;
}
}

View file

@ -56,7 +56,7 @@ public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
}
private float getSpeed(Direction direction) {
float speed = tile.getSpeed();
float speed = blockEntity.getSpeed();
if (speed != 0 && sourceFacing != null) {
if (sourceFacing.getAxis() == direction.getAxis())
@ -68,8 +68,8 @@ public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
}
protected void updateSourceFacing() {
if (tile.hasSource()) {
BlockPos source = tile.source.subtract(pos);
if (blockEntity.hasSource()) {
BlockPos source = blockEntity.source.subtract(pos);
sourceFacing = Direction.getNearest(source.getX(), source.getY(), source.getZ());
} else {
sourceFacing = null;

View file

@ -128,11 +128,6 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements Namea
.getDescriptionId());
}
@Override
public boolean shouldRenderNormally() {
return true;
}
public int getAirLevel() {
return airLevel;
}

View file

@ -2,8 +2,8 @@ package com.simibubi.create.content.curiosities.toolbox;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.simibubi.create.AllBlockPartials;
@ -13,7 +13,7 @@ import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.BlockState;
public class ToolBoxInstance extends TileEntityInstance<ToolboxTileEntity> implements IDynamicInstance {
public class ToolBoxInstance extends BlockEntityInstance<ToolboxTileEntity> implements DynamicInstance {
private final Direction facing;
private ModelData lid;
@ -28,7 +28,7 @@ public class ToolBoxInstance extends TileEntityInstance<ToolboxTileEntity> imple
@Override
public void init() {
BlockState blockState = tile.getBlockState();
BlockState blockState = blockEntity.getBlockState();
Instancer<ModelData> drawerModel = materialManager.defaultSolid()
.material(Materials.TRANSFORMED)
@ -37,7 +37,7 @@ public class ToolBoxInstance extends TileEntityInstance<ToolboxTileEntity> imple
drawers = new ModelData[]{drawerModel.createInstance(), drawerModel.createInstance()};
lid = materialManager.defaultCutout()
.material(Materials.TRANSFORMED)
.getModel(AllBlockPartials.TOOLBOX_LIDS.get(tile.getColor()), blockState)
.getModel(AllBlockPartials.TOOLBOX_LIDS.get(blockEntity.getColor()), blockState)
.createInstance();
}
@ -56,8 +56,8 @@ public class ToolBoxInstance extends TileEntityInstance<ToolboxTileEntity> imple
float partialTicks = AnimationTickHolder.getPartialTicks();
float lidAngle = tile.lid.getValue(partialTicks);
float drawerOffset = tile.drawers.getValue(partialTicks);
float lidAngle = blockEntity.lid.getValue(partialTicks);
float drawerOffset = blockEntity.drawers.getValue(partialTicks);
lid.loadIdentity()
.translate(instancePos)

View file

@ -10,7 +10,6 @@ import java.util.Set;
import java.util.UUID;
import java.util.WeakHashMap;
import com.jozufozu.flywheel.api.FlywheelRendered;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
@ -43,7 +42,7 @@ import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
public class ToolboxTileEntity extends SmartTileEntity implements MenuProvider, Nameable, FlywheelRendered {
public class ToolboxTileEntity extends SmartTileEntity implements MenuProvider, Nameable {
public LerpedFloat lid = LerpedFloat.linear()
.startWithValue(0);

View file

@ -8,8 +8,8 @@ import java.util.Map;
import com.jozufozu.flywheel.api.InstanceData;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.logistics.block.flap.FlapData;
import com.simibubi.create.foundation.render.AllMaterialSpecs;
@ -19,7 +19,7 @@ import com.simibubi.create.foundation.utility.animation.InterpolatedValue;
import net.minecraft.core.Direction;
import net.minecraft.world.level.LightLayer;
public class BeltTunnelInstance extends TileEntityInstance<BeltTunnelTileEntity> implements IDynamicInstance {
public class BeltTunnelInstance extends BlockEntityInstance<BeltTunnelTileEntity> implements DynamicInstance {
private final Map<Direction, ArrayList<FlapData>> tunnelFlaps;
@ -70,13 +70,13 @@ public class BeltTunnelInstance extends TileEntityInstance<BeltTunnelTileEntity>
@Override
public boolean shouldReset() {
return super.shouldReset() || tunnelFlaps.size() != tile.flaps.size();
return super.shouldReset() || tunnelFlaps.size() != blockEntity.flaps.size();
}
@Override
public void beginFrame() {
tunnelFlaps.forEach((direction, keys) -> {
InterpolatedValue flapValue = tile.flaps.get(direction);
InterpolatedValue flapValue = blockEntity.flaps.get(direction);
if (flapValue == null) {
return;
}

View file

@ -9,7 +9,6 @@ import java.util.Set;
import org.apache.commons.lang3.tuple.Pair;
import com.jozufozu.flywheel.api.FlywheelRendered;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape;
@ -40,7 +39,7 @@ import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
public class BeltTunnelTileEntity extends SmartTileEntity implements FlywheelRendered {
public class BeltTunnelTileEntity extends SmartTileEntity {
public Map<Direction, InterpolatedChasingValue> flaps;
public Set<Direction> sides;
@ -175,11 +174,6 @@ public class BeltTunnelTileEntity extends SmartTileEntity implements FlywheelRen
flapsToSend.clear();
}
@Override
public boolean shouldRenderNormally() {
return true;
}
@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {}

View file

@ -1,7 +1,7 @@
package com.simibubi.create.content.logistics.block.depot;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
@ -9,7 +9,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.util.Mth;
public class EjectorInstance extends ShaftInstance implements IDynamicInstance {
public class EjectorInstance extends ShaftInstance implements DynamicInstance {
protected final EjectorTileEntity tile;

View file

@ -576,11 +576,6 @@ public class EjectorTileEntity extends KineticTileEntity {
return super.getCapability(cap, side);
}
@Override
public boolean shouldRenderNormally() {
return true;
}
public float getLidProgress(float pt) {
return lidProgress.getValue(pt);
}

View file

@ -1,14 +1,14 @@
package com.simibubi.create.content.logistics.block.diodes;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.ITickableInstance;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.api.instance.TickableInstance;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance;
import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.foundation.utility.Color;
public class BrassDiodeInstance extends TileEntityInstance<BrassDiodeTileEntity> implements ITickableInstance {
public class BrassDiodeInstance extends BlockEntityInstance<BrassDiodeTileEntity> implements TickableInstance {
protected final ModelData indicator;
@ -30,11 +30,11 @@ public class BrassDiodeInstance extends TileEntityInstance<BrassDiodeTileEntity>
@Override
public void tick() {
if (previousState == tile.state) return;
if (previousState == blockEntity.state) return;
indicator.setColor(getColor());
previousState = tile.state;
previousState = blockEntity.state;
}
@Override
@ -48,6 +48,6 @@ public class BrassDiodeInstance extends TileEntityInstance<BrassDiodeTileEntity>
}
protected int getColor() {
return Color.mixColors(0x2c0300, 0xcd0000, tile.getProgress());
return Color.mixColors(0x2c0300, 0xcd0000, blockEntity.getProgress());
}
}

View file

@ -4,7 +4,6 @@ import static com.simibubi.create.content.logistics.block.diodes.BrassDiodeBlock
import java.util.List;
import com.jozufozu.flywheel.api.FlywheelRendered;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour;
@ -19,7 +18,7 @@ import net.minecraft.world.level.block.DiodeBlock;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
public abstract class BrassDiodeTileEntity extends SmartTileEntity implements FlywheelRendered {
public abstract class BrassDiodeTileEntity extends SmartTileEntity {
protected int state;
ScrollValueBehaviour maxState;

View file

@ -5,8 +5,8 @@ import java.util.ArrayList;
import com.jozufozu.flywheel.api.InstanceData;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance;
import com.jozufozu.flywheel.core.PartialModel;
import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.logistics.block.flap.FlapData;
@ -16,7 +16,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.core.Direction;
import net.minecraft.world.level.LightLayer;
public class FunnelInstance extends TileEntityInstance<FunnelTileEntity> implements IDynamicInstance {
public class FunnelInstance extends BlockEntityInstance<FunnelTileEntity> implements DynamicInstance {
private final ArrayList<FlapData> flaps;
@ -65,7 +65,7 @@ public class FunnelInstance extends TileEntityInstance<FunnelTileEntity> impleme
public void beginFrame() {
if (flaps == null) return;
float flapness = tile.flap.get(AnimationTickHolder.getPartialTicks());
float flapness = blockEntity.flap.get(AnimationTickHolder.getPartialTicks());
for (FlapData flap : flaps) {
flap.setFlapness(flapness);

View file

@ -3,7 +3,6 @@ package com.simibubi.create.content.logistics.block.funnel;
import java.lang.ref.WeakReference;
import java.util.List;
import com.jozufozu.flywheel.api.FlywheelRendered;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSoundEvents;
@ -37,7 +36,7 @@ import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.fml.DistExecutor;
public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringInformation, FlywheelRendered {
public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringInformation {
private FilteringBehaviour filtering;
private InvManipulationBehaviour invManipulation;
@ -336,9 +335,4 @@ public class FunnelTileEntity extends SmartTileEntity implements IHaveHoveringIn
.onFunnelTransfer(level, worldPosition, stack);
}
@Override
public boolean shouldRenderNormally() {
return true;
}
}

View file

@ -7,7 +7,7 @@ import com.jozufozu.flywheel.api.InstanceData;
import com.jozufozu.flywheel.api.Instancer;
import com.jozufozu.flywheel.api.Material;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
@ -24,7 +24,7 @@ import net.minecraft.util.Mth;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
public class ArmInstance extends SingleRotatingInstance implements IDynamicInstance {
public class ArmInstance extends SingleRotatingInstance implements DynamicInstance {
final ModelData base;
final ModelData lowerBody;
@ -69,7 +69,7 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta
@Override
public void beginFrame() {
if (arm.phase == ArmTileEntity.Phase.DANCING && tile.getSpeed() != 0) {
if (arm.phase == ArmTileEntity.Phase.DANCING && blockEntity.getSpeed() != 0) {
animateArm(true);
firstRender = true;
return;
@ -107,7 +107,7 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta
int color;
if (rave) {
float renderTick = AnimationTickHolder.getRenderTime(this.arm.getLevel()) + (tile.hashCode() % 64);
float renderTick = AnimationTickHolder.getRenderTime(this.arm.getLevel()) + (blockEntity.hashCode() % 64);
baseAngle = (renderTick * 10) % 360;
lowerArmAngle = Mth.lerp((Mth.sin(renderTick / 4) + 1) / 2, -45, 15);
upperArmAngle = Mth.lerp((Mth.sin(renderTick / 8) + 1) / 4, -45, 95);
@ -172,7 +172,7 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta
@Override
protected Instancer<RotatingData> getModel() {
return getRotatingMaterial().getModel(AllBlockPartials.ARM_COG, tile.getBlockState());
return getRotatingMaterial().getModel(AllBlockPartials.ARM_COG, blockEntity.getBlockState());
}
@Override

View file

@ -517,11 +517,6 @@ public class ArmTileEntity extends KineticTileEntity implements ITransformableTE
return true;
}
@Override
public boolean shouldRenderNormally() {
return true;
}
private class SelectionModeValueBox extends CenteredSideValueBoxTransform {
public SelectionModeValueBox() {

View file

@ -2,8 +2,8 @@ package com.simibubi.create.content.logistics.block.redstone;
import com.jozufozu.flywheel.api.Material;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.Rotate;
import com.jozufozu.flywheel.util.transform.Translate;
@ -15,7 +15,7 @@ import com.simibubi.create.foundation.utility.Color;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.state.properties.AttachFace;
public class AnalogLeverInstance extends TileEntityInstance<AnalogLeverTileEntity> implements IDynamicInstance {
public class AnalogLeverInstance extends BlockEntityInstance<AnalogLeverTileEntity> implements DynamicInstance {
protected final ModelData handle;
protected final ModelData indicator;
@ -42,12 +42,12 @@ public class AnalogLeverInstance extends TileEntityInstance<AnalogLeverTileEntit
@Override
public void beginFrame() {
if (!tile.clientState.settled())
if (!blockEntity.clientState.settled())
animateLever();
}
protected void animateLever() {
float state = tile.clientState.get(AnimationTickHolder.getPartialTicks());
float state = blockEntity.clientState.get(AnimationTickHolder.getPartialTicks());
indicator.setColor(Color.mixColors(0x2C0300, 0xCD0000, state / 15f));

View file

@ -2,7 +2,6 @@ package com.simibubi.create.content.logistics.block.redstone;
import java.util.List;
import com.jozufozu.flywheel.api.FlywheelRendered;
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
@ -16,7 +15,7 @@ import net.minecraft.util.Mth;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggleInformation, FlywheelRendered {
public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggleInformation {
int state = 0;
int lastChange;

View file

@ -2,8 +2,8 @@ package com.simibubi.create.content.schematics.block;
import com.jozufozu.flywheel.api.Material;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.api.instance.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.api.instance.DynamicInstance;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance;
import com.jozufozu.flywheel.core.materials.model.ModelData;
import com.jozufozu.flywheel.util.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
@ -12,7 +12,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.core.Direction;
public class SchematicannonInstance extends TileEntityInstance<SchematicannonTileEntity> implements IDynamicInstance {
public class SchematicannonInstance extends BlockEntityInstance<SchematicannonTileEntity> implements DynamicInstance {
private final ModelData connector;
private final ModelData pipe;
@ -30,12 +30,12 @@ public class SchematicannonInstance extends TileEntityInstance<SchematicannonTil
public void beginFrame() {
float partialTicks = AnimationTickHolder.getPartialTicks();
double[] cannonAngles = SchematicannonRenderer.getCannonAngles(tile, pos, partialTicks);
double[] cannonAngles = SchematicannonRenderer.getCannonAngles(blockEntity, pos, partialTicks);
double yaw = cannonAngles[0];
double pitch = cannonAngles[1];
double recoil = SchematicannonRenderer.getRecoil(tile, partialTicks);
double recoil = SchematicannonRenderer.getRecoil(blockEntity, partialTicks);
PoseStack ms = new PoseStack();
TransformStack msr = TransformStack.cast(ms);

View file

@ -6,7 +6,6 @@ import java.util.List;
import javax.annotation.Nullable;
import com.jozufozu.flywheel.api.FlywheelRendered;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllSoundEvents;
@ -62,7 +61,7 @@ import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.wrapper.EmptyHandler;
public class SchematicannonTileEntity extends SmartTileEntity implements MenuProvider, FlywheelRendered {
public class SchematicannonTileEntity extends SmartTileEntity implements MenuProvider {
public static final int NEIGHBOUR_CHECKING = 100;
public static final int MAX_ANCHOR_DISTANCE = 256;
@ -817,11 +816,6 @@ public class SchematicannonTileEntity extends SmartTileEntity implements MenuPro
return INFINITE_EXTENT_AABB;
}
@Override
public boolean shouldRenderNormally() {
return true;
}
public enum State {
STOPPED, PAUSED, RUNNING;
}

View file

@ -1,10 +1,13 @@
package com.simibubi.create.foundation.data;
import java.util.function.BiFunction;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
import com.jozufozu.flywheel.backend.instancing.entity.IEntityInstanceFactory;
import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance;
import com.tterrag.registrate.AbstractRegistrate;
import com.tterrag.registrate.builders.BuilderCallback;
import com.tterrag.registrate.builders.EntityBuilder;
@ -15,6 +18,7 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.util.NonNullPredicate;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
@ -22,7 +26,8 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
public class CreateEntityBuilder<T extends Entity, P> extends EntityBuilder<T, P> {
@Nullable
private NonNullSupplier<IEntityInstanceFactory<? super T>> instanceFactory;
private NonNullSupplier<BiFunction<MaterialManager, T, EntityInstance<? super T>>> instanceFactory;
private NonNullPredicate<T> renderNormally;
public static <T extends Entity, P> EntityBuilder<T, P> create(AbstractRegistrate<?> owner, P parent, String name, BuilderCallback callback, EntityType.EntityFactory<T> factory, MobCategory classification) {
return (new CreateEntityBuilder<>(owner, parent, name, callback, factory, classification)).defaultLang();
@ -32,23 +37,34 @@ public class CreateEntityBuilder<T extends Entity, P> extends EntityBuilder<T, P
super(owner, parent, name, callback, factory, classification);
}
public CreateEntityBuilder<T, P> instance(NonNullSupplier<IEntityInstanceFactory<? super T>> instanceFactory) {
public CreateEntityBuilder<T, P> instance(NonNullSupplier<BiFunction<MaterialManager, T, EntityInstance<? super T>>> instanceFactory) {
return instance(instanceFactory, true);
}
public CreateEntityBuilder<T, P> instance(NonNullSupplier<BiFunction<MaterialManager, T, EntityInstance<? super T>>> instanceFactory, boolean renderNormally) {
return instance(instanceFactory, be -> true);
}
public CreateEntityBuilder<T, P> instance(NonNullSupplier<BiFunction<MaterialManager, T, EntityInstance<? super T>>> instanceFactory, NonNullPredicate<T> renderNormally) {
if (this.instanceFactory == null) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::registerInstance);
}
this.instanceFactory = instanceFactory;
this.renderNormally = renderNormally;
return this;
}
protected void registerInstance() {
OneTimeEventReceiver.addModListener(FMLClientSetupEvent.class, $ -> {
NonNullSupplier<IEntityInstanceFactory<? super T>> instanceFactory = this.instanceFactory;
NonNullSupplier<BiFunction<MaterialManager, T, EntityInstance<? super T>>> instanceFactory = this.instanceFactory;
if (instanceFactory != null) {
InstancedRenderRegistry.getInstance()
.entity(getEntry())
.factory(instanceFactory.get());
NonNullPredicate<T> renderNormally = this.renderNormally;
InstancedRenderRegistry.configure(getEntry())
.factory(instanceFactory.get())
.skipRender(be -> !renderNormally.test(be))
.apply();
}
});

View file

@ -1,9 +1,12 @@
package com.simibubi.create.foundation.data;
import java.util.function.BiFunction;
import javax.annotation.Nullable;
import com.jozufozu.flywheel.api.MaterialManager;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
import com.jozufozu.flywheel.backend.instancing.tile.ITileInstanceFactory;
import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstance;
import com.tterrag.registrate.AbstractRegistrate;
import com.tterrag.registrate.builders.BlockEntityBuilder;
import com.tterrag.registrate.builders.BuilderCallback;
@ -12,13 +15,15 @@ import com.tterrag.registrate.util.nullness.NonNullSupplier;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.util.NonNullPredicate;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
public class CreateTileEntityBuilder<T extends BlockEntity, P> extends BlockEntityBuilder<T, P> {
@Nullable
private NonNullSupplier<ITileInstanceFactory<? super T>> instanceFactory;
private NonNullSupplier<BiFunction<MaterialManager, T, BlockEntityInstance<? super T>>> instanceFactory;
private NonNullPredicate<T> renderNormally;
public static <T extends BlockEntity, P> BlockEntityBuilder<T, P> create(AbstractRegistrate<?> owner, P parent,
String name, BuilderCallback callback, BlockEntityFactory<T> factory) {
@ -30,23 +35,34 @@ public class CreateTileEntityBuilder<T extends BlockEntity, P> extends BlockEnti
super(owner, parent, name, callback, factory);
}
public CreateTileEntityBuilder<T, P> instance(NonNullSupplier<ITileInstanceFactory<? super T>> instanceFactory) {
public CreateTileEntityBuilder<T, P> instance(NonNullSupplier<BiFunction<MaterialManager, T, BlockEntityInstance<? super T>>> instanceFactory) {
return instance(instanceFactory, true);
}
public CreateTileEntityBuilder<T, P> instance(NonNullSupplier<BiFunction<MaterialManager, T, BlockEntityInstance<? super T>>> instanceFactory, boolean renderNormally) {
return instance(instanceFactory, be -> renderNormally);
}
public CreateTileEntityBuilder<T, P> instance(NonNullSupplier<BiFunction<MaterialManager, T, BlockEntityInstance<? super T>>> instanceFactory, NonNullPredicate<T> renderNormally) {
if (this.instanceFactory == null) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::registerInstance);
}
this.instanceFactory = instanceFactory;
this.renderNormally = renderNormally;
return this;
}
protected void registerInstance() {
OneTimeEventReceiver.addModListener(FMLClientSetupEvent.class, $ -> {
NonNullSupplier<ITileInstanceFactory<? super T>> instanceFactory = this.instanceFactory;
NonNullSupplier<BiFunction<MaterialManager, T, BlockEntityInstance<? super T>>> instanceFactory = this.instanceFactory;
if (instanceFactory != null) {
InstancedRenderRegistry.getInstance()
.tile(getEntry())
.factory(instanceFactory.get());
NonNullPredicate<T> renderNormally = this.renderNormally;
InstancedRenderRegistry.configure(getEntry())
.factory(instanceFactory.get())
.skipRender(be -> !renderNormally.test(be))
.apply();
}
});
}

View file

@ -1,12 +1,12 @@
package com.simibubi.create.foundation.render;
import com.jozufozu.flywheel.core.shader.spec.IBooleanStateProvider;
import com.jozufozu.flywheel.core.shader.spec.BooleanStateProvider;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.KineticDebugger;
import net.minecraft.resources.ResourceLocation;
public class RainbowDebugStateProvider implements IBooleanStateProvider {
public class RainbowDebugStateProvider implements BooleanStateProvider {
public static final RainbowDebugStateProvider INSTANCE = new RainbowDebugStateProvider();
public static final ResourceLocation NAME = Create.asResource("rainbow_debug");

View file

@ -48,8 +48,8 @@ public class TileEntityRenderHelper {
Iterator<BlockEntity> iterator = customRenderTEs.iterator();
while (iterator.hasNext()) {
BlockEntity tileEntity = iterator.next();
if (Backend.canUseInstancing(renderWorld) && InstancedRenderRegistry.getInstance()
.shouldSkipRender(tileEntity)) continue;
if (Backend.canUseInstancing(renderWorld) && InstancedRenderRegistry.shouldSkipRender(tileEntity))
continue;
BlockEntityRenderer<BlockEntity> renderer = Minecraft.getInstance().getBlockEntityRenderDispatcher().getRenderer(tileEntity);
if (renderer == null) {

View file

@ -32,6 +32,6 @@ Technology that empowers the player.'''
[[dependencies.create]]
modId="flywheel"
mandatory=true
versionRange="[1.18-0.5.0,1.18-0.5.1)"
versionRange="[1.18-0.5.1,1.18-0.5.2)"
ordering="AFTER"
side="BOTH"