Skip to content

Commit

Permalink
Merge pull request #67 from rosebudmods/1.20.6
Browse files Browse the repository at this point in the history
port to 1.20.6
  • Loading branch information
ix0rai authored Jul 15, 2024
2 parents c586de8 + d8f6beb commit 9fd5388
Show file tree
Hide file tree
Showing 77 changed files with 289 additions and 307 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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/" }
Expand Down Expand Up @@ -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
Expand Down
17 changes: 8 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
22 changes: 13 additions & 9 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -130,26 +131,29 @@ 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.
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
case $MAX_FD in #(
'' | 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
Expand Down Expand Up @@ -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" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
41 changes: 20 additions & 21 deletions src/main/java/io/ix0rai/bodacious_berries/block/BasicBerryBush.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}

Expand All @@ -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
Expand All @@ -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);
}
}
Expand All @@ -103,29 +95,38 @@ 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
* <br> if the player clicking has bone meal, grow the plant if possible or pick berries if fully grown
* <br> otherwise, pick berries if possible
* @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);
}
}

Expand Down Expand Up @@ -155,14 +156,12 @@ protected void appendProperties(StateManager.Builder<Block, BlockState> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<Block, BlockState> builder) {
builder.add(FACING);
Expand Down Expand Up @@ -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);
}
}

Expand Down
Loading

0 comments on commit 9fd5388

Please sign in to comment.