mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-05 04:49:10 +01:00
bring back curios compat
This commit is contained in:
parent
f8d3d022fd
commit
c0bf5f0d93
6 changed files with 38 additions and 29 deletions
|
@ -111,9 +111,8 @@ dependencies {
|
|||
compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61:api")
|
||||
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.18.1-61")
|
||||
|
||||
// TODO Curios
|
||||
/* runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.0")
|
||||
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.16.5-4.0.5.0:api")*/
|
||||
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.1-5.0.3.0")
|
||||
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.18.1-5.0.3.0:api")
|
||||
|
||||
// TODO Enchantability
|
||||
/* compile fg.deobf("quarris.enchantability:Enchantability:11.0.48")*/
|
||||
|
|
|
@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
|
|||
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 net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -39,7 +40,9 @@ import net.minecraftforge.items.IItemHandler;
|
|||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
import org.apache.commons.lang3.tuple.ImmutableTriple;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import top.theillusivec4.curios.api.CuriosApi;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -290,12 +293,11 @@ public final class Helper {
|
|||
}
|
||||
|
||||
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player) {
|
||||
// TODO Curios
|
||||
/* if (Compat.hasCompat("curios")) {
|
||||
Optional<ItemStack> stack = CuriosApi.getCuriosHelper().findEquippedCurio(predicate, player).map(ImmutableTriple::getRight);
|
||||
if (Compat.hasCompat("curios")) {
|
||||
var stack = CuriosApi.getCuriosHelper().findEquippedCurio(predicate, player).map(ImmutableTriple::getRight);
|
||||
if (stack.isPresent())
|
||||
return stack.get();
|
||||
}*/
|
||||
}
|
||||
for (var i = 0; i < player.getInventory().getContainerSize(); i++) {
|
||||
var slot = player.getInventory().getItem(i);
|
||||
if (!slot.isEmpty() && predicate.test(slot))
|
||||
|
|
|
@ -16,8 +16,8 @@ public final class Compat {
|
|||
|
||||
private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder()
|
||||
.put("patchouli", PatchouliCompat::new)
|
||||
/* .put("curios", CuriosCompat::new)
|
||||
.put("enchantability", EnchantibilityCompat::new)*/
|
||||
.put("curios", CuriosCompat::new)
|
||||
//.put("enchantability", EnchantibilityCompat::new)
|
||||
.build();
|
||||
private static final Map<String, ICompat> MODULES = new HashMap<>();
|
||||
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
// TODO Curios
|
||||
/*
|
||||
package de.ellpeck.naturesaura.compat;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.data.ItemTagProvider;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tags.ITag;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
|
@ -58,14 +54,18 @@ public class CuriosCompat implements ICompat {
|
|||
}
|
||||
|
||||
private void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) {
|
||||
ItemStack stack = event.getObject();
|
||||
var stack = event.getObject();
|
||||
if (TYPES.containsKey(stack.getItem())) {
|
||||
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "curios"), new ICapabilityProvider() {
|
||||
private final LazyOptional<ICurio> curio = LazyOptional.of(() -> new ICurio() {
|
||||
@Override
|
||||
public void curioTick(String identifier, int index, LivingEntity livingEntity) {
|
||||
stack.getItem().inventoryTick(stack, livingEntity.level, livingEntity, -1, false);
|
||||
public void curioTick(SlotContext slotContext) {
|
||||
stack.getItem().inventoryTick(stack, slotContext.entity().level, slotContext.entity(), -1, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,7 +74,7 @@ public class CuriosCompat implements ICompat {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canSync(String identifier, int index, LivingEntity livingEntity) {
|
||||
public boolean canSync(SlotContext slotContext) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -92,10 +92,9 @@ public class CuriosCompat implements ICompat {
|
|||
|
||||
@Override
|
||||
public void addItemTags(ItemTagProvider provider) {
|
||||
for (Map.Entry<Item, String> entry : TYPES.entrySet()) {
|
||||
ITag.INamedTag<Item> tag = ItemTags.createOptional(new ResourceLocation("curios", entry.getValue()));
|
||||
provider.getOrCreateBuilder(tag).add(entry.getKey());
|
||||
for (var entry : TYPES.entrySet()) {
|
||||
var tag = ItemTags.createOptional(new ResourceLocation("curios", entry.getValue()));
|
||||
provider.tag(tag).add(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -8,6 +8,8 @@ import net.minecraft.data.tags.BlockTagsProvider;
|
|||
import net.minecraft.data.tags.ItemTagsProvider;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
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.data.ExistingFileHelper;
|
||||
|
||||
|
@ -31,4 +33,9 @@ public class ItemTagProvider extends ItemTagsProvider {
|
|||
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_);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.mojang.math.Vector3f;
|
|||
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;
|
||||
|
@ -17,6 +18,8 @@ import net.minecraft.world.item.Item;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import top.theillusivec4.curios.api.CuriosApi;
|
||||
|
||||
import java.util.HashSet;
|
||||
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);
|
||||
}
|
||||
|
||||
// TODO Curios
|
||||
/* if (Compat.hasCompat("curios")) {
|
||||
if (Compat.hasCompat("curios")) {
|
||||
IItemHandler handler = CuriosApi.getCuriosHelper().getEquippedCurios(player).orElse(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);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private void renderStack(ItemStack stack, Player player, RenderType type, ItemStack main, ItemStack second, PoseStack matrices, MultiBufferSource buffer, int packedLight) {
|
||||
|
|
Loading…
Reference in a new issue