mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 19:53:41 +01:00
okay you can use it now
fixed a lighting bug (with a hack, again) everything now uses the new api (kinetic components on contraptions are slightly broken)
This commit is contained in:
parent
67d59540cf
commit
e690f2b8ac
41 changed files with 431 additions and 221 deletions
|
@ -5,7 +5,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
|||
import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour.AttachmentTypes;
|
||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
||||
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.*;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -227,7 +227,7 @@ public class AllBlockPartials {
|
|||
return ctx.getRotating().getModel(this, referenceState);
|
||||
}
|
||||
|
||||
public InstancedModel<RotatingData> renderOnRotating(InstancedTileRenderDispatcher ctx, BlockState referenceState) {
|
||||
public InstancedModel<RotatingData> renderOnRotating(InstancedTileRenderer ctx, BlockState referenceState) {
|
||||
return ctx.get(KineticRenderMaterials.ROTATING).getModel(this, referenceState);
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ public class AllBlockPartials {
|
|||
return ctx.getBelts().getModel(this, referenceState);
|
||||
}
|
||||
|
||||
public InstancedModel<BeltData> renderOnBelt(InstancedTileRenderDispatcher ctx, BlockState referenceState) {
|
||||
public InstancedModel<BeltData> renderOnBelt(InstancedTileRenderer ctx, BlockState referenceState) {
|
||||
return ctx.get(KineticRenderMaterials.BELTS).getModel(this, referenceState);
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ public class AllBlockPartials {
|
|||
return renderOnDirectionalSouthRotating(ctx, referenceState, facing);
|
||||
}
|
||||
|
||||
public InstancedModel<RotatingData> renderOnDirectionalSouthRotating(InstancedTileRenderDispatcher dispatcher, BlockState referenceState) {
|
||||
public InstancedModel<RotatingData> renderOnDirectionalSouthRotating(InstancedTileRenderer dispatcher, BlockState referenceState) {
|
||||
Direction facing = referenceState.get(FACING);
|
||||
return renderOnDirectionalSouthRotating(dispatcher, referenceState, facing);
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ public class AllBlockPartials {
|
|||
return renderOnDirectionalSouthRotating(ctx.getKinetics(), referenceState, facing);
|
||||
}
|
||||
|
||||
public InstancedModel<RotatingData> renderOnDirectionalSouthRotating(InstancedTileRenderDispatcher dispatcher, BlockState referenceState, Direction facing) {
|
||||
public InstancedModel<RotatingData> renderOnDirectionalSouthRotating(InstancedTileRenderer dispatcher, BlockState referenceState, Direction facing) {
|
||||
Supplier<MatrixStack> ms = () -> {
|
||||
MatrixStack stack = new MatrixStack();
|
||||
MatrixStacker.of(stack)
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.simibubi.create.content.contraptions.base.*;
|
|||
import com.simibubi.create.content.contraptions.components.actors.*;
|
||||
import com.simibubi.create.content.contraptions.components.clock.CuckooClockRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.crafter.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.HandCrankRenderer;
|
||||
|
@ -14,6 +15,7 @@ import com.simibubi.create.content.contraptions.components.deployer.DeployerRend
|
|||
import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.fan.EncasedFanRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.fan.EncasedFanTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.fan.FanInstance;
|
||||
import com.simibubi.create.content.contraptions.components.fan.NozzleTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
|
||||
|
@ -28,6 +30,7 @@ import com.simibubi.create.content.contraptions.components.motor.CreativeMotorRe
|
|||
import com.simibubi.create.content.contraptions.components.motor.CreativeMotorTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.press.MechanicalPressRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.press.MechanicalPressTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.saw.SawInstance;
|
||||
import com.simibubi.create.content.contraptions.components.saw.SawRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.saw.SawTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.BearingRenderer;
|
||||
|
@ -133,20 +136,21 @@ public class AllTileEntities {
|
|||
.tileEntity("encased_shaft", EncasedShaftTileEntity::new)
|
||||
.validBlocks(AllBlocks.ANDESITE_ENCASED_SHAFT, AllBlocks.BRASS_ENCASED_SHAFT, AllBlocks.ENCASED_CHAIN_DRIVE)
|
||||
.renderer(() -> EncasedShaftRenderer::new)
|
||||
.onRegister(SingleRotatingShaftInstance::register)
|
||||
.onRegister(ShaftInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<AdjustablePulleyTileEntity> ADJUSTABLE_PULLEY = Create.registrate()
|
||||
.tileEntity("adjustable_pulley", AdjustablePulleyTileEntity::new)
|
||||
.validBlocks(AllBlocks.ADJUSTABLE_CHAIN_GEARSHIFT)
|
||||
.renderer(() -> EncasedShaftRenderer::new)
|
||||
.onRegister(SingleRotatingShaftInstance::register)
|
||||
.onRegister(ShaftInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<EncasedFanTileEntity> ENCASED_FAN = Create.registrate()
|
||||
.tileEntity("encased_fan", EncasedFanTileEntity::new)
|
||||
.validBlocks(AllBlocks.ENCASED_FAN)
|
||||
.renderer(() -> EncasedFanRenderer::new)
|
||||
.onRegister(FanInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<NozzleTileEntity> NOZZLE = Create.registrate()
|
||||
|
@ -173,6 +177,7 @@ public class AllTileEntities {
|
|||
.tileEntity("turntable", TurntableTileEntity::new)
|
||||
.validBlocks(AllBlocks.TURNTABLE)
|
||||
.renderer(() -> KineticTileEntityRenderer::new)
|
||||
.onRegister(SingleRotatingInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<HandCrankTileEntity> HAND_CRANK = Create.registrate()
|
||||
|
@ -180,7 +185,7 @@ public class AllTileEntities {
|
|||
.validBlocks(AllBlocks.HAND_CRANK, AllBlocks.COPPER_VALVE_HANDLE)
|
||||
.validBlocks(AllBlocks.DYED_VALVE_HANDLES)
|
||||
.renderer(() -> HandCrankRenderer::new)
|
||||
.onRegister(BackHalfShaftInstance::register)
|
||||
.onRegister(SingleRotatingInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<CuckooClockTileEntity> CUCKOO_CLOCK = Create.registrate()
|
||||
|
@ -223,7 +228,7 @@ public class AllTileEntities {
|
|||
.tileEntity("fluid_valve", FluidValveTileEntity::new)
|
||||
.validBlocks(AllBlocks.FLUID_VALVE)
|
||||
.renderer(() -> FluidValveRenderer::new)
|
||||
.onRegister(SingleRotatingShaftInstance::register)
|
||||
.onRegister(ShaftInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<FluidTankTileEntity> FLUID_TANK = Create.registrate()
|
||||
|
@ -242,7 +247,7 @@ public class AllTileEntities {
|
|||
.tileEntity("hose_pulley", HosePulleyTileEntity::new)
|
||||
.validBlocks(AllBlocks.HOSE_PULLEY)
|
||||
.renderer(() -> HosePulleyRenderer::new)
|
||||
.onRegister(SingleRotatingShaftInstance::register)
|
||||
.onRegister(ShaftInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<SpoutTileEntity> SPOUT = Create.registrate()
|
||||
|
@ -293,7 +298,7 @@ public class AllTileEntities {
|
|||
.tileEntity("mechanical_piston", MechanicalPistonTileEntity::new)
|
||||
.validBlocks(AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON)
|
||||
.renderer(() -> MechanicalPistonRenderer::new)
|
||||
.onRegister(SingleRotatingShaftInstance::register)
|
||||
.onRegister(ShaftInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<WindmillBearingTileEntity> WINDMILL_BEARING = Create.registrate()
|
||||
|
@ -321,7 +326,7 @@ public class AllTileEntities {
|
|||
.tileEntity("rope_pulley", PulleyTileEntity::new)
|
||||
.validBlocks(AllBlocks.ROPE_PULLEY)
|
||||
.renderer(() -> PulleyRenderer::new)
|
||||
.onRegister(SingleRotatingShaftInstance::register)
|
||||
.onRegister(ShaftInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<ChassisTileEntity> CHASSIS = Create.registrate()
|
||||
|
@ -341,6 +346,7 @@ public class AllTileEntities {
|
|||
.tileEntity("saw", SawTileEntity::new)
|
||||
.validBlocks(AllBlocks.MECHANICAL_SAW)
|
||||
.renderer(() -> SawRenderer::new)
|
||||
.onRegister(SawInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<HarvesterTileEntity> HARVESTER = Create.registrate()
|
||||
|
@ -407,7 +413,7 @@ public class AllTileEntities {
|
|||
.tileEntity("mechanical_press", MechanicalPressTileEntity::new)
|
||||
.validBlocks(AllBlocks.MECHANICAL_PRESS)
|
||||
.renderer(() -> MechanicalPressRenderer::new)
|
||||
.onRegister(SingleRotatingShaftInstance::register)
|
||||
.onRegister(ShaftInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<MechanicalMixerTileEntity> MECHANICAL_MIXER = Create.registrate()
|
||||
|
@ -421,7 +427,7 @@ public class AllTileEntities {
|
|||
.tileEntity("deployer", DeployerTileEntity::new)
|
||||
.validBlocks(AllBlocks.DEPLOYER)
|
||||
.renderer(() -> DeployerRenderer::new)
|
||||
.onRegister(SingleRotatingShaftInstance::register)
|
||||
.onRegister(ShaftInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<BasinTileEntity> BASIN = Create.registrate()
|
||||
|
@ -440,7 +446,7 @@ public class AllTileEntities {
|
|||
.tileEntity("mechanical_crafter", MechanicalCrafterTileEntity::new)
|
||||
.validBlocks(AllBlocks.MECHANICAL_CRAFTER)
|
||||
.renderer(() -> MechanicalCrafterRenderer::new)
|
||||
.onRegister(ShaftlessCogInstance::register)
|
||||
.onRegister(MechanicalCrafterInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<SequencedGearshiftTileEntity> SEQUENCED_GEARSHIFT = Create.registrate()
|
||||
|
@ -454,21 +460,21 @@ public class AllTileEntities {
|
|||
.tileEntity("rotation_speed_controller", SpeedControllerTileEntity::new)
|
||||
.validBlocks(AllBlocks.ROTATION_SPEED_CONTROLLER)
|
||||
.renderer(() -> SpeedControllerRenderer::new)
|
||||
.onRegister(SingleRotatingShaftInstance::register)
|
||||
.onRegister(ShaftInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<SpeedGaugeTileEntity> SPEEDOMETER = Create.registrate()
|
||||
.tileEntity("speedometer", SpeedGaugeTileEntity::new)
|
||||
.validBlocks(AllBlocks.SPEEDOMETER)
|
||||
.renderer(() -> GaugeRenderer::speed)
|
||||
.onRegister(SingleRotatingShaftInstance::register)
|
||||
.onRegister(ShaftInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<StressGaugeTileEntity> STRESSOMETER = Create.registrate()
|
||||
.tileEntity("stressometer", StressGaugeTileEntity::new)
|
||||
.validBlocks(AllBlocks.STRESSOMETER)
|
||||
.renderer(() -> GaugeRenderer::stress)
|
||||
.onRegister(SingleRotatingShaftInstance::register)
|
||||
.onRegister(ShaftInstance::register)
|
||||
.register();
|
||||
|
||||
public static final TileEntityEntry<AnalogLeverTileEntity> ANALOG_LEVER = Create.registrate()
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.simibubi.create.foundation.block.render.CustomBlockModels;
|
|||
import com.simibubi.create.foundation.block.render.SpriteShifter;
|
||||
import com.simibubi.create.foundation.item.CustomItemModels;
|
||||
import com.simibubi.create.foundation.item.CustomRenderedItems;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBufferCache;
|
||||
import com.simibubi.create.foundation.render.contraption.ContraptionRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.gl.shader.ShaderHelper;
|
||||
|
@ -44,7 +44,7 @@ public class CreateClient {
|
|||
public static SchematicHandler schematicHandler;
|
||||
public static SchematicAndQuillHandler schematicAndQuillHandler;
|
||||
public static SuperByteBufferCache bufferCache;
|
||||
public static InstancedTileRenderDispatcher kineticRenderer;
|
||||
public static InstancedTileRenderer kineticRenderer;
|
||||
public static final Outliner outliner = new Outliner();
|
||||
|
||||
private static CustomBlockModels customBlockModels;
|
||||
|
@ -72,7 +72,7 @@ public class CreateClient {
|
|||
bufferCache.registerCompartment(KineticTileEntityRenderer.KINETIC_TILE);
|
||||
bufferCache.registerCompartment(ContraptionRenderer.CONTRAPTION, 20);
|
||||
|
||||
kineticRenderer = new InstancedTileRenderDispatcher();
|
||||
kineticRenderer = new InstancedTileRenderer();
|
||||
|
||||
AllKeys.register();
|
||||
AllContainerTypes.registerScreenFactories();
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
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 BackHalfShaftInstance extends HalfShaftInstance {
|
||||
public static void register(TileEntityType<? extends KineticTileEntity> type) {
|
||||
InstancedTileRenderRegistry.instance.register(type, BackHalfShaftInstance::new);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, BackHalfShaftInstance::new));
|
||||
}
|
||||
|
||||
public BackHalfShaftInstance(InstancedTileRenderDispatcher modelManager, KineticTileEntity tile) {
|
||||
public BackHalfShaftInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
|
@ -9,13 +9,16 @@ import net.minecraft.block.BlockState;
|
|||
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 HalfShaftInstance extends SingleRotatingInstance {
|
||||
public static void register(TileEntityType<? extends KineticTileEntity> type) {
|
||||
InstancedTileRenderRegistry.instance.register(type, HalfShaftInstance::new);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, HalfShaftInstance::new));
|
||||
}
|
||||
|
||||
public HalfShaftInstance(InstancedTileRenderDispatcher modelManager, KineticTileEntity tile) {
|
||||
public HalfShaftInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
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 HorizontalHalfShaftInstance extends HalfShaftInstance {
|
||||
public static void register(TileEntityType<? extends KineticTileEntity> type) {
|
||||
InstancedTileRenderRegistry.instance.register(type, HorizontalHalfShaftInstance::new);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, HorizontalHalfShaftInstance::new));
|
||||
}
|
||||
|
||||
public HorizontalHalfShaftInstance(InstancedTileRenderDispatcher modelManager, KineticTileEntity tile) {
|
||||
public HorizontalHalfShaftInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -472,9 +472,7 @@ public abstract class KineticTileEntity extends SmartTileEntity
|
|||
@Override
|
||||
public void requestModelDataUpdate() {
|
||||
super.requestModelDataUpdate();
|
||||
if (this.removed) {
|
||||
FastRenderDispatcher.enqueueRemove(this);
|
||||
} else {
|
||||
if (!this.removed) {
|
||||
FastRenderDispatcher.enqueueUpdate(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.simibubi.create.content.contraptions.KineticDebugger;
|
|||
import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock;
|
||||
import com.simibubi.create.foundation.render.Compartment;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.IInstancedTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstanceContext;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
|
@ -26,7 +25,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
|||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
@EventBusSubscriber(value = Dist.CLIENT)
|
||||
public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTileEntity> implements IInstancedTileEntityRenderer<KineticTileEntity> {
|
||||
public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTileEntity> {
|
||||
|
||||
public static final Compartment<BlockState> KINETIC_TILE = new Compartment<>();
|
||||
public static boolean rainbowMode = false;
|
||||
|
@ -45,12 +44,10 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
|
|||
// addInstanceData(new InstanceContext.World<>(te));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInstanceData(InstanceContext<KineticTileEntity> ctx) {
|
||||
renderRotatingBuffer(ctx, getRotatedModel(ctx));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForRebuild(InstanceContext<KineticTileEntity> ctx) {
|
||||
getRotatedModel(ctx).clearInstanceData();
|
||||
}
|
||||
|
|
|
@ -3,54 +3,46 @@ package com.simibubi.create.content.contraptions.base;
|
|||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.contraptions.relays.elementary.CogWheelBlock;
|
||||
import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.*;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class KineticTileInstance<T extends KineticTileEntity> extends TileEntityInstance<T> {
|
||||
|
||||
public KineticTileInstance(InstancedTileRenderDispatcher modelManager, T tile) {
|
||||
public KineticTileInstance(InstancedTileRenderer modelManager, T tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
protected void updateRotation(InstanceKey<RotatingData> key, Direction.Axis axis) {
|
||||
protected final void updateRotation(InstanceKey<RotatingData> key, Direction.Axis axis) {
|
||||
key.modifyInstance(data -> {
|
||||
final BlockPos pos = tile.getPos();
|
||||
|
||||
data.setRotationalSpeed(tile.getSpeed())
|
||||
.setRotationOffset(getRotationOffsetForPosition(tile, pos, axis))
|
||||
.setRotationOffset(getRotationOffset(axis))
|
||||
.setRotationAxis(axis);
|
||||
});
|
||||
}
|
||||
|
||||
protected final Consumer<RotatingData> setupFunc(float speed, Direction.Axis axis) {
|
||||
return data -> {
|
||||
final BlockPos pos = tile.getPos();
|
||||
|
||||
data.setBlockLight(tile.getWorld().getLightLevel(LightType.BLOCK, tile.getPos()))
|
||||
.setSkyLight(tile.getWorld().getLightLevel(LightType.SKY, tile.getPos()))
|
||||
data.setBlockLight(tile.getWorld().getLightLevel(LightType.BLOCK, pos))
|
||||
.setSkyLight(tile.getWorld().getLightLevel(LightType.SKY, pos))
|
||||
.setTileEntity(tile)
|
||||
.setRotationalSpeed(speed)
|
||||
.setRotationOffset(getRotationOffsetForPosition(tile, pos, axis))
|
||||
.setRotationOffset(getRotationOffset(axis))
|
||||
.setRotationAxis(axis);
|
||||
};
|
||||
}
|
||||
|
||||
protected final void relight(KineticData<?> data) {
|
||||
World world = tile.getWorld();
|
||||
|
||||
data.setBlockLight(world.getLightLevel(LightType.BLOCK, tile.getPos()))
|
||||
.setSkyLight(world.getLightLevel(LightType.SKY, tile.getPos()));
|
||||
data.setBlockLight(world.getLightLevel(LightType.BLOCK, pos))
|
||||
.setSkyLight(world.getLightLevel(LightType.SKY, pos));
|
||||
}
|
||||
|
||||
protected static float getRotationOffsetForPosition(KineticTileEntity te, final BlockPos pos, final Direction.Axis axis) {
|
||||
float offset = CogWheelBlock.isLargeCog(te.getBlockState()) ? 11.25f : 0;
|
||||
protected float getRotationOffset(final Direction.Axis axis) {
|
||||
float offset = CogWheelBlock.isLargeCog(lastState) ? 11.25f : 0;
|
||||
double d = (((axis == Direction.Axis.X) ? 0 : pos.getX()) + ((axis == Direction.Axis.Y) ? 0 : pos.getY())
|
||||
+ ((axis == Direction.Axis.Z) ? 0 : pos.getZ())) % 2;
|
||||
if (d == 0) {
|
||||
|
@ -64,9 +56,8 @@ public abstract class KineticTileInstance<T extends KineticTileEntity> extends T
|
|||
.with(ShaftBlock.AXIS, axis);
|
||||
}
|
||||
|
||||
public static Direction.Axis getRotationAxisOf(KineticTileEntity te) {
|
||||
return ((IRotate) te.getBlockState()
|
||||
.getBlock()).getRotationAxis(te.getBlockState());
|
||||
public Direction.Axis getRotationAxis() {
|
||||
return ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
|
||||
}
|
||||
|
||||
protected final RenderMaterial<InstancedModel<RotatingData>> rotatingMaterial() {
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
public class ShaftlessCogInstance extends SingleRotatingInstance {
|
||||
public static void register(TileEntityType<? extends KineticTileEntity> type) {
|
||||
InstancedTileRenderRegistry.instance.register(type, ShaftlessCogInstance::new);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, ShaftlessCogInstance::new));
|
||||
}
|
||||
|
||||
public ShaftlessCogInstance(InstancedTileRenderDispatcher modelManager, KineticTileEntity tile) {
|
||||
public ShaftlessCogInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.content.contraptions.base;
|
||||
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstanceKey;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
|
@ -8,29 +8,32 @@ import com.simibubi.create.foundation.render.instancing.RotatingData;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
import static com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer.KINETIC_TILE;
|
||||
|
||||
public class SingleRotatingInstance extends KineticTileInstance<KineticTileEntity> {
|
||||
public static void register(TileEntityType<? extends KineticTileEntity> type) {
|
||||
InstancedTileRenderRegistry.instance.register(type, SingleRotatingInstance::new);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, SingleRotatingInstance::new));
|
||||
}
|
||||
|
||||
protected InstanceKey<RotatingData> rotatingModelKey;
|
||||
|
||||
public SingleRotatingInstance(InstancedTileRenderDispatcher modelManager, KineticTileEntity tile) {
|
||||
public SingleRotatingInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
Direction.Axis axis = ((IRotate) tile.getBlockState().getBlock()).getRotationAxis(tile.getBlockState());
|
||||
Direction.Axis axis = ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
|
||||
rotatingModelKey = getModel().setupInstance(setupFunc(tile.getSpeed(), axis));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
Direction.Axis axis = ((IRotate) tile.getBlockState().getBlock()).getRotationAxis(tile.getBlockState());
|
||||
Direction.Axis axis = ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
|
||||
updateRotation(rotatingModelKey, axis);
|
||||
}
|
||||
|
||||
|
@ -46,7 +49,7 @@ public class SingleRotatingInstance extends KineticTileInstance<KineticTileEntit
|
|||
}
|
||||
|
||||
protected BlockState getRenderedBlockState() {
|
||||
return tile.getBlockState();
|
||||
return lastState;
|
||||
}
|
||||
|
||||
protected InstancedModel<RotatingData> getModel() {
|
||||
|
|
|
@ -3,18 +3,20 @@ package com.simibubi.create.content.contraptions.components.actors;
|
|||
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.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
public class DrillInstance extends SingleRotatingInstance {
|
||||
public static void register(TileEntityType<? extends KineticTileEntity> type) {
|
||||
InstancedTileRenderRegistry.instance.register(type, DrillInstance::new);
|
||||
}
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, DrillInstance::new)); }
|
||||
|
||||
public DrillInstance(InstancedTileRenderDispatcher modelManager, KineticTileEntity tile) {
|
||||
public DrillInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.simibubi.create.content.contraptions.components.crafter;
|
||||
|
||||
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.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class MechanicalCrafterInstance extends SingleRotatingInstance {
|
||||
public static void register(TileEntityType<? extends KineticTileEntity> type) {
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, MechanicalCrafterInstance::new));
|
||||
}
|
||||
|
||||
public MechanicalCrafterInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InstancedModel<RotatingData> getModel() {
|
||||
Direction facing = lastState.get(MechanicalCrafterBlock.HORIZONTAL_FACING);
|
||||
|
||||
Supplier<MatrixStack> ms = () -> {
|
||||
MatrixStack stack = new MatrixStack();
|
||||
MatrixStacker.of(stack)
|
||||
.centre()
|
||||
.rotateZ(90)
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(AngleHelper.verticalAngle(facing))
|
||||
.unCentre();
|
||||
return stack;
|
||||
};
|
||||
return rotatingMaterial().getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, lastState, facing, ms);
|
||||
}
|
||||
}
|
|
@ -9,7 +9,6 @@ import com.simibubi.create.content.contraptions.components.deployer.DeployerTile
|
|||
import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.State;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.IInstancedTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstanceContext;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
|
@ -33,7 +32,7 @@ import net.minecraft.world.World;
|
|||
import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE;
|
||||
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
|
||||
|
||||
public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity> implements IInstancedTileEntityRenderer<DeployerTileEntity> {
|
||||
public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity> {
|
||||
|
||||
public DeployerRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
|
@ -53,12 +52,10 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInstanceData(InstanceContext<DeployerTileEntity> ctx) {
|
||||
KineticTileEntityRenderer.renderRotatingKineticBlock(ctx, getRenderedBlockState(ctx.te));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForRebuild(InstanceContext<DeployerTileEntity> ctx) {
|
||||
KineticTileEntityRenderer.markForRebuild(ctx, getRenderedBlockState(ctx.te));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
package com.simibubi.create.content.contraptions.components.fan;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstanceKey;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
public class FanInstance extends KineticTileInstance<EncasedFanTileEntity> {
|
||||
public static void register(TileEntityType<? extends EncasedFanTileEntity> type) {
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, FanInstance::new));
|
||||
}
|
||||
|
||||
protected InstanceKey<RotatingData> shaft;
|
||||
protected InstanceKey<RotatingData> fan;
|
||||
|
||||
public FanInstance(InstancedTileRenderer modelManager, EncasedFanTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
final Direction direction = lastState.get(FACING);
|
||||
final Direction.Axis axis = ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
|
||||
|
||||
InstancedModel<RotatingData> shaftHalf =
|
||||
AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouthRotating(modelManager, lastState, direction.getOpposite());
|
||||
InstancedModel<RotatingData> fanInner =
|
||||
AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectionalSouthRotating(modelManager, lastState, direction.getOpposite());
|
||||
|
||||
shaft = shaftHalf.setupInstance(data -> {
|
||||
BlockPos behind = pos.offset(direction.getOpposite());
|
||||
int blockLight = world.getLightLevel(LightType.BLOCK, behind);
|
||||
int skyLight = world.getLightLevel(LightType.SKY, behind);
|
||||
|
||||
data.setRotationalSpeed(tile.getSpeed())
|
||||
.setRotationOffset(getRotationOffset(axis))
|
||||
.setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector())
|
||||
.setTileEntity(tile)
|
||||
.setBlockLight(blockLight)
|
||||
.setSkyLight(skyLight);
|
||||
});
|
||||
fan = fanInner.setupInstance(data -> {
|
||||
BlockPos inFront = pos.offset(direction);
|
||||
int blockLight = world.getLightLevel(LightType.BLOCK, inFront);
|
||||
int skyLight = world.getLightLevel(LightType.SKY, inFront);
|
||||
|
||||
data.setRotationalSpeed(getFanSpeed())
|
||||
.setRotationOffset(getRotationOffset(axis))
|
||||
.setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector())
|
||||
.setTileEntity(tile)
|
||||
.setBlockLight(blockLight)
|
||||
.setSkyLight(skyLight);
|
||||
});
|
||||
}
|
||||
|
||||
private float getFanSpeed() {
|
||||
float speed = tile.getSpeed() * 5;
|
||||
if (speed > 0)
|
||||
speed = MathHelper.clamp(speed, 80, 64 * 20);
|
||||
if (speed < 0)
|
||||
speed = MathHelper.clamp(speed, -64 * 20, -80);
|
||||
return speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUpdate() {
|
||||
Direction.Axis axis = lastState.get(FACING).getAxis();
|
||||
updateRotation(shaft, axis);
|
||||
|
||||
fan.modifyInstance(data -> {
|
||||
data.setRotationalSpeed(getFanSpeed())
|
||||
.setRotationOffset(getRotationOffset(axis))
|
||||
.setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLight() {
|
||||
final Direction direction = lastState.get(FACING);
|
||||
|
||||
shaft.modifyInstance(data -> {
|
||||
BlockPos behind = pos.offset(direction.getOpposite());
|
||||
int blockLight = world.getLightLevel(LightType.BLOCK, behind);
|
||||
int skyLight = world.getLightLevel(LightType.SKY, behind);
|
||||
data.setBlockLight(blockLight)
|
||||
.setSkyLight(skyLight);
|
||||
});
|
||||
fan.modifyInstance(data -> {
|
||||
BlockPos inFront = pos.offset(direction);
|
||||
int blockLight = world.getLightLevel(LightType.BLOCK, inFront);
|
||||
int skyLight = world.getLightLevel(LightType.SKY, inFront);
|
||||
data.setBlockLight(blockLight)
|
||||
.setSkyLight(skyLight);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
shaft.delete();
|
||||
fan.delete();
|
||||
shaft = fan = null;
|
||||
}
|
||||
}
|
|
@ -3,18 +3,20 @@ package com.simibubi.create.content.contraptions.components.millstone;
|
|||
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.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
public class MillStoneCogInstance extends SingleRotatingInstance {
|
||||
public static void register(TileEntityType<? extends KineticTileEntity> type) {
|
||||
InstancedTileRenderRegistry.instance.register(type, MillStoneCogInstance::new);
|
||||
}
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, MillStoneCogInstance::new)); }
|
||||
|
||||
public MillStoneCogInstance(InstancedTileRenderDispatcher modelManager, KineticTileEntity tile) {
|
||||
public MillStoneCogInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,11 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer {
|
|||
super(dispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobalRenderer(KineticTileEntity tile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSafe(KineticTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package com.simibubi.create.content.contraptions.components.saw;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
public class SawInstance extends SingleRotatingInstance {
|
||||
public static void register(TileEntityType<? extends KineticTileEntity> type) {
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, SawInstance::new));
|
||||
}
|
||||
|
||||
public SawInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InstancedModel<RotatingData> getModel() {
|
||||
if (lastState.get(FACING).getAxis().isHorizontal())
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouthRotating(modelManager, lastState.rotate(tile.getWorld(), tile.getPos(), Rotation.CLOCKWISE_180));
|
||||
else
|
||||
return rotatingMaterial().getModel(KineticTileEntityRenderer.KINETIC_TILE, shaft(getRotationAxis()));
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
|||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.instancing.IInstancedTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstanceContext;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
|
@ -32,7 +31,7 @@ import net.minecraft.util.math.Vec3d;
|
|||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> implements IInstancedTileEntityRenderer<SawTileEntity> {
|
||||
public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
||||
|
||||
public SawRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
|
@ -47,12 +46,10 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> implement
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInstanceData(InstanceContext<SawTileEntity> ctx) {
|
||||
KineticTileEntityRenderer.renderRotatingBuffer(ctx, getRotatedModel(ctx));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForRebuild(InstanceContext<SawTileEntity> ctx) {
|
||||
getRotatedModel(ctx).clearInstanceData();
|
||||
}
|
||||
|
|
|
@ -3,18 +3,21 @@ package com.simibubi.create.content.contraptions.fluids;
|
|||
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.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
public class PumpCogInstance extends SingleRotatingInstance {
|
||||
public static void register(TileEntityType<? extends KineticTileEntity> type) {
|
||||
InstancedTileRenderRegistry.instance.register(type, PumpCogInstance::new);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, PumpCogInstance::new));
|
||||
}
|
||||
|
||||
public PumpCogInstance(InstancedTileRenderDispatcher modelManager, KineticTileEntity tile) {
|
||||
public PumpCogInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.content.contraptions.relays.advanced;
|
|||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.IInstancedTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstanceContext;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
|
@ -10,7 +9,7 @@ import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRendere
|
|||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
|
||||
public class SpeedControllerRenderer extends SmartTileEntityRenderer<SpeedControllerTileEntity> implements IInstancedTileEntityRenderer<SpeedControllerTileEntity> {
|
||||
public class SpeedControllerRenderer extends SmartTileEntityRenderer<SpeedControllerTileEntity> {
|
||||
|
||||
public SpeedControllerRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
|
@ -23,12 +22,10 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer<SpeedContro
|
|||
// addInstanceData(new InstanceContext.World<>(tileEntityIn));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInstanceData(InstanceContext<SpeedControllerTileEntity> ctx) {
|
||||
KineticTileEntityRenderer.renderRotatingBuffer(ctx, getRotatedModel(ctx));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForRebuild(InstanceContext<SpeedControllerTileEntity> ctx) {
|
||||
getRotatedModel(ctx).clearInstanceData();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
||||
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.*;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
@ -14,6 +14,8 @@ import net.minecraft.tileentity.TileEntityType;
|
|||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Consumer;
|
||||
|
@ -21,7 +23,8 @@ import java.util.function.Supplier;
|
|||
|
||||
public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
|
||||
public static void register(TileEntityType<? extends BeltTileEntity> type) {
|
||||
InstancedTileRenderRegistry.instance.register(type, BeltInstance::new);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, BeltInstance::new));
|
||||
}
|
||||
|
||||
private boolean upward;
|
||||
|
@ -35,7 +38,7 @@ public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
|
|||
protected ArrayList<InstanceKey<BeltData>> keys;
|
||||
protected InstanceKey<RotatingData> pulleyKey;
|
||||
|
||||
public BeltInstance(InstancedTileRenderDispatcher modelManager, BeltTileEntity tile) {
|
||||
public BeltInstance(InstancedTileRenderer modelManager, BeltTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
@ -75,7 +78,7 @@ public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
|
|||
if (tile.hasPulley()) {
|
||||
InstancedModel<RotatingData> pulleyModel = getPulleyModel(blockState);
|
||||
|
||||
pulleyKey = pulleyModel.setupInstance(setupFunc(tile.getSpeed(), getRotationAxisOf(tile)));
|
||||
pulleyKey = pulleyModel.setupInstance(setupFunc(tile.getSpeed(), getRotationAxis()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +89,7 @@ public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
|
|||
}
|
||||
|
||||
if (pulleyKey != null) {
|
||||
updateRotation(pulleyKey, getRotationAxisOf(tile));
|
||||
updateRotation(pulleyKey, getRotationAxis());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
|||
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
|
||||
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
||||
import com.simibubi.create.foundation.render.ShadowRenderHelper;
|
||||
import com.simibubi.create.foundation.render.instancing.*;
|
||||
import com.simibubi.create.foundation.render.instancing.BeltData;
|
||||
import com.simibubi.create.foundation.render.instancing.InstanceContext;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
@ -31,7 +34,7 @@ import net.minecraft.world.LightType;
|
|||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> implements IInstancedTileEntityRenderer<BeltTileEntity> {
|
||||
public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
||||
|
||||
public BeltRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
|
@ -54,7 +57,6 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> impleme
|
|||
return te.isController();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInstanceData(InstanceContext<BeltTileEntity> ctx) {
|
||||
BeltTileEntity te = ctx.te;
|
||||
BlockState blockState = te.getBlockState();
|
||||
|
@ -146,7 +148,6 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> impleme
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markForRebuild(InstanceContext<BeltTileEntity> ctx) {
|
||||
BeltTileEntity te = ctx.te;
|
||||
|
||||
|
|
|
@ -2,24 +2,27 @@ package com.simibubi.create.content.contraptions.relays.encased;
|
|||
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
public class SingleRotatingShaftInstance extends SingleRotatingInstance {
|
||||
public class ShaftInstance extends SingleRotatingInstance {
|
||||
|
||||
public static void register(TileEntityType<? extends KineticTileEntity> type) {
|
||||
InstancedTileRenderRegistry.instance.register(type, SingleRotatingShaftInstance::new);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, ShaftInstance::new));
|
||||
}
|
||||
|
||||
public SingleRotatingShaftInstance(InstancedTileRenderDispatcher dispatcher, KineticTileEntity tile) {
|
||||
public ShaftInstance(InstancedTileRenderer dispatcher, KineticTileEntity tile) {
|
||||
super(dispatcher, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState getRenderedBlockState() {
|
||||
return shaft(getRotationAxisOf(tile));
|
||||
return shaft(getRotationAxis());
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.relays.encased;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstanceKey;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
|
@ -14,17 +14,20 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SplitShaftInstance extends KineticTileInstance<SplitShaftTileEntity> {
|
||||
public static void register(TileEntityType<? extends SplitShaftTileEntity> type) {
|
||||
InstancedTileRenderRegistry.instance.register(type, SplitShaftInstance::new);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, SplitShaftInstance::new));
|
||||
}
|
||||
|
||||
protected ArrayList<InstanceKey<RotatingData>> keys;
|
||||
|
||||
public SplitShaftInstance(InstancedTileRenderDispatcher modelManager, SplitShaftTileEntity tile) {
|
||||
public SplitShaftInstance(InstancedTileRenderer modelManager, SplitShaftTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
@ -80,7 +83,7 @@ public class SplitShaftInstance extends KineticTileInstance<SplitShaftTileEntity
|
|||
final BlockPos pos = tile.getPos();
|
||||
|
||||
data.setRotationalSpeed(tile.getSpeed() * tile.getRotationSpeedModifier(dir))
|
||||
.setRotationOffset(getRotationOffsetForPosition(tile, pos, axis))
|
||||
.setRotationOffset(getRotationOffset(axis))
|
||||
.setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.relays.gearbox;
|
|||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstanceKey;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
|
@ -14,19 +14,22 @@ import net.minecraft.tileentity.TileEntityType;
|
|||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
|
||||
public static void register(TileEntityType<? extends GearboxTileEntity> type) {
|
||||
InstancedTileRenderRegistry.instance.register(type, GearboxInstance::new);
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, GearboxInstance::new));
|
||||
}
|
||||
|
||||
protected EnumMap<Direction, InstanceKey<RotatingData>> keys;
|
||||
protected Direction sourceFacing;
|
||||
|
||||
public GearboxInstance(InstancedTileRenderDispatcher modelManager, GearboxTileEntity tile) {
|
||||
public GearboxInstance(InstancedTileRenderer modelManager, GearboxTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
@ -54,7 +57,7 @@ public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
|
|||
data.setBlockLight(blockLight)
|
||||
.setSkyLight(skyLight)
|
||||
.setRotationalSpeed(getSpeed(direction))
|
||||
.setRotationOffset(getRotationOffsetForPosition(tile, pos, axis))
|
||||
.setRotationOffset(getRotationOffset(axis))
|
||||
.setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector())
|
||||
.setTileEntity(tile);
|
||||
});
|
||||
|
@ -93,7 +96,7 @@ public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
|
|||
Direction.Axis axis = direction.getAxis();
|
||||
|
||||
data.setRotationalSpeed(getSpeed(direction))
|
||||
.setRotationOffset(getRotationOffsetForPosition(tile, pos, axis))
|
||||
.setRotationOffset(getRotationOffset(axis))
|
||||
.setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,12 +3,21 @@ package com.simibubi.create.content.logistics.block.mechanicalArm;
|
|||
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.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedTileRenderRegistry;
|
||||
import com.simibubi.create.foundation.render.instancing.RotatingData;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
||||
public class ArmInstance extends SingleRotatingInstance {
|
||||
public ArmInstance(InstancedTileRenderDispatcher modelManager, KineticTileEntity tile) {
|
||||
public static void register(TileEntityType<? extends KineticTileEntity> type) {
|
||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||
InstancedTileRenderRegistry.instance.register(type, ArmInstance::new));
|
||||
}
|
||||
|
||||
public ArmInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ import net.minecraftforge.client.event.EntityViewRenderEvent;
|
|||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
||||
import net.minecraftforge.event.TickEvent.Phase;
|
||||
import net.minecraftforge.event.TickEvent.RenderTickEvent;
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.simibubi.create.foundation.mixin;
|
||||
|
||||
import com.simibubi.create.foundation.render.FastRenderDispatcher;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.LocalCapture;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Mixin(World.class)
|
||||
public class OnRemoveTileMixin {
|
||||
|
||||
@Shadow @Final public boolean isRemote;
|
||||
|
||||
/**
|
||||
* JUSTIFICATION: This method is called whenever a tile entity is removed due
|
||||
* to a change in block state, even on the client. By hooking into this method,
|
||||
* we gain easy access to the information while having no impact on performance.
|
||||
*/
|
||||
@Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/World;getTileEntity(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/tileentity/TileEntity;"), method = "removeTileEntity", locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void onRemoveTile(BlockPos pos, CallbackInfo ci, TileEntity te) {
|
||||
if (isRemote) FastRenderDispatcher.enqueueRemove(te);
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.foundation.render.contraption.ContraptionRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.gl.shader.ShaderHelper;
|
||||
import com.simibubi.create.foundation.render.instancing.TileEntityInstance;
|
||||
import com.simibubi.create.foundation.render.light.ILightListener;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.WorldAttached;
|
||||
|
@ -25,13 +26,17 @@ import net.minecraft.world.LightType;
|
|||
import net.minecraft.world.chunk.Chunk;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class FastRenderDispatcher {
|
||||
|
||||
public static WorldAttached<ConcurrentLinkedQueue<TileEntity>> addedTiles = new WorldAttached<>(ConcurrentLinkedQueue::new);
|
||||
public static WorldAttached<ConcurrentLinkedQueue<TileEntity>> removedTiles = new WorldAttached<>(ConcurrentLinkedQueue::new);
|
||||
public static WorldAttached<ConcurrentLinkedQueue<TileEntity>> queuedUpdates = new WorldAttached<>(ConcurrentLinkedQueue::new);
|
||||
public static WorldAttached<ConcurrentLinkedQueue<TileEntity>> queuedRemovals = new WorldAttached<>(ConcurrentLinkedQueue::new);
|
||||
public static WorldAttached<ConcurrentLinkedQueue<TileEntityInstance<?>>> addedLastTick = new WorldAttached<>(ConcurrentLinkedQueue::new);
|
||||
|
||||
private static Matrix4f projectionMatrixThisFrame = null;
|
||||
|
||||
|
@ -40,34 +45,28 @@ public class FastRenderDispatcher {
|
|||
}
|
||||
|
||||
public static void enqueueUpdate(TileEntity te) {
|
||||
addedTiles.get(te.getWorld()).add(te);
|
||||
queuedUpdates.get(te.getWorld()).add(te);
|
||||
}
|
||||
|
||||
public static void enqueueRemove(TileEntity te) {
|
||||
removedTiles.get(te.getWorld()).add(te);
|
||||
queuedRemovals.get(te.getWorld()).add(te);
|
||||
}
|
||||
|
||||
public static void tick() {
|
||||
ClientWorld world = Minecraft.getInstance().world;
|
||||
|
||||
ConcurrentLinkedQueue<TileEntity> added = addedTiles.get(world);
|
||||
runQueue(addedLastTick.get(world), TileEntityInstance::updateLight);
|
||||
runQueue(queuedUpdates.get(world), CreateClient.kineticRenderer::update);
|
||||
runQueue(queuedRemovals.get(world), CreateClient.kineticRenderer::remove);
|
||||
}
|
||||
|
||||
if (added != null) {
|
||||
while (!added.isEmpty()) {
|
||||
TileEntity te = added.poll();
|
||||
private static <T> void runQueue(@Nullable Queue<T> q, Consumer<T> action) {
|
||||
if (q == null) return;
|
||||
|
||||
CreateClient.kineticRenderer.update(te);
|
||||
}
|
||||
}
|
||||
while (!q.isEmpty()) {
|
||||
T t = q.poll();
|
||||
|
||||
ConcurrentLinkedQueue<TileEntity> removed = removedTiles.get(world);
|
||||
|
||||
if (removed != null) {
|
||||
while (!removed.isEmpty()) {
|
||||
TileEntity te = removed.poll();
|
||||
|
||||
CreateClient.kineticRenderer.remove(te);
|
||||
}
|
||||
action.accept(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.simibubi.create.foundation.render;
|
||||
|
||||
import com.simibubi.create.foundation.render.contraption.RenderedContraption;
|
||||
import com.simibubi.create.foundation.render.gl.shader.Shader;
|
||||
import com.simibubi.create.foundation.render.gl.shader.ShaderCallback;
|
||||
import com.simibubi.create.foundation.render.gl.shader.ShaderHelper;
|
||||
|
@ -13,12 +12,12 @@ import javax.annotation.Nullable;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class InstancedTileRenderDispatcher {
|
||||
public class InstancedTileRenderer {
|
||||
protected Map<TileEntity, TileEntityInstance<?>> renderers = new HashMap<>();
|
||||
|
||||
protected Map<MaterialType<?>, RenderMaterial<?>> materials = new HashMap<>();
|
||||
|
||||
public InstancedTileRenderDispatcher() {
|
||||
public InstancedTileRenderer() {
|
||||
registerMaterials();
|
||||
}
|
||||
|
||||
|
@ -40,7 +39,10 @@ public class InstancedTileRenderDispatcher {
|
|||
} else {
|
||||
TileEntityInstance<? super T> renderer = InstancedTileRenderRegistry.instance.create(this, tile);
|
||||
|
||||
renderers.put(tile, renderer);
|
||||
if (renderer != null) {
|
||||
FastRenderDispatcher.addedLastTick.get(tile.getWorld()).add(renderer);
|
||||
renderers.put(tile, renderer);
|
||||
}
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
@ -75,25 +77,11 @@ public class InstancedTileRenderDispatcher {
|
|||
}
|
||||
}
|
||||
|
||||
public <T extends TileEntity> void addInstancedData(RenderedContraption c, T te, IInstancedTileEntityRenderer<T> renderer) {
|
||||
renderer.addInstanceData(new InstanceContext.Contraption<>(te, c));
|
||||
}
|
||||
|
||||
/**
|
||||
* This function should be called after building instances.
|
||||
* It must be called either on the render thread before committing to rendering, or in a place where there are
|
||||
* guaranteed to be no race conditions with the render thread, i.e. when constructing a FastContraptionRenderer.
|
||||
*/
|
||||
public void markAllDirty() {
|
||||
for (RenderMaterial<?> material : materials.values()) {
|
||||
material.runOnAll(InstancedModel::markDirty);
|
||||
}
|
||||
}
|
||||
|
||||
public void invalidate() {
|
||||
for (RenderMaterial<?> material : materials.values()) {
|
||||
material.delete();
|
||||
}
|
||||
renderers.clear();
|
||||
}
|
||||
|
||||
public void render(RenderType layer, Matrix4f projection, Matrix4f view) {
|
|
@ -1,6 +1,6 @@
|
|||
package com.simibubi.create.foundation.render.contraption;
|
||||
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.gl.shader.Shader;
|
||||
import com.simibubi.create.foundation.render.instancing.BeltModel;
|
||||
import com.simibubi.create.foundation.render.instancing.KineticRenderMaterials;
|
||||
|
@ -8,7 +8,7 @@ import com.simibubi.create.foundation.render.instancing.RenderMaterial;
|
|||
import com.simibubi.create.foundation.render.instancing.RotatingModel;
|
||||
import com.simibubi.create.foundation.render.instancing.actors.RotatingActorModel;
|
||||
|
||||
public class ContraptionKineticRenderer extends InstancedTileRenderDispatcher {
|
||||
public class ContraptionKineticRenderer extends InstancedTileRenderer {
|
||||
|
||||
@Override
|
||||
public void registerMaterials() {
|
||||
|
|
|
@ -7,14 +7,15 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Con
|
|||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.foundation.render.gl.shader.ShaderHelper;
|
||||
import com.simibubi.create.foundation.render.instancing.*;
|
||||
import com.simibubi.create.foundation.render.instancing.IInstanceRendered;
|
||||
import com.simibubi.create.foundation.render.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.instancing.KineticRenderMaterials;
|
||||
import com.simibubi.create.foundation.render.instancing.RenderMaterial;
|
||||
import com.simibubi.create.foundation.render.instancing.actors.StaticRotatingActorData;
|
||||
import com.simibubi.create.foundation.render.light.ContraptionLighter;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.template.Template;
|
||||
|
@ -44,7 +45,6 @@ public class RenderedContraption {
|
|||
buildLayers(contraption);
|
||||
buildInstancedTiles(contraption);
|
||||
buildActors(contraption);
|
||||
kinetics.markAllDirty();
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
|
@ -91,11 +91,7 @@ public class RenderedContraption {
|
|||
if (!tileEntities.isEmpty()) {
|
||||
for (TileEntity te : tileEntities) {
|
||||
if (te instanceof IInstanceRendered) {
|
||||
TileEntityRenderer<TileEntity> renderer = TileEntityRendererDispatcher.instance.getRenderer(te);
|
||||
|
||||
if (renderer instanceof IInstancedTileEntityRenderer) {
|
||||
kinetics.addInstancedData(this, te, (IInstancedTileEntityRenderer<? super TileEntity>) renderer);
|
||||
}
|
||||
kinetics.getRenderer(te); // this is enough to instantiate the model instance
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
package com.simibubi.create.foundation.render.instancing;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public interface IInstancedTileEntityRenderer<T extends TileEntity> {
|
||||
|
||||
void addInstanceData(InstanceContext<T> ctx);
|
||||
|
||||
void markForRebuild(InstanceContext<T> ctx);
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package com.simibubi.create.foundation.render.instancing;
|
||||
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IRendererFactory<T extends TileEntity> {
|
||||
TileEntityInstance<? super T> create(InstancedTileRenderDispatcher manager, T te);
|
||||
TileEntityInstance<? super T> create(InstancedTileRenderer manager, T te);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package com.simibubi.create.foundation.render.instancing;
|
||||
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.contraption.RenderedContraption;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@Deprecated
|
||||
|
@ -22,30 +21,10 @@ public abstract class InstanceContext<T extends TileEntity> {
|
|||
return getKinetics().get(KineticRenderMaterials.BELTS);
|
||||
}
|
||||
|
||||
public abstract InstancedTileRenderDispatcher getKinetics();
|
||||
public abstract InstancedTileRenderer getKinetics();
|
||||
|
||||
public abstract boolean checkWorldLight();
|
||||
|
||||
public static class Contraption<T extends TileEntity> extends InstanceContext<T> {
|
||||
|
||||
public final RenderedContraption c;
|
||||
|
||||
public Contraption(T te, RenderedContraption c) {
|
||||
super(te);
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstancedTileRenderDispatcher getKinetics() {
|
||||
return c.kinetics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkWorldLight() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class World<T extends TileEntity> extends InstanceContext<T> {
|
||||
|
||||
public World(T te) {
|
||||
|
@ -53,7 +32,7 @@ public abstract class InstanceContext<T extends TileEntity> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public InstancedTileRenderDispatcher getKinetics() {
|
||||
public InstancedTileRenderer getKinetics() {
|
||||
return CreateClient.kineticRenderer;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,7 @@ import com.simibubi.create.foundation.render.BufferedModel;
|
|||
import com.simibubi.create.foundation.render.RenderMath;
|
||||
import com.simibubi.create.foundation.render.gl.GlBuffer;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL31;
|
||||
import org.lwjgl.opengl.GL33;
|
||||
import org.lwjgl.opengl.*;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simibubi.create.foundation.render.instancing;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class InstancedTileRenderRegistry {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public <T extends TileEntity> TileEntityInstance<? super T> create(InstancedTileRenderDispatcher manager, T tile) {
|
||||
public <T extends TileEntity> TileEntityInstance<? super T> create(InstancedTileRenderer manager, T tile) {
|
||||
TileEntityType<?> type = tile.getType();
|
||||
IRendererFactory<? super T> factory = (IRendererFactory<? super T>) this.renderers.get(type);
|
||||
|
||||
|
|
|
@ -1,18 +1,24 @@
|
|||
package com.simibubi.create.foundation.render.instancing;
|
||||
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.InstancedTileRenderer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class TileEntityInstance<T extends TileEntity> {
|
||||
|
||||
protected final InstancedTileRenderDispatcher modelManager;
|
||||
protected final InstancedTileRenderer modelManager;
|
||||
protected final T tile;
|
||||
protected final World world;
|
||||
protected final BlockPos pos;
|
||||
protected BlockState lastState;
|
||||
|
||||
public TileEntityInstance(InstancedTileRenderDispatcher modelManager, T tile) {
|
||||
public TileEntityInstance(InstancedTileRenderer modelManager, T tile) {
|
||||
this.modelManager = modelManager;
|
||||
this.tile = tile;
|
||||
this.world = tile.getWorld();
|
||||
this.pos = tile.getPos();
|
||||
this.lastState = tile.getBlockState();
|
||||
init();
|
||||
}
|
||||
|
@ -25,8 +31,8 @@ public abstract class TileEntityInstance<T extends TileEntity> {
|
|||
onUpdate();
|
||||
} else {
|
||||
remove();
|
||||
init();
|
||||
lastState = currentState;
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,7 @@ import org.lwjgl.opengl.*;
|
|||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
// TODO: Don't immediately destroy light volumes.
|
||||
// There's a high chance that a contraption will stop and soon after start again.
|
||||
// By caching lightvolumes based on their volumes/locations, we can save having
|
||||
// to reread all the lighting data in those cases.
|
||||
public class LightVolume {
|
||||
|
||||
private GridAlignedBB sampleVolume;
|
||||
|
@ -31,7 +26,7 @@ public class LightVolume {
|
|||
setSampleVolume(sampleVolume);
|
||||
|
||||
this.glTexture = new GlTexture(GL20.GL_TEXTURE_3D);
|
||||
this.lightData = MemoryUtil.memAlloc(this.textureVolume.volume() * 2); // TODO: maybe figure out how to pack light coords into a single byte
|
||||
this.lightData = MemoryUtil.memAlloc(this.textureVolume.volume() * 2);
|
||||
}
|
||||
|
||||
private void setSampleVolume(GridAlignedBB sampleVolume) {
|
||||
|
@ -225,10 +220,7 @@ public class LightVolume {
|
|||
int sizeX = textureVolume.sizeX();
|
||||
int sizeY = textureVolume.sizeY();
|
||||
int sizeZ = textureVolume.sizeZ();
|
||||
if (sizeX * sizeY * sizeZ * 2 > lightData.capacity())
|
||||
throw new IllegalStateException("Volume too big for buffer");
|
||||
|
||||
lightData.rewind();
|
||||
GL12.glTexImage3D(GL12.GL_TEXTURE_3D, 0, GL40.GL_RG8, sizeX, sizeY, sizeZ, 0, GL40.GL_RG, GL40.GL_UNSIGNED_BYTE, lightData);
|
||||
bufferDirty = false;
|
||||
}
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"minVersion": "0.8"
|
||||
"minVersion": "0.8", "mixins": ["OnRemoveTileMixin"]
|
||||
}
|
Loading…
Reference in a new issue