Skip to content

Commit

Permalink
~ Change: SpyGlass What is that ported to 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
FaeWulf committed Nov 4, 2024
1 parent 0676ddf commit 053fd21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package xyz.faewulf.diversity.mixin.spyglassWhatIsThat;

import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
Expand All @@ -10,5 +13,5 @@
public interface AbstractFurnaceBlockEntityMixin {

@Accessor
Object2IntOpenHashMap<ResourceLocation> getRecipesUsed();
Reference2IntOpenHashMap<ResourceKey<Recipe<?>>> getRecipesUsed();
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package xyz.faewulf.diversity.util;

import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Reference2IntMap;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
Expand All @@ -21,6 +23,7 @@
import net.minecraft.world.entity.monster.ZombieVillager;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BeehiveBlock;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -109,10 +112,10 @@ public static Component parseBlockState(Level world, Player player, BlockPos blo
if (blockEntity instanceof AbstractFurnaceBlockEntity abstractFurnaceBlockEntity) {

AtomicInteger totalExp = new AtomicInteger();
for (Object2IntMap.Entry<ResourceLocation> entry : ((AbstractFurnaceBlockEntityMixin) abstractFurnaceBlockEntity).getRecipesUsed().object2IntEntrySet()) {
world.getRecipeManager().byKey(entry.getKey()).ifPresent(recipe -> {
for (Reference2IntMap.Entry<ResourceKey<Recipe<?>>> entry : ((AbstractFurnaceBlockEntityMixin) abstractFurnaceBlockEntity).getRecipesUsed().reference2IntEntrySet()) {
((ServerLevel) world).recipeAccess().byKey(entry.getKey()).ifPresent(recipe -> {
int multiplier = entry.getIntValue();
float experience = ((AbstractCookingRecipe) recipe.value()).getExperience();
float experience = ((AbstractCookingRecipe) recipe.value()).experience();

int i = Mth.floor((float) multiplier * experience);
float f = Mth.frac((float) multiplier * experience);
Expand Down

0 comments on commit 053fd21

Please sign in to comment.