mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 11:53:29 +01:00
re-added curios compat
This commit is contained in:
parent
af05de4708
commit
572a63fe20
8 changed files with 67 additions and 48 deletions
7
src/generated/resources/data/curios/tags/items/belt.json
Normal file
7
src/generated/resources/data/curios/tags/items/belt.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"naturesaura:aura_cache",
|
||||
"naturesaura:aura_trove"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"naturesaura:eye",
|
||||
"naturesaura:eye_improved"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"naturesaura:shockwave_creator"
|
||||
]
|
||||
}
|
6
src/generated/resources/data/curios/tags/items/ring.json
Normal file
6
src/generated/resources/data/curios/tags/items/ring.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"naturesaura:death_ring"
|
||||
]
|
||||
}
|
|
@ -46,6 +46,7 @@ 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;
|
||||
|
@ -331,10 +332,9 @@ public final class Helper {
|
|||
|
||||
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, PlayerEntity player) {
|
||||
if (Compat.hasCompat("curios")) {
|
||||
// TODO curios
|
||||
/* Optional<ItemStack> stack = CuriosAPI.getCurioEquipped(predicate, player).map(ImmutableTriple::getRight);
|
||||
Optional<ItemStack> stack = CuriosApi.getCuriosHelper().findEquippedCurio(predicate, player).map(ImmutableTriple::getRight);
|
||||
if (stack.isPresent())
|
||||
return stack.get();*/
|
||||
return stack.get();
|
||||
}
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||
ItemStack slot = player.inventory.getStackInSlot(i);
|
||||
|
|
|
@ -7,6 +7,8 @@ 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.tags.ItemTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -20,41 +22,29 @@ import net.minecraftforge.fml.InterModComms;
|
|||
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import top.theillusivec4.curios.api.CuriosCapability;
|
||||
import top.theillusivec4.curios.api.SlotTypeMessage;
|
||||
import top.theillusivec4.curios.api.SlotTypePreset;
|
||||
import top.theillusivec4.curios.api.type.capability.ICurio;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
// TODO curios
|
||||
public class CuriosCompat implements ICompat {
|
||||
@Override
|
||||
public void setup() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupClient() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemTags(ItemTagProvider provider) {
|
||||
|
||||
}
|
||||
|
||||
/*private static final Map<Item, Tag<Item>> TYPES = ImmutableMap.<Item, Tag<Item>>builder()
|
||||
.put(ModItems.EYE, CurioTags.CHARM)
|
||||
.put(ModItems.EYE_IMPROVED, CurioTags.CHARM)
|
||||
.put(ModItems.AURA_CACHE, CurioTags.BELT)
|
||||
.put(ModItems.AURA_TROVE, CurioTags.BELT)
|
||||
.put(ModItems.SHOCKWAVE_CREATOR, CurioTags.NECKLACE)
|
||||
.put(ModItems.DEATH_RING, CurioTags.RING)
|
||||
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();
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
FMLJavaModLoadingContext.get().getModEventBus().register(this); // inter mod comms
|
||||
MinecraftForge.EVENT_BUS.register(this); // capabilities
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::sendImc);
|
||||
MinecraftForge.EVENT_BUS.addGenericListener(ItemStack.class, this::onCapabilitiesAttach);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,16 +52,11 @@ public class CuriosCompat implements ICompat {
|
|||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void sendImc(InterModEnqueueEvent event) {
|
||||
TYPES.values().stream().distinct().forEach(t -> {
|
||||
String path = t.getId().getPath();
|
||||
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage(path));
|
||||
});
|
||||
private void sendImc(InterModEnqueueEvent event) {
|
||||
TYPES.values().stream().distinct().forEach(t -> InterModComms.sendTo("curios", SlotTypeMessage.REGISTER_TYPE, () -> new SlotTypeMessage.Builder(t).build()));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) {
|
||||
private void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) {
|
||||
ItemStack stack = event.getObject();
|
||||
if (TYPES.containsKey(stack.getItem())) {
|
||||
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "curios"), new ICapabilityProvider() {
|
||||
|
@ -82,8 +67,9 @@ public class CuriosCompat implements ICompat {
|
|||
return LazyOptional.empty();
|
||||
return LazyOptional.of(() -> (T) new ICurio() {
|
||||
@Override
|
||||
public void onCurioTick(String identifier, int index, LivingEntity livingEntity) {
|
||||
public void curioTick(String identifier, int index, LivingEntity livingEntity) {
|
||||
stack.getItem().inventoryTick(stack, livingEntity.world, livingEntity, -1, false);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,7 +78,7 @@ public class CuriosCompat implements ICompat {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSyncToTracking(String identifier, LivingEntity livingEntity) {
|
||||
public boolean canSync(String identifier, int index, LivingEntity livingEntity) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -103,7 +89,9 @@ public class CuriosCompat implements ICompat {
|
|||
|
||||
@Override
|
||||
public void addItemTags(ItemTagProvider provider) {
|
||||
for (Map.Entry<Item, Tag<Item>> entry : TYPES.entrySet())
|
||||
provider.getBuilder(entry.getValue()).add(entry.getKey());
|
||||
}*/
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.data.DataGenerator;
|
|||
import net.minecraft.data.ItemTagsProvider;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ITag;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraftforge.common.Tags;
|
||||
|
@ -30,4 +31,9 @@ public class ItemTagProvider extends ItemTagsProvider {
|
|||
|
||||
Compat.addItemTags(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<Item> getOrCreateBuilder(ITag.INamedTag<Item> tag) {
|
||||
return super.getOrCreateBuilder(tag);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ import net.minecraft.util.math.vector.Vector3f;
|
|||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import top.theillusivec4.curios.api.CuriosApi;
|
||||
import top.theillusivec4.curios.api.type.capability.ICuriosItemHandler;
|
||||
import top.theillusivec4.curios.api.type.inventory.ICurioStacksHandler;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -60,16 +63,12 @@ public class PlayerLayerTrinkets extends LayerRenderer<AbstractClientPlayerEntit
|
|||
}
|
||||
|
||||
if (Compat.hasCompat("curios")) {
|
||||
// TODO curios
|
||||
/*ICurioItemHandler handler = CuriosAPI.getCuriosHandler(player).orElse(null);
|
||||
IItemHandler handler = CuriosApi.getCuriosHelper().getEquippedCurios(player).orElse(null);
|
||||
if (handler != null) {
|
||||
for (IItemHandler items : handler.getCurioMap().values()) {
|
||||
for (int i = 0; i < items.getSlots(); i++) {
|
||||
this.renderStack(items.getStackInSlot(i), player, type, main, second, matrices, buffer, packedLight);
|
||||
for (int i = 0; i < handler.getSlots(); i++)
|
||||
this.renderStack(handler.getStackInSlot(i), player, type, main, second, matrices, buffer, packedLight);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
private void renderStack(ItemStack stack, PlayerEntity player, RenderType type, ItemStack main, ItemStack second, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight) {
|
||||
|
|
Loading…
Reference in a new issue