Skip to content

Commit

Permalink
Remove bad usages of ClientWorld
Browse files Browse the repository at this point in the history
  • Loading branch information
Pepperoni-Jabroni committed Jan 25, 2021
1 parent ad238aa commit ce3a35f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package pepjebs.mapatlases.recipe;

import com.google.common.primitives.Ints;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
Expand All @@ -19,12 +17,16 @@
import java.util.*;

public class MapAtlasesAddRecipe extends SpecialCraftingRecipe {

private World world = null;

public MapAtlasesAddRecipe(Identifier id) {
super(id);
}

@Override
public boolean matches(CraftingInventory inv, World world) {
this.world = world;
List<ItemStack> itemStacks = MapAtlasesAccessUtils.getItemStacksFromGrid(inv);
ItemStack atlas = MapAtlasesAccessUtils.getAtlasFromItemStacks(itemStacks);

Expand Down Expand Up @@ -52,7 +54,7 @@ public boolean matches(CraftingInventory inv, World world) {

@Override
public ItemStack craft(CraftingInventory inv) {
ClientWorld world = MinecraftClient.getInstance().world;
if (world == null) return ItemStack.EMPTY;
List<ItemStack> itemStacks = MapAtlasesAccessUtils.getItemStacksFromGrid(inv);
// Grab the Atlas in the Grid
ItemStack atlas = MapAtlasesAccessUtils.getAtlasFromItemStacks(itemStacks);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package pepjebs.mapatlases.utils;

import net.minecraft.client.world.ClientWorld;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.FilledMapItem;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -85,7 +84,7 @@ public static List<MapState> getMapStatesFromItemStacks(World world, List<ItemSt
.collect(Collectors.toList());
}

public static Set<Integer> getMapIdsFromItemStacks(ClientWorld world, List<ItemStack> itemStacks) {
public static Set<Integer> getMapIdsFromItemStacks(World world, List<ItemStack> itemStacks) {
return getMapStatesFromItemStacks(world, itemStacks).stream()
.map(MapAtlasesAccessUtils::getMapIntFromState).collect(Collectors.toSet());
}
Expand Down

0 comments on commit ce3a35f

Please sign in to comment.