Skip to content

Commit 8753b7d

Browse files
committed
updated to 1.21 (no way)
1 parent 96dbc25 commit 8753b7d

File tree

7 files changed

+52
-30
lines changed

7 files changed

+52
-30
lines changed

build.gradle

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
plugins {
2-
id 'fabric-loom' version '0.12-SNAPSHOT'
2+
id 'fabric-loom' version '1.6-SNAPSHOT'
33
id 'maven-publish'
44
}
55

6-
sourceCompatibility = JavaVersion.VERSION_17
7-
targetCompatibility = JavaVersion.VERSION_17
6+
sourceCompatibility = JavaVersion.VERSION_21
7+
targetCompatibility = JavaVersion.VERSION_21
88

99
archivesBaseName = project.archives_base_name
1010
version = project.mod_version
@@ -45,14 +45,17 @@ processResources {
4545

4646
tasks.withType(JavaCompile).configureEach {
4747
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
48-
it.options.release = 17
48+
it.options.release = 21
4949
}
5050

5151
java {
5252
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
5353
// if it is present.
5454
// If you remove this line, sources will not be generated.
5555
withSourcesJar()
56+
57+
sourceCompatibility = JavaVersion.VERSION_21
58+
targetCompatibility = JavaVersion.VERSION_21
5659
}
5760

5861
jar {

gradle.properties

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Done to increase the memory available to gradle.
22
org.gradle.jvmargs=-Xmx1G
3+
org.gradle.java.home=C:/Program Files/Java/jdk-21/
34

45
# Fabric Properties
5-
minecraft_version=1.20
6-
yarn_mappings=1.20+build.1
7-
loader_version=0.14.21
6+
minecraft_version=1.21
7+
yarn_mappings=1.21+build.2
8+
loader_version=0.15.11
89

910
#Fabric api
10-
fabric_version=0.83.0+1.20
11+
fabric_version=0.100.3+1.21
1112

1213
# Mod Properties
1314
mod_version = 1.0.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/net/just_s/sds/mixin/DebugStickMixin.java

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
import net.just_s.sds.Config;
44
import net.minecraft.block.Block;
55
import net.minecraft.block.BlockState;
6+
import net.minecraft.component.DataComponentTypes;
7+
import net.minecraft.component.type.DebugStickStateComponent;
68
import net.minecraft.entity.player.PlayerEntity;
79
import net.minecraft.item.DebugStickItem;
810
import net.minecraft.item.ItemStack;
9-
import net.minecraft.nbt.NbtCompound;
11+
import net.minecraft.registry.entry.RegistryEntry;
1012
import net.minecraft.state.StateManager;
1113
import net.minecraft.state.property.Property;
1214
import net.minecraft.text.Text;
13-
import net.minecraft.util.Util;
1415
import net.minecraft.util.math.BlockPos;
15-
import net.minecraft.registry.Registries;
1616
import net.minecraft.world.WorldAccess;
1717
import org.jetbrains.annotations.Nullable;
1818
import org.spongepowered.asm.mixin.Mixin;
@@ -36,13 +36,19 @@ private static <T extends Comparable<T>> BlockState cycle(BlockState state, Prop
3636
return null;
3737
}
3838

39+
@Shadow
40+
private static <T> T cycle(Iterable<T> values, @Nullable T value, boolean inverse) {
41+
return null;
42+
}
43+
3944
@Inject(at = @At("HEAD"), method = "use", cancellable = true)
4045
private void onUSE(PlayerEntity player, BlockState state, WorldAccess world, BlockPos pos, boolean update, ItemStack stack, CallbackInfoReturnable<Boolean> cir) {
4146
// if the player already does have the rights to use Debug Stick, the mod should not interfere
4247
if (player.isCreativeLevelTwoOp()) {return;}
4348

4449
Block block = state.getBlock();
45-
StateManager<Block, BlockState> stateManager = block.getStateManager();
50+
RegistryEntry<Block> registryEntry = state.getRegistryEntry();
51+
StateManager<Block, BlockState> stateManager = (registryEntry.value()).getStateManager();
4652
Collection<Property<?>> collection = stateManager.getProperties();
4753

4854
// check if block is modifiable by the config
@@ -52,22 +58,23 @@ private void onUSE(PlayerEntity player, BlockState state, WorldAccess world, Blo
5258
return;
5359
}
5460

55-
// https://minecraft.fandom.com/wiki/Debug_Stick#Item_data
61+
// https://minecraft.wiki/w/Debug_Stick
5662
// to remember the data of which property for which block is chosen,
57-
// Minecraft Devs decided to use NBT data for Debug Stick.
58-
// Who am I to disagree?
59-
NbtCompound nbtCompound = stack.getOrCreateSubNbt("DebugProperty");
63+
// Minecraft Devs decided to use Component for Debug Stick.
64+
// Who am I to disagree? (btw thx to @MrBretze for example code)
65+
DebugStickStateComponent stateComponent = stack.get(DataComponentTypes.DEBUG_STICK_STATE);
6066

61-
String blockName = Registries.BLOCK.getId(block).toString();
62-
String propertyName = nbtCompound.getString(blockName);
67+
if (stateComponent == null) {
68+
return;
69+
}
6370

64-
Property<?> property = stateManager.getProperty(propertyName);
71+
Property<?> property = stateComponent.properties().get(registryEntry);
6572

6673
if (player.isSneaking()) {
6774
// select next property
6875
property = getNextProperty(collection, property, block);
6976
// save chosen property in the NBT data of Debug Stick
70-
nbtCompound.putString(blockName, property.getName());
77+
stack.set(DataComponentTypes.DEBUG_STICK_STATE, stateComponent.with(registryEntry, property));
7178

7279
// send the player a message of successful selecting
7380
sendMessage(player, Text.of(
@@ -105,11 +112,11 @@ private void onUSE(PlayerEntity player, BlockState state, WorldAccess world, Blo
105112
* Choose next property that is appropriate for the configuration file
106113
* */
107114
private Property<?> getNextProperty(Collection<Property<?>> collection, @Nullable Property<?> property, @Nullable Block block) {
108-
int len = collection.size();
115+
int i = 0;
109116
do { // simply scrolling through the list of properties until suitable is found
110-
property = Util.next(collection, property);
111-
len--;
112-
} while (len > 0 && !isPropertyModifiable(property, block));
117+
property = cycle(collection, property, false);
118+
i++;
119+
} while (i < collection.size() && !isPropertyModifiable(property, block));
113120
return property;
114121
}
115122

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"type": "minecraft:crafting_shapeless",
3+
"ingredients": [
4+
{"item": "minecraft:stick"},
5+
{"item": "minecraft:chorus_fruit"}
6+
],
7+
"result": {
8+
"id": "minecraft:debug_stick",
9+
"count": 1
10+
}
11+
}

src/main/resources/data/sds/recipes/debug_stick.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{"item": "minecraft:chorus_fruit"}
66
],
77
"result": {
8-
"count": 1,
9-
"item": "minecraft:debug_stick"
8+
"id": "minecraft:debug_stick",
9+
"count": 1
1010
}
1111
}

src/main/resources/fabric.mod.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
],
2828

2929
"depends": {
30-
"fabricloader": ">=0.14.6",
30+
"fabricloader": ">=0.15.10",
3131
"fabric": "*",
32-
"minecraft": ">=1.20",
33-
"java": ">=17"
32+
"minecraft": ">=1.20.5",
33+
"java": ">=21"
3434
},
3535
"suggests": {
3636
"another-mod": "*"

0 commit comments

Comments
 (0)