mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-14 06:24:12 +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) {
|
public void onMinecartPass(BlockState state, World world, BlockPos pos, AbstractMinecartEntity cart) {
|
||||||
if (!cart.canBeRidden() && !(cart instanceof FurnaceMinecartEntity))
|
if (!cart.canBeRidden() && !(cart instanceof FurnaceMinecartEntity))
|
||||||
return;
|
return;
|
||||||
if (state.get(POWERED))
|
|
||||||
disassemble(world, pos, cart);
|
withTileEntityDo(world, pos, te -> {
|
||||||
else
|
if(te.isMinecartUpdateValid()) {
|
||||||
|
if (state.get(POWERED)) {
|
||||||
assemble(world, pos, cart);
|
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) {
|
protected void assemble(World world, BlockPos pos, AbstractMinecartEntity cart) {
|
||||||
|
@ -15,11 +15,22 @@ import net.minecraft.tileentity.TileEntityType;
|
|||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
public class CartAssemblerTileEntity extends SmartTileEntity {
|
public class CartAssemblerTileEntity extends SmartTileEntity {
|
||||||
|
private static final int assemblyCooldown = 8;
|
||||||
|
|
||||||
protected ScrollOptionBehaviour<CartMovementMode> movementMode;
|
protected ScrollOptionBehaviour<CartMovementMode> movementMode;
|
||||||
|
private int ticksSinceMinecartUpdate;
|
||||||
|
|
||||||
public CartAssemblerTileEntity(TileEntityType<? extends CartAssemblerTileEntity> type) {
|
public CartAssemblerTileEntity(TileEntityType<? extends CartAssemblerTileEntity> type) {
|
||||||
super(type);
|
super(type);
|
||||||
|
ticksSinceMinecartUpdate = assemblyCooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
super.tick();
|
||||||
|
if(ticksSinceMinecartUpdate < assemblyCooldown) {
|
||||||
|
ticksSinceMinecartUpdate++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,7 +70,14 @@ public class CartAssemblerTileEntity extends SmartTileEntity {
|
|||||||
public String getTranslationKey() {
|
public String getTranslationKey() {
|
||||||
return translationKey;
|
return translationKey;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetTicksSinceMinecartUpdate() {
|
||||||
|
ticksSinceMinecartUpdate = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMinecartUpdateValid() {
|
||||||
|
return ticksSinceMinecartUpdate >= assemblyCooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"4": "create:block/bearing_top",
|
"4": "create:block/bearing_top",
|
||||||
"5": "create:block/mechanical_bearing_side",
|
"5": "create:block/mechanical_bearing_side",
|
||||||
"clutch_off": "create:block/clutch_off",
|
"clutch_off": "create:block/clutch_off",
|
||||||
"rail": "block/rail",
|
"rail": "block/powered_rail",
|
||||||
"translation_chassis_side": "create:block/cart_assembler_side",
|
"translation_chassis_side": "create:block/cart_assembler_side",
|
||||||
"particle": "create:block/cart_assembler_side"
|
"particle": "create:block/cart_assembler_side"
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"parent": "create:block/cart_assembler/block",
|
"parent": "create:block/cart_assembler/block",
|
||||||
"textures": {
|
"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