Skip to content

Commit

Permalink
Update to Fabric 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
MattCzyr committed Nov 17, 2024
1 parent 27779a3 commit f9fbad0
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 40 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## Version 3.0.4
#### NeoForge 1.21.3
- Updated to NeoForge 1.21.3
- Fixed compass also performing offhand item action after opening GUI

## Version 2.2.8
#### Fabric 1.21.3
- Updated to Fabric 1.21.3
- Fixed compass also performing offhand item action after opening GUI

## Version 1.11.8
#### Forge 1.21.3
- Updated to Forge 1.21.3
- Fixed compass also performing offhand item action after opening GUI

## Version 2.2.7
#### Fabric 1.21.1
- Fixed uncraftable Nature's Compass recipe
Expand Down
2 changes: 1 addition & 1 deletion 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
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.2
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.9

# Mod Properties
mod_version=1.21.1-2.2.7-fabric
mod_version=1.21.3-2.2.8-fabric
maven_group=com.chaosthedude.naturescompass
archives_base_name=naturescompass

# Dependencies
fabric_version=0.102.1+1.21.1
fabric_version=0.108.0+1.21.3
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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
Expand Down
5 changes: 4 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# 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
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
2 changes: 2 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class NaturesCompass implements ModInitializer {
public void onInitialize() {
NaturesCompassConfig.load();

Registry.register(Registries.ITEM, Identifier.of(MODID, "naturescompass"), NATURES_COMPASS_ITEM);
Registry.register(Registries.ITEM, NaturesCompassItem.KEY, NATURES_COMPASS_ITEM);

Registry.register(Registries.DATA_COMPONENT_TYPE, Identifier.of(MODID, "biome_id"), BIOME_ID_COMPONENT);
Registry.register(Registries.DATA_COMPONENT_TYPE, Identifier.of(MODID, "compass_state"), COMPASS_STATE_COMPONENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected void enableScissor(DrawContext context) {
}

@Override
protected int getRowBottom(int index) {
public int getRowBottom(int index) {
return getRowTop(index) + itemHeight;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,31 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;

public class NaturesCompassItem extends Item {

public static final String NAME = "naturescompass";

public static final RegistryKey<Item> KEY = RegistryKey.of(RegistryKeys.ITEM, Identifier.of(NaturesCompass.MODID, NAME));

private BiomeSearchWorker worker;

public NaturesCompassItem() {
super(new Settings().maxCount(1));
super(new Settings().registryKey(KEY).maxCount(1));
}

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
public ActionResult use(World world, PlayerEntity player, Hand hand) {
if (!player.isSneaking()) {
if (world.isClient) {
final ItemStack stack = ItemUtils.getHeldNatureCompass(player);
Expand All @@ -54,7 +60,7 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand h
}
setState(player.getStackInHand(hand), null, CompassState.INACTIVE, player);
}
return TypedActionResult.pass(player.getStackInHand(hand));
return ActionResult.CONSUME;
}

public void searchForBiome(ServerWorld world, PlayerEntity player, Identifier biomeID, BlockPos pos, ItemStack stack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public static void apply(TeleportPacket packet, ServerPlayNetworking.Context con
final int y = findValidTeleportHeight(context.player().getEntityWorld(), x, z);

context.player().stopRiding();
context.player().networkHandler.requestTeleport(x, y, z, context.player().getYaw(), context.player().getPitch(), Collections.emptySet());
context.player().networkHandler.requestTeleport(x, y, z, context.player().getYaw(), context.player().getPitch());

if (!context.player().isFallFlying()) {
if (!context.player().isGliding()) {
context.player().setVelocity(context.player().getVelocity().getX(), 0, context.player().getVelocity().getZ());
context.player().setOnGround(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
public class BiomeUtils {

public static Registry<Biome> getBiomeRegistry(World world) {
return world.getRegistryManager().get(RegistryKeys.BIOME);
return world.getRegistryManager().getOrThrow(RegistryKeys.BIOME);
}

public static Identifier getIdentifierForBiome(World world, Biome biome) {
return getBiomeRegistry(world).getId(biome);
}

public static Optional<Biome> getBiomeForIdentifier(World world, Identifier id) {
return getBiomeRegistry(world).getOrEmpty(id);
return getBiomeRegistry(world).getOptionalValue(id);
}

public static List<Identifier> getAllowedBiomeIDs(World world) {
Expand All @@ -68,7 +68,7 @@ public static List<Identifier> getGeneratingDimensionIDs(ServerWorld serverWorld
final Registry<Biome> biomeRegistry = getBiomeRegistry(serverWorld);
for (ServerWorld world : serverWorld.getServer().getWorlds()) {
Set<RegistryEntry<Biome>> biomeSet = world.getChunkManager().getChunkGenerator().getBiomeSource().getBiomes();
RegistryEntry<Biome> biomeEntry = biomeRegistry.getEntry(biomeRegistry.getKey(biome).get()).get();
RegistryEntry<Biome> biomeEntry = biomeRegistry.getEntry(biome);
if (biomeSet.contains(biomeEntry)) {
dimensions.add(world.getRegistryKey().getValue());
}
Expand Down Expand Up @@ -107,8 +107,8 @@ public static String getBiomeTags(World world, Biome biome) {
// This will ignore duplicates and keep things sorted alphabetically
Set<String> biomeCategories = new TreeSet<String>();
Registry<Biome> biomeRegistry = getBiomeRegistry(world);
if (biomeRegistry.getKey(biome).isPresent() && biomeRegistry.getEntry(biomeRegistry.getKey(biome).get()).isPresent()) {
RegistryEntry<Biome> biomeEntry = biomeRegistry.getEntry(biomeRegistry.getKey(biome).get()).get();
if (biomeRegistry.getEntry(biome) != null) {
RegistryEntry<Biome> biomeEntry = biomeRegistry.getEntry(biome);
// Extremely hacky way of extracting a biome's categories from its tags
List<TagKey<Biome>> categoryTags = biomeEntry.streamTags().filter(tag -> tag.id().getPath().startsWith("is_")).collect(Collectors.toList());
for (TagKey<Biome> tag : categoryTags) {
Expand Down Expand Up @@ -223,13 +223,9 @@ public static boolean biomeIDIsBlacklisted(World world, Identifier biomeID) {
}

public static boolean biomeIDIsHidden(World world, Identifier biomeID) {
if (getBiomeForIdentifier(world, biomeID).isPresent()) {
final Registry<Biome> biomeRegistry = getBiomeRegistry(world);
final Biome biome = getBiomeForIdentifier(world, biomeID).get();
if (biomeRegistry.getKey(biome).isPresent() && biomeRegistry.getEntry(biomeRegistry.getKey(biome).get()).isPresent()) {
final RegistryEntry<Biome> biomeHolder = biomeRegistry.getEntry(biomeRegistry.getKey(biome).get()).get();
return biomeHolder.streamTags().anyMatch(tag -> tag.id().getPath().equals("c:hidden_from_locator_selection"));
}
final Registry<Biome> biomeRegistry = getBiomeRegistry(world);
if (biomeRegistry.getEntry(biomeID).isPresent()) {
return biomeRegistry.getEntry(biomeID).get().streamTags().anyMatch(tag -> tag.id().getPath().equals("c:hidden_from_locator_selection"));
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public BiomeSearchWorker(ServerWorld world, PlayerEntity player, ItemStack stack
this.startPos = startPos;
x = startPos.getX();
z = startPos.getZ();
yValues = MathHelper.stream(startPos.getY(), world.getBottomY() + 1, world.getTopY(), 64).toArray();
yValues = MathHelper.stream(startPos.getY(), world.getBottomY() + 1, world.getBottomY() + world.getHeight(), 64).toArray();
sampleSpace = NaturesCompassConfig.sampleSpaceModifier * BiomeUtils.getBiomeSize(world);
maxSamples = NaturesCompassConfig.maxSamples;
maxRadius = NaturesCompassConfig.radiusModifier * BiomeUtils.getBiomeSize(world);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@
"SLS"
],
"key": {
"S": {
"tag": "saplings"
},
"L":{
"tag": "logs"
},
"C":{
"item": "minecraft:compass"
}
"S": "#saplings",
"L": "#logs",
"C": "minecraft:compass"
},
"result": {
"id": "naturescompass:naturescompass"
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
],
"accessWidener" : "naturescompass.accesswidener",
"depends": {
"fabricloader": ">=0.16.2",
"fabricloader": ">=0.16.7",
"fabric-api": "*",
"minecraft": "~1.21.1",
"minecraft": "~1.21.3",
"java": ">=21"
},
"suggests": {
Expand Down

0 comments on commit f9fbad0

Please sign in to comment.