Skip to content

Commit

Permalink
moved structure mob check
Browse files Browse the repository at this point in the history
  • Loading branch information
TelepathicGrunt committed Feb 16, 2022
1 parent 23e6486 commit f19e2dc
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### **(V.3.3.11 Changes) (1.18.1 Minecraft)**

#### Optimization:
Slightly optimized natural mob spawning over time for RS's structure checks.

#### Config:
Fixed Savanna Mansion maps not showing up as a villager trade due to typo in config.
(Config should auto fix that one typo next time you run the game)


### **(V.3.3.10 Changes) (1.18.1 Minecraft)**

#### Config:
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ org.gradle.jvmargs = -Xmx2G

# Mod Properties
mc_version = 1.18.1
mod_version = 3.3.10
mod_version = 3.3.11
maven_group = com.telepathicgrunt
archives_base_name = repurposed_structures_fabric

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import draylar.omegaconfig.api.Comment;
import draylar.omegaconfig.api.Config;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
Expand All @@ -28,10 +29,35 @@ public void save() {
// Add logic here when adding new mob spawn structures to config."
// The logic needs to do a putIfAbsent to add the missing structures between the config versions when updating."

configVersion = 1;
if(configVersion == 1) {
removeEntries(villagerMapTrades, "minecraft:cartographer", "repurposed_structures:mansion_savannna");
addEntries(villagerMapTrades, "minecraft:cartographer", new MobMapTrades.VillagerTradeEntry("repurposed_structures:mansion_savanna", "MANSION", 4, 14, 12, 10));
}

configVersion = 2;
Config.super.save();
}

private void addEntries(Map<String, List<MobMapTrades.VillagerTradeEntry>> map, String key, MobMapTrades.VillagerTradeEntry entry){
// assign entry
if(!map.containsKey(key) || map.get(key).stream().noneMatch(e -> e.structure.equals(entry.structure))) {
List<MobMapTrades.VillagerTradeEntry> newList = new ArrayList<>();
newList.add(entry);
if(map.containsKey(key)) {
newList.addAll(map.get(key));
}
map.put(key, newList);
}
}

private void removeEntries(Map<String, List<MobMapTrades.VillagerTradeEntry>> map, String key, String entry){
if (map.containsKey(key)) {
List<MobMapTrades.VillagerTradeEntry> newList = new ArrayList<>(map.get(key));
newList.removeIf(listEntry -> listEntry.structure.equals(entry));
map.put(key, newList);
}
}

@Comment("""
Expand All @@ -52,7 +78,7 @@ public void save() {
new MobMapTrades.VillagerTradeEntry("repurposed_structures:mansion_desert", "MANSION", 4, 14, 12, 10),
new MobMapTrades.VillagerTradeEntry("repurposed_structures:mansion_jungle", "MANSION", 4, 14, 12, 10),
new MobMapTrades.VillagerTradeEntry("repurposed_structures:mansion_oak", "MANSION", 4, 14, 12, 10),
new MobMapTrades.VillagerTradeEntry("repurposed_structures:mansion_savannna", "MANSION", 4, 14, 12, 10),
new MobMapTrades.VillagerTradeEntry("repurposed_structures:mansion_savanna", "MANSION", 4, 14, 12, 10),
new MobMapTrades.VillagerTradeEntry("repurposed_structures:mansion_snowy", "MANSION", 4, 14, 12, 10),
new MobMapTrades.VillagerTradeEntry("repurposed_structures:mansion_taiga", "MANSION", 4, 14, 12, 10)
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


@Mixin(TreeFeature.class)
public class LessjungleBushInStructuresMixin {
public class LessJungleBushInStructuresMixin {

@Inject(
method = "place(Lnet/minecraft/world/level/levelgen/feature/FeaturePlaceContext;)Z",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class StructureMobSpawningMixin {

@Inject(
method = "getMobsAt(Lnet/minecraft/world/level/biome/Biome;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/entity/MobCategory;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/util/random/WeightedRandomList;",
at = @At(value = "HEAD"),
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/StructureFeatureManager;getStructureWithPieceAt(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/levelgen/feature/StructureFeature;)Lnet/minecraft/world/level/levelgen/structure/StructureStart;", ordinal = 0),
cancellable = true
)
private void repurposedstructures_structureMobs(Biome biome, StructureFeatureManager accessor, MobCategory group, BlockPos pos, CallbackInfoReturnable<WeightedRandomList<MobSpawnSettings.SpawnerData>> cir) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/repurposed_structures.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"entities.DolphinEntityDolphinSwimToTreasureGoalMixin",
"entities.ShulkerEntityInvoker",
"features.DungeonFeatureAccessor",
"features.LessjungleBushInStructuresMixin",
"features.LessJungleBushInStructuresMixin",
"features.NoBasaltColumnsInStructuresMixin",
"features.NoDeltasInStructuresMixin",
"features.NoLakesInStructuresMixin",
Expand Down

0 comments on commit f19e2dc

Please sign in to comment.