Skip to content

Commit

Permalink
conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
gottsch committed Dec 17, 2024
1 parent 9f58c5d commit 1919d23
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,17 @@ public abstract class EverFurnaceBlockEntity extends LockableContainerBlockEntit
private static final int OUTPUT_SLOT = 2;
@Unique
private static final String LAST_GAME_TIME_TAG = "everfurnace_lastGameTime";
@Unique
private static final String REMAINING_TIME_TAG = "everfurnace_remainingTime";
@Unique
private static final String COOLDOWN_TIME_TAG = "everfurnace_cooldownTime";

@Unique
private long everfurnace$lastGameTime;
@Unique
private int everfurnace$remainingTime;
@Unique
private int everfurnace$Cooldown;

protected EverFurnaceBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
super(blockEntityType, blockPos, blockState);
Expand Down Expand Up @@ -90,13 +98,20 @@ private static void onTick(ServerWorld world, BlockPos pos, BlockState state, Ab
long localLastGameTime = blockEntityMixin.getEverfurnace$lastGameTime();
blockEntityMixin.setEverfurnace$lastGameTime(blockEntity.getWorld().getTime());

// if not burning - no fuel left - then exit
if (!everFurnaceBlockEntity.callIsBurning()){
return;
}

// calculate the difference between game time and the lastGameTime
long deltaTime = blockEntity.getWorld().getTime() - localLastGameTime;

int remainingTime = blockEntityMixin.getEverfurnace$remainingTime();
int cooldownTime = blockEntityMixin.getEverfurnace$Cooldown();

// TODO if delta < 20 && remaining == 0 then return
// TODO use HopperBlockEntity.TRANSFER_COOLDOWN for the max cooldown

// exit if not enough time has passed
if (deltaTime < 20) {
return;
Expand Down Expand Up @@ -252,4 +267,20 @@ private static void onTick(ServerWorld world, BlockPos pos, BlockState state, Ab
public void setEverfurnace$lastGameTime(long gameTime) {
this.everfurnace$lastGameTime = gameTime;
}
@Unique
public int getEverfurnace$remainingTime() {
return everfurnace$remainingTime;
}
@Unique
public void setEverfurnace$remainingTime(int everfurnace$remainingTime) {
this.everfurnace$remainingTime = everfurnace$remainingTime;
}
@Unique
public int getEverfurnace$Cooldown() {
return everfurnace$Cooldown;
}
@Unique
public void setEverfurnace$Cooldown(int everfurnace$Cooldown) {
this.everfurnace$Cooldown = everfurnace$Cooldown;
}
}

0 comments on commit 1919d23

Please sign in to comment.