diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 27112c6c..6ec2e42b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -8,11 +8,11 @@ jobs:
steps:
- uses: actions/checkout@v3
- - name: set up JDK 17
+ - name: set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
- java-version: '17'
+ java-version: '21'
- name: grant execute permission for gradlew
run: chmod +x gradlew
- name: build with gradle
diff --git a/build.gradle b/build.gradle
index 5910d829..ecbe33b0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,5 @@
plugins {
- id "fabric-loom" version "1.2.4"
+ id "fabric-loom" version "1.6.+"
id "io.github.juuxel.loom-quiltflower" version "1.10.0"
id "com.github.johnrengelman.shadow" version "7.1.2"
id "java-library"
@@ -11,6 +11,14 @@ int javaVersion = Integer.parseInt(project.java_version)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
+loom {
+ runs {
+ client {
+ vmArgs "-Dfabric-tag-conventions-v1.legacyTagWarning=DEV_VERBOSE"
+ }
+ }
+}
+
repositories {
maven { url = "https://maven.gegy.dev/" }
maven { url = "https://maven.terraformersmc.com/releases/" }
@@ -39,7 +47,6 @@ dependencies {
// dependencies for config
shadow("com.electronwill.night-config:core:${project.night_config_version}")
shadow("com.electronwill.night-config:toml:${project.night_config_version}")
- include(modImplementation("dev.lambdaurora:spruceui:${project.spruceui_version}"))
modImplementation("com.terraformersmc:modmenu:${project.mod_menu_version}") { transitive = false }
// fabric api
diff --git a/gradle.properties b/gradle.properties
index 68bf53b6..9efd22e6 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -3,21 +3,20 @@ org.gradle.jvmargs=-Xmx1G
# fabric properties
# check these on https://fabricmc.net/versions.html
-minecraft_version=1.20.2
-quilt_mappings=1
-loader_version=0.14.22
+minecraft_version=1.20.6
+quilt_mappings=3
+loader_version=0.15.10
# mod properties
-java_version = 17
-mod_version = 2.1.1+mc1.20.2
+java_version = 21
+mod_version = 2.1.1+mc1.20.6
maven_group = io.ix0rai.bodacious_berries
archives_base_name = bodacious_berries
# mod dependencies
-fabric_api_version=0.89.3+1.20.2
-emi_version=1.0.21+1.20.2
-spruceui_version=5.0.3+1.20.2
-mod_menu_version=8.0.0
+fabric_api_version=0.97.8+1.20.6
+emi_version=1.1.6+1.20.6
+mod_menu_version=10.0.0-beta.1
# other dependencies
night_config_version=3.6.6
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index c1962a79..e6441136 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 0c85a1f7..b82aa23a 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index aeb74cbb..1aa94a42 100755
--- a/gradlew
+++ b/gradlew
@@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
-APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -130,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
+ fi
fi
# Increase the maximum file descriptors if we can.
@@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC3045
+ # shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -198,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-# Collect all arguments for the java command;
-# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
-# shell script including quotes and variable substitutions, so put them in
-# double quotes to make sure that they get re-expanded; and
-# * put everything else in single quotes, so that it's not re-expanded.
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
diff --git a/gradlew.bat b/gradlew.bat
index 93e3f59f..25da30db 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
diff --git a/src/main/java/io/ix0rai/bodacious_berries/block/BasicBerryBush.java b/src/main/java/io/ix0rai/bodacious_berries/block/BasicBerryBush.java
index 926d31ef..72c6b9dd 100644
--- a/src/main/java/io/ix0rai/bodacious_berries/block/BasicBerryBush.java
+++ b/src/main/java/io/ix0rai/bodacious_berries/block/BasicBerryBush.java
@@ -20,6 +20,7 @@
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
+import net.minecraft.util.ItemInteractionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
@@ -29,7 +30,6 @@
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
-@SuppressWarnings("deprecation")
public class BasicBerryBush extends PlantBlock implements BerryBush {
protected static final Vec3d BERRY_BUSH_SLOWING_VECTOR = new Vec3d(0.5D, 0.25D, 0.5D);
protected static final int GROW_CHANCE = 5;
@@ -63,7 +63,7 @@ public BasicBerryBush(Berry berry, int maxAge, VoxelShape smallShape, VoxelShape
* @return what kind of berries this block grows
*/
@Override
- public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
+ public ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state) {
return this.getBerryItem().getDefaultStack();
}
@@ -76,14 +76,6 @@ public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos po
return state.get(getAge()) < sizeChangeAge ? smallShape : largeShape;
}
- /**
- * determines whether this block still needs to be random ticked - i.e. whether it can still grow or not
- */
- @Override
- public boolean hasRandomTicks(BlockState state) {
- return state.get(getAge()) < maxAge;
- }
-
/**
* runs when this bush is ticked
* grows the bush if it can, a random throw is met, and light level is high enough
@@ -92,7 +84,7 @@ public boolean hasRandomTicks(BlockState state) {
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, RandomGenerator random) {
int age = state.get(getAge());
// if the age isn't maximum and the light level is high enough grow the bush
- if (age <= maxAge && random.nextInt(GROW_CHANCE) == 0 && world.getBaseLightLevel(pos.up(), 0) >= 9) {
+ if (age < maxAge && random.nextInt(GROW_CHANCE) == 0 && world.getBaseLightLevel(pos.up(), 0) >= 9) {
grow(world, pos, state, age + 1);
}
}
@@ -103,11 +95,22 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random
*/
@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
- if (entity instanceof LivingEntity && !UNSLOWED_ENTITIES.contains(entity.getType()) && state.get(getAge()) < sizeChangeAge) {
+ if (entity instanceof LivingEntity && !UNSLOWED_ENTITIES.contains(entity.getType()) && state.get(getAge()) >= sizeChangeAge) {
entity.setMovementMultiplier(state, BERRY_BUSH_SLOWING_VECTOR);
}
}
+ @Override
+ protected ItemInteractionResult onInteract(
+ ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity entity, Hand hand, BlockHitResult hitResult
+ ) {
+ int age = state.get(getAge());
+ boolean isMaxAge = age == getMaxAge();
+ return !isMaxAge && stack.isOf(Items.BONE_MEAL)
+ ? ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION
+ : super.onInteract(stack, state, world, pos, entity, hand, hitResult);
+ }
+
/**
* handles when our berry bush is right-clicked
*
if the player clicking has bone meal, grow the plant if possible or pick berries if fully grown
@@ -115,17 +118,15 @@ public void onEntityCollision(BlockState state, World world, BlockPos pos, Entit
* @return whether the action fails or passes
*/
@Override
- public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
+ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity entity, BlockHitResult hitResult) {
final int currentAge = state.get(getAge());
// if bone meal is allowed to be used, pass action
- if (hasRandomTicks(state) && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) {
- return ActionResult.PASS;
- } else if (currentAge == maxAge) {
+ if (currentAge == maxAge) {
// otherwise, give berries/unripe berries
return pickBerries(pos, world, state, this.getBerryItem());
} else {
// otherwise, do default use action from superclass
- return super.onUse(state, world, pos, player, hand, hit);
+ return super.onUse(state, world, pos, entity, hitResult);
}
}
@@ -155,14 +156,12 @@ protected void appendProperties(StateManager.Builder builder)
@Override
public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) {
- // hasRandomTicks checks the same thing as this method
- return hasRandomTicks(state);
+ return state.get(getAge()) < getMaxAge();
}
@Override
public boolean canFertilize(World world, RandomGenerator random, BlockPos pos, BlockState state) {
- // hasRandomTicks checks the same thing as this method
- return hasRandomTicks(state);
+ return isFertilizable(world, pos, state);
}
@Override
diff --git a/src/main/java/io/ix0rai/bodacious_berries/block/BerryHarvesterBlock.java b/src/main/java/io/ix0rai/bodacious_berries/block/BerryHarvesterBlock.java
index 1c5bac48..a943b041 100644
--- a/src/main/java/io/ix0rai/bodacious_berries/block/BerryHarvesterBlock.java
+++ b/src/main/java/io/ix0rai/bodacious_berries/block/BerryHarvesterBlock.java
@@ -1,5 +1,6 @@
package io.ix0rai.bodacious_berries.block;
+import com.mojang.serialization.MapCodec;
import io.ix0rai.bodacious_berries.block.entity.BerryHarvesterBlockEntity;
import io.ix0rai.bodacious_berries.registry.BodaciousBlocks;
import net.minecraft.block.Block;
@@ -33,6 +34,12 @@ public BerryHarvesterBlock(Settings settings) {
this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH));
}
+ @Override
+ protected MapCodec extends BlockWithEntity> getCodec() {
+ // todo
+ return null;
+ }
+
@Override
protected void appendProperties(StateManager.Builder builder) {
builder.add(FACING);
@@ -62,12 +69,12 @@ public BlockRenderType getRenderType(BlockState state) {
}
@Override
- public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
+ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity entity, BlockHitResult hitResult) {
if (!world.isClient) {
// create screen
NamedScreenHandlerFactory screenHandlerFactory = state.createScreenHandlerFactory(world, pos);
if (screenHandlerFactory != null) {
- player.openHandledScreen(screenHandlerFactory);
+ entity.openHandledScreen(screenHandlerFactory);
}
}
diff --git a/src/main/java/io/ix0rai/bodacious_berries/block/BerryVine.java b/src/main/java/io/ix0rai/bodacious_berries/block/BerryVine.java
index a3924597..ef8a7799 100644
--- a/src/main/java/io/ix0rai/bodacious_berries/block/BerryVine.java
+++ b/src/main/java/io/ix0rai/bodacious_berries/block/BerryVine.java
@@ -13,14 +13,13 @@
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
+import net.minecraft.util.ItemInteractionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.random.RandomGenerator;
-import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
-@SuppressWarnings("deprecation")
public class BerryVine extends VineBlock implements BerryBush {
protected static final int MAX_AGE = 3;
protected static final int MAX_BERRY_AMOUNT = 3;
@@ -34,7 +33,7 @@ public BerryVine(Berry berry) {
}
@Override
- public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
+ public ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state) {
return this.getBerryItem().getDefaultStack();
}
@@ -43,11 +42,6 @@ protected void appendProperties(StateManager.Builder builder)
builder.add(AGE, UP, NORTH, EAST, SOUTH, WEST);
}
- @Override
- public boolean hasRandomTicks(BlockState state) {
- return state.get(AGE) < MAX_AGE;
- }
-
@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, RandomGenerator random) {
super.randomTick(state, world, pos, random);
@@ -60,13 +54,20 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random
}
@Override
- public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
- if (hasRandomTicks(state) && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) {
- return ActionResult.PASS;
- } else if (state.get(AGE) == MAX_AGE) {
+ protected ItemInteractionResult onInteract(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity entity, Hand hand, BlockHitResult hitResult) {
+ int age = state.get(AGE);
+ boolean isMaxAge = age == MAX_AGE;
+ return !isMaxAge && stack.isOf(Items.BONE_MEAL)
+ ? ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION
+ : super.onInteract(stack, state, world, pos, entity, hand, hitResult);
+ }
+
+ @Override
+ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity entity, BlockHitResult hitResult) {
+ if (state.get(AGE) == MAX_AGE) {
return BasicBerryBush.pickBerries(pos, world, state, this.getBerryItem());
} else {
- return super.onUse(state, world, pos, player, hand, hit);
+ return super.onUse(state, world, pos, entity, hitResult);
}
}
@@ -97,12 +98,12 @@ public int getMaxBerryAmount() {
@Override
public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) {
- return this.hasRandomTicks(state);
+ return state.get(getAge()) < MAX_AGE;
}
@Override
public boolean canFertilize(World world, RandomGenerator random, BlockPos pos, BlockState state) {
- return this.hasRandomTicks(state);
+ return isFertilizable(world, pos, state);
}
@Override
diff --git a/src/main/java/io/ix0rai/bodacious_berries/block/CloudberryBush.java b/src/main/java/io/ix0rai/bodacious_berries/block/CloudberryBush.java
index 836e7ef3..9ff1d160 100644
--- a/src/main/java/io/ix0rai/bodacious_berries/block/CloudberryBush.java
+++ b/src/main/java/io/ix0rai/bodacious_berries/block/CloudberryBush.java
@@ -9,7 +9,6 @@
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.ActionResult;
-import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.random.RandomGenerator;
@@ -30,11 +29,6 @@ protected void appendProperties(StateManager.Builder builder)
super.appendProperties(builder);
}
- @Override
- public boolean hasRandomTicks(BlockState state) {
- return true;
- }
-
@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, RandomGenerator random) {
if (Boolean.TRUE.equals(state.get(DYING))) {
@@ -52,9 +46,9 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random
}
@Override
- public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
+ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity entity, BlockHitResult hitResult) {
if (Boolean.FALSE.equals(state.get(DYING))) {
- super.onUse(state, world, pos, player, hand, hit);
+ super.onUse(state, world, pos, entity, hitResult);
}
return ActionResult.FAIL;
diff --git a/src/main/java/io/ix0rai/bodacious_berries/block/DoubleBerryBush.java b/src/main/java/io/ix0rai/bodacious_berries/block/DoubleBerryBush.java
index 642bc4d0..ba43f8f9 100644
--- a/src/main/java/io/ix0rai/bodacious_berries/block/DoubleBerryBush.java
+++ b/src/main/java/io/ix0rai/bodacious_berries/block/DoubleBerryBush.java
@@ -16,15 +16,14 @@
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
+import net.minecraft.util.ItemInteractionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.random.RandomGenerator;
-import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
-@SuppressWarnings("deprecation")
public class DoubleBerryBush extends TallPlantBlock implements BerryBush {
public static final int MAX_AGE = 3;
public static final IntProperty AGE = Properties.AGE_3;
@@ -40,7 +39,7 @@ public DoubleBerryBush(Berry berry) {
}
@Override
- public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) {
+ public ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state) {
return this.getBerryItem().getDefaultStack();
}
@@ -56,11 +55,6 @@ protected void appendProperties(StateManager.Builder builder)
builder.add(getAge()).add(HALF);
}
- @Override
- public boolean hasRandomTicks(BlockState state) {
- return state.get(getAge()) < MAX_AGE;
- }
-
@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, RandomGenerator random) {
int age = state.get(getAge());
@@ -72,12 +66,12 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random
@Override
public boolean isFertilizable(WorldView world, BlockPos pos, BlockState state) {
- return hasRandomTicks(state);
+ return state.get(getAge()) < MAX_AGE;
}
@Override
public boolean canFertilize(World world, RandomGenerator random, BlockPos pos, BlockState state) {
- return hasRandomTicks(state);
+ return isFertilizable(world, pos, state);
}
@Override
@@ -91,13 +85,20 @@ public void grow(ServerWorld world, BlockPos pos, BlockState state, int newAge)
}
@Override
- public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
- if (hasRandomTicks(state) && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) {
- return ActionResult.PASS;
- } else if (state.get(getAge()) == MAX_AGE) {
+ protected ItemInteractionResult onInteract(ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity entity, Hand hand, BlockHitResult hitResult) {
+ int age = state.get(AGE);
+ boolean isMaxAge = age == MAX_AGE;
+ return !isMaxAge && stack.isOf(Items.BONE_MEAL)
+ ? ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION
+ : super.onInteract(stack, state, world, pos, entity, hand, hitResult);
+ }
+
+ @Override
+ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hitResult) {
+ if (state.get(getAge()) == MAX_AGE) {
return BasicBerryBush.pickBerries(pos, world, state, this.getBerryItem());
} else {
- return super.onUse(state, world, pos, player, hand, hit);
+ return super.onUse(state, world, pos, player, hitResult);
}
}
diff --git a/src/main/java/io/ix0rai/bodacious_berries/block/GrowingBerryBush.java b/src/main/java/io/ix0rai/bodacious_berries/block/GrowingBerryBush.java
index 750195a4..3e5e79d6 100644
--- a/src/main/java/io/ix0rai/bodacious_berries/block/GrowingBerryBush.java
+++ b/src/main/java/io/ix0rai/bodacious_berries/block/GrowingBerryBush.java
@@ -4,12 +4,13 @@
import net.minecraft.block.BlockState;
import net.minecraft.block.TallPlantBlock;
import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.property.IntProperty;
import net.minecraft.state.property.Properties;
-import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
+import net.minecraft.util.ItemInteractionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.random.RandomGenerator;
@@ -33,11 +34,6 @@ public void grow(ServerWorld world, BlockPos pos, BlockState state, int newAge)
}
}
- @Override
- public boolean hasRandomTicks(BlockState state) {
- return state.get(getAge()) <= maxAge;
- }
-
@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, RandomGenerator random) {
int age = state.get(getAge());
@@ -47,19 +43,22 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random
}
@Override
- public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
- // a GrowingBerryBush cannot produce berries until it grows to its double bush state
- if (hasRandomTicks(state) && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) {
+ protected ItemInteractionResult onInteract(
+ ItemStack stack, BlockState state, World world, BlockPos pos, PlayerEntity entity, Hand hand, BlockHitResult hitResult
+ ) {
+ int i = state.get(getAge());
+ boolean isMaxAge = i == getMaxAge();
+ if (isMaxAge && stack.isOf(Items.BONE_MEAL)) {
final int newAge = Math.min(maxAge, state.get(getAge()) + 1);
// grow to a double bush if new age exceeds maximum
if (newAge > maxAge) {
TallPlantBlock.placeAt(world, futureBush.getDefaultState(), pos, Block.NOTIFY_LISTENERS);
}
- return ActionResult.PASS;
+ return ItemInteractionResult.CONSUME;
}
- return ActionResult.FAIL;
+ return super.onInteract(stack, state, world, pos, entity, hand, hitResult);
}
@Override
diff --git a/src/main/java/io/ix0rai/bodacious_berries/block/JuicerBlock.java b/src/main/java/io/ix0rai/bodacious_berries/block/JuicerBlock.java
index cd94730c..b4655957 100644
--- a/src/main/java/io/ix0rai/bodacious_berries/block/JuicerBlock.java
+++ b/src/main/java/io/ix0rai/bodacious_berries/block/JuicerBlock.java
@@ -1,5 +1,6 @@
package io.ix0rai.bodacious_berries.block;
+import com.mojang.serialization.MapCodec;
import io.ix0rai.bodacious_berries.block.entity.JuicerBlockEntity;
import io.ix0rai.bodacious_berries.registry.BodaciousBlocks;
import net.minecraft.block.Block;
@@ -14,20 +15,25 @@
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.ActionResult;
-import net.minecraft.util.Hand;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
-@SuppressWarnings("deprecation")
public class JuicerBlock extends BlockWithEntity {
public static final BooleanProperty RUNNING = BooleanProperty.of("running");
+ public static final MapCodec CODEC = createCodec(JuicerBlock::new);
+
public JuicerBlock(Settings settings) {
super(settings);
this.setDefaultState(this.getDefaultState().with(RUNNING, false));
}
+ @Override
+ protected MapCodec extends BlockWithEntity> getCodec() {
+ return CODEC;
+ }
+
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new JuicerBlockEntity(pos, state);
@@ -44,7 +50,7 @@ public BlockRenderType getRenderType(BlockState state) {
}
@Override
- public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
+ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hitResult) {
if (!world.isClient) {
// create screen
NamedScreenHandlerFactory screenHandlerFactory = state.createScreenHandlerFactory(world, pos);
diff --git a/src/main/java/io/ix0rai/bodacious_berries/block/SpikedBerryBush.java b/src/main/java/io/ix0rai/bodacious_berries/block/SpikedBerryBush.java
index f71a34f0..1f587a73 100644
--- a/src/main/java/io/ix0rai/bodacious_berries/block/SpikedBerryBush.java
+++ b/src/main/java/io/ix0rai/bodacious_berries/block/SpikedBerryBush.java
@@ -32,8 +32,11 @@ public SpikedBerryBush(Berry berry, int maxAge, VoxelShape smallShape, VoxelShap
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
super.onEntityCollision(state, world, pos, entity);
- if (!(world.isClient) && movedMinDistance(entity) && !UNSLOWED_ENTITIES.contains(entity.getType()) && state.get(getAge()) < sizeChangeAge) {
- entity.damage(world.getDamageSources().sweetBerryBush(), damage);
+ if (!(world.isClient) && !UNSLOWED_ENTITIES.contains(entity.getType()) && state.get(getAge()) >= sizeChangeAge) {
+ boolean movedMinDistance = movedMinDistance(entity);
+ if (movedMinDistance) {
+ entity.damage(world.getDamageSources().sweetBerryBush(), damage);
+ }
}
}
diff --git a/src/main/java/io/ix0rai/bodacious_berries/block/entity/BerryHarvesterBlockEntity.java b/src/main/java/io/ix0rai/bodacious_berries/block/entity/BerryHarvesterBlockEntity.java
index 376cd41f..d814ad52 100644
--- a/src/main/java/io/ix0rai/bodacious_berries/block/entity/BerryHarvesterBlockEntity.java
+++ b/src/main/java/io/ix0rai/bodacious_berries/block/entity/BerryHarvesterBlockEntity.java
@@ -20,6 +20,7 @@
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
+import net.minecraft.registry.HolderLookup;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.sound.SoundCategory;
@@ -40,14 +41,13 @@ public BerryHarvesterBlockEntity(BlockPos pos, BlockState state) {
}
@Override
- public void readNbt(NbtCompound nbt) {
- super.readNbt(nbt);
- Inventories.readNbt(nbt, inventory);
+ public void method_11014(NbtCompound nbt, HolderLookup.Provider lookupProvider) {
+ Inventories.readNbt(nbt, inventory, lookupProvider);
}
@Override
- public void writeNbt(NbtCompound nbt) {
- Inventories.writeNbt(nbt, inventory);
+ public void writeNbt(NbtCompound nbt, HolderLookup.Provider lookupProvider) {
+ Inventories.writeNbt(nbt, inventory, lookupProvider);
}
@Override
@@ -56,8 +56,8 @@ public Packet toUpdatePacket() {
}
@Override
- public NbtCompound toSyncedNbt() {
- return toNbt();
+ public NbtCompound toSyncedNbt(HolderLookup.Provider lookupProvider) {
+ return toNbt(lookupProvider);
}
public static void tick(World world, BlockPos pos, BlockState state, BerryHarvesterBlockEntity harvester) {
diff --git a/src/main/java/io/ix0rai/bodacious_berries/block/entity/JuicerBlockEntity.java b/src/main/java/io/ix0rai/bodacious_berries/block/entity/JuicerBlockEntity.java
index 80b6d8b2..a588e8e2 100644
--- a/src/main/java/io/ix0rai/bodacious_berries/block/entity/JuicerBlockEntity.java
+++ b/src/main/java/io/ix0rai/bodacious_berries/block/entity/JuicerBlockEntity.java
@@ -18,6 +18,7 @@
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeHolder;
+import net.minecraft.registry.HolderLookup;
import net.minecraft.screen.ArrayPropertyDelegate;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.PropertyDelegate;
@@ -66,14 +67,13 @@ public JuicerBlockEntity(BlockPos pos, BlockState state) {
}
@Override
- public void readNbt(NbtCompound nbt) {
- super.readNbt(nbt);
- Inventories.readNbt(nbt, inventory);
+ public void method_11014(NbtCompound nbt, HolderLookup.Provider lookupProvider) {
+ Inventories.readNbt(nbt, inventory, lookupProvider);
}
@Override
- public void writeNbt(NbtCompound nbt) {
- Inventories.writeNbt(nbt, inventory);
+ public void writeNbt(NbtCompound nbt, HolderLookup.Provider lookupProvider) {
+ Inventories.writeNbt(nbt, inventory, lookupProvider);
}
@Override
diff --git a/src/main/java/io/ix0rai/bodacious_berries/block/entity/JuicerRecipe.java b/src/main/java/io/ix0rai/bodacious_berries/block/entity/JuicerRecipe.java
index 8cc40138..c408449d 100644
--- a/src/main/java/io/ix0rai/bodacious_berries/block/entity/JuicerRecipe.java
+++ b/src/main/java/io/ix0rai/bodacious_berries/block/entity/JuicerRecipe.java
@@ -4,17 +4,19 @@
import com.mojang.datafixers.util.Either;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
+import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import io.ix0rai.bodacious_berries.BodaciousBerries;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
-import net.minecraft.network.PacketByteBuf;
+import net.minecraft.network.RegistryByteBuf;
+import net.minecraft.network.codec.PacketCodec;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.RecipeHolder;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.RecipeType;
-import net.minecraft.registry.DynamicRegistryManager;
+import net.minecraft.registry.HolderLookup;
import net.minecraft.registry.Registries;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.collection.DefaultedList;
@@ -77,8 +79,8 @@ public boolean matches(Inventory inv, World world) {
}
@Override
- public ItemStack craft(Inventory inventory, DynamicRegistryManager registryManager) {
- return getResult(registryManager).copy();
+ public ItemStack craft(Inventory inventory, HolderLookup.Provider provider) {
+ return getResult(provider).copy();
}
@Override
@@ -87,7 +89,7 @@ public boolean fits(int width, int height) {
}
@Override
- public ItemStack getResult(DynamicRegistryManager registryManager) {
+ public ItemStack getResult(HolderLookup.Provider provider) {
return this.result;
}
@@ -162,15 +164,15 @@ private static boolean check(Predicate function) {
*/
public record IngredientSet(Ingredient ingredient0, Ingredient ingredient1, Ingredient ingredient2, Ingredient receptacle) {
private static final Codec ALL_CODEC = RecordCodecBuilder.create((instance) -> instance.group(
- Ingredient.field_46095.fieldOf("all").forGetter((set) -> set.ingredient0),
- Ingredient.field_46095.fieldOf("receptacle").forGetter((set) -> set.receptacle)
+ Ingredient.DISALLOW_EMPTY_CODEC.fieldOf("all").forGetter((set) -> set.ingredient0),
+ Ingredient.DISALLOW_EMPTY_CODEC.fieldOf("receptacle").forGetter((set) -> set.receptacle)
).apply(instance, (ingredient, receptacle) -> new IngredientSet(ingredient, ingredient, ingredient, receptacle)));
private static final Codec INDIVIDUAL_CODEC = RecordCodecBuilder.create((instance) -> instance.group(
- Ingredient.field_46095.fieldOf("0").forGetter((set) -> set.ingredient0),
- Ingredient.field_46095.fieldOf("1").forGetter((set) -> set.ingredient1),
- Ingredient.field_46095.fieldOf("2").forGetter((set) -> set.ingredient2),
- Ingredient.field_46095.fieldOf("receptacle").forGetter((set) -> set.receptacle)
+ Ingredient.DISALLOW_EMPTY_CODEC.fieldOf("0").forGetter((set) -> set.ingredient0),
+ Ingredient.DISALLOW_EMPTY_CODEC.fieldOf("1").forGetter((set) -> set.ingredient1),
+ Ingredient.DISALLOW_EMPTY_CODEC.fieldOf("2").forGetter((set) -> set.ingredient2),
+ Ingredient.DISALLOW_EMPTY_CODEC.fieldOf("receptacle").forGetter((set) -> set.receptacle)
).apply(instance, IngredientSet::new));
private static final Codec> EITHER_CODEC = Codec.either(
@@ -194,32 +196,53 @@ private boolean ingredientsMatch() {
}
public static class Serializer implements RecipeSerializer {
- private static final Codec CODEC = RecordCodecBuilder.create((instance) -> instance.group(
- IngredientSet.CODEC.fieldOf("ingredients").forGetter((recipe) -> new IngredientSet(recipe.ingredient0, recipe.ingredient1, recipe.ingredient2, recipe.receptacle)),
- Registries.ITEM.getCodec().xmap(ItemStack::new, ItemStack::getItem).fieldOf("result").forGetter((recipe) -> recipe.result)
+ private static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> instance.group(
+ IngredientSet.CODEC.fieldOf("ingredients").forGetter((recipe) -> {
+ if (recipe instanceof JuicerRecipe juicerRecipe) {
+ return new IngredientSet(juicerRecipe.ingredient0, juicerRecipe.ingredient1, juicerRecipe.ingredient2, juicerRecipe.receptacle);
+ } else {
+ throw new RuntimeException("recipe error");
+ }
+ }),
+ Registries.ITEM.getCodec().xmap(ItemStack::new, ItemStack::getItem).fieldOf("result").forGetter((recipe) -> {
+ if (recipe instanceof JuicerRecipe juicerRecipe) {
+ return juicerRecipe.result;
+ } else {
+ throw new RuntimeException("recipe error");
+ }
+ })
).apply(instance, (set, result) -> new JuicerRecipe(set.ingredient0(), set.ingredient1(), set.ingredient2(), set.receptacle(), result)));
+ private final PacketCodec packetCodec;
+
+ public Serializer() {
+ packetCodec = PacketCodec.create(this::write, this::read);
+ }
+
+ public JuicerRecipe read(RegistryByteBuf buf) {
+ Ingredient input1 = Ingredient.PACKET_CODEC.decode(buf);
+ Ingredient input2 = Ingredient.PACKET_CODEC.decode(buf);
+ Ingredient input3 = Ingredient.PACKET_CODEC.decode(buf);
+ Ingredient receptacle = Ingredient.PACKET_CODEC.decode(buf);
+ ItemStack result = ItemStack.PACKET_CODEC.decode(buf);
+ return new JuicerRecipe(input1, input2, input3, receptacle, result);
+ }
- @Override
- public JuicerRecipe read(PacketByteBuf buf) {
- Ingredient input1 = Ingredient.fromPacket(buf);
- Ingredient input2 = Ingredient.fromPacket(buf);
- Ingredient input3 = Ingredient.fromPacket(buf);
- Ingredient receptacle = Ingredient.fromPacket(buf);
- return new JuicerRecipe(input1, input2, input3, receptacle, buf.readItemStack());
+ public void write(RegistryByteBuf packetData, JuicerRecipe recipe) {
+ Ingredient.PACKET_CODEC.encode(packetData, recipe.ingredient0());
+ Ingredient.PACKET_CODEC.encode(packetData, recipe.ingredient1());
+ Ingredient.PACKET_CODEC.encode(packetData, recipe.ingredient2());
+ Ingredient.PACKET_CODEC.encode(packetData, recipe.receptacle());
+ ItemStack.PACKET_CODEC.encode(packetData, recipe.getResult());
}
@Override
- public Codec method_53736() {
+ public MapCodec getCodec() {
return CODEC;
}
@Override
- public void write(PacketByteBuf packetData, JuicerRecipe recipe) {
- recipe.ingredient0().write(packetData);
- recipe.ingredient1().write(packetData);
- recipe.ingredient2().write(packetData);
- recipe.receptacle().write(packetData);
- packetData.writeItemStack(recipe.getResult());
+ public PacketCodec getPacketCodec() {
+ return packetCodec;
}
}
}
diff --git a/src/main/java/io/ix0rai/bodacious_berries/config/BodaciousConfigScreen.java b/src/main/java/io/ix0rai/bodacious_berries/config/BodaciousConfigScreen.java
index 870a38f3..e435dad6 100644
--- a/src/main/java/io/ix0rai/bodacious_berries/config/BodaciousConfigScreen.java
+++ b/src/main/java/io/ix0rai/bodacious_berries/config/BodaciousConfigScreen.java
@@ -1,24 +1,18 @@
package io.ix0rai.bodacious_berries.config;
-import dev.lambdaurora.spruceui.Position;
-import dev.lambdaurora.spruceui.SpruceTexts;
-import dev.lambdaurora.spruceui.option.SpruceBooleanOption;
-import dev.lambdaurora.spruceui.option.SpruceOption;
-import dev.lambdaurora.spruceui.option.SpruceSimpleActionOption;
-import dev.lambdaurora.spruceui.screen.SpruceScreen;
-import dev.lambdaurora.spruceui.widget.SpruceButtonWidget;
-import dev.lambdaurora.spruceui.widget.container.SpruceOptionListWidget;
import io.ix0rai.bodacious_berries.BodaciousBerries;
import io.ix0rai.bodacious_berries.registry.Berry;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.gui.screen.option.SimpleOptionsScreen;
+import net.minecraft.client.option.Option;
import org.jetbrains.annotations.Nullable;
+import java.util.ArrayList;
+import java.util.List;
import java.util.function.Consumer;
-import java.util.function.Supplier;
import static io.ix0rai.bodacious_berries.BodaciousBerries.CONFIG;
@@ -26,73 +20,25 @@
* based on the configuration screen for lambdabettergrass by lambdaurora
*/
@Environment(EnvType.CLIENT)
-public class BodaciousConfigScreen extends SpruceScreen {
- private final Screen parent;
-
- private final SpruceOption resetOption;
- private final SpruceOption[] generationOptions = new SpruceOption[Berry.values().length];
+public class BodaciousConfigScreen extends SimpleOptionsScreen {
public BodaciousConfigScreen(@Nullable Screen parent) {
- super(BodaciousBerries.translatableText("config.title"));
- this.parent = parent;
+ super(parent, MinecraftClient.getInstance().options, BodaciousBerries.translatableText("config.title"), createOptions());
+ }
+ @SuppressWarnings("unchecked")
+ private static Option[] createOptions() {
+ List