added curios compatibility

This commit is contained in:
Ellpeck 2020-01-26 19:26:50 +01:00
parent 13e793d703
commit bea159dcd5
16 changed files with 275 additions and 178 deletions

View file

@ -86,6 +86,9 @@ repositories {
maven { maven {
url = "https://maven.blamejared.com" url = "https://maven.blamejared.com"
} }
maven {
url = "https://maven.theillusivec4.top/"
}
} }
dependencies { dependencies {
@ -96,6 +99,9 @@ dependencies {
compile fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.14.4:5.0.0.89") compile fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.14.4:5.0.0.89")
compile fg.deobf("vazkii.patchouli:Patchouli:1.1-23.115") compile fg.deobf("vazkii.patchouli:Patchouli:1.1-23.115")
runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.14.4-1.0.6.1")
compileOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.14.4-1.0.6.1:api")
} }
// Example for how to get properties into the manifest for reading by the runtime.. // Example for how to get properties into the manifest for reading by the runtime..

View file

@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"naturesaura:aura_cache",
"naturesaura:aura_trove"
]
}

View file

@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"naturesaura:eye",
"naturesaura:eye_improved"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"naturesaura:shockwave_creator"
]
}

View file

@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl; import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.chunk.AuraChunk;
import de.ellpeck.naturesaura.compat.Compat;
import net.minecraft.advancements.Advancement; import net.minecraft.advancements.Advancement;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -44,7 +45,9 @@ import net.minecraftforge.items.IItemHandlerModifiable;
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;
@ -52,8 +55,10 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Optional;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate;
public final class Helper { public final class Helper {
@ -378,4 +383,18 @@ public final class Helper {
return Blocks.WHITE_WOOL; return Blocks.WHITE_WOOL;
} }
} }
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, PlayerEntity player) {
if (Compat.hasCompat("curios")) {
Optional<ItemStack> stack = CuriosAPI.getCurioEquipped(predicate, player).map(ImmutableTriple::getRight);
if (stack.isPresent())
return stack.get();
}
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack slot = player.inventory.getStackInSlot(i);
if (!slot.isEmpty() && predicate.test(slot))
return slot;
}
return ItemStack.EMPTY;
}
} }

View file

@ -6,7 +6,6 @@ import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.misc.IWorldData; import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.api.multiblock.IMultiblock; import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
import de.ellpeck.naturesaura.blocks.multi.Multiblock; import de.ellpeck.naturesaura.blocks.multi.Multiblock;
import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.misc.WorldData; import de.ellpeck.naturesaura.misc.WorldData;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -15,7 +14,6 @@ import net.minecraft.util.Tuple;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.apache.commons.lang3.mutable.MutableFloat; import org.apache.commons.lang3.mutable.MutableFloat;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
@ -39,38 +37,16 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
private boolean auraPlayerInteraction(PlayerEntity player, int amount, boolean extract, boolean simulate) { private boolean auraPlayerInteraction(PlayerEntity player, int amount, boolean extract, boolean simulate) {
if (extract && player.isCreative()) if (extract && player.isCreative())
return true; return true;
ItemStack stack = Helper.getEquippedItem(s -> s.getCapability(NaturesAuraAPI.capAuraContainer).isPresent(), player);
if (Compat.baubles) { // Baubles dont exist for 1.14 yet if (!stack.isEmpty()) {
/*
IItemHandler baubles = BaublesApi.getBaublesHandler(player);
for (int i = 0; i < baubles.getSlots(); i++) {
ItemStack stack = baubles.getStackInSlot(i);
if (!stack.isEmpty() && stack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null);
if (extract)
amount -= container.drainAura(amount, simulate);
else
amount -= container.storeAura(amount, simulate);
if (amount <= 0)
return true;
}
}
*/
}
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stack = player.inventory.getStackInSlot(i);
if (!stack.isEmpty() && stack.getCapability(NaturesAuraAPI.capAuraContainer).isPresent()) {
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null); IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null);
if (extract) if (extract) {
amount -= container.drainAura(amount, simulate); amount -= container.drainAura(amount, simulate);
else } else {
amount -= container.storeAura(amount, simulate); amount -= container.storeAura(amount, simulate);
if (amount <= 0)
return true;
} }
return amount <= 0;
} }
return false; return false;
} }

