Directional sources of rotation

- Fixed gearbox pretending to be a deployer
- Fixed reversed rendering in the furnace engine TER
- Motors, fans, flywheels and handcranks now reverse their rotation when facing in negative axisdirections. Addresses #236
- Cart assemblers no longer auto-attach to blocks on their sides (top only)
This commit is contained in:
simibubi 2020-06-04 21:02:29 +02:00
parent 82ed9cd85d
commit cfdc9d0a5e
18 changed files with 196 additions and 174 deletions

View file

@ -53,7 +53,7 @@ public class AllShapes {
.forDirectional(),
CRANK = shape(5, 0, 5, 11, 6, 11).add(1, 3, 1, 15, 8, 15)
.forDirectional(),
CART_ASSEMBLER = shape(VoxelShapes.fullCube()).add(-2, 0, 1, 18, 13, 15)
CART_ASSEMBLER = shape(0,12,0,16,16,16).add(-2, 0, 1, 18, 14, 15)
.forHorizontalAxis(),
STOCKPILE_SWITCH = shape(0, 0, 0, 16, 2, 16).add(1, 0, 1, 15, 16, 15)
.add(0, 14, 0, 16, 16, 16)

View file

@ -58,7 +58,6 @@ import com.simibubi.create.content.contraptions.relays.encased.ClutchTileEntity;
import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftRenderer;
import com.simibubi.create.content.contraptions.relays.encased.EncasedShaftTileEntity;
import com.simibubi.create.content.contraptions.relays.encased.SplitShaftRenderer;
import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock;
import com.simibubi.create.content.contraptions.relays.gauge.GaugeRenderer;
import com.simibubi.create.content.contraptions.relays.gauge.SpeedGaugeTileEntity;
import com.simibubi.create.content.contraptions.relays.gauge.StressGaugeTileEntity;
@ -259,8 +258,8 @@ public class AllTileEntities {
bind(MECHANICAL_PRESS, MechanicalPressRenderer::new);
bind(MECHANICAL_MIXER, MechanicalMixerRenderer::new);
bind(MECHANICAL_CRAFTER, MechanicalCrafterRenderer::new);
bind(SPEEDOMETER, disp -> new GaugeRenderer(disp, GaugeBlock.Type.SPEED));
bind(STRESSOMETER, disp -> new GaugeRenderer(disp, GaugeBlock.Type.STRESS));
bind(SPEEDOMETER, GaugeRenderer::speed);
bind(STRESSOMETER, GaugeRenderer::stress);
bind(BASIN, BasinRenderer::new);
bind(DEPLOYER, DeployerRenderer::new);
bind(FLYWHEEL, FlywheelRenderer::new);

View file

@ -28,6 +28,8 @@ import net.minecraft.nbt.NBTUtil;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.AxisDirection;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
@ -446,4 +448,8 @@ public abstract class KineticTileEntity extends SmartTileEntity
return flickerTally;
}
public static float convertToDirection(float axisSpeed, Direction d) {
return d.getAxisDirection() == AxisDirection.POSITIVE ? axisSpeed : -axisSpeed;
}
}

View file

