Skip to content

Commit

Permalink
Fix #719
Browse files Browse the repository at this point in the history
  • Loading branch information
SFort committed May 21, 2024
1 parent 81d7761 commit b0c91d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ org.gradle.jvmargs=-Xmx1G
# Mod Properties
maven_group = com.unascribed
archives_base_name = fabrication
version = 3.4.17
version = 3.4.18
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
import net.minecraft.entity.vehicle.FurnaceMinecartEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
Expand All @@ -35,6 +36,7 @@ public abstract class MixinFurnaceMinecartEntity extends AbstractMinecartEntity
public double pushZ;

public int fabrication$pauseFuel = 0;
public Direction fabrication$lastMovDirection = null;

public MixinFurnaceMinecartEntity(EntityType<?> type, World world) {
super(type, world);
Expand All @@ -50,6 +52,7 @@ protected void toggleOnUnpoweredPoweredRail(BlockPos pos, BlockState state, Call
if (!FabConf.isEnabled("*.toggleable_furnace_carts")) return;
if (state.isOf(Blocks.POWERED_RAIL) && !state.get(PoweredRailBlock.POWERED)) {
if (fuel > 0) {
fabrication$lastMovDirection = this.getMovementDirection();
fabrication$pauseFuel += fuel;
fuel = 0;
pushX = 0;
Expand All @@ -58,7 +61,7 @@ protected void toggleOnUnpoweredPoweredRail(BlockPos pos, BlockState state, Call
} else if (fabrication$pauseFuel > 0) {
fuel += fabrication$pauseFuel;
fabrication$pauseFuel = 0;
Direction dir = this.getMovementDirection();
Direction dir = fabrication$lastMovDirection == null ? this.getMovementDirection() : fabrication$lastMovDirection;
pushX = dir.getOffsetX();
pushZ = dir.getOffsetZ();
}
Expand All @@ -68,11 +71,13 @@ protected void toggleOnUnpoweredPoweredRail(BlockPos pos, BlockState state, Call
protected void writeCustomDataToTag(NbtCompound nbt, CallbackInfo ci) {
super.writeCustomDataToNbt(nbt);
nbt.putInt("fabrication:PauseFuel", fabrication$pauseFuel);
nbt.putByte("fabrication:LastMoveDir", (byte) fabrication$lastMovDirection.getId());
}

@FabInject(at=@At("TAIL"), method="readCustomDataFromNbt(Lnet/minecraft/nbt/NbtCompound;)V")
protected void readCustomDataFromTag(NbtCompound nbt, CallbackInfo ci) {
fabrication$pauseFuel = nbt.getInt("fabrication:PauseFuel");
if (nbt.contains("fabrication:LastMoveDir", NbtElement.BYTE_TYPE)) fabrication$lastMovDirection = Direction.byId(nbt.getByte("fabrication:LastMoveDir"));
}

public int fabrication$tgfc$getPauseFuel() {
Expand Down

0 comments on commit b0c91d0

Please sign in to comment.