bring back curios compat

This commit is contained in:
Ell 2021-12-19 16:35:03 +01:00
parent f8d3d022fd
commit c0bf5f0d93
6 changed files with 38 additions and 29 deletions

View file

@ -111,9 +111,8 @@ dependencies {
compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61:api") compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61:api")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61") runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61")
// TODO Curios runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.1-5.0.3.0")
/* runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.0") compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.1-5.0.3.0:api")
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.0:api")*/
// TODO Enchantability // TODO Enchantability
/* compile fg.deobf("quarris.enchantability:Enchantability:11.0.48")*/ /* compile fg.deobf("quarris.enchantability:Enchantability:11.0.48")*/

View file

@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.api.misc.ILevelData;
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.chunk.AuraChunk;
import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.misc.LevelData; import de.ellpeck.naturesaura.misc.LevelData;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
@ -39,7 +40,9 @@ import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry; import net.minecraftforge.registries.IForgeRegistryEntry;
import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import top.theillusivec4.curios.api.CuriosApi;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -290,12 +293,11 @@ public final class Helper {
} }
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player) { public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player) {
// TODO Curios if (Compat.hasCompat("curios")) {
/* if (Compat.hasCompat("curios")) { var stack = CuriosApi.getCuriosHelper().findEquippedCurio(predicate, player).map(ImmutableTriple::getRight);
Optional<ItemStack> stack = CuriosApi.getCuriosHelper().findEquippedCurio(predicate, player).map(ImmutableTriple::getRight);
if (stack.isPresent()) if (stack.isPresent())
return stack.get(); return stack.get();
}*/ }
for (var i = 0; i < player.getInventory().getContainerSize(); i++) { for (var i = 0; i < player.getInventory().getContainerSize(); i++) {
var slot = player.getInventory().getItem(i); var slot = player.getInventory().getItem(i);
if (!slot.isEmpty() && predicate.test(slot)) if (!slot.isEmpty() && predicate.test(slot))

View file

@ -16,8 +16,8 @@ public final class Compat {
private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder() private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder()
.put("patchouli", PatchouliCompat::new) .put("patchouli", PatchouliCompat::new)
/* .put("curios", CuriosCompat::new) .put("curios", CuriosCompat::new)
.put("enchantability", EnchantibilityCompat::new)*/ //.put("enchantability", EnchantibilityCompat::new)
.build(); .build();
private static final Map<String, ICompat> MODULES = new HashMap<>(); private static final Map<String, ICompat> MODULES = new HashMap<>();

View file

@ -1,18 +1,14 @@
// TODO Curios
/*
package de.ellpeck.naturesaura.compat; package de.ellpeck.naturesaura.compat;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.data.ItemTagProvider; import de.ellpeck.naturesaura.data.ItemTagProvider;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.entity.LivingEntity; import net.minecraft.core.Direction;
import net.minecraft.item.Item; import net.minecraft.resources.ResourceLocation;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.util.Direction; import net.minecraft.world.item.Item;
import net.minecraft.util.ResourceLocation; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.capabilities.ICapabilityProvider;
@ -58,14 +54,18 @@ public class CuriosCompat implements ICompat {
} }
private void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) { private void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) {
ItemStack stack = event.getObject(); var stack = event.getObject();
if (TYPES.containsKey(stack.getItem())) { if (TYPES.containsKey(stack.getItem())) {
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "curios"), new ICapabilityProvider() { event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "curios"), new ICapabilityProvider() {
private final LazyOptional<ICurio> curio = LazyOptional.of(() -> new ICurio() { private final LazyOptional<ICurio> curio = LazyOptional.of(() -> new ICurio() {
@Override @Override
public void curioTick(String identifier, int index, LivingEntity livingEntity) { public void curioTick(SlotContext slotContext) {
stack.getItem().inventoryTick(stack, livingEntity.level, livingEntity, -1, false); stack.getItem().inventoryTick(stack, slotContext.entity().level, slotContext.entity(), -1, false);
}
@Override
public ItemStack getStack() {
return stack;
} }
@Override @Override
@ -74,7 +74,7 @@ public class CuriosCompat implements ICompat {
} }
@Override @Override
public boolean canSync(String identifier, int index, LivingEntity livingEntity) { public boolean canSync(SlotContext slotContext) {
return true; return true;
} }
}); });
@ -92,10 +92,9 @@ public class CuriosCompat implements ICompat {
@Override @Override
public void addItemTags(ItemTagProvider provider) { public void addItemTags(ItemTagProvider provider) {
for (Map.Entry<Item, String> entry : TYPES.entrySet()) { for (var entry : TYPES.entrySet()) {
ITag.INamedTag<Item> tag = ItemTags.createOptional(new ResourceLocation("curios", entry.getValue())); var tag = ItemTags.createOptional(new ResourceLocation("curios", entry.getValue()));
provider.getOrCreateBuilder(tag).add(entry.getKey()); provider.tag(tag).add(entry.getKey());
} }
} }
} }
*/

View file

@ -8,6 +8,8 @@ import net.minecraft.data.tags.BlockTagsProvider;
import net.minecraft.data.tags.ItemTagsProvider; import net.minecraft.data.tags.ItemTagsProvider;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.world.item.Item;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.common.data.ExistingFileHelper;
@ -31,4 +33,9 @@ public class ItemTagProvider extends ItemTagsProvider {
Compat.addItemTags(this); Compat.addItemTags(this);
} }
@Override
public TagAppender<Item> tag(Tag.Named<Item> p_126549_) {
// super is protected, but CuriosCompat needs this
return super.tag(p_126549_);
}
} }

View file

@ -5,6 +5,7 @@ import com.mojang.math.Vector3f;
import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.api.render.ITrinketItem; import de.ellpeck.naturesaura.api.render.ITrinketItem;
import de.ellpeck.naturesaura.api.render.ITrinketItem.RenderType; import de.ellpeck.naturesaura.api.render.ITrinketItem.RenderType;
import de.ellpeck.naturesaura.compat.Compat;
import net.minecraft.client.model.PlayerModel; import net.minecraft.client.model.PlayerModel;
import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.MultiBufferSource;
@ -17,6 +18,8 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler;
import top.theillusivec4.curios.api.CuriosApi;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -57,14 +60,13 @@ public class PlayerLayerTrinkets extends RenderLayer<AbstractClientPlayer, Playe
this.renderStack(player.getInventory().getItem(i), player, type, main, second, matrices, buffer, packedLight); this.renderStack(player.getInventory().getItem(i), player, type, main, second, matrices, buffer, packedLight);
} }
// TODO Curios if (Compat.hasCompat("curios")) {
/* if (Compat.hasCompat("curios")) {
IItemHandler handler = CuriosApi.getCuriosHelper().getEquippedCurios(player).orElse(null); IItemHandler handler = CuriosApi.getCuriosHelper().getEquippedCurios(player).orElse(null);
if (handler != null) { if (handler != null) {
for (int i = 0; i < handler.getSlots(); i++) for (var i = 0; i < handler.getSlots(); i++)
this.renderStack(handler.getStackInSlot(i), player, type, main, second, matrices, buffer, packedLight); 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) { private void renderStack(ItemStack stack, Player player, RenderType type, ItemStack main, ItemStack second, PoseStack matrices, MultiBufferSource buffer, int packedLight) {