@ -1,5 +1,6 @@
package com.simibubi.create.content.contraptions.components.crank;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
import net.minecraft.nbt.CompoundNBT;
@ -30,7 +31,10 @@ public class HandCrankTileEntity extends GeneratingKineticTileEntity {
@Override
public float getGeneratedSpeed() {
return inUse == 0 ? 0 : backwards ? -32 : 32;
if (!AllBlocks.HAND_CRANK.has(getBlockState()))
return 0;
int speed = inUse == 0 ? 0 : backwards ? -32 : 32;
return convertToDirection(speed, getBlockState().get(HandCrankBlock.FACING));
}
@Override

View file

@ -82,10 +82,12 @@ public class EncasedFanTileEntity extends GeneratingKineticTileEntity {
}
public Direction getAirFlowDirection() {
if (getSpeed() == 0)
float speed = getSpeed();
if (speed == 0)
return null;
Direction facing = getBlockState().get(BlockStateProperties.FACING);
return getSpeed() > 0 ? facing : facing.getOpposite();
speed = convertToDirection(speed, facing);
return speed > 0 ? facing : facing.getOpposite();
}
@Override

View file

@ -125,7 +125,7 @@ public class NozzleTileEntity extends SmartTileEntity {
return 0;
if (fan.getSpeed() == 0)
return 0;
pushing = fan.getSpeed() > 0;
pushing = fan.getAirFlowDirection() == fan.getBlockState().get(EncasedFanBlock.FACING);
return fan.getMaxDistance();
}

View file

@ -39,7 +39,7 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity {
@Override
public float getGeneratedSpeed() {
return generatedSpeed;
return convertToDirection(generatedSpeed, getBlockState().get(FlywheelBlock.HORIZONTAL_FACING));
}
@Override
@ -60,7 +60,7 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity {
@Override
public void readClientUpdate(CompoundNBT tag) {
super.readClientUpdate(tag);
visualSpeed.withSpeed(1 / 32f).target(generatedSpeed);
visualSpeed.withSpeed(1 / 32f).target(getGeneratedSpeed());
}
@Override
@ -84,7 +84,7 @@ public class FlywheelTileEntity extends GeneratingKineticTileEntity {
super.tick();
if (world.isRemote) {
visualSpeed.target(generatedSpeed);
visualSpeed.target(getGeneratedSpeed());
visualSpeed.tick();
angle += visualSpeed.value * 3 / 10f;
angle %= 360;

View file

@ -21,14 +21,18 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
@Override
protected void renderSafe(T te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer, int light,
int overlay) {
Block block = te.getBlockState().getBlock();
Block block = te.getBlockState()
.getBlock();
if (block instanceof EngineBlock) {
EngineBlock engineBlock = (EngineBlock) block;
AllBlockPartials frame = engineBlock.getFrameModel();
if (frame != null) {
Direction facing = te.getBlockState().get(EngineBlock.HORIZONTAL_FACING);
Direction facing = te.getBlockState()
.get(EngineBlock.HORIZONTAL_FACING);
float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing));
frame.renderOn(te.getBlockState()).translate(0, 0, -1).rotateCentered(Direction.UP, angle)
frame.renderOn(te.getBlockState())
.rotateCentered(Direction.UP, angle)
.translate(0, 0, -1)
.light(WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getBlockState(), te.getPos()))
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
}

View file

@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.motor;
import java.util.List;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
@ -48,7 +49,9 @@ public class CreativeMotorTileEntity extends GeneratingKineticTileEntity {
@Override
public float getGeneratedSpeed() {
return generatedSpeed.getValue();
if (!AllBlocks.CREATIVE_MOTOR.has(getBlockState()))
return 0;
return convertToDirection(generatedSpeed.getValue(), getBlockState().get(CreativeMotorBlock.FACING));
}
public static int step(StepContext context) {

View file

@ -8,7 +8,6 @@ import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.contraptions.components.structureMovement.AllContraptionTypes;
import com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementTraits;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerTileEntity.CartMovementMode;
import com.simibubi.create.foundation.utility.NBTHelper;
@ -20,7 +19,6 @@ import net.minecraft.state.properties.RailShape;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.Direction.AxisDirection;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IWorld;
@ -63,18 +61,6 @@ public class MountedContraption extends Contraption {
protected boolean addToInitialFrontier(World world, BlockPos pos, Direction direction, List<BlockPos> frontier) {
frontier.clear();
frontier.add(pos.up());
BlockState state = world.getBlockState(pos);
if (!AllBlocks.CART_ASSEMBLER.has(state))
return false;
Axis axis = state.get(CartAssemblerBlock.RAIL_SHAPE) == RailShape.EAST_WEST ? Axis.Z : Axis.X;
for (AxisDirection axisDirection : AxisDirection.values()) {
Direction facingFromAxis = Direction.getFacingFromAxis(axisDirection, axis);
BlockPos offset = pos.offset(facingFromAxis);
BlockState blockState = world.getBlockState(offset);
if (!BlockMovementTraits.isBrittle(blockState)
|| BlockMovementTraits.isBlockAttachedTowards(blockState, facingFromAxis.getOpposite()))
frontier.add(offset);
}
return true;
}

View file

@ -20,7 +20,15 @@ public class GaugeRenderer extends KineticTileEntityRenderer {
protected GaugeBlock.Type type;
public GaugeRenderer(TileEntityRendererDispatcher dispatcher, GaugeBlock.Type type) {
public static GaugeRenderer speed(TileEntityRendererDispatcher dispatcher) {
return new GaugeRenderer(dispatcher, Type.SPEED);
}
public static GaugeRenderer stress(TileEntityRendererDispatcher dispatcher) {
return new GaugeRenderer(dispatcher, Type.STRESS);
}
protected GaugeRenderer(TileEntityRendererDispatcher dispatcher, GaugeBlock.Type type) {
super(dispatcher);
this.type = type;
}

View file

@ -31,7 +31,7 @@ public class GearboxBlock extends RotatedPillarKineticBlock {
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return AllTileEntities.DEPLOYER.create();
return AllTileEntities.GEARBOX.create();
}
@Override

View file

@ -1,12 +1,13 @@
{
"__comment": "Model generated using MrCrayfish's Model Creator (https://mrcrayfish.com/tools?id=mc)",
"credit": "Made with Blockbench",
"parent": "block/block",
"textures": {
"particle": "create:block/linear_chassis_side",
"gearbox_top": "create:block/gearbox_top",
"4": "create:block/bearing_top",
"5": "create:block/mechanical_bearing_side",
"clutch_off": "create:block/clutch_off",
"rail": "minecraft:block/rail",
"translation_chassis_side": "create:block/linear_chassis_side"
"rail": "block/rail",
"translation_chassis_side": "create:block/cart_assembler_side",
"particle": "create:block/cart_assembler_side"
},
"elements": [
{
@ -14,80 +15,89 @@
"from": [0, 1, 0],
"to": [16, 1, 16],
"faces": {
"up": { "texture": "#rail", "uv": [ 0, 0, 16, 16 ] },
"down": { "texture": "#rail", "uv": [ 0, 0, 16, 16 ], "rotation": 180 }
"up": {"uv": [0, 0, 16, 16], "texture": "#rail"},
"down": {"uv": [0, 0, 16, 16], "rotation": 180, "texture": "#rail"}
}
},
{
"name": "Side",
"from": [ 0, 0, 0 ],
"to": [ 2, 16, 16 ],
"from": [13.875, 0.062, 1.125],
"to": [17.875, 13.937, 14.875],
"faces": {
"north": { "texture": "#gearbox_top", "uv": [ 14, 0, 16, 16 ] },
"east": { "texture": "#translation_chassis_side", "uv": [ 0, 0, 16, 16 ], "rotation": 90 },
"south": { "texture": "#gearbox_top", "uv": [ 0, 16, 2, 0 ] },
"west": { "texture": "#translation_chassis_side", "uv": [ 0, 0, 16, 16 ], "rotation": 90 },
"up": { "texture": "#translation_chassis_side", "uv": [ 0, 0, 2, 16 ] },
"down": { "texture": "#translation_chassis_side", "uv": [ 0, 0, 2, 16 ] }
}
},
{
"name": "Side",
"from": [ 14, 0, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"north": { "texture": "#gearbox_top", "uv": [ 0, 0, 2, 16 ] },
"east": { "texture": "#translation_chassis_side", "uv": [ 0, 0, 16, 16 ], "rotation": 90 },
"south": { "texture": "#gearbox_top", "uv": [ 14, 16, 16, 0 ] },
"west": { "texture": "#translation_chassis_side", "uv": [ 0, 0, 16, 16 ], "rotation": 90 },
"up": { "texture": "#translation_chassis_side", "uv": [ 14, 0, 16, 16 ] },
"down": { "texture": "#translation_chassis_side", "uv": [ 14, 0, 16, 16 ] }
}
},
{
"name": "Top",
"from": [ 2, 14, 0 ],
"to": [ 14, 16, 16 ],
"faces": {
"north": { "texture": "#gearbox_top", "uv": [ 2, 0, 14, 2 ] },
"south": { "texture": "#gearbox_top", "uv": [ 2, 0, 14, 2 ] },
"up": { "texture": "#translation_chassis_side", "uv": [ 2, 0, 14, 16 ], "rotation": 180 },
"down": { "texture": "#translation_chassis_side", "uv": [ 2, 0, 14, 16 ] }
}
},
{
"name": "Indicator",
"from": [ 1, 10, 2 ],
"to": [ 15, 14, 14 ],
"faces": {
"north": { "texture": "#clutch_off", "uv": [ 1, 6, 15, 10 ] },
"south": { "texture": "#clutch_off", "uv": [ 1, 6, 15, 10 ] },
"down": { "texture": "#gearbox_top", "uv": [ 1, 2, 15, 14 ] }
}
},
{
"name": "Side",
"from": [ 15.875, 0.062, 1.125 ],
"to": [ 17.875, 12.937, 14.875 ],
"faces": {
"north": { "texture": "#gearbox_top", "uv": [ 0, 0, 2, 12.875 ] },
"east": { "texture": "#translation_chassis_side", "uv": [ 2, 1, 14, 15 ], "rotation": 90 },
"south": { "texture": "#gearbox_top", "uv": [ 14, 16, 16, 3 ] },
"up": { "texture": "#translation_chassis_side", "uv": [ 7, 1, 9, 15 ] },
"down": { "texture": "#translation_chassis_side", "uv": [ 7, 1, 9, 15 ] }
"north": {"uv": [1, 4, 15, 0], "rotation": 90, "texture": "#translation_chassis_side"},
"east": {"uv": [1, 1, 15, 15], "rotation": 90, "texture": "#translation_chassis_side"},
"south": {"uv": [1, 0, 15, 4], "rotation": 90, "texture": "#translation_chassis_side"},
"west": {"uv": [1, 1, 15, 15], "rotation": 90, "texture": "#translation_chassis_side"},
"up": {"uv": [5, 1, 9, 15], "texture": "#translation_chassis_side"},
"down": {"uv": [2, 1, 6, 15], "texture": "#translation_chassis_side"}
}
},
{
"name": "Side",
"from": [-1.875, 0.062, 1.125],
"to": [ 0.125, 12.937, 14.875 ],
"to": [2.125, 13.937, 14.875],
"faces": {
"north": { "texture": "#gearbox_top", "uv": [ 14, 0, 16, 12.875 ] },
"south": { "texture": "#gearbox_top", "uv": [ 0, 16, 2, 3 ] },
"west": { "texture": "#translation_chassis_side", "uv": [ 2, 1, 14, 15 ], "rotation": 90 },
"up": { "texture": "#translation_chassis_side", "uv": [ 7, 1, 9, 15 ] },
"down": { "texture": "#translation_chassis_side", "uv": [ 7, 1, 9, 15 ] }
"north": {"uv": [1, 0, 15, 4], "rotation": 90, "texture": "#translation_chassis_side"},
"east": {"uv": [1, 15, 15, 1], "rotation": 90, "texture": "#translation_chassis_side"},
"south": {"uv": [1, 4, 15, 0], "rotation": 90, "texture": "#translation_chassis_side"},
"west": {"uv": [1, 15, 15, 1], "rotation": 90, "texture": "#translation_chassis_side"},
"up": {"uv": [9, 1, 5, 15], "texture": "#translation_chassis_side"},
"down": {"uv": [6, 1, 2, 15], "texture": "#translation_chassis_side"}
}
},
{
"from": [0, 12, 0],
"to": [16, 16, 16],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 23, 8]},
"faces": {
"north": {"uv": [0, 0, 16, 4], "texture": "#5"},
"east": {"uv": [0, 0, 16, 4], "texture": "#5"},
"south": {"uv": [0, 0, 16, 4], "texture": "#5"},
"west": {"uv": [0, 0, 16, 4], "texture": "#5"},
"up": {"uv": [0, 0, 16, 16], "texture": "#4"},
"down": {"uv": [0, 0, 16, 16], "texture": "#translation_chassis_side"}
}
},
{
"from": [2, 10, 1],
"to": [14, 12, 15],
"rotation": {"angle": 0, "axis": "y", "origin": [18, 22, 10]},
"faces": {
"north": {"uv": [2, 7, 14, 9], "texture": "#clutch_off"},
"south": {"uv": [2, 7, 14, 9], "texture": "#clutch_off"},
"down": {"uv": [2, 1, 14, 15], "texture": "#translation_chassis_side"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"thirdperson_lefthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"firstperson_righthand": {
"rotation": [0, 45, 0],
"scale": [0.4, 0.4, 0.4]
},
"firstperson_lefthand": {
"rotation": [0, 225, 0],
"scale": [0.4, 0.4, 0.4]
},
"ground": {
"translation": [0, 3, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, 225, 0],
"scale": [0.625, 0.625, 0.625]
},
"fixed": {
"scale": [0.5, 0.5, 0.5]
}
}
]
}

View file

@ -1,7 +1,7 @@
{
"__comment": "Model generated using MrCrayfish's Model Creator (https://mrcrayfish.com/tools?id=mc)",
"textures": {
"translation_chassis_side": "create:block/linear_chassis_side"
"translation_chassis_side": "create:block/cart_assembler_side"
},
"elements": [
{

View file

@ -1,47 +1,47 @@
{
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"credit": "Made with Blockbench",
"parent": "block/block",
"textures": {
"0": "create:block/gearbox_top",
"0": "create:block/andesite_casing",
"1": "create:block/gearbox",
"particle": "create:block/gearbox_top"
"particle": "create:block/andesite_casing"
},
"elements": [
{
"name": "Bottom",
"from": [ 0.0, 0.0, 0.0 ],
"to": [ 16.0, 2.0, 16.0 ],
"from": [0, 0, 0],
"to": [16, 2, 16],
"faces": {
"north": { "texture": "#0", "uv": [ 0.0, 14.0, 16.0, 16.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 14.0, 16.0, 16.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 14.0, 16.0, 16.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 14.0, 16.0, 16.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }
"north": {"uv": [0, 14, 16, 16], "texture": "#0"},
"east": {"uv": [0, 14, 16, 16], "texture": "#0"},
"south": {"uv": [0, 14, 16, 16], "texture": "#0"},
"west": {"uv": [0, 14, 16, 16], "texture": "#0"},
"up": {"uv": [0, 0, 16, 16], "texture": "#0"},
"down": {"uv": [0, 0, 16, 16], "texture": "#0"}
}
},
{
"name": "Core",
"from": [ 1.0, 2.0, 1.0 ],
"to": [ 15.0, 14.0, 15.0 ],
"from": [1, 2, 1],
"to": [15, 14, 15],
"faces": {
"north": { "texture": "#1", "uv": [ 1.0, 2.0, 15.0, 14.0 ] },
"east": { "texture": "#1", "uv": [ 1.0, 2.0, 15.0, 14.0 ] },
"south": { "texture": "#1", "uv": [ 1.0, 2.0, 15.0, 14.0 ] },
"west": { "texture": "#1", "uv": [ 1.0, 2.0, 15.0, 14.0 ] }
"north": {"uv": [1, 2, 15, 14], "texture": "#1"},
"east": {"uv": [1, 2, 15, 14], "texture": "#1"},
"south": {"uv": [1, 2, 15, 14], "texture": "#1"},
"west": {"uv": [1, 2, 15, 14], "texture": "#1"}
}
},
{
"name": "Top",
"from": [ 0.0, 14.0, 0.0 ],
"to": [ 16.0, 16.0, 16.0 ],
"from": [0, 14, 0],
"to": [16, 16, 16],
"faces": {
"north": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 2.0 ] },
"east": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 2.0 ] },
"south": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 2.0 ] },
"west": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 2.0 ] },
"up": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 16.0 ] },
"down": { "texture": "#0", "uv": [ 0.0, 0.0, 16.0, 16.0 ] }
"north": {"uv": [0, 0, 16, 2], "texture": "#0"},
"east": {"uv": [0, 0, 16, 2], "texture": "#0"},
"south": {"uv": [0, 0, 16, 2], "texture": "#0"},
"west": {"uv": [0, 0, 16, 2], "texture": "#0"},
"up": {"uv": [0, 0, 16, 16], "texture": "#0"},
"down": {"uv": [0, 0, 16, 16], "texture": "#0"}
}
}
]

View file

@ -2,7 +2,7 @@
"credit": "Made with Blockbench",
"parent": "block/block",
"textures": {
"0": "create:block/gearbox_top",
"0": "create:block/andesite_casing",
"1": "create:block/gearbox",
"particle": "create:block/axis",
"1_0": "create:block/axis",

View file

@ -4,7 +4,7 @@
"textures": {
"0": "create:block/axis",
"1": "create:block/axis_top",
"gearbox_top": "create:block/gearbox_top",
"gearbox_top": "create:block/andesite_casing",
"gearbox": "create:block/gearbox",
"particle": "create:block/axis"
},

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B