View file

@ -5,14 +5,12 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
import de.ellpeck.naturesaura.api.misc.IWorldData; import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects; import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects;
import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.events.CommonEvents; import de.ellpeck.naturesaura.events.CommonEvents;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.potion.ModPotions;
import de.ellpeck.naturesaura.proxy.ClientProxy; import de.ellpeck.naturesaura.proxy.ClientProxy;
import de.ellpeck.naturesaura.proxy.IProxy; import de.ellpeck.naturesaura.proxy.IProxy;
import de.ellpeck.naturesaura.proxy.ServerProxy; import de.ellpeck.naturesaura.proxy.ServerProxy;
@ -20,7 +18,6 @@ import de.ellpeck.naturesaura.recipes.ModRecipes;
import de.ellpeck.naturesaura.reg.ModRegistry; import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
@ -62,8 +59,6 @@ public final class NaturesAura {
}; };
public void setup(FMLCommonSetupEvent event) { public void setup(FMLCommonSetupEvent event) {
ModConfig.instance.apply();
this.preInit(event); this.preInit(event);
this.init(event); this.init(event);
this.postInit(event); this.postInit(event);
@ -76,10 +71,6 @@ public final class NaturesAura {
Helper.registerCap(IAuraChunk.class); Helper.registerCap(IAuraChunk.class);
Helper.registerCap(IWorldData.class); Helper.registerCap(IWorldData.class);
new ModBlocks();
new ModItems();
new ModPotions();
Compat.preInit(); Compat.preInit();
PacketHandler.init(); PacketHandler.init();
new Multiblocks(); new Multiblocks();
@ -90,6 +81,8 @@ public final class NaturesAura {
} }
private void init(FMLCommonSetupEvent event) { private void init(FMLCommonSetupEvent event) {
ModConfig.instance.apply();
ModRecipes.init(); ModRecipes.init();
ModRegistry.init(); ModRegistry.init();
DrainSpotEffects.init(); DrainSpotEffects.init();

View file

@ -1,79 +0,0 @@
/* TODO baubles
package de.ellpeck.naturesaura.compat;
import baubles.api.BaubleType;
import baubles.api.IBauble;
import baubles.api.cap.BaublesCapabilities;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BaublesCompat {
@SubscribeEvent
public void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) {
Item item = event.getObject().getItem();
if (item == ModItems.EYE || item == ModItems.EYE_IMPROVED)
this.addCap(event, stack -> BaubleType.CHARM);
else if (item == ModItems.AURA_CACHE)
this.addCap(event, new UpdatingBauble(BaubleType.BELT, true));
else if (item == ModItems.AURA_TROVE)
this.addCap(event, new UpdatingBauble(BaubleType.BELT, true));
else if (item == ModItems.SHOCKWAVE_CREATOR)
this.addCap(event, new UpdatingBauble(BaubleType.AMULET, false));
}
private void addCap(AttachCapabilitiesEvent<ItemStack> event, IBauble type) {
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "bauble"), new ICapabilityProvider() {
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
return capability == BaublesCapabilities.CAPABILITY_ITEM_BAUBLE;
}
@Nullable
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
return capability == BaublesCapabilities.CAPABILITY_ITEM_BAUBLE ? (T) type : null;
}
});
}
private static class UpdatingBauble implements IBauble {
private final BaubleType type;
private final boolean sync;
public UpdatingBauble(BaubleType type, boolean sync) {
this.type = type;
this.sync = sync;
}
@Override
public BaubleType getBaubleType(ItemStack itemstack) {
return this.type;
}
@Override
public boolean willAutoSync(ItemStack itemstack, LivingEntity player) {
return this.sync;
}
@Override
public void onWornTick(ItemStack stack, LivingEntity player) {
stack.getItem().onUpdate(stack, player.world, player, -1, false);
}
}
}
*/

View file

@ -1,34 +1,56 @@
package de.ellpeck.naturesaura.compat; package de.ellpeck.naturesaura.compat;
import com.google.common.collect.ImmutableMap;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat; import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat;
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat; import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
import de.ellpeck.naturesaura.misc.ItemTagProvider;
import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModList;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Predicate;
import java.util.function.Supplier;
public final class Compat { public final class Compat {
public static final String CRAFT_TWEAKER = "crafttweaker"; private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder()
public static boolean baubles; .put("patchouli", PatchouliCompat::new)
public static boolean craftTweaker; .put("curios", CuriosCompat::new)
public static boolean mtLib; .put("crafttweaker", CraftTweakerCompat::new)
.build();
private static final Map<String, ICompat> MODULES = new HashMap<>();
public static void preInit() { public static void preInit() {
ModList mods = ModList.get(); populateModules(ModList.get()::isLoaded);
baubles = mods.isLoaded("baubles"); MODULES.values().forEach(ICompat::preInit);
craftTweaker = mods.isLoaded(CRAFT_TWEAKER);
mtLib = mods.isLoaded("mtlib");
/*if (baubles)
MinecraftForge.EVENT_BUS.register(new BaublesCompat());*/
PatchouliCompat.preInit();
} }
public static void preInitClient() { public static void preInitClient() {
PatchouliCompat.preInitClient(); MODULES.values().forEach(ICompat::preInitClient);
} }
public static void postInit() { public static void postInit() {
if (craftTweaker && mtLib) MODULES.values().forEach(ICompat::postInit);
CraftTweakerCompat.postInit(); }
public static boolean hasCompat(String mod) {
return MODULES.containsKey(mod);
}
public static void addItemTags(ItemTagProvider provider) {
// since other mods don't get loaded in runData, just populate all modules
populateModules(s -> true);
MODULES.values().forEach(m -> m.addItemTags(provider));
}
private static void populateModules(Predicate<String> isLoaded) {
for (Map.Entry<String, Supplier<ICompat>> entry : MODULE_TYPES.entrySet()) {
String id = entry.getKey();
if (isLoaded.test(id)) {
MODULES.put(id, entry.getValue().get());
NaturesAura.LOGGER.info("Loading compat module for mod " + id);
}
}
} }
} }

View file

@ -0,0 +1,102 @@
package de.ellpeck.naturesaura.compat;
import com.google.common.collect.ImmutableMap;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.misc.ItemTagProvider;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.Tag;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import top.theillusivec4.curios.api.CurioTags;
import top.theillusivec4.curios.api.CuriosAPI;
import top.theillusivec4.curios.api.capability.CuriosCapability;
import top.theillusivec4.curios.api.capability.ICurio;
import top.theillusivec4.curios.api.imc.CurioIMCMessage;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;
public class CuriosCompat implements ICompat {
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)
.build();
@Override
public void preInit() {
FMLJavaModLoadingContext.get().getModEventBus().register(this); // inter mod comms
MinecraftForge.EVENT_BUS.register(this); // capabilities
}
@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));
});
}
@SubscribeEvent
public void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) {
ItemStack stack = event.getObject();
if (TYPES.containsKey(stack.getItem())) {
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "curios"), new ICapabilityProvider() {
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
if (cap != CuriosCapability.ITEM)
return LazyOptional.empty();
return LazyOptional.of(() -> (T) new ICurio() {
@Override
public void onCurioTick(String identifier, int index, LivingEntity livingEntity) {
stack.getItem().inventoryTick(stack, livingEntity.world, livingEntity, -1, false);
}
@Override
public boolean canRightClickEquip() {
return true;
}
@Override
public boolean shouldSyncToTracking(String identifier, LivingEntity livingEntity) {
return true;
}
});
}
});
}
}
@Override
public void preInitClient() {
}
@Override
public void postInit() {
}
@Override
public void addItemTags(ItemTagProvider provider) {
for (Map.Entry<Item, Tag<Item>> entry : TYPES.entrySet())
provider.getBuilder(entry.getValue()).add(entry.getKey());
}
}

