Skip to content

Commit

Permalink
reinstate curios compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellpeck committed Sep 26, 2024
1 parent c5e8935 commit 226eefc
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 26 deletions.
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ repositories {
maven {
url = "https://maven.theillusivec4.top/"
}
maven {
url = uri("https://maven.octo-studios.com/releases")
}
}

base {
Expand Down Expand Up @@ -98,8 +101,7 @@ dependencies {
compileOnly "mezz.jei:jei-${minecraft_version}-neoforge-api:${jei_version}"
runtimeOnly "mezz.jei:jei-${minecraft_version}-neoforge:${jei_version}"

// runtimeOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}"
// compileOnly "top.theillusivec4.curios:curios-neoforge:${curios_version}:api"
implementation "top.theillusivec4.curios:curios-neoforge:${curios_version}"

compileOnly "vazkii.patchouli:Patchouli:${patchouli_version}:api"
runtimeOnly "vazkii.patchouli:Patchouli:${patchouli_version}"
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ neo_version_range=[21.1.0,)
loader_version_range=[4,)

jei_version=19.18.3.204
# TODO what to do about curios being discontinued? try out https://www.curseforge.com/minecraft/mc-mods/adorned?
# curios_version=7.2.0+1.20.4
curios_version=9.0.11+1.21
patchouli_version=1.21-87-NEOFORGE

## Mod Properties
Expand Down
6 changes: 6 additions & 0 deletions src/generated/resources/data/curios/tags/item/belt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"naturesaura:aura_cache",
"naturesaura:aura_trove"
]
}
6 changes: 6 additions & 0 deletions src/generated/resources/data/curios/tags/item/charm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"naturesaura:eye",
"naturesaura:eye_improved"
]
}
5 changes: 5 additions & 0 deletions src/generated/resources/data/curios/tags/item/necklace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"naturesaura:shockwave_creator"
]
}
5 changes: 5 additions & 0 deletions src/generated/resources/data/curios/tags/item/ring.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"naturesaura:death_ring"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"entities": [
"minecraft:player"
],
"slots": [
"charm",
"belt",
"ring",
"necklace"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"add_cosmetic": true,
"size": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"add_cosmetic": true,
"size": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"add_cosmetic": true,
"size": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"add_cosmetic": true,
"size": 1
}
8 changes: 5 additions & 3 deletions src/main/java/de/ellpeck/naturesaura/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
import de.ellpeck.naturesaura.chunk.AuraChunk;
import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.misc.LevelData;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
Expand Down Expand Up @@ -50,6 +51,8 @@
import net.neoforged.neoforge.capabilities.ICapabilityProvider;
import net.neoforged.neoforge.items.IItemHandler;
import net.neoforged.neoforge.items.IItemHandlerModifiable;
import top.theillusivec4.curios.api.CuriosApi;
import top.theillusivec4.curios.api.SlotResult;

import java.lang.reflect.Modifier;
import java.util.List;
Expand Down Expand Up @@ -300,15 +303,14 @@ public static <T> void populateObjectHolders(Class<?> clazz, Registry<T> registr
}

