Skip to content

Commit

Permalink
initial port to 1.19, fix rare crash if a structure is invalid (closes
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Jun 9, 2022
1 parent 93359dd commit ab5cc9d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 33 deletions.
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
id 'io.github.juuxel.loom-quiltflower' version '1.7.1'
}

// TOOD fix mc dep in fmj
version = "${project.mod_version}+${project.minecraft_base_version}"
group = project.maven_group

Expand All @@ -15,8 +14,6 @@ repositories {
maven { url = "https://maven.shedaniel.me/" }
maven { url = "https://maven.wispforest.io/" }
maven { url = "https://storage.googleapis.com/devan-maven/" }

mavenLocal()
}

dependencies {
Expand All @@ -33,7 +30,6 @@ dependencies {
// REI
modCompileOnly "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}"
modLocalRuntime "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}"
modLocalRuntime "dev.architectury:architectury-fabric:5.4.14"

// DevLogin
modLocalRuntime "com.ptsmods:devlogin:1.2.1"
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://wispforest.io/versions
minecraft_base_version=1.19
minecraft_version=1.19-pre4
yarn_mappings=1.19-pre4+build.1
loader_version=0.14.6
minecraft_version=1.19
yarn_mappings=1.19+build.1
loader_version=0.14.7

# Mod Properties
mod_version=0.2.0
Expand All @@ -15,19 +15,19 @@ org.gradle.jvmargs=-Xmx1G

# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.53.4+1.19
fabric_version=0.55.3+1.19

# https://github.com/OnyxStudios/Cardinal-Components-API/releases
cca_version=5.0.0-beta.1

# https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-fabric/
rei_version=9.0.466
rei_version=9.0.472

# https://maven.wispforest.io/io/wispforest/owo-lib/
owo_version=0.7.3-pre9+1.19
owo_version=0.7.3+1.19

# https://www.curseforge.com/minecraft/mc-mods/modmenu/files
modmenu_version=4.0.0-beta.4
modmenu_version=4.0.0

# https://storage.googleapis.com/devan-maven/
stacc_version=1.3.2
stacc_version=1.3.3
4 changes: 0 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@ pluginManagement {
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
maven {
name = 'Cotton'
url = 'https://server.bbkr.space/artifactory/libs-release/'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory;
import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry;
import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder;
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
import net.fabricmc.fabric.api.loot.v2.FabricLootPoolBuilder;
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.minecraft.entity.EntityType;
import net.minecraft.loot.LootPool;
import net.minecraft.loot.LootTables;
import net.minecraft.loot.condition.RandomChanceLootCondition;
import net.minecraft.loot.entry.LootPoolEntryType;
Expand Down Expand Up @@ -81,16 +82,13 @@ public void onInitialize() {
LootOps.injectItem(NumismaticOverhaulItems.GOLD_COIN, .01f, LootTables.STRONGHOLD_LIBRARY_CHEST, LootTables.BASTION_TREASURE_CHEST, LootTables.STRONGHOLD_CORRIDOR_CHEST,
LootTables.PILLAGER_OUTPOST_CHEST, LootTables.BURIED_TREASURE_CHEST, LootTables.SIMPLE_DUNGEON_CHEST, LootTables.ABANDONED_MINESHAFT_CHEST);

LootTableLoadingCallback.EVENT.register((resourceManager, manager, id, supplier, setter) -> {
LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> {
if (anyMatch(id, LootTables.SIMPLE_DUNGEON_CHEST, LootTables.ABANDONED_MINESHAFT_CHEST)) {
supplier.withPool(FabricLootPoolBuilder.builder().withEntry(MoneyBagLootEntry.builder(500, 2000).build()).conditionally(RandomChanceLootCondition.builder(0.75f))
.build());
tableBuilder.pool(LootPool.builder().with(MoneyBagLootEntry.builder(500, 2000)).conditionally(RandomChanceLootCondition.builder(0.75f)));
} else if (anyMatch(id, LootTables.BASTION_TREASURE_CHEST, LootTables.STRONGHOLD_CORRIDOR_CHEST, LootTables.PILLAGER_OUTPOST_CHEST, LootTables.BURIED_TREASURE_CHEST)) {
supplier.withPool(FabricLootPoolBuilder.builder().withEntry(MoneyBagLootEntry.builder(1500, 4000).build()).conditionally(RandomChanceLootCondition.builder(0.75f))
.build());
tableBuilder.pool(LootPool.builder().with(MoneyBagLootEntry.builder(1500, 4000)).conditionally(RandomChanceLootCondition.builder(0.75f)));
} else if (anyMatch(id, LootTables.STRONGHOLD_LIBRARY_CHEST)) {
supplier.withPool(FabricLootPoolBuilder.builder().withEntry(MoneyBagLootEntry.builder(2000, 6000).build()).conditionally(RandomChanceLootCondition.builder(0.85f))
.build());
tableBuilder.pool(LootPool.builder().with(MoneyBagLootEntry.builder(2000, 6000)).conditionally(RandomChanceLootCondition.builder(0.85f)));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import net.minecraft.util.registry.RegistryEntryList;
import net.minecraft.village.TradeOffer;
import net.minecraft.village.TradeOffers;
import net.minecraft.world.gen.structure.StructureTypeKeys;
import net.minecraft.world.gen.structure.StructureTypes;
import net.minecraft.world.gen.structure.StructureKeys;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -65,7 +64,7 @@ public TradeOffer create(Entity entity, Random random) {
final var registry = serverWorld.getRegistryManager().get(Registry.STRUCTURE_KEY);
final var feature = RegistryAccess.getEntry(registry, this.structureId);

if (feature == null) {
if (feature == null || feature.getKey().isEmpty()) {
NumismaticOverhaul.LOGGER.error("Tried to create map to invalid structure " + this.structureId);
return null;
}
Expand All @@ -77,11 +76,11 @@ public TradeOffer create(Entity entity, Random random) {
final var blockPos = result.getFirst();

var iconType = MapIcon.Type.TARGET_X;
if (feature.matchesId(StructureTypeKeys.MONUMENT.getValue()))
if (feature.matchesId(StructureKeys.MONUMENT.getValue()))
iconType = MapIcon.Type.MONUMENT;
if (feature.matchesId(StructureTypeKeys.MANSION.getValue()))
if (feature.matchesId(StructureKeys.MANSION.getValue()))
iconType = MapIcon.Type.MANSION;
if (feature.matchesId(StructureTypeKeys.PILLAGER_OUTPOST.getValue()))
if (feature.matchesId(StructureKeys.PILLAGER_OUTPOST.getValue()))
iconType = MapIcon.Type.TARGET_POINT;

ItemStack itemStack = FilledMapItem.createMap(serverWorld, blockPos.getX(), blockPos.getZ(), (byte) 2, true, true);
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 @@ -36,10 +36,10 @@
"depends": {
"fabricloader": ">=0.10.8",
"fabric": "*",
"minecraft": ">=1.18.2",
"minecraft": ">=1.19",
"cardinal-components-base": "*",
"cardinal-components-entity": "*",
"owo": ">=0.7.0",
"owo": ">=0.7.3",
"cloth-config": ">=6.0.0"
},
"custom": {
Expand Down

0 comments on commit ab5cc9d

Please sign in to comment.