View file

@ -0,0 +1,14 @@
package de.ellpeck.naturesaura.compat;
import de.ellpeck.naturesaura.misc.ItemTagProvider;
public interface ICompat {
void preInit();
void preInitClient();
void postInit();
void addItemTags(ItemTagProvider provider);
}

View file

@ -2,18 +2,36 @@ package de.ellpeck.naturesaura.compat.crafttweaker;
import com.blamejared.crafttweaker.api.CraftTweakerAPI; import com.blamejared.crafttweaker.api.CraftTweakerAPI;
import com.blamejared.crafttweaker.api.actions.IAction; import com.blamejared.crafttweaker.api.actions.IAction;
import de.ellpeck.naturesaura.compat.ICompat;
import de.ellpeck.naturesaura.misc.ItemTagProvider;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
public final class CraftTweakerCompat { public class CraftTweakerCompat implements ICompat {
public static final List<Supplier<IAction>> SCHEDULED_ACTIONS = new ArrayList<>(); public static final List<Supplier<IAction>> SCHEDULED_ACTIONS = new ArrayList<>();
public static void postInit() { @Override
public void preInit() {
}
@Override
public void preInitClient() {
}
@Override
public void postInit() {
for (Supplier<IAction> action : SCHEDULED_ACTIONS) for (Supplier<IAction> action : SCHEDULED_ACTIONS)
CraftTweakerAPI.apply(action.get()); CraftTweakerAPI.apply(action.get());
SCHEDULED_ACTIONS.clear(); SCHEDULED_ACTIONS.clear();
} }
@Override
public void addItemTags(ItemTagProvider provider) {
}
} }

