Skip to content

Commit

Permalink
initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
gottsch committed Dec 9, 2024
1 parent 6639be3 commit 85b91a5
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Changelog for EverFurnace 1.21.2
# Changelog for EverFurnace 1.21.4

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0] - 2024-12-08
## [1.0.0] - 2024-12-09
- Initial release.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.2
yarn_mappings=1.21.2+build.1
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.1
loader_version=0.16.9

# Mod Properties
Expand All @@ -14,4 +14,4 @@ maven_group=gottsch
archives_base_name=everfurnace

# Dependencies
fabric_version=0.106.1+1.21.2
fabric_version=0.111.0+1.21.4
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ private static void onTick(ServerWorld world, BlockPos pos, BlockState state, Ab
// calculate totalBurnTimeRemaining
ItemStack fuelStack = blockEntity.inventory.get(AbstractFurnaceBlockEntity.FUEL_SLOT_INDEX);
if (fuelStack.isEmpty()) return;
long totalBurnTimeRemaining = (long) (fuelStack.getCount() - 1) * blockEntity.fuelTime + blockEntity.burnTime;
long totalBurnTimeRemaining = (long) (fuelStack.getCount() - 1) * blockEntity.litTotalTime + blockEntity.litTimeRemaining;

// calculate totalCookTimeRemaining
long totalCookTimeRemaining = (long) (cookStack.getCount() -1) * blockEntity.cookTimeTotal + (blockEntity.cookTimeTotal - blockEntity.cookTime);
long totalCookTimeRemaining = (long) (cookStack.getCount() -1) * blockEntity.cookingTotalTime + (blockEntity.cookingTotalTime - blockEntity.cookingTimeSpent);

// determine the max amount of time that can be used before one or both input run out.
long maxInputTime = Math.min(totalBurnTimeRemaining, totalCookTimeRemaining);
Expand All @@ -135,63 +135,63 @@ private static void onTick(ServerWorld world, BlockPos pos, BlockState state, Ab
long actualAppliedTime = Math.min(deltaTime, maxInputTime);

// have to calculate fuel time as it is no longer calculated during readNbt() as in 1.21.1
if (blockEntity.fuelTime == 0) {
blockEntity.fuelTime = blockEntity.getFuelTime(blockEntity.getWorld().getFuelRegistry(), fuelStack);
if (blockEntity.litTotalTime == 0) {
blockEntity.litTotalTime = blockEntity.getFuelTime(blockEntity.getWorld().getFuelRegistry(), fuelStack);
}
if (actualAppliedTime < blockEntity.fuelTime) {
if (actualAppliedTime < blockEntity.litTotalTime) {
// reduce burn time
blockEntity.burnTime =- (int) actualAppliedTime;
if (blockEntity.burnTime <= 0) {
blockEntity.litTimeRemaining =- (int) actualAppliedTime;
if (blockEntity.litTimeRemaining <= 0) {
Item fuelItem = fuelStack.getItem();
// reduce the size of the fuel stack
fuelStack.decrement(1);
if (fuelStack.isEmpty()) {
blockEntity.burnTime = 0;
blockEntity.litTimeRemaining = 0;
blockEntity.inventory.set(1, fuelItem.getRecipeRemainder());
} else {
blockEntity.burnTime =+ blockEntity.fuelTime;
blockEntity.litTimeRemaining =+ blockEntity.litTotalTime;
}
}
} else {
int quotient = (int) (Math.floorDivExact(actualAppliedTime, blockEntity.fuelTime));
long remainder = actualAppliedTime % blockEntity.fuelTime;
int quotient = (int) (Math.floorDivExact(actualAppliedTime, blockEntity.litTotalTime));
long remainder = actualAppliedTime % blockEntity.litTotalTime;
// reduced stack by quotient
Item fuelItem = fuelStack.getItem();
fuelStack.decrement(quotient);
// reduce burnTime by remainder
blockEntity.burnTime =- (int)remainder;
if (blockEntity.burnTime <= 0) {
// reduce litTimeRemaining by remainder
blockEntity.litTimeRemaining =- (int)remainder;
if (blockEntity.litTimeRemaining <= 0) {
// reduce the size of the fuel stack
fuelStack.decrement(1);
}
if (fuelStack.isEmpty()) {
blockEntity.burnTime = 0;
blockEntity.litTimeRemaining = 0;
blockEntity.inventory.set(1, fuelItem.getRecipeRemainder());
} else {
blockEntity.burnTime =+ blockEntity.fuelTime;
blockEntity.litTimeRemaining =+ blockEntity.litTotalTime;
}
}

if (actualAppliedTime < blockEntity.cookTimeTotal) {
if (actualAppliedTime < blockEntity.cookingTotalTime) {
// increment cook time
blockEntity.cookTime =+ (int) actualAppliedTime;
if (blockEntity.cookTime >= blockEntity.cookTimeTotal) {
blockEntity.cookingTimeSpent =+ (int) actualAppliedTime;
if (blockEntity.cookingTimeSpent >= blockEntity.cookingTotalTime) {
if (AbstractFurnaceBlockEntity.craftRecipe(world.getRegistryManager(), recipeEntry, singleStackRecipeInput, blockEntity.inventory, blockEntity.getMaxCountPerStack())) {
blockEntity.setLastRecipe(recipeEntry);
}
if (cookStack.isEmpty()) {
blockEntity.cookTime = 0;
blockEntity.cookTimeTotal = 0;
blockEntity.cookingTimeSpent = 0;
blockEntity.cookingTotalTime = 0;
} else {
blockEntity.cookTimeTotal -= blockEntity.cookTimeTotal;
blockEntity.cookingTotalTime -= blockEntity.cookingTotalTime;
}
}
}
// actual applied time is greated that cook time total,
// there, need to apply a factor of
else {
int quotient = (int) (Math.floorDivExact(actualAppliedTime, blockEntity.cookTimeTotal));
long remainder = actualAppliedTime % blockEntity.cookTimeTotal;
int quotient = (int) (Math.floorDivExact(actualAppliedTime, blockEntity.cookingTotalTime));
long remainder = actualAppliedTime % blockEntity.cookingTotalTime;
// reduced stack by quotient
boolean isSuccessful = false;
for (int iterations = 0; iterations < quotient; iterations++) {
Expand All @@ -201,16 +201,16 @@ private static void onTick(ServerWorld world, BlockPos pos, BlockState state, Ab
if (isSuccessful) blockEntity.setLastRecipe(recipeEntry);

// increment cook time
blockEntity.cookTime =+ (int) remainder;
if (blockEntity.cookTime >= blockEntity.cookTimeTotal) {
blockEntity.cookingTimeSpent =+ (int) remainder;
if (blockEntity.cookingTimeSpent >= blockEntity.cookingTotalTime) {
if (AbstractFurnaceBlockEntity.craftRecipe(world.getRegistryManager(), recipeEntry, singleStackRecipeInput, blockEntity.inventory, blockEntity.getMaxCountPerStack())) {
blockEntity.setLastRecipe(recipeEntry);
}
if (cookStack.isEmpty()) {
blockEntity.cookTime = 0;
blockEntity.cookTimeTotal = 0;
blockEntity.cookingTimeSpent = 0;
blockEntity.cookingTotalTime = 0;
} else {
blockEntity.cookTimeTotal -= blockEntity.cookTimeTotal;
blockEntity.cookingTotalTime -= blockEntity.cookingTotalTime;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/everfurnace.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity INPUT_SLO
accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity FUEL_SLOT_INDEX I
accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity OUTPUT_SLOT_INDEX I
accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity inventory Lnet/minecraft/util/collection/DefaultedList;
accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity burnTime I
accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity cookTime I
accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity fuelTime I
accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity cookTimeTotal I
accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity litTotalTime I
accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity litTimeRemaining I
accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity cookingTotalTime I
accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity cookingTimeSpent I
accessible field net/minecraft/block/entity/AbstractFurnaceBlockEntity matchGetter Lnet/minecraft/recipe/ServerRecipeManager$MatchGetter;
accessible method net/minecraft/block/entity/AbstractFurnaceBlockEntity isBurning ()Z
accessible method net/minecraft/block/entity/AbstractFurnaceBlockEntity canAcceptRecipeOutput (Lnet/minecraft/registry/DynamicRegistryManager;Lnet/minecraft/recipe/RecipeEntry;Lnet/minecraft/recipe/input/SingleStackRecipeInput;Lnet/minecraft/util/collection/DefaultedList;I)Z
Expand Down

0 comments on commit 85b91a5

Please sign in to comment.