Skip to content

Commit 53ca813

Browse files
committed
Update to MC 1.15
1 parent 3aa1664 commit 53ca813

5 files changed

Lines changed: 14 additions & 85 deletions

File tree

build.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
mod_version=0.2.2
2-
minecraft_version=1.14.4
3-
forge_version=28.1.1
2+
minecraft_version=1.15.2
3+
forge_version=31.1.37
44
mcp_mappings_channel=snapshot
5-
mcp_mappings_version=20190719-1.14.3
6-
cyclopscore_version=1.6.0-1017
5+
mcp_mappings_version=20200225-1.15.1
6+
cyclopscore_version=1.6.1-1055
77
release_type=release
88
fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44
99

src/main/java/org/cyclops/structuredcrafting/block/BlockStructuredCrafter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import net.minecraft.state.DirectionProperty;
1010
import net.minecraft.state.StateContainer;
1111
import net.minecraft.state.properties.BlockStateProperties;
12+
import net.minecraft.util.ActionResultType;
1213
import net.minecraft.util.Direction;
1314
import net.minecraft.util.Hand;
1415
import net.minecraft.util.math.BlockPos;
@@ -47,11 +48,12 @@ public BlockState getStateForPlacement(BlockItemUseContext context) {
4748
}
4849

4950
@Override
50-
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand,
51-
BlockRayTraceResult hit) {
51+
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand,
52+
BlockRayTraceResult hit) {
5253
ItemStack heldItem = player.getHeldItem(hand);
5354
if(player != null && !heldItem.isEmpty() && heldItem.getItem() == Items.STICK) {
5455
worldIn.setBlockState(pos, state.with(FACING, hit.getFace().getOpposite()));
56+
return ActionResultType.SUCCESS;
5557
}
5658
return super.onBlockActivated(state, worldIn, pos, player, hand, hit);
5759
}

src/main/java/org/cyclops/structuredcrafting/craft/WorldCraftingMatrix.java

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,31 @@
11
package org.cyclops.structuredcrafting.craft;
22

3-
import com.google.common.cache.CacheBuilder;
4-
import com.google.common.cache.CacheLoader;
5-
import com.google.common.cache.LoadingCache;
63
import com.google.common.collect.Lists;
74
import com.google.common.collect.Maps;
8-
import com.google.common.util.concurrent.UncheckedExecutionException;
95
import lombok.ToString;
10-
import net.minecraft.inventory.IInventory;
116
import net.minecraft.item.ItemStack;
127
import net.minecraft.item.crafting.IRecipe;
13-
import net.minecraft.item.crafting.IRecipeSerializer;
148
import net.minecraft.item.crafting.IRecipeType;
159
import net.minecraft.util.Direction;
1610
import net.minecraft.util.NonNullList;
17-
import net.minecraft.util.ResourceLocation;
1811
import net.minecraft.util.math.BlockPos;
1912
import net.minecraft.world.World;
20-
import net.minecraft.world.dimension.DimensionType;
21-
import net.minecraft.world.server.ServerWorld;
22-
import net.minecraftforge.common.DimensionManager;
23-
import net.minecraftforge.fml.server.ServerLifecycleHooks;
24-
import org.apache.commons.lang3.tuple.Pair;
2513
import org.apache.logging.log4j.Level;
14+
import org.cyclops.cyclopscore.helper.CraftingHelpers;
2615
import org.cyclops.structuredcrafting.StructuredCrafting;
2716
import org.cyclops.structuredcrafting.block.BlockStructuredCrafter;
2817
import org.cyclops.structuredcrafting.craft.provider.IItemStackProvider;
2918
import org.cyclops.structuredcrafting.craft.provider.IItemStackProviderRegistry;
3019

3120
import java.util.List;
3221
import java.util.Map;
33-
import java.util.concurrent.ExecutionException;
34-
import java.util.concurrent.TimeUnit;
3522

3623
/**
3724
* A crafting matrix represented with blockstates.
3825
* @author rubensworks
3926
*/
4027
public class WorldCraftingMatrix {
4128

42-
private static final LoadingCache<Pair<WorldInventoryCrafting, DimensionType>, IRecipe> CACHE_RECIPES = CacheBuilder.newBuilder()
43-
.expireAfterWrite(1, TimeUnit.MINUTES).build(new CacheLoader<Pair<WorldInventoryCrafting, DimensionType>, IRecipe>() {
44-
@Override
45-
public IRecipe load(Pair<WorldInventoryCrafting, DimensionType> key) throws Exception {
46-
ServerWorld world = DimensionManager.getWorld(ServerLifecycleHooks.getCurrentServer(), key.getRight(), false, false);
47-
IRecipe recipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, key.getLeft(), world).orElse(null);
48-
49-
if (recipe == null) {
50-
recipe = NULL_RECIPE;
51-
}
52-
return recipe;
53-
}
54-
});
55-
// A dummy recipe that represents null, because guava's cache doesn't allow null entries.
56-
private static final IRecipe NULL_RECIPE = new IRecipe() {
57-
58-
@Override
59-
public boolean matches(IInventory inv, World worldIn) {
60-
return false;
61-
}
62-
63-
@Override
64-
public ItemStack getCraftingResult(IInventory inv) {
65-
return null;
66-
}
67-
68-
@Override
69-
public boolean canFit(int width, int height) {
70-
return false;
71-
}
72-
73-
@Override
74-
public ItemStack getRecipeOutput() {
75-
return null;
76-
}
77-
78-
@Override
79-
public ResourceLocation getId() {
80-
return null;
81-
}
82-
83-
@Override
84-
public IRecipeSerializer<?> getSerializer() {
85-
return null;
86-
}
87-
88-
@Override
89-
public IRecipeType<?> getType() {
90-
return null;
91-
}
92-
};
93-
9429
private final World world;
9530
private final BlockPos centerPos;
9631
private final Direction.Axis axis;
@@ -254,15 +189,7 @@ public void setPosition(int i, int j, int rotation, BlockPos pos, IItemStackProv
254189
}
255190

256191
protected IRecipe getRecipe(World world) {
257-
try {
258-
IRecipe recipe = CACHE_RECIPES.get(Pair.of(inventoryCrafting, world.getDimension().getType()));
259-
if (recipe == NULL_RECIPE) {
260-
recipe = null;
261-
}
262-
return recipe;
263-
} catch (ExecutionException | UncheckedExecutionException e) {
264-
return null;
265-
}
192+
return CraftingHelpers.findRecipeCached(IRecipeType.CRAFTING, inventoryCrafting, world, true).orElse(null);
266193
}
267194

268195
public ItemStack getOutput(World world) {

src/main/resources/META-INF/mods.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ Craft stuff in your world, automatically.
1414
[[dependencies.structuredcrafting]]
1515
modId="cyclopscore"
1616
mandatory=true
17-
versionRange="[1.6.0,)"
17+
versionRange="[1.6.1,)"
1818
ordering="NONE"
1919
side="BOTH"
2020
[[dependencies.structuredcrafting]]
2121
modId="forge"
2222
mandatory=true
23-
versionRange="[28.1,)"
23+
versionRange="[31.1,)"
2424
ordering="NONE"
2525
side="BOTH"
2626
[[dependencies.structuredcrafting]]
2727
modId="minecraft"
2828
mandatory=true
29-
versionRange="[1.14.4]"
29+
versionRange="[1.15.2]"
3030
ordering="NONE"
3131
side="BOTH"

0 commit comments

Comments
 (0)