Clutch vs Gearshift

- Gearshifter -> Gearshift
- Added the Clutch, using the prior model of the Gearshift
- New Model for Gearshift
- Generalized conditional shaft connectors for rendering
This commit is contained in:
simibubi 2019-08-28 19:45:41 +02:00
parent a0734dffaf
commit cb366a287a
27 changed files with 189 additions and 67 deletions

View file

@ -20,10 +20,11 @@ import com.simibubi.create.modules.contraptions.redstone.ContactBlock;
import com.simibubi.create.modules.contraptions.relays.AxisBlock;
import com.simibubi.create.modules.contraptions.relays.AxisTunnelBlock;
import com.simibubi.create.modules.contraptions.relays.BeltBlock;
import com.simibubi.create.modules.contraptions.relays.ClutchBlock;
import com.simibubi.create.modules.contraptions.relays.CogWheelBlock;
import com.simibubi.create.modules.contraptions.relays.EncasedBeltBlock;
import com.simibubi.create.modules.contraptions.relays.GearboxBlock;
import com.simibubi.create.modules.contraptions.relays.GearshifterBlock;
import com.simibubi.create.modules.contraptions.relays.GearshiftBlock;
import com.simibubi.create.modules.economy.ShopShelfBlock;
import com.simibubi.create.modules.gardens.CocoaLogBlock;
import com.simibubi.create.modules.logistics.block.ExtractorBlock;
@ -66,7 +67,8 @@ public enum AllBlocks {
LARGE_GEAR(new CogWheelBlock(true)),
AXIS_TUNNEL(new AxisTunnelBlock()),
ENCASED_BELT(new EncasedBeltBlock()),
GEARSHIFTER(new GearshifterBlock()),
CLUTCH(new ClutchBlock()),
GEARSHIFT(new GearshiftBlock()),
GEARBOX(new GearboxBlock()),
BELT(new BeltBlock()),
BELT_PULLEY(new RenderUtilityAxisBlock()),

View file

@ -17,16 +17,17 @@ import com.simibubi.create.modules.contraptions.relays.AxisTunnelTileEntity;
import com.simibubi.create.modules.contraptions.relays.AxisTunnelTileEntityRenderer;
import com.simibubi.create.modules.contraptions.relays.BeltTileEntity;
import com.simibubi.create.modules.contraptions.relays.BeltTileEntityRenderer;
import com.simibubi.create.modules.contraptions.relays.ClutchTileEntity;
import com.simibubi.create.modules.contraptions.relays.GearboxTileEntity;
import com.simibubi.create.modules.contraptions.relays.GearboxTileEntityRenderer;
import com.simibubi.create.modules.contraptions.relays.GearshifterTileEntity;
import com.simibubi.create.modules.contraptions.relays.GearshifterTileEntityRenderer;
import com.simibubi.create.modules.contraptions.relays.GearshiftTileEntity;
import com.simibubi.create.modules.contraptions.relays.SidedAxisTunnelTileEntityRenderer;
import com.simibubi.create.modules.economy.ShopShelfTileEntity;
import com.simibubi.create.modules.logistics.block.ExtractorTileEntity;
import com.simibubi.create.modules.logistics.block.FlexcrateTileEntity;
import com.simibubi.create.modules.logistics.block.LinkedExtractorTileEntity;
import com.simibubi.create.modules.logistics.block.RedstoneBridgeTileEntity;
import com.simibubi.create.modules.logistics.block.LinkedTileEntityRenderer;
import com.simibubi.create.modules.logistics.block.RedstoneBridgeTileEntity;
import com.simibubi.create.modules.logistics.block.StockswitchTileEntity;
import com.simibubi.create.modules.schematics.block.SchematicTableTileEntity;
import com.simibubi.create.modules.schematics.block.SchematicannonRenderer;
@ -57,7 +58,9 @@ public enum AllTileEntities {
MOTOR(MotorTileEntity::new, AllBlocks.MOTOR), GEARBOX(GearboxTileEntity::new, AllBlocks.GEARBOX),
TURNTABLE(TurntableTileEntity::new, AllBlocks.TURNTABLE),
AXIS_TUNNEL(AxisTunnelTileEntity::new, AllBlocks.AXIS_TUNNEL, AllBlocks.ENCASED_BELT),
GEARSHIFTER(GearshifterTileEntity::new, AllBlocks.GEARSHIFTER), BELT(BeltTileEntity::new, AllBlocks.BELT),
CLUTCH(ClutchTileEntity::new, AllBlocks.CLUTCH),
GEARSHIFT(GearshiftTileEntity::new, AllBlocks.GEARSHIFT),
BELT(BeltTileEntity::new, AllBlocks.BELT),
MECHANICAL_PISTON(MechanicalPistonTileEntity::new, AllBlocks.MECHANICAL_PISTON, AllBlocks.STICKY_MECHANICAL_PISTON),
DRILL(DrillTileEntity::new, AllBlocks.DRILL),
CRUSHING_WHEEL(CrushingWheelTileEntity::new, AllBlocks.CRUSHING_WHEEL),
@ -67,15 +70,14 @@ public enum AllTileEntities {
// Logistics
REDSTONE_BRIDGE(RedstoneBridgeTileEntity::new, AllBlocks.REDSTONE_BRIDGE),
STOCKSWITCH(StockswitchTileEntity::new, AllBlocks.STOCKSWITCH),
FLEXCRATE(FlexcrateTileEntity::new, AllBlocks.FLEXCRATE),
EXTRACTOR(ExtractorTileEntity::new, AllBlocks.EXTRACTOR),
FLEXCRATE(FlexcrateTileEntity::new, AllBlocks.FLEXCRATE), EXTRACTOR(ExtractorTileEntity::new, AllBlocks.EXTRACTOR),
LINKED_EXTRACTOR(LinkedExtractorTileEntity::new, AllBlocks.LINKED_EXTRACTOR),
// Economy
SHOP_SHELF(ShopShelfTileEntity::new, AllBlocks.SHOP_SHELF),
;
private Supplier<? extends TileEntity> supplier;
public TileEntityType<?> type;
private AllBlocks[] blocks;
@ -108,7 +110,8 @@ public enum AllTileEntities {
bind(MotorTileEntity.class, new MotorTileEntityRenderer());
bind(AxisTunnelTileEntity.class, new AxisTunnelTileEntityRenderer());
bind(GearboxTileEntity.class, new GearboxTileEntityRenderer());
bind(GearshifterTileEntity.class, new GearshifterTileEntityRenderer());
bind(GearshiftTileEntity.class, new SidedAxisTunnelTileEntityRenderer());
bind(ClutchTileEntity.class, new SidedAxisTunnelTileEntityRenderer());
bind(BeltTileEntity.class, new BeltTileEntityRenderer());
bind(MechanicalPistonTileEntity.class, new MechanicalPistonTileEntityRenderer());
bind(DrillTileEntity.class, new KineticTileEntityRenderer());

View file

@ -9,7 +9,7 @@ import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
import com.simibubi.create.modules.contraptions.relays.BeltTileEntity;
import com.simibubi.create.modules.contraptions.relays.EncasedBeltBlock;
import com.simibubi.create.modules.contraptions.relays.GearboxTileEntity;
import com.simibubi.create.modules.contraptions.relays.GearshifterTileEntity;
import com.simibubi.create.modules.contraptions.relays.SidedAxisTunnelTileEntity;
import net.minecraft.block.BlockState;
import net.minecraft.state.IProperty;
@ -86,7 +86,7 @@ public class RotationPropagator {
return 0;
}
private static int getAxisModifier(KineticTileEntity te, Direction direction) {
private static float getAxisModifier(KineticTileEntity te, Direction direction) {
if (!te.hasSource())
return 1;
Direction source = te.getSourceFacing();
@ -95,8 +95,8 @@ public class RotationPropagator {
return direction.getAxis() == source.getAxis() ? direction == source ? 1 : -1
: direction.getAxisDirection() == source.getAxisDirection() ? -1 : 1;
if (te instanceof GearshifterTileEntity)
return source == direction ? 1 : te.getBlockState().get(BlockStateProperties.POWERED) ? -1 : 1;
if (te instanceof SidedAxisTunnelTileEntity)
return ((SidedAxisTunnelTileEntity) te).getRotationSpeedModifier(direction);
return 1;
}
@ -199,6 +199,8 @@ public class RotationPropagator {
public static void handleRemoved(World worldIn, BlockPos pos, KineticTileEntity removedTE) {
if (worldIn.isRemote)
return;
if (removedTE == null)
return;
if (removedTE.getSpeed() == 0)
return;

View file

@ -88,7 +88,7 @@ public abstract class KineticTileEntity extends SyncedTileEntity {
this.speed = speed;
if (hasWorld() && speed != 0 && world.isRemote) {
Random r = getWorld().rand;
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 2; i++) {
float x = getPos().getX() + (r.nextFloat() - .5f) / 2f + .5f;
float y = getPos().getY() + (r.nextFloat() - .5f) / 2f + .5f;
float z = getPos().getZ() + (r.nextFloat() - .5f) / 2f + .5f;

View file

@ -0,0 +1,25 @@
package com.simibubi.create.modules.contraptions.relays;
import com.simibubi.create.foundation.utility.ItemDescription;
import com.simibubi.create.foundation.utility.ItemDescription.Palette;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockReader;
public class ClutchBlock extends GearshiftBlock {
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new ClutchTileEntity();
}
@Override
public ItemDescription getDescription() {
Palette color = Palette.Red;
return new ItemDescription(color).withSummary("A controllable rotation switch for connected shafts.")
.withBehaviour("When Powered", h("Stops", color) + " conveying rotation to the other side.")
.createTabs();
}
}

View file

@ -0,0 +1,23 @@
package com.simibubi.create.modules.contraptions.relays;
import com.simibubi.create.AllTileEntities;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
public class ClutchTileEntity extends SidedAxisTunnelTileEntity {
public ClutchTileEntity() {
super(AllTileEntities.CLUTCH.type);
}
@Override
public float getRotationSpeedModifier(Direction face) {
if (hasSource()) {
if (face != getSourceFacing() && getBlockState().get(BlockStateProperties.POWERED))
return 0;
}
return 1;
}
}

View file

@ -1,5 +1,7 @@
package com.simibubi.create.modules.contraptions.relays;
import com.simibubi.create.foundation.utility.ItemDescription;
import com.simibubi.create.foundation.utility.ItemDescription.Palette;
import com.simibubi.create.modules.contraptions.RotationPropagator;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
@ -15,20 +17,27 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
public class GearshifterBlock extends AxisTunnelBlock {
public class GearshiftBlock extends AxisTunnelBlock {
public static final BooleanProperty POWERED = BlockStateProperties.POWERED;
public GearshifterBlock() {
public GearshiftBlock() {
super();
setDefaultState(getDefaultState().with(POWERED, false));
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new GearshifterTileEntity();
return new GearshiftTileEntity();
}
@Override
public ItemDescription getDescription() {
Palette color = Palette.Red;
return new ItemDescription(color).withSummary("A controllable rotation switch for connected shafts.")
.withBehaviour("When Powered", h("Reverses", color) + " the incoming rotation on the other side.").createTabs();
}
@Override
protected void fillStateContainer(Builder<Block, BlockState> builder) {
builder.add(POWERED);
@ -49,8 +58,9 @@ public class GearshifterBlock extends AxisTunnelBlock {
boolean previouslyPowered = state.get(POWERED);
if (previouslyPowered != worldIn.isBlockPowered(pos)) {
RotationPropagator.handleRemoved(worldIn, pos, (KineticTileEntity) worldIn.getTileEntity(pos));
worldIn.setBlockState(pos, state.cycle(POWERED), 2);
if (!previouslyPowered)
RotationPropagator.handleRemoved(worldIn, pos, (KineticTileEntity) worldIn.getTileEntity(pos));
}
}

View file

@ -0,0 +1,23 @@
package com.simibubi.create.modules.contraptions.relays;
import com.simibubi.create.AllTileEntities;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.Direction;
public class GearshiftTileEntity extends SidedAxisTunnelTileEntity {
public GearshiftTileEntity() {
super(AllTileEntities.GEARSHIFT.type);
}
@Override
public float getRotationSpeedModifier(Direction face) {
if (hasSource()) {
if (face != getSourceFacing() && getBlockState().get(BlockStateProperties.POWERED))
return -1;
}
return 1;
}
}

View file

@ -1,12 +0,0 @@
package com.simibubi.create.modules.contraptions.relays;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
public class GearshifterTileEntity extends KineticTileEntity {
public GearshifterTileEntity() {
super(AllTileEntities.GEARSHIFTER.type);
}
}

View file

@ -0,0 +1,16 @@
package com.simibubi.create.modules.contraptions.relays;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
public abstract class SidedAxisTunnelTileEntity extends KineticTileEntity {
public SidedAxisTunnelTileEntity(TileEntityType<?> typeIn) {
super(typeIn);
}
public abstract float getRotationSpeedModifier(Direction face);
}

View file

@ -13,7 +13,7 @@ import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.client.model.animation.Animation;
public class GearshifterTileEntityRenderer extends KineticTileEntityRenderer {
public class SidedAxisTunnelTileEntityRenderer extends KineticTileEntityRenderer {
@Override
public void renderTileEntityFast(KineticTileEntity te, double x, double y, double z, float partialTicks,
@ -33,12 +33,12 @@ public class GearshifterTileEntityRenderer extends KineticTileEntityRenderer {
float offset = getRotationOffsetForPosition(te, pos, axis);
float angle = (time * te.getSpeed()) % 360;
float modifier = 1;
if (te instanceof SidedAxisTunnelTileEntity)
modifier = ((SidedAxisTunnelTileEntity) te).getRotationSpeedModifier(direction);
if (te.hasSource()) {
if (direction != te.getSourceFacing() && te.getBlockState().get(BlockStateProperties.POWERED))
angle = -angle;
}
angle *= modifier;
angle += offset;
angle = angle / 180f * (float) Math.PI;

View file

@ -0,0 +1,14 @@
{
"forge_marker": 1,
"variants": {
"powered" : {
"true": { "model": "create:block/clutch_on" },
"false": { "model": "create:block/clutch_off" }
},
"axis": {
"y": { "x": 90 },
"x": { "y": 90 },
"z": {}
}
}
}

View file

@ -0,0 +1,14 @@
{
"forge_marker": 1,
"variants": {
"powered" : {
"true": { "model": "create:block/gearshift_on" },
"false": { "model": "create:block/gearshift_off" }
},
"axis": {
"x": { "y": 90 },
"y": { "x": 90 },
"z": {}
}
}
}

View file

@ -1,15 +0,0 @@
{
"forgemarker": 1,
"defaults": {
"model": "create:block/gearshifter_off"
},
"variants": {
"powered=false,axis=y": { "model": "create:block/gearshifter_off", "x": 90 },
"powered=false,axis=z": { "model": "create:block/gearshifter_off" },
"powered=false,axis=x": { "model": "create:block/gearshifter_off", "y": 90 },
"powered=true,axis=y": { "model": "create:block/gearshifter_on", "x": 90 },
"powered=true,axis=z": { "model": "create:block/gearshifter_on" },
"powered=true,axis=x": { "model": "create:block/gearshifter_on", "y": 90 }
}
}

View file

@ -15,7 +15,8 @@
"block.create.large_gear": "Large Cogwheel",
"block.create.turntable": "Turntable",
"block.create.gearbox": "Gearbox",
"block.create.gearshifter": "Gearshifter",
"block.create.gearshift": "Gearshift",
"block.create.clutch": "Clutch",
"block.create.axis": "Axis",
"block.create.encased_belt": "Encased Belt",
"block.create.axis_tunnel": "Encased Axis",

View file

@ -0,0 +1,7 @@
{
"parent": "create:block/gearshift_off",
"textures": {
"0": "create:block/clutch_off",
"particle": "create:block/clutch_off"
}
}

View file

@ -0,0 +1,7 @@
{
"parent": "create:block/gearshift_off",
"textures": {
"0": "create:block/clutch_on",
"particle": "create:block/clutch_on"
}
}

View file

@ -2,9 +2,9 @@
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"parent": "block/cube",
"textures": {
"0": "create:block/gearshifter_off",
"0": "create:block/gearshift_off",
"1": "create:block/gearbox",
"particle": "create:block/gearshifter_off"
"particle": "create:block/gearshift_off"
},
"elements": [
{

View file

@ -0,0 +1,7 @@
{
"parent": "create:block/gearshift_off",
"textures": {
"0": "create:block/gearshift_on",
"particle": "create:block/gearshift_on"
}
}

View file

@ -1,8 +0,0 @@
{
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"parent": "create:block/gearshifter_off",
"textures": {
"0": "create:block/gearshifter_on",
"particle": "create:block/gearshifter_on"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "create:block/clutch_off"
}

View file

@ -0,0 +1,3 @@
{
"parent": "create:block/gearshift_off"
}

View file

@ -1,3 +0,0 @@
{
"parent": "create:block/gearshifter_off"
}

View file

Before

Width:  |  Height:  |  Size: 426 B

After

Width:  |  Height:  |  Size: 426 B

View file

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 435 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B