public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player, boolean hotbarOnly) {
// TODO curios?
/* if (Compat.hasCompat("curios")) {
if (Compat.hasCompat("curios")) {
var inventory = CuriosApi.getCuriosInventory(player);
if (inventory.isPresent()) {
var stack = inventory.get().findFirstCurio(predicate).map(SlotResult::stack);
if (stack.isPresent())
return stack.get();
}
}*/
}
var invSize = hotbarOnly ? 9 : player.getInventory().getContainerSize();
for (var i = 0; i < invSize; i++) {
var slot = player.getInventory().getItem(i);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/de/ellpeck/naturesaura/compat/Compat.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public final class Compat {
@SuppressWarnings("Convert2MethodRef") // bleh classloading compat issues
private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder()
.put("patchouli", () -> new PatchouliCompat())
// TODO curios?
//.put("curios", () -> new CuriosCompat())
.put("curios", () -> new CuriosCompat())
//.put("enchantability", EnchantibilityCompat::new)
.build();
private static final Map<String, ICompat> MODULES = new HashMap<>();
Expand Down
26 changes: 12 additions & 14 deletions src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// TODO curios?
/*
package de.ellpeck.naturesaura.compat;

import com.google.common.collect.ImmutableMap;
Expand All @@ -26,13 +24,13 @@
public class CuriosCompat implements ICompat {

private static final Map<Item, String> TYPES = ImmutableMap.<Item, String>builder()
.put(ModItems.EYE, "charm")
.put(ModItems.EYE_IMPROVED, "charm")
.put(ModItems.AURA_CACHE, "belt")
.put(ModItems.AURA_TROVE, "belt")
.put(ModItems.SHOCKWAVE_CREATOR, "necklace")
.put(ModItems.DEATH_RING, "ring")
.build();
.put(ModItems.EYE, "charm")
.put(ModItems.EYE_IMPROVED, "charm")
.put(ModItems.AURA_CACHE, "belt")
.put(ModItems.AURA_TROVE, "belt")
.put(ModItems.SHOCKWAVE_CREATOR, "necklace")
.put(ModItems.DEATH_RING, "ring")
.build();

@Override
public void addCapabilities(RegisterCapabilitiesEvent event) {
Expand Down Expand Up @@ -69,7 +67,7 @@ public void gatherData(GatherDataEvent event) {
@Override
public void addItemTags(ItemTagProvider provider) {
for (var entry : CuriosCompat.TYPES.entrySet()) {
var tag = ItemTags.create(new ResourceLocation("curios", entry.getValue()));
var tag = ItemTags.create(ResourceLocation.fromNamespaceAndPath("curios", entry.getValue()));
provider.tag(tag).add(entry.getKey());
}
}
Expand All @@ -82,12 +80,12 @@ public CuriosProvider(PackOutput output, ExistingFileHelper fileHelper, Completa

@Override
public void generate(HolderLookup.Provider provider, ExistingFileHelper existingFileHelper) {
for (var type : CuriosCompat.TYPES.values()) {
this.createSlot(type);
}
var types = CuriosCompat.TYPES.values().stream().distinct().toArray(String[]::new);
this.createEntities("entities").addPlayer().addSlots(types);
for (var type : types)
this.createSlot(type).size(1).addCosmetic(true);
}

}

}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.api.render.ITrinketItem;
import de.ellpeck.naturesaura.api.render.ITrinketItem.RenderType;
import de.ellpeck.naturesaura.compat.Compat;
import net.minecraft.client.model.PlayerModel;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.renderer.MultiBufferSource;
Expand All @@ -17,6 +18,7 @@
import net.minecraft.world.item.ItemStack;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import top.theillusivec4.curios.api.CuriosApi;

import java.util.HashSet;
import java.util.Set;
Expand Down Expand Up @@ -57,15 +59,14 @@ private void render(Player player, RenderType type, ItemStack main, ItemStack se
this.renderStack(player.getInventory().getItem(i), player, type, main, second, matrices, buffer, packedLight);
}

// TODO curios?
/* if (Compat.hasCompat("curios")) {
if (Compat.hasCompat("curios")) {
var inventory = CuriosApi.getCuriosInventory(player).orElse(null);
if (inventory != null) {
var handler = inventory.getEquippedCurios();
for (var i = 0; i < handler.getSlots(); i++)
this.renderStack(handler.getStackInSlot(i), player, type, main, second, matrices, buffer, packedLight);
}
}*/
}
}

private void renderStack(ItemStack stack, Player player, RenderType type, ItemStack main, ItemStack second, PoseStack matrices, MultiBufferSource buffer, int packedLight) {
Expand Down

0 comments on commit 226eefc

Please sign in to comment.