Skip to content

Commit

Permalink
Merge branch '1.21'
Browse files Browse the repository at this point in the history
* 1.21:
  1.0.2
  updated mixins to avoid deadlock
  • Loading branch information
Faboslav committed Nov 24, 2024
2 parents 04f52e7 + c560776 commit 5b678e5
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 117 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.2

- Fixed possible deadlocks on worldgen (Thanks to pietro-lopes)

## 1.0.1

- Improved witch village structure details
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.faboslav.villagesandpillages.init;

import com.faboslav.villagesandpillages.VillagesAndPillages;
import com.faboslav.villagesandpillages.platform.StructureTypeRegistry;
import com.faboslav.villagesandpillages.world.structures.VillageWitchStructure;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.world.gen.structure.Structure;
import net.minecraft.world.gen.structure.StructureType;

public final class VillagesAndPillagesStructureTypes
{
public static final TagKey<Structure> VILLAGE_WITCH = TagKey.of(RegistryKeys.STRUCTURE,
Identifier.of(VillagesAndPillages.MOD_ID, "village_witch"));
public static StructureType<VillageWitchStructure> VILLAGE_WITCH_STRUCTURE = () -> VillageWitchStructure.CODEC;

static {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.faboslav.villagesandpillages.mixin;

import com.faboslav.villagesandpillages.init.VillagesAndPillagesStructureTypes;
import com.yungnickyoung.minecraft.yungsapi.util.MixinUtils;
import net.minecraft.block.Blocks;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.gen.feature.TreeFeature;
import net.minecraft.world.gen.feature.TreeFeatureConfig;
import net.minecraft.world.gen.feature.util.FeatureContext;
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.CallbackInfoReturnable;

@Mixin(TreeFeature.class)
public class TreeFeatureMixin
{
@Inject(
method = "generate(Lnet/minecraft/world/gen/feature/util/FeatureContext;)Z",
at = @At(value = "HEAD"),
cancellable = true
)
private void villagesAndPillages_noTreeOrLessTreeInStructures(
FeatureContext<TreeFeatureConfig> context,
CallbackInfoReturnable<Boolean> cir
) {
if (!(context.getWorld() instanceof ChunkRegion worldGenRegion)) return;

if ((worldGenRegion.getBlockState(context.getOrigin().down()).isOf(Blocks.MOSS_BLOCK) || context.getRandom().nextFloat() > 0.5) && MixinUtils.isPositionInTaggedStructure(worldGenRegion, context.getOrigin(), VillagesAndPillagesStructureTypes.VILLAGE_WITCH)) {
cir.setReturnValue(false);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"villagesandpillages:village_witch"
]
}
25 changes: 12 additions & 13 deletions common/src/main/resources/villagesandpillages-common.mixins.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{
"required": true,
"package": "com.faboslav.villagesandpillages.mixin",
"compatibilityLevel": "JAVA_${modJavaVersion}",
"minVersion": "0.8",
"injectors": {
"defaultRequire": 1
},
"mixins": [
"LessTreesInVillageWitchMixin",
"NoTreesOnWitchVillageHouseMixin",
"StructureTemplateMixin",
"accessor.StructureProcessorAccessor"
]
"required": true,
"package": "com.faboslav.villagesandpillages.mixin",
"compatibilityLevel": "JAVA_${modJavaVersion}",
"minVersion": "0.8",
"injectors": {
"defaultRequire": 1
},
"mixins": [
"StructureTemplateMixin",
"TreeFeatureMixin",
"accessor.StructureProcessorAccessor"
]
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ org.gradle.caching=true
mod_java_version=21
mod_name=Villages & Pillages
mod_id=villagesandpillages
mod_version=1.0.1
mod_version=1.0.2
mod_author=Faboslav
mod_description=Structure mod that brings an exciting twist to Minecraft by introducing hostile and unfriendly pillages, providing a thrilling contrast to the peaceful villages.
maven_group=com.faboslav.villagesandpillages
Expand All @@ -24,8 +24,8 @@ yarn_mappings_patch=1.21+build.4
enabled_platforms=fabric,neoforge

# Common
yungsapi_minecraft_version=1.21
yungsapi_version=5.0.0
yungsapi_minecraft_version=1.21.1
yungsapi_version=5.1.3

# Fabric https://fabricmc.net/versions.html
fabric_loader_version=0.15.11
Expand Down

0 comments on commit 5b678e5

Please sign in to comment.