Skip to content

Commit

Permalink
Merge pull request #198 from Gilly7CE/mcversion-gilly7ce-197-support-…
Browse files Browse the repository at this point in the history
…1.21

Add support for 1.21.1
  • Loading branch information
Gilly7CE authored Sep 8, 2024
2 parents b329df2 + 4db5106 commit d1c2fa9
Show file tree
Hide file tree
Showing 35 changed files with 387 additions and 546 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/mainbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: setup jdk 17
- name: setup jdk 21
uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: 17
java-version: 21
- name: Cache Gradle packages
uses: actions/cache@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/prbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: setup jdk 17
- name: setup jdk 21
uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: 17
java-version: 21
- name: Cache Gradle packages
uses: actions/cache@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: 17
java-version: 21
cache: "gradle"
- name: Grant execute permission to gradlew
run: chmod +x gradlew
Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -9,8 +9,8 @@ repositories {
}
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.minecraft_version + '-' + project.mod_version
Expand Down Expand Up @@ -59,8 +59,8 @@ tasks.withType(JavaCompile).configureEach {
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

// Minecraft 1.18 (pre2) upwards uses Java 17.
it.options.release = 17
// Minecraft 1.20.5 upwards uses Java 21.
it.options.release = 21
}

java {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.20.3
yarn_mappings=1.20.3+build.1
loader_version=0.15.7
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.3
# Mod Properties
mod_version=1.3.1
maven_group=carpet-addons-not-found
archives_base_name=carpet-addons-not-found
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
# fabric_version=0.25.1+build.416-1.16
carpet_core_version=1.4.128+v231205
carpet_minecraft_version=1.20.3
carpet_core_version=1.4.147+v240613
carpet_minecraft_version=1.21
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.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-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
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package carpetaddonsnotfound.flowerpotrules;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FlowerPotBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.event.GameEvent;

public class AlwaysPickFlowersFromPotsRule {
public static boolean execute(BlockState blockState, World world, BlockPos blockPos, PlayerEntity player) {
Block potBlock = blockState.getBlock();
Block content;
if (!(potBlock instanceof FlowerPotBlock flowerPotBlock) || (content = flowerPotBlock.getContent()) == Blocks.AIR) {
return false;
}

ItemStack itemStack = new ItemStack(content);
if (!player.giveItemStack(itemStack)) {
player.dropItem(itemStack, false);
}

world.setBlockState(blockPos, Blocks.FLOWER_POT.getDefaultState(), 3);
world.emitGameEvent(player, GameEvent.BLOCK_CHANGE, blockPos);
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package carpetaddonsnotfound.flowerpotrules;

import carpetaddonsnotfound.CarpetAddonsNotFoundSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import java.util.Map;

public class FlowerPotRuleManager {
public static boolean executeRule(Map<Block, Block> contentToPotted,
PlayerEntity player,
Hand hand,
World world,
BlockPos blockPos,
BlockState blockState,

Block currentContent) {
if (CarpetAddonsNotFoundSettings.replaceFlowersInPots) {
return ReplaceFlowersInPotsRule.execute(contentToPotted, player, hand, world, blockPos, currentContent);
}

if (CarpetAddonsNotFoundSettings.alwaysPickFlowersFromPots) {
return AlwaysPickFlowersFromPotsRule.execute(blockState, world, blockPos, player);
}

return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package carpetaddonsnotfound.flowerpotrules;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FlowerPotBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stat.Stats;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.event.GameEvent;

import java.util.Map;

public class ReplaceFlowersInPotsRule {
public static boolean execute(Map<Block, Block> contentToPotted, PlayerEntity player, Hand hand, World world,
BlockPos blockPos, Block currentContent) {
ItemStack playerStack = player.getStackInHand(hand);
Item item = playerStack.getItem();
Block newPot =
(item instanceof BlockItem ? contentToPotted.getOrDefault(((BlockItem) item).getBlock(), Blocks.AIR)
: Blocks.AIR);
if (!(newPot instanceof FlowerPotBlock) || ((FlowerPotBlock) newPot).getContent() == currentContent) {
return false;
}

ItemStack dropStack = new ItemStack(currentContent.asItem(), 1);
if (!player.giveItemStack(dropStack)) {
player.dropStack(dropStack);
}

BlockState blockState = newPot.getDefaultState();
world.setBlockState(blockPos, blockState, 3);
world.emitGameEvent(player, GameEvent.BLOCK_CHANGE, blockPos);
player.incrementStat(Stats.POT_FLOWER);
playerStack.decrementUnlessCreative(1, player);
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
package carpetaddonsnotfound.instantmining;

import net.minecraft.block.BlockState;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;

public class BlockBreakingSpeedRatioCalculator {
public static float getBlockBreakingSpeedRatio(LivingEntity livingEntity, BlockState blockState) {
int efficiencyLevel = EnchantmentHelper.getEfficiency(livingEntity);
public static float getBlockBreakingSpeedRatio(DynamicRegistryManager registryManager, LivingEntity livingEntity,
BlockState blockState) {
RegistryEntry<Enchantment> efficienyRegistryEntry =
registryManager.get(RegistryKeys.ENCHANTMENT).entryOf(Enchantments.EFFICIENCY);
int efficiencyLevel = EnchantmentHelper.getLevel(efficienyRegistryEntry, livingEntity.getWeaponStack());
int hasteAmplifier = StatusEffectUtil.getHasteAmplifier(livingEntity);
ItemStack mainHand = livingEntity.getEquippedStack(EquipmentSlot.MAINHAND);

Expand All @@ -20,7 +28,7 @@ public static float getBlockBreakingSpeedRatio(LivingEntity livingEntity, BlockS
return 1.0f;
}

var instantMiningRatioCalculator = new CompositeInstantMiningRatioCalculator();
CompositeInstantMiningRatioCalculator instantMiningRatioCalculator = new CompositeInstantMiningRatioCalculator();
return instantMiningRatioCalculator.getInstantMiningRatio(blockState, mainHand.getItem());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package carpetaddonsnotfound.mixins;

import carpetaddonsnotfound.mixins.invokers.EntityInvokerMixin;
import carpetaddonsnotfound.spectatorplayersuseportals.SpectatorPlayersUsePortalsRule;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.MovementType;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientPlayerEntity.class)
public abstract class ClientPlayerEntity_SpectatorPlayersUsePortalsMixin extends AbstractClientPlayerEntity implements
EntityInvokerMixin {

public ClientPlayerEntity_SpectatorPlayersUsePortalsMixin(ClientWorld world,
GameProfile profile) {
super(world, profile);
}

@Inject(method = "move", at = @At("TAIL"))
private void movePlayerInSpectator(MovementType movementType, Vec3d movement, CallbackInfo ci) {
SpectatorPlayersUsePortalsRule.movePlayerInSpectator(this);
}
}
Loading

0 comments on commit d1c2fa9

Please sign in to comment.