flywheels render with the new tech, and therefore have more accurate lighting
This commit is contained in:
parent
456ed364a4
commit
d50e07369b
5 changed files with 82 additions and 10 deletions
|
@ -17,6 +17,7 @@ import com.simibubi.create.content.contraptions.components.fan.EncasedFanRendere
|
||||||
import com.simibubi.create.content.contraptions.components.fan.EncasedFanTileEntity;
|
import com.simibubi.create.content.contraptions.components.fan.EncasedFanTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.components.fan.FanInstance;
|
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.fan.NozzleTileEntity;
|
||||||
|
import com.simibubi.create.content.contraptions.components.flywheel.FlyWheelInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelRenderer;
|
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelRenderer;
|
||||||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
|
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.components.flywheel.engine.EngineRenderer;
|
import com.simibubi.create.content.contraptions.components.flywheel.engine.EngineRenderer;
|
||||||
|
@ -372,7 +373,7 @@ public class AllTileEntities {
|
||||||
.tileEntity("flywheel", FlywheelTileEntity::new)
|
.tileEntity("flywheel", FlywheelTileEntity::new)
|
||||||
.validBlocks(AllBlocks.FLYWHEEL)
|
.validBlocks(AllBlocks.FLYWHEEL)
|
||||||
.renderer(() -> FlywheelRenderer::new)
|
.renderer(() -> FlywheelRenderer::new)
|
||||||
.onRegister(HorizontalHalfShaftInstance::register)
|
.onRegister(FlyWheelInstance::register)
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
public static final TileEntityEntry<FurnaceEngineTileEntity> FURNACE_ENGINE = Create.registrate()
|
public static final TileEntityEntry<FurnaceEngineTileEntity> FURNACE_ENGINE = Create.registrate()
|
||||||
|
|
|
@ -18,18 +18,17 @@ public class HalfShaftInstance extends SingleRotatingInstance {
|
||||||
InstancedTileRenderRegistry.instance.register(type, HalfShaftInstance::new));
|
InstancedTileRenderRegistry.instance.register(type, HalfShaftInstance::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HalfShaftInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
public HalfShaftInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InstancedModel<RotatingData> getModel() {
|
protected InstancedModel<RotatingData> getModel() {
|
||||||
BlockState state = tile.getBlockState();
|
|
||||||
Direction dir = getShaftDirection();
|
Direction dir = getShaftDirection();
|
||||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouthRotating(modelManager, state, dir);
|
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouthRotating(modelManager, lastState, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Direction getShaftDirection() {
|
protected Direction getShaftDirection() {
|
||||||
return tile.getBlockState().get(BlockStateProperties.FACING);
|
return lastState.get(BlockStateProperties.FACING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,12 @@ public class HorizontalHalfShaftInstance extends HalfShaftInstance {
|
||||||
InstancedTileRenderRegistry.instance.register(type, HorizontalHalfShaftInstance::new));
|
InstancedTileRenderRegistry.instance.register(type, HorizontalHalfShaftInstance::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HorizontalHalfShaftInstance(InstancedTileRenderer modelManager, KineticTileEntity tile) {
|
public HorizontalHalfShaftInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Direction getShaftDirection() {
|
protected Direction getShaftDirection() {
|
||||||
return tile.getBlockState().get(BlockStateProperties.HORIZONTAL_FACING).getOpposite();
|
return lastState.get(BlockStateProperties.HORIZONTAL_FACING).getOpposite();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
package com.simibubi.create.content.contraptions.components.flywheel;
|
||||||
|
|
||||||
|
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.SuperByteBuffer;
|
||||||
|
import com.simibubi.create.foundation.render.instancing.*;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.Rotation;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.fml.DistExecutor;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> {
|
||||||
|
public static void register(TileEntityType<? extends FlywheelTileEntity> type) {
|
||||||
|
DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
|
||||||
|
InstancedTileRenderRegistry.instance.register(type, FlyWheelInstance::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Direction facing;
|
||||||
|
|
||||||
|
protected InstanceKey<RotatingData> shaft;
|
||||||
|
protected InstanceKey<RotatingData> wheel;
|
||||||
|
|
||||||
|
public FlyWheelInstance(InstancedTileRenderer<?> modelManager, FlywheelTileEntity tile) {
|
||||||
|
super(modelManager, tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
facing = lastState.get(BlockStateProperties.HORIZONTAL_FACING);
|
||||||
|
|
||||||
|
Direction.Axis axis = ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
|
||||||
|
Consumer<RotatingData> setup = setupFunc(tile.getSpeed(), axis);
|
||||||
|
shaft = shaftModel().setupInstance(setup);
|
||||||
|
wheel = wheelModel().setupInstance(setup);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onUpdate() {
|
||||||
|
Direction.Axis axis = ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
|
||||||
|
updateRotation(shaft, axis);
|
||||||
|
updateRotation(wheel, axis);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateLight() {
|
||||||
|
shaft.modifyInstance(this::relight);
|
||||||
|
wheel.modifyInstance(this::relight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
shaft.delete();
|
||||||
|
wheel.delete();
|
||||||
|
shaft = null;
|
||||||
|
wheel = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected InstancedModel<RotatingData> shaftModel() {
|
||||||
|
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouthRotating(modelManager, lastState, facing.getOpposite());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected InstancedModel<RotatingData> wheelModel() {
|
||||||
|
BlockState rotate = lastState.rotate(Rotation.CLOCKWISE_90);
|
||||||
|
return AllBlockPartials.FLYWHEEL.renderOnDirectionalSouthRotating(modelManager, rotate, rotate.get(BlockStateProperties.HORIZONTAL_FACING));
|
||||||
|
}
|
||||||
|
}
|
|
@ -69,9 +69,9 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
|
||||||
.renderInto(ms, vb);
|
.renderInto(ms, vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING)
|
// kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING)
|
||||||
.getAxis(), AngleHelper.rad(angle), light);
|
// .getAxis(), AngleHelper.rad(angle), light);
|
||||||
wheel.renderInto(ms, vb);
|
// wheel.renderInto(ms, vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue