mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-11 13:04:05 +01:00
Cart Assemblers now stop disassembeled minecarts and send assembled minecarts on their way automatically. Power to assemble cart.
This commit is contained in:
parent
e669bb3b27
commit
b70343b32c
@ -76,10 +76,20 @@ public class CartAssemblerBlock extends AbstractRailBlock implements ITE<CartAss
|
||||
public void onMinecartPass(BlockState state, World world, BlockPos pos, AbstractMinecartEntity cart) {
|
||||
if (!cart.canBeRidden() && !(cart instanceof FurnaceMinecartEntity))
|
||||
return;
|
||||
if (state.get(POWERED))
|
||||
disassemble(world, pos, cart);
|
||||
else
|
||||
assemble(world, pos, cart);
|
||||
|
||||
withTileEntityDo(world, pos, te -> {
|
||||
if(te.isMinecartUpdateValid()) {
|
||||
if (state.get(POWERED)) {
|
||||
assemble(world, pos, cart);
|
||||
cart.setVelocity(cart.getAdjustedHorizontalFacing().getXOffset(), cart.getAdjustedHorizontalFacing().getYOffset(), cart.getAdjustedHorizontalFacing().getZOffset());
|
||||
}
|
||||
else {
|
||||
disassemble(world, pos, cart);
|
||||
cart.setVelocity(0, 0, 0);
|
||||
}
|
||||
te.resetTicksSinceMinecartUpdate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void assemble(World world, BlockPos pos, AbstractMinecartEntity cart) {
|
||||
|
@ -15,11 +15,22 @@ import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class CartAssemblerTileEntity extends SmartTileEntity {
|
||||
private static final int assemblyCooldown = 8;
|
||||
|
||||
protected ScrollOptionBehaviour<CartMovementMode> movementMode;
|
||||
private int ticksSinceMinecartUpdate;
|
||||
|
||||
public CartAssemblerTileEntity(TileEntityType<? extends CartAssemblerTileEntity> type) {
|
||||
super(type);
|
||||
ticksSinceMinecartUpdate = assemblyCooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if(ticksSinceMinecartUpdate < assemblyCooldown) {
|
||||
ticksSinceMinecartUpdate++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,7 +70,14 @@ public class CartAssemblerTileEntity extends SmartTileEntity {
|
||||
public String getTranslationKey() {
|
||||
return translationKey;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void resetTicksSinceMinecartUpdate() {
|
||||
ticksSinceMinecartUpdate = 0;
|
||||
}
|
||||
|
||||
public boolean isMinecartUpdateValid() {
|
||||
return ticksSinceMinecartUpdate >= assemblyCooldown;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
"4": "create:block/bearing_top",
|
||||
"5": "create:block/mechanical_bearing_side",
|
||||
"clutch_off": "create:block/clutch_off",
|
||||
"rail": "block/rail",
|
||||
"rail": "block/powered_rail",
|
||||
"translation_chassis_side": "create:block/cart_assembler_side",
|
||||
"particle": "create:block/cart_assembler_side"
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"parent": "create:block/cart_assembler/block",
|
||||
"textures": {
|
||||
"clutch_off": "create:block/clutch_on"
|
||||
"clutch_off": "create:block/clutch_on",
|
||||
"rail": "block/powered_rail_on"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user