Skip to content

Commit

Permalink
1.21.2/1.21.3 port (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko authored Nov 14, 2024
1 parent b377d53 commit c70738e
Show file tree
Hide file tree
Showing 38 changed files with 230 additions and 175 deletions.
4 changes: 2 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.7-SNAPSHOT'
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -79,7 +79,7 @@ processResources {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"

it.options.release = 21
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11
minecraft_version=1.21.2
yarn_mappings=1.21.2+build.1
loader_version=0.16.7
# check available versions on maven (https://masa.dy.fi/maven/carpet/fabric-carpet/) for the given minecraft version you are using
carpet_core_version=1.4.147+v240613
carpet_core_version=1.4.158+v241022
# for gametests
fabric_api_version=0.100.3+1.21
fabric_api_version=0.106.0+1.21.2

# Mod Properties
mod_version = 1.4.148
mod_version = 1.4.158
maven_group = carpet-extra
archives_base_name = carpet-extra

Expand All @@ -23,12 +23,12 @@ org.gradle.jvmargs=-Xmx1G
# The Curseforge versions "names" or ids for the main branch (comma separated: 1.16.4,1.16.5)
# This is needed because CF uses too vague names for prereleases and release candidates
# Can also be the version ID directly coming from https://minecraft.curseforge.com/api/game/versions?token=[API_TOKEN]
release-curse-versions = Minecraft 1.21:1.21,Minecraft 1.21:1.21.1
release-curse-versions = Minecraft 1.21:1.21.2,Minecraft 1.21:1.21.3
# Whether or not to build another branch on release
release-extra-branch = false
# The name of the second branch to release
release-extra-branch-name = future
# The "name" or id of the Curseforge version for the secondary branch
# This is needed because CF uses too vague names for snapshots
# Can also be the version ID directly coming from https://minecraft.curseforge.com/api/game/versions?token=[API_TOKEN]
release-extra-curse-version = Minecraft 1.19:1.19.3
release-extra-curse-version = Minecraft 1.20:1.20.4-Snapshot
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.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
31 changes: 18 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# 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"'
# 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 @@ -133,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 @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# 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.

# 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, 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
14 changes: 7 additions & 7 deletions src/gametest/java/carpetextra/test/DispenserWithBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public class DispenserWithBlock {
static final String STRUCTURE = "carpet-extra:dispenserbase";
static final String BATCH = "dispenserwithblock";
static final int DISPENSER_DELAY = 4;
BlockPos lapis = new BlockPos(2, 1, 0);
BlockPos button = new BlockPos(0, 2, 0);
BlockPos dispenser = new BlockPos(1, 2, 0);
BlockPos lapis = new BlockPos(2, 0, 0);
BlockPos button = new BlockPos(0, 1, 0);
BlockPos dispenser = new BlockPos(1, 1, 0);

@BeforeBatch(batchId = BATCH)
public void before(ServerWorld world) {
Expand Down Expand Up @@ -117,22 +117,22 @@ public void shearPumpkinBreaks(TestContext ctx) {

@GameTest(templateName = STRUCTURE, batchId = BATCH)
public void boatOnRegularIce(TestContext ctx) {
boatTest(ctx, Items.OAK_BOAT, Blocks.ICE, EntityType.BOAT);
boatTest(ctx, Items.OAK_BOAT, Blocks.ICE, EntityType.OAK_BOAT);
}

@GameTest(templateName = STRUCTURE, batchId = BATCH)
public void boatOnPackedIce(TestContext ctx) {
boatTest(ctx, Items.OAK_BOAT, Blocks.PACKED_ICE, EntityType.BOAT);
boatTest(ctx, Items.OAK_BOAT, Blocks.PACKED_ICE, EntityType.OAK_BOAT);
}

@GameTest(templateName = STRUCTURE, batchId = BATCH)
public void boatOnBlueIce(TestContext ctx) {
boatTest(ctx, Items.OAK_BOAT, Blocks.BLUE_ICE, EntityType.BOAT);
boatTest(ctx, Items.OAK_BOAT, Blocks.BLUE_ICE, EntityType.OAK_BOAT);
}

@GameTest(templateName = STRUCTURE, batchId = BATCH)
public void chestBoatOnIce(TestContext ctx) {
boatTest(ctx, Items.OAK_CHEST_BOAT, Blocks.ICE, EntityType.CHEST_BOAT);
boatTest(ctx, Items.OAK_CHEST_BOAT, Blocks.ICE, EntityType.OAK_CHEST_BOAT);
}

private void boatTest(TestContext ctx, Item item, Block block, EntityType<?> expectedEntity) {
Expand Down
4 changes: 2 additions & 2 deletions src/gametest/java/carpetextra/test/WartFarming.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public class WartFarming {
private static final String STRUCTURE = "carpet-extra:wartbase";
private static final String BATCH = "wartfarming";

BlockPos soulSand = new BlockPos(0, 1, 0);
BlockPos lapis = new BlockPos(3, 2, 0);
BlockPos soulSand = new BlockPos(0, 0, 0);
BlockPos lapis = new BlockPos(3, 1, 0);

@BeforeBatch(batchId = BATCH)
public void before(ServerWorld world) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import net.minecraft.entity.passive.CowEntity;
import net.minecraft.entity.passive.GoatEntity;
import net.minecraft.entity.passive.MooshroomEntity;
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.item.BoatItem;
import net.minecraft.item.HoeItem;
Expand Down Expand Up @@ -64,10 +63,10 @@ public class CarpetExtraDispenserBehaviors {
public static final DispenserBehavior FEED_ANIMAL = new FeedAnimalDispenserBehavior();
public static final DispenserBehavior FEED_MOOSHROOM = new FeedMooshroomDispenserBehavior();
// dispensersFillMinecarts
public static final DispenserBehavior FILL_MINECART_CHEST = new FillMinecartDispenserBehavior(AbstractMinecartEntity.Type.CHEST);
public static final DispenserBehavior FILL_MINECART_FURNACE = new FillMinecartDispenserBehavior(AbstractMinecartEntity.Type.FURNACE);
public static final DispenserBehavior FILL_MINECART_TNT = new FillMinecartDispenserBehavior(AbstractMinecartEntity.Type.TNT);
public static final DispenserBehavior FILL_MINECART_HOPPER = new FillMinecartDispenserBehavior(AbstractMinecartEntity.Type.HOPPER);
public static final DispenserBehavior FILL_MINECART_CHEST = new FillMinecartDispenserBehavior(EntityType.CHEST_MINECART);
public static final DispenserBehavior FILL_MINECART_FURNACE = new FillMinecartDispenserBehavior(EntityType.FURNACE_MINECART);
public static final DispenserBehavior FILL_MINECART_TNT = new FillMinecartDispenserBehavior(EntityType.TNT_MINECART);
public static final DispenserBehavior FILL_MINECART_HOPPER = new FillMinecartDispenserBehavior(EntityType.HOPPER_MINECART);
// dispensersMilkAnimals
public static final DispenserBehavior MILK_ANIMAL = new MilkAnimalDispenserBehavior();
public static final DispenserBehavior MILK_MOOSHROOM = new MilkMooshroomDispenserBehavior();
Expand Down Expand Up @@ -110,9 +109,8 @@ public static DispenserBehavior getCustomDispenserBehavior(ServerWorld world, Bl

// chickenShearing
if(CarpetExtraSettings.chickenShearing && item == Items.SHEARS) {
boolean hasShearableChickens = !world.getEntitiesByType(EntityType.CHICKEN, frontBlockBox, EntityPredicates.VALID_LIVING_ENTITY.and((chickenEntity) -> {
return !((AnimalEntity) chickenEntity).isBaby();
})).isEmpty();
boolean hasShearableChickens = !world.getEntitiesByType(EntityType.CHICKEN, frontBlockBox, EntityPredicates.VALID_LIVING_ENTITY.and((chickenEntity) ->
!((AnimalEntity) chickenEntity).isBaby())).isEmpty();

if(hasShearableChickens) {
return SHEAR_CHICKEN;
Expand All @@ -127,18 +125,16 @@ public static DispenserBehavior getCustomDispenserBehavior(ServerWorld world, Bl
// dispensersFeedAnimals
if(CarpetExtraSettings.dispensersFeedAnimals) {
// check for animals that can be bred with the current item being dispensed in front of dispenser
boolean hasFeedableAnimals = !world.getEntitiesByClass(AnimalEntity.class, frontBlockBox, EntityPredicates.VALID_LIVING_ENTITY.and((animalEntity) -> {
return ((AnimalEntity) animalEntity).isBreedingItem(stack);
})).isEmpty();
boolean hasFeedableAnimals = !world.getEntitiesByClass(AnimalEntity.class, frontBlockBox, EntityPredicates.VALID_LIVING_ENTITY.and((animalEntity) ->
((AnimalEntity) animalEntity).isBreedingItem(stack))).isEmpty();

if(hasFeedableAnimals) {
return FEED_ANIMAL;
}

// get brown mooshrooms in front of dispenser
boolean hasFeedableMooshrooms = !world.getEntitiesByType(EntityType.MOOSHROOM, frontBlockBox, EntityPredicates.VALID_LIVING_ENTITY.and((mooshroomEntity) -> {
return ((MooshroomEntity) mooshroomEntity).getVariant() == MooshroomEntity.Type.BROWN;
})).isEmpty();
boolean hasFeedableMooshrooms = !world.getEntitiesByType(EntityType.MOOSHROOM, frontBlockBox, EntityPredicates.VALID_LIVING_ENTITY.and((mooshroomEntity) ->
((MooshroomEntity) mooshroomEntity).getVariant() == MooshroomEntity.Type.BROWN)).isEmpty();

// check if item is a small flower
if(hasFeedableMooshrooms && stack.isIn(ItemTags.SMALL_FLOWERS)) {
Expand Down Expand Up @@ -173,9 +169,8 @@ else if(item == Items.HOPPER) {
// bucket to milk
if(item == Items.BUCKET) {
// check for cows, mooshrooms, or goats in front of dispenser
boolean hasMilkable = !world.getEntitiesByClass(AnimalEntity.class, frontBlockBox, EntityPredicates.VALID_LIVING_ENTITY.and((animalEntity) -> {
return animalEntity instanceof CowEntity || animalEntity instanceof GoatEntity;
})).isEmpty();
boolean hasMilkable = !world.getEntitiesByClass(AnimalEntity.class, frontBlockBox, EntityPredicates.VALID_LIVING_ENTITY.and((animalEntity) ->
animalEntity instanceof CowEntity || animalEntity instanceof GoatEntity)).isEmpty();

if(hasMilkable) {
return MILK_ANIMAL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static ItemStack eatItem(AnimalEntity animal, ItemStack foodStack) {
animal.playSound(SoundEvents.ENTITY_CAT_EAT, 1.0F, 1.0F);
}
else if(type == EntityType.FOX) {
animal.playSound(animal.getEatSound(foodStack), 1.0F, 1.0F);
animal.playSound(SoundEvents.ENTITY_FOX_EAT, 1.0F, 1.0F);
}

// remove one item and return
Expand All @@ -103,14 +103,10 @@ private static boolean canLoveWithItem(AnimalEntity animal, ItemStack foodStack)
Item item = foodStack.getItem();

// llamas only breed with hay bales
if((type == EntityType.LLAMA || type == EntityType.TRADER_LLAMA) && item != Items.HAY_BLOCK) {
if ((type == EntityType.LLAMA || type == EntityType.TRADER_LLAMA) && item != Items.HAY_BLOCK) {
return false;
}
// horses/donkeys/mules only breed with golden carrot, golden apple, or enchanted golden apple
else if((type == EntityType.HORSE || type == EntityType.DONKEY || type == EntityType.MULE) && !(item == Items.GOLDEN_CARROT || item == Items.GOLDEN_APPLE || item == Items.ENCHANTED_GOLDEN_APPLE)) {
return false;
}

return true;
else return (type != EntityType.HORSE && type != EntityType.DONKEY && type != EntityType.MULE) || (item == Items.GOLDEN_CARROT || item == Items.GOLDEN_APPLE || item == Items.ENCHANTED_GOLDEN_APPLE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.block.DispenserBlock;
import net.minecraft.block.dispenser.FallibleItemDispenserBehavior;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
import net.minecraft.entity.vehicle.MinecartEntity;
import net.minecraft.item.ItemStack;
Expand All @@ -15,9 +16,9 @@
import net.minecraft.util.math.Box;

public class FillMinecartDispenserBehavior extends FallibleItemDispenserBehavior {
private final AbstractMinecartEntity.Type MINECART_TYPE;
private final EntityType<? extends AbstractMinecartEntity> MINECART_TYPE;

public FillMinecartDispenserBehavior(AbstractMinecartEntity.Type minecartType) {
public FillMinecartDispenserBehavior(EntityType<? extends AbstractMinecartEntity> minecartType) {
this.MINECART_TYPE = minecartType;
}

Expand All @@ -34,7 +35,7 @@ protected ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) {
if(!minecarts.isEmpty()) {
// choose a random minecart in front of dispenser to fill
MinecartEntity oldMinecart = minecarts.get(world.random.nextInt(minecarts.size()));
AbstractMinecartEntity newMinecart = AbstractMinecartEntity.create(world, oldMinecart.getX(), oldMinecart.getY(), oldMinecart.getZ(), this.MINECART_TYPE, ItemStack.EMPTY, null);
AbstractMinecartEntity newMinecart = AbstractMinecartEntity.create(world, oldMinecart.getX(), oldMinecart.getY(), oldMinecart.getZ(), this.MINECART_TYPE, SpawnReason.DISPENSER, ItemStack.EMPTY, null);

// Copy data from original minecart to new minecart
// Possibly missing some things to copy here. Add more if needed
Expand Down
Loading

0 comments on commit c70738e

Please sign in to comment.