View file

@ -4,8 +4,9 @@ import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.multiblock.Matcher; import de.ellpeck.naturesaura.api.multiblock.Matcher;
import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.compat.ICompat;
import de.ellpeck.naturesaura.events.ClientEvents; import de.ellpeck.naturesaura.events.ClientEvents;
import de.ellpeck.naturesaura.misc.ItemTagProvider;
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler; import de.ellpeck.naturesaura.renderers.SupporterFancyHandler;
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler.FancyInfo; import de.ellpeck.naturesaura.renderers.SupporterFancyHandler.FancyInfo;
import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.gui.AbstractGui;
@ -25,17 +26,29 @@ import java.time.Month;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
public final class PatchouliCompat { public class PatchouliCompat implements ICompat {
private static final ResourceLocation BOOK = new ResourceLocation(NaturesAura.MOD_ID, "book"); private static final ResourceLocation BOOK = new ResourceLocation(NaturesAura.MOD_ID, "book");
public static void preInit() { @Override
public void preInit() {
PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.instance.rfConverter.get()); PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.instance.rfConverter.get());
PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":chunk_loader", ModConfig.instance.chunkLoader.get()); PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":chunk_loader", ModConfig.instance.chunkLoader.get());
} }
public static void preInitClient() { @Override
MinecraftForge.EVENT_BUS.register(new PatchouliCompat()); public void preInitClient() {
MinecraftForge.EVENT_BUS.register(this);
}
@Override
public void addItemTags(ItemTagProvider provider) {
}
@Override
public void postInit() {
} }
@SubscribeEvent @SubscribeEvent
@ -107,7 +120,7 @@ public final class PatchouliCompat {
ResourceLocation res = new ResourceLocation(name); ResourceLocation res = new ResourceLocation(name);
T recipe = recipes.get(res); T recipe = recipes.get(res);
if (recipe == null) if (recipe == null)
recipe = recipes.get(new ResourceLocation(Compat.CRAFT_TWEAKER, res.getPath())); recipe = recipes.get(new ResourceLocation("crafttweaker", res.getPath()));
return recipe; return recipe;
} }
} }

View file

