Skip to content

Commit

Permalink
Merge branch '1.18' into 1.19.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Nov 24, 2023
2 parents de2b59f + e038423 commit fd1e162
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion felt-recipe-api/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
mixin_extras=true
mixin_extras=true
module_version=1.0.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,31 @@

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(AbstractFurnaceBlockEntity.class)
public class AbstractFurnaceBlockEntityMixin {

@Unique private static final String INT_BURN_TIME_KEY = "IntBurnTime";
@Unique private static final String INT_COOK_TIME_KEY = "IntCookTime";
@Unique private static final String INT_COOK_TIME_TOTAL_KEY = "IntCookTimeTotal";

@Shadow int litTime;
@Shadow int cookingProgress;
@Shadow int cookingTotalTime;

@Redirect(method = "burn", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;grow(I)V"))
private static void injectAmount(ItemStack instance, int increment, Recipe<?> recipe, NonNullList<ItemStack> nonNullList, int i){
instance.grow(recipe.getResultItem().getCount());
Expand All @@ -26,4 +41,25 @@ private static boolean canFit(boolean original, @Nullable Recipe<?> recipe, NonN
private static boolean canFit2(boolean original, @Nullable Recipe<?> recipe, NonNullList<ItemStack> nonNullList, int i){
return nonNullList.get(2).getCount() + recipe.getResultItem().getCount() <= i;
}

@Inject(method = "load", at = @At("TAIL"))
public void load$TAIL(CompoundTag tag, CallbackInfo ci) {
if (tag.contains(INT_BURN_TIME_KEY)) {
this.litTime = tag.getInt(INT_BURN_TIME_KEY);
}
if (tag.contains(INT_COOK_TIME_KEY)) {
this.cookingProgress = tag.getInt(INT_COOK_TIME_KEY);
}
if (tag.contains(INT_COOK_TIME_TOTAL_KEY)) {
this.cookingTotalTime = tag.getInt(INT_COOK_TIME_TOTAL_KEY);
}
}

@Inject(method = "saveAdditional", at = @At("TAIL"))
public void saveAdditional$TAIL(CompoundTag tag, CallbackInfo ci) {
tag.putInt(INT_BURN_TIME_KEY, this.litTime);
tag.putInt(INT_COOK_TIME_KEY, this.cookingProgress);
tag.putInt(INT_COOK_TIME_TOTAL_KEY, this.cookingTotalTime);
}

}

0 comments on commit fd1e162

Please sign in to comment.