Skip to content

Commit d9a6903

Browse files
committed
Update to MC 1.21
1 parent 43b1cdc commit d9a6903

11 files changed

Lines changed: 61 additions & 69 deletions

File tree

build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'net.neoforged.gradle.userdev' version '7.0.97'
2+
id 'net.neoforged.gradle.userdev' version '7.0.145'
33
id 'net.darkhax.curseforgegradle' version '1.0.8'
44
id 'com.diffplug.spotless' version '5.14.3'
55
id 'com.modrinth.minotaur' version '2.+'
@@ -31,7 +31,7 @@ base {
3131
}
3232

3333
// Set Java details
34-
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
34+
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
3535
compileJava.options.compilerArgs << "-Xmaxerrs" << "9999"
3636
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
3737

@@ -90,10 +90,10 @@ dependencies {
9090
}
9191

9292
// Project lombok
93-
compileOnly 'org.projectlombok:lombok:1.18.22'
94-
annotationProcessor 'org.projectlombok:lombok:1.18.22'
95-
testCompileOnly 'org.projectlombok:lombok:1.18.22'
96-
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
93+
compileOnly 'org.projectlombok:lombok:1.18.30'
94+
annotationProcessor 'org.projectlombok:lombok:1.18.30'
95+
testCompileOnly 'org.projectlombok:lombok:1.18.30'
96+
testAnnotationProcessor 'org.projectlombok:lombok:1.18.30'
9797
}
9898

9999
runs {
@@ -287,6 +287,8 @@ publishing {
287287

288288
idea {
289289
module {
290+
downloadSources = true
291+
downloadJavadoc = true
290292
for (String excludeDirName in ["run", "out", "logs", "gradle"]) {
291293
File excludeDir = new File(projectDir, excludeDirName)
292294
excludeDirs.add(excludeDir)

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
mod_id=structuredcrafting
22
mod_version=0.2.6
3-
minecraft_version=1.20.4
4-
neoforge_version=20.4.160-beta
5-
cyclopscore_version=1.19.0-409
3+
minecraft_version=1.21
4+
neoforge_version=21.0.43-beta
5+
cyclopscore_version=1.19.1-452
66
release_type=release
77
fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44
88

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

src/main/java/org/cyclops/structuredcrafting/Capabilities.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/main/java/org/cyclops/structuredcrafting/RegistryEntries.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
*/
1515
public class RegistryEntries {
1616

17-
public static final DeferredHolder<Item, Item> ITEM_STRUCTURED_CRAFTER = DeferredHolder.create(Registries.ITEM, new ResourceLocation("structuredcrafting:structured_crafter"));
17+
public static final DeferredHolder<Item, Item> ITEM_STRUCTURED_CRAFTER = DeferredHolder.create(Registries.ITEM, ResourceLocation.parse("structuredcrafting:structured_crafter"));
1818

19-
public static final DeferredHolder<Block, Block> BLOCK_STRUCTURED_CRAFTER = DeferredHolder.create(Registries.BLOCK, new ResourceLocation("structuredcrafting:structured_crafter"));
19+
public static final DeferredHolder<Block, Block> BLOCK_STRUCTURED_CRAFTER = DeferredHolder.create(Registries.BLOCK, ResourceLocation.parse("structuredcrafting:structured_crafter"));
2020

21-
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<BlockEntityStructuredCrafter>> BLOCK_ENTITY_STRUCTURED_CRAFTER = DeferredHolder.create(Registries.BLOCK_ENTITY_TYPE, new ResourceLocation("structuredcrafting:structured_crafter"));
21+
public static final DeferredHolder<BlockEntityType<?>, BlockEntityType<BlockEntityStructuredCrafter>> BLOCK_ENTITY_STRUCTURED_CRAFTER = DeferredHolder.create(Registries.BLOCK_ENTITY_TYPE, ResourceLocation.parse("structuredcrafting:structured_crafter"));
2222

2323
}

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import net.minecraft.core.BlockPos;
55
import net.minecraft.core.Direction;
66
import net.minecraft.world.InteractionHand;
7-
import net.minecraft.world.InteractionResult;
7+
import net.minecraft.world.ItemInteractionResult;
88
import net.minecraft.world.entity.player.Player;
99
import net.minecraft.world.item.ItemStack;
1010
import net.minecraft.world.item.Items;
@@ -67,14 +67,12 @@ public BlockState getStateForPlacement(BlockPlaceContext context) {
6767
}
6868

6969
@Override
70-
public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand hand,
71-
BlockHitResult hit) {
70+
protected ItemInteractionResult useItemOn(ItemStack itemStack, BlockState blockState, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
7271
ItemStack heldItem = player.getItemInHand(hand);
73-
if(player != null && !heldItem.isEmpty() && heldItem.getItem() == Items.STICK) {
74-
worldIn.setBlockAndUpdate(pos, state.setValue(FACING, hit.getDirection().getOpposite()));
75-
return InteractionResult.SUCCESS;
72+
if(player != null && heldItem.getItem() == Items.STICK) {
73+
level.setBlockAndUpdate(pos, blockState.setValue(FACING, hit.getDirection().getOpposite()));
74+
return ItemInteractionResult.SUCCESS;
7675
}
77-
return super.use(state, worldIn, pos, player, hand, hit);
76+
return super.useItemOn(itemStack, blockState, level, pos, player, hand, hit);
7877
}
79-
8078
}

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

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.minecraft.core.Direction;
88
import net.minecraft.core.NonNullList;
99
import net.minecraft.world.item.ItemStack;
10+
import net.minecraft.world.item.crafting.CraftingInput;
1011
import net.minecraft.world.item.crafting.Recipe;
1112
import net.minecraft.world.item.crafting.RecipeHolder;
1213
import net.minecraft.world.item.crafting.RecipeType;
@@ -195,15 +196,15 @@ public void setPosition(int i, int j, int rotation, BlockPos pos, IItemStackProv
195196

196197
@Nullable
197198
protected Recipe getRecipe(Level level) {
198-
return CraftingHelpers.findRecipeCached(RecipeType.CRAFTING, inventoryCrafting, level, true)
199+
return CraftingHelpers.findRecipeCached(RecipeType.CRAFTING, inventoryCrafting.asCraftInput(), level, true)
199200
.map(RecipeHolder::value)
200201
.orElse(null);
201202
}
202203

203204
public ItemStack getOutput(Level level) {
204205
Recipe recipe = getRecipe(level);
205206
if (recipe != null) {
206-
return recipe.assemble(inventoryCrafting, level.registryAccess());
207+
return recipe.assemble(inventoryCrafting.asCraftInput(), level.registryAccess());
207208
}
208209
return ItemStack.EMPTY;
209210
}
@@ -216,37 +217,42 @@ public ItemStack getOutput(Level level) {
216217
*/
217218
public boolean handleRemainingItems(Level level, Direction inputSide, boolean simulate) {
218219
Recipe recipe = getRecipe(level);
219-
NonNullList<ItemStack> remainingStacks = recipe.getRemainingItems(inventoryCrafting);
220-
for(int i = 0; i < remainingStacks.size(); i++) {
221-
ItemStack originalStack = inventoryCrafting.getItem(i);
222-
ItemStack remainingStack = remainingStacks.get(i);
223-
if(originalStack != null && !originalStack.isEmpty()) {
224-
if (providers[i] != null) {
225-
// Consume one item from input
226-
boolean success = providers[i].reduceItemStack(level, positions[i], inputSide, simulate);
220+
CraftingInput craftInput = inventoryCrafting.asCraftInput();
221+
NonNullList<ItemStack> remainingStacks = recipe.getRemainingItems(craftInput);
222+
for(int r = 0; r < 3; r++) {
223+
for(int c = 0; c < 3; c++) {
224+
int i = r * 3 + c;
227225

228-
// If consumption failed, consider the whole crafting job failed
229-
if (!success) {
230-
// Restore all previous slots if not simulating
231-
if (!simulate) {
232-
for(int j = 0; j < i; j++) {
233-
ItemStack stackToRestore = inventoryCrafting.getItem(j);
234-
if(stackToRestore != null && !stackToRestore.isEmpty() && providers[j] != null) {
235-
providers[j].addItemStack(level, positions[j], inputSide, stackToRestore, false);
226+
ItemStack originalStack = inventoryCrafting.getItem(i);
227+
ItemStack remainingStack = r < craftInput.width() && c < craftInput.height() ? remainingStacks.get(r * craftInput.height() + c) : ItemStack.EMPTY;
228+
if(originalStack != null && !originalStack.isEmpty()) {
229+
if (providers[i] != null) {
230+
// Consume one item from input
231+
boolean success = providers[i].reduceItemStack(level, positions[i], inputSide, simulate);
232+
233+
// If consumption failed, consider the whole crafting job failed
234+
if (!success) {
235+
// Restore all previous slots if not simulating
236+
if (!simulate) {
237+
for(int j = 0; j < i; j++) {
238+
ItemStack stackToRestore = inventoryCrafting.getItem(j);
239+
if(stackToRestore != null && !stackToRestore.isEmpty() && providers[j] != null) {
240+
providers[j].addItemStack(level, positions[j], inputSide, stackToRestore, false);
241+
}
236242
}
237243
}
238-
}
239244

240-
return false;
241-
}
245+
return false;
246+
}
242247

243-
// Add a possibly remaining stack to the slot
244-
if (!remainingStack.isEmpty() && remainingStack.getCount() > 0) {
245-
providers[i].addItemStack(level, positions[i], inputSide, remainingStack, simulate);
248+
// Add a possibly remaining stack to the slot
249+
if (!remainingStack.isEmpty() && remainingStack.getCount() > 0) {
250+
providers[i].addItemStack(level, positions[i], inputSide, remainingStack, simulate);
251+
}
252+
} else {
253+
StructuredCrafting.clog(org.apache.logging.log4j.Level.WARN, "The structured crafting provider for position "
254+
+ i + " did not exist for stack " + originalStack);
246255
}
247-
} else {
248-
StructuredCrafting.clog(org.apache.logging.log4j.Level.WARN, "The structured crafting provider for position "
249-
+ i + " did not exist for stack " + originalStack);
250256
}
251257
}
252258
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static int getItemStackHashCode(ItemStack itemStack) {
6060
return 0;
6161
}
6262
return Objects.hashCode(itemStack.getCount(), Item.getId(itemStack.getItem()),
63-
itemStack.hasTag() ? itemStack.getTag() : 0);
63+
itemStack.getComponents().isEmpty() ? itemStack.getComponents().hashCode() : 0);
6464
}
6565

6666
@Override

src/main/java/org/cyclops/structuredcrafting/modcompat/capabilities/WorkerStructuredCrafterTileCompat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import net.minecraft.world.level.block.entity.BlockEntityType;
55
import net.neoforged.neoforge.capabilities.BaseCapability;
66
import net.neoforged.neoforge.capabilities.ICapabilityProvider;
7+
import org.cyclops.commoncapabilities.api.capability.Capabilities;
78
import org.cyclops.commoncapabilities.api.capability.work.IWorker;
89
import org.cyclops.cyclopscore.modcompat.capabilities.ICapabilityConstructor;
9-
import org.cyclops.structuredcrafting.Capabilities;
1010
import org.cyclops.structuredcrafting.blockentity.BlockEntityStructuredCrafter;
1111

1212
import javax.annotation.Nullable;
@@ -25,7 +25,7 @@ public ICapabilityProvider<BlockEntityStructuredCrafter, Direction, IWorker> cre
2525

2626
@Override
2727
public BaseCapability<IWorker, Direction> getCapability() {
28-
return Capabilities.WORKER;
28+
return Capabilities.Worker.BLOCK;
2929
}
3030

3131
public static class Worker implements IWorker {

0 commit comments

Comments
 (0)