@ -12,11 +12,10 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGratedChute; import de.ellpeck.naturesaura.blocks.tiles.TileEntityGratedChute;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar; import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter; import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter;
import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.enchant.ModEnchantment; import de.ellpeck.naturesaura.enchant.ModEnchantment;
import de.ellpeck.naturesaura.items.ItemAuraCache; import de.ellpeck.naturesaura.items.ItemAuraCache;
import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.items.ItemRangeVisualizer; import de.ellpeck.naturesaura.items.ItemRangeVisualizer;
import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.packet.PacketAuraChunk; import de.ellpeck.naturesaura.packet.PacketAuraChunk;
import de.ellpeck.naturesaura.particles.ParticleHandler; import de.ellpeck.naturesaura.particles.ParticleHandler;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -195,33 +194,9 @@ public class ClientEvents {
ParticleHandler.updateParticles(); ParticleHandler.updateParticles();
if (Compat.baubles) { heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, mc.player);
// TODO baubles heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player);
/*IItemHandler baubles = BaublesApi.getBaublesHandler(mc.player); heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player);
for (int i = 0; i < baubles.getSlots(); i++) {
ItemStack slot = baubles.getStackInSlot(i);
if (!slot.isEmpty()) {
if (slot.getItem() instanceof AuraCache)
heldCache = slot;
else if (slot.getItem() == ModItems.EYE)
heldEye = slot;
else if (slot.getItem() == ModItems.EYE_IMPROVED)
heldOcular = slot;
}
}*/
}
for (int i = 0; i < mc.player.inventory.getSizeInventory(); i++) {
ItemStack slot = mc.player.inventory.getStackInSlot(i);
if (!slot.isEmpty()) {
if (slot.getItem() instanceof ItemAuraCache)
heldCache = slot;
else if (slot.getItem() == ModItems.EYE && i <= 8)
heldEye = slot;
else if (slot.getItem() == ModItems.EYE_IMPROVED)
heldOcular = slot;
}
}
if (!heldOcular.isEmpty() && mc.world.getGameTime() % 20 == 0) { if (!heldOcular.isEmpty() && mc.world.getGameTime() % 20 == 0) {
SHOWING_EFFECTS.clear(); SHOWING_EFFECTS.clear();

View file

@ -1,10 +1,13 @@
package de.ellpeck.naturesaura.misc; package de.ellpeck.naturesaura.misc;
import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.data.DataGenerator; import net.minecraft.data.DataGenerator;
import net.minecraft.data.ItemTagsProvider; import net.minecraft.data.ItemTagsProvider;
import net.minecraft.item.Item;
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.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
public class ItemTagProvider extends ItemTagsProvider { public class ItemTagProvider extends ItemTagsProvider {
@ -22,5 +25,12 @@ public class ItemTagProvider extends ItemTagsProvider {
this.copy(BlockTags.SLABS, ItemTags.SLABS); this.copy(BlockTags.SLABS, ItemTags.SLABS);
this.getBuilder(Tags.Items.RODS_WOODEN).add(ModItems.ANCIENT_STICK); this.getBuilder(Tags.Items.RODS_WOODEN).add(ModItems.ANCIENT_STICK);
Compat.addItemTags(this);
}
@Override
public Tag.Builder<Item> getBuilder(Tag<Item> tagIn) {
return super.getBuilder(tagIn);
} }
} }

View file

@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.renderers;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
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.entity.player.AbstractClientPlayerEntity; import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
import net.minecraft.client.renderer.entity.IEntityRenderer; import net.minecraft.client.renderer.entity.IEntityRenderer;
import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.client.renderer.entity.layers.LayerRenderer;
@ -13,6 +14,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.potion.Effects; import net.minecraft.potion.Effects;
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 top.theillusivec4.curios.api.capability.ICurioItemHandler;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.HashSet; import java.util.HashSet;
@ -58,12 +62,16 @@ public class PlayerLayerTrinkets extends LayerRenderer<AbstractClientPlayerEntit
this.renderStack(player.inventory.getStackInSlot(i), player, type, main, second); this.renderStack(player.inventory.getStackInSlot(i), player, type, main, second);
} }
/*if (Compat.baubles) { TODO baubles if (Compat.hasCompat("curios")) {
IItemHandler baubles = BaublesApi.getBaublesHandler(player); ICurioItemHandler handler = CuriosAPI.getCuriosHandler(player).orElse(null);
for (int i = 0; i < baubles.getSlots(); i++) { if (handler != null) {
this.renderStack(baubles.getStackInSlot(i), player, type, main, second); for (IItemHandler items : handler.getCurioMap().values()) {
for (int i = 0; i < items.getSlots(); i++) {
this.renderStack(items.getStackInSlot(i), player, type, main, second);
}
}
}
} }
}*/
} }
private void renderStack(ItemStack stack, PlayerEntity player, RenderType type, ItemStack main, ItemStack second) { private void renderStack(ItemStack stack, PlayerEntity player, RenderType type, ItemStack main, ItemStack second) {