mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58:34 +01:00
added curios compatibility
This commit is contained in:
parent
13e793d703
commit
bea159dcd5
16 changed files with 275 additions and 178 deletions
|
@ -86,6 +86,9 @@ repositories {
|
|||
maven {
|
||||
url = "https://maven.blamejared.com"
|
||||
}
|
||||
maven {
|
||||
url = "https://maven.theillusivec4.top/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -96,6 +99,9 @@ dependencies {
|
|||
|
||||
compile fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.14.4:5.0.0.89")
|
||||
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..
|
||||
|
|
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,6 +6,7 @@ import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
|||
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
|
||||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -44,7 +45,9 @@ import net.minecraftforge.items.IItemHandlerModifiable;
|
|||
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;
|
||||
|
@ -52,8 +55,10 @@ import java.lang.reflect.Field;
|
|||
import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public final class Helper {
|
||||
|
||||
|
@ -378,4 +383,18 @@ public final class Helper {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
|||
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
||||
import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
|
||||
import de.ellpeck.naturesaura.blocks.multi.Multiblock;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import de.ellpeck.naturesaura.misc.WorldData;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
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.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.mutable.MutableFloat;
|
||||
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) {
|
||||
if (extract && player.isCreative())
|
||||
return true;
|
||||
|
||||
if (Compat.baubles) { // Baubles dont exist for 1.14 yet
|
||||
/*
|
||||
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()) {
|
||||
ItemStack stack = Helper.getEquippedItem(s -> s.getCapability(NaturesAuraAPI.capAuraContainer).isPresent(), player);
|
||||
if (!stack.isEmpty()) {
|
||||
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer).orElse(null);
|
||||
if (extract)
|
||||
if (extract) {
|
||||
amount -= container.drainAura(amount, simulate);
|
||||
else
|
||||
} else {
|
||||
amount -= container.storeAura(amount, simulate);
|
||||
if (amount <= 0)
|
||||
return true;
|
||||
}
|
||||
return amount <= 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.item.IAuraRecharge;
|
||||
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||
import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import de.ellpeck.naturesaura.events.CommonEvents;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.potion.ModPotions;
|
||||
import de.ellpeck.naturesaura.proxy.ClientProxy;
|
||||
import de.ellpeck.naturesaura.proxy.IProxy;
|
||||
import de.ellpeck.naturesaura.proxy.ServerProxy;
|
||||
|
@ -20,7 +18,6 @@ import de.ellpeck.naturesaura.recipes.ModRecipes;
|
|||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
|
@ -62,8 +59,6 @@ public final class NaturesAura {
|
|||
};
|
||||
|
||||
public void setup(FMLCommonSetupEvent event) {
|
||||
ModConfig.instance.apply();
|
||||
|
||||
this.preInit(event);
|
||||
this.init(event);
|
||||
this.postInit(event);
|
||||
|
@ -76,10 +71,6 @@ public final class NaturesAura {
|
|||
Helper.registerCap(IAuraChunk.class);
|
||||
Helper.registerCap(IWorldData.class);
|
||||
|
||||
new ModBlocks();
|
||||
new ModItems();
|
||||
new ModPotions();
|
||||
|
||||
Compat.preInit();
|
||||
PacketHandler.init();
|
||||
new Multiblocks();
|
||||
|
@ -90,6 +81,8 @@ public final class NaturesAura {
|
|||
}
|
||||
|
||||
private void init(FMLCommonSetupEvent event) {
|
||||
ModConfig.instance.apply();
|
||||
|
||||
ModRecipes.init();
|
||||
ModRegistry.init();
|
||||
DrainSpotEffects.init();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -1,34 +1,56 @@
|
|||
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.patchouli.PatchouliCompat;
|
||||
import de.ellpeck.naturesaura.misc.ItemTagProvider;
|
||||
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 static final String CRAFT_TWEAKER = "crafttweaker";
|
||||
public static boolean baubles;
|
||||
public static boolean craftTweaker;
|
||||
public static boolean mtLib;
|
||||
private static final Map<String, Supplier<ICompat>> MODULE_TYPES = ImmutableMap.<String, Supplier<ICompat>>builder()
|
||||
.put("patchouli", PatchouliCompat::new)
|
||||
.put("curios", CuriosCompat::new)
|
||||
.put("crafttweaker", CraftTweakerCompat::new)
|
||||
.build();
|
||||
private static final Map<String, ICompat> MODULES = new HashMap<>();
|
||||
|
||||
public static void preInit() {
|
||||
ModList mods = ModList.get();
|
||||
baubles = mods.isLoaded("baubles");
|
||||
craftTweaker = mods.isLoaded(CRAFT_TWEAKER);
|
||||
mtLib = mods.isLoaded("mtlib");
|
||||
|
||||
/*if (baubles)
|
||||
MinecraftForge.EVENT_BUS.register(new BaublesCompat());*/
|
||||
|
||||
PatchouliCompat.preInit();
|
||||
populateModules(ModList.get()::isLoaded);
|
||||
MODULES.values().forEach(ICompat::preInit);
|
||||
}
|
||||
|
||||
public static void preInitClient() {
|
||||
PatchouliCompat.preInitClient();
|
||||
MODULES.values().forEach(ICompat::preInitClient);
|
||||
}
|
||||
|
||||
public static void postInit() {
|
||||
if (craftTweaker && mtLib)
|
||||
CraftTweakerCompat.postInit();
|
||||
MODULES.values().forEach(ICompat::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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
102
src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java
Normal file
102
src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java
Normal 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());
|
||||
}
|
||||
}
|
14
src/main/java/de/ellpeck/naturesaura/compat/ICompat.java
Normal file
14
src/main/java/de/ellpeck/naturesaura/compat/ICompat.java
Normal 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);
|
||||
}
|
|
@ -2,18 +2,36 @@ package de.ellpeck.naturesaura.compat.crafttweaker;
|
|||
|
||||
import com.blamejared.crafttweaker.api.CraftTweakerAPI;
|
||||
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.List;
|
||||
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 void postInit() {
|
||||
@Override
|
||||
public void preInit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInitClient() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
for (Supplier<IAction> action : SCHEDULED_ACTIONS)
|
||||
CraftTweakerAPI.apply(action.get());
|
||||
SCHEDULED_ACTIONS.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemTags(ItemTagProvider provider) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,9 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
|||
import de.ellpeck.naturesaura.ModConfig;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
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.misc.ItemTagProvider;
|
||||
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler;
|
||||
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler.FancyInfo;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
|
@ -25,17 +26,29 @@ import java.time.Month;
|
|||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public final class PatchouliCompat {
|
||||
public class PatchouliCompat implements ICompat {
|
||||
|
||||
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 + ":chunk_loader", ModConfig.instance.chunkLoader.get());
|
||||
}
|
||||
|
||||
public static void preInitClient() {
|
||||
MinecraftForge.EVENT_BUS.register(new PatchouliCompat());
|
||||
@Override
|
||||
public void preInitClient() {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemTags(ItemTagProvider provider) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit() {
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -107,7 +120,7 @@ public final class PatchouliCompat {
|
|||
ResourceLocation res = new ResourceLocation(name);
|
||||
T recipe = recipes.get(res);
|
||||
if (recipe == null)
|
||||
recipe = recipes.get(new ResourceLocation(Compat.CRAFT_TWEAKER, res.getPath()));
|
||||
recipe = recipes.get(new ResourceLocation("crafttweaker", res.getPath()));
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,10 @@ import de.ellpeck.naturesaura.api.render.IVisualizable;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGratedChute;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import de.ellpeck.naturesaura.enchant.ModEnchantment;
|
||||
import de.ellpeck.naturesaura.items.ItemAuraCache;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.items.ItemRangeVisualizer;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.packet.PacketAuraChunk;
|
||||
import de.ellpeck.naturesaura.particles.ParticleHandler;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -195,33 +194,9 @@ public class ClientEvents {
|
|||
|
||||
ParticleHandler.updateParticles();
|
||||
|
||||
if (Compat.baubles) {
|
||||
// TODO baubles
|
||||
/*IItemHandler baubles = BaublesApi.getBaublesHandler(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;
|
||||
}
|
||||
}
|
||||
heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, mc.player);
|
||||
heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player);
|
||||
heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player);
|
||||
|
||||
if (!heldOcular.isEmpty() && mc.world.getGameTime() % 20 == 0) {
|
||||
SHOWING_EFFECTS.clear();
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package de.ellpeck.naturesaura.misc;
|
||||
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.ItemTagsProvider;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraftforge.common.Tags;
|
||||
|
||||
public class ItemTagProvider extends ItemTagsProvider {
|
||||
|
@ -22,5 +25,12 @@ public class ItemTagProvider extends ItemTagsProvider {
|
|||
this.copy(BlockTags.SLABS, ItemTags.SLABS);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.renderers;
|
|||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
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.entity.player.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.renderer.entity.IEntityRenderer;
|
||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
|
||||
|
@ -13,6 +14,9 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.potion.Effects;
|
||||
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.capability.ICurioItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashSet;
|
||||
|
@ -58,12 +62,16 @@ public class PlayerLayerTrinkets extends LayerRenderer<AbstractClientPlayerEntit
|
|||
this.renderStack(player.inventory.getStackInSlot(i), player, type, main, second);
|
||||
}
|
||||
|
||||
/*if (Compat.baubles) { TODO baubles
|
||||
IItemHandler baubles = BaublesApi.getBaublesHandler(player);
|
||||
for (int i = 0; i < baubles.getSlots(); i++) {
|
||||
this.renderStack(baubles.getStackInSlot(i), player, type, main, second);
|
||||
if (Compat.hasCompat("curios")) {
|
||||
ICurioItemHandler handler = CuriosAPI.getCuriosHandler(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private void renderStack(ItemStack stack, PlayerEntity player, RenderType type, ItemStack main, ItemStack second) {
|
||||
|
|
Loading…
Reference in a new issue