Skip to content

Commit

Permalink
Fix mixin refmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle committed Mar 26, 2021
1 parent 08eb48d commit 804ffe0
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 16 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,8 @@ Initial 1.16.3 release

## [3.0.1] - 2021-03-25
### Fixed
- Correct java build target version
- Correct java build target version.

## [3.0.2] - 2021-03-26
### Fixed
- Mixin refmaps being generated
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.possible_triangle.brazier.config.ServerConfig;
import me.shedaniel.architectury.registry.RegistrySupplier;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagContainer;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.entries.LootTableReference;
Expand All @@ -21,6 +22,7 @@ public class Conditional {

private static final List<Conditional> CONDITIONALS = new ArrayList<>();

@SafeVarargs
public static Conditional when(Predicate<ServerConfig> condition, RegistrySupplier<? extends ItemLike>... items) {
Conditional conditional = new Conditional(condition);
CONDITIONALS.add(conditional);
Expand Down Expand Up @@ -50,6 +52,16 @@ public static void injectLoot(ResourceLocation target, Consumer<LootPool.Builder
.forEach(table);
}

public static void removeTags(TagContainer tags) {
/* TODO remove tags from disabled items
TagCollection<Item> itemTags = tags.getItems();
disabled().map(ItemLike::asItem).forEach(item -> {
tags.getItems().getMatchingTags(item).stream()
.map(itemTags::getTag);
});
*/
}

public final Predicate<ServerConfig> condition;
public final List<RegistrySupplier<? extends ItemLike>> items = new ArrayList<>();
public final List<Pair<ResourceLocation, ResourceLocation>> loot = new ArrayList<>();
Expand All @@ -58,17 +70,18 @@ private Conditional(Predicate<ServerConfig> condition) {
this.condition = condition;
}

Conditional add(RegistrySupplier<? extends ItemLike>... item) {
@SafeVarargs
final Conditional add(RegistrySupplier<? extends ItemLike>... item) {
items.addAll(Arrays.asList(item));
return this;
}

Conditional loot(ResourceLocation target, ResourceLocation inject) {
final Conditional loot(ResourceLocation target, ResourceLocation inject) {
loot.add(new Pair<>(target, inject));
return this;
}

Conditional loot(ResourceLocation target, String inject) {
final Conditional loot(ResourceLocation target, String inject) {
return loot(target, new ResourceLocation(Brazier.MOD_ID, "inject/" + inject));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public static void setup() {
Conditional.when(config -> config.JUNGLE_LOOT).loot(BuiltInLootTables.JUNGLE_TEMPLE, "flame_jungle_temple");

Conditional.when($ -> !Platform.isModLoaded("nether_extension"))
.add(Content.ASH, Content.WARPED_NETHERWART)
.loot(EntityType.WITHER_SKELETON.getDefaultLootTable(), "wither_ash")
.loot(Blocks.NETHER_WART.getLootTable(), "warped_wart");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"minecraft:netherite_block",
"minecraft:crying_obsidian",
"minecraft:ancient_debris",
"minecraft:gilded_blackstone"
"minecraft:gilded_blackstone",
{
"id": "caverns_and_chasms:necromium_block",
"required": false
}
]
}
9 changes: 0 additions & 9 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ loom {
mixinConfigs = ["brazier-forge.mixins.json", "brazier-common.mixins.json"]
}

minecraft {
runs {
client {
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
}
}
}

dependencies {
forge "net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}"
// Remove the next line if you don't want to depend on the API
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.possible_triangle.brazier.forge;

import com.possible_triangle.brazier.Conditional;
import com.possible_triangle.brazier.block.BrazierBlock;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.event.TagsUpdatedEvent;
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.SubscribeEvent;
Expand All @@ -19,7 +21,12 @@ public static void onMobSpawn(LivingSpawnEvent.CheckSpawn event) {

@SubscribeEvent
public static void onLootLoaded(LootTableLoadEvent event) {
//Conditional.injectLoot(event.getName(), p -> event.getTable().addPool(p.build()));
Conditional.injectLoot(event.getName(), p -> event.getTable().addPool(p.build()));
}

@SubscribeEvent
public static void onTagLoaded(TagsUpdatedEvent event) {
Conditional.removeTags(event.getTagManager());
}

}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ minecraft_version=1.16.5

# Mod
archives_base_name=brazier
mod_version=3.0.1
mod_version=3.0.2
maven_group=com.possible_triangle

# Architectury
Expand Down

0 comments on commit 804ffe0

Please sign in to comment.