mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Things
This commit is contained in:
parent
d0b7e95ed5
commit
0c493b9169
3 changed files with 28 additions and 24 deletions
|
@ -3,7 +3,6 @@ package de.ellpeck.actuallyadditions.mod;
|
||||||
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
|
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.CustomEnergyStorage;
|
|
||||||
import net.minecraft.core.registries.Registries;
|
import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
|
@ -31,10 +30,7 @@ public class ActuallyTabs {
|
||||||
.filter(stack -> stack.getItem() instanceof ItemEnergy).toList();
|
.filter(stack -> stack.getItem() instanceof ItemEnergy).toList();
|
||||||
charged.forEach(stack -> {
|
charged.forEach(stack -> {
|
||||||
if(stack.getItem() instanceof ItemEnergy itemEnergy) {
|
if(stack.getItem() instanceof ItemEnergy itemEnergy) {
|
||||||
CustomEnergyStorage storage = new CustomEnergyStorage(itemEnergy.maxPower, itemEnergy.transfer, itemEnergy.transfer);
|
stack.set(ActuallyComponents.ENERGY_STORAGE.get(), itemEnergy.maxPower); //TODO dunno if this works
|
||||||
storage.setEnergyStored(itemEnergy.maxPower);
|
|
||||||
stack.set(ActuallyComponents.ENERGY_STORAGE.get(), storage);
|
|
||||||
stack.getOrCreateTag().putBoolean("Charged", true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
stacks.addAll(charged);
|
stacks.addAll(charged);
|
||||||
|
|
|
@ -12,18 +12,12 @@ package de.ellpeck.actuallyadditions.mod.jei;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.ActuallyRecipes;
|
import de.ellpeck.actuallyadditions.mod.crafting.*;
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.FermentingRecipe;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.MiningLensRecipe;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.CrusherScreen;
|
import de.ellpeck.actuallyadditions.mod.inventory.gui.CrusherScreen;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoffeeMachine;
|
import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoffeeMachine;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFurnaceDouble;
|
import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFurnaceDouble;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineCategory;
|
import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineCategory;
|
||||||
import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherCategory;
|
import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherCategory;
|
||||||
import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeCategory;
|
import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeCategory;
|
||||||
|
@ -31,21 +25,22 @@ import de.ellpeck.actuallyadditions.mod.jei.fermenting.FermentingCategory;
|
||||||
import de.ellpeck.actuallyadditions.mod.jei.laser.LaserRecipeCategory;
|
import de.ellpeck.actuallyadditions.mod.jei.laser.LaserRecipeCategory;
|
||||||
import de.ellpeck.actuallyadditions.mod.jei.lens.MiningLensRecipeCategory;
|
import de.ellpeck.actuallyadditions.mod.jei.lens.MiningLensRecipeCategory;
|
||||||
import de.ellpeck.actuallyadditions.mod.jei.pressing.PressingCategory;
|
import de.ellpeck.actuallyadditions.mod.jei.pressing.PressingCategory;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.CapHelper;
|
||||||
import mezz.jei.api.IModPlugin;
|
import mezz.jei.api.IModPlugin;
|
||||||
import mezz.jei.api.JeiPlugin;
|
import mezz.jei.api.JeiPlugin;
|
||||||
import mezz.jei.api.constants.RecipeTypes;
|
import mezz.jei.api.constants.RecipeTypes;
|
||||||
import mezz.jei.api.helpers.IJeiHelpers;
|
import mezz.jei.api.helpers.IJeiHelpers;
|
||||||
import mezz.jei.api.recipe.RecipeType;
|
import mezz.jei.api.recipe.RecipeType;
|
||||||
import mezz.jei.api.registration.IGuiHandlerRegistration;
|
import mezz.jei.api.registration.*;
|
||||||
import mezz.jei.api.registration.IRecipeCatalystRegistration;
|
|
||||||
import mezz.jei.api.registration.IRecipeCategoryRegistration;
|
|
||||||
import mezz.jei.api.registration.IRecipeRegistration;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@JeiPlugin
|
@JeiPlugin
|
||||||
public class JEIActuallyAdditionsPlugin implements IModPlugin {
|
public class JEIActuallyAdditionsPlugin implements IModPlugin {
|
||||||
public static final ResourceLocation ID = ActuallyAdditions.modLoc("jei_plugin");
|
public static final ResourceLocation ID = ActuallyAdditions.modLoc("jei_plugin");
|
||||||
|
@ -62,13 +57,20 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin {
|
||||||
public static final RecipeType<CrushingRecipe> CRUSHING = RecipeType.create(ActuallyAdditions.MODID, "crushing", CrushingRecipe.class);
|
public static final RecipeType<CrushingRecipe> CRUSHING = RecipeType.create(ActuallyAdditions.MODID, "crushing", CrushingRecipe.class);
|
||||||
public static final RecipeType<MiningLensRecipe> MINING_LENS = RecipeType.create(ActuallyAdditions.MODID, "mining_lens", MiningLensRecipe.class);
|
public static final RecipeType<MiningLensRecipe> MINING_LENS = RecipeType.create(ActuallyAdditions.MODID, "mining_lens", MiningLensRecipe.class);
|
||||||
|
|
||||||
// @Override TODO: See if this is still needed
|
@Override
|
||||||
// public void registerItemSubtypes(@Nonnull ISubtypeRegistration reg) {
|
public void registerItemSubtypes(@Nonnull ISubtypeRegistration reg) {
|
||||||
// ActuallyItems.ITEMS.getEntries().forEach(entry -> {
|
ActuallyItems.ITEMS.getEntries().forEach(entry -> {
|
||||||
// if (entry.get() instanceof ItemEnergy)
|
if (entry.get() instanceof ItemEnergy)
|
||||||
// reg.useNbtForSubtypes(entry.get());
|
reg.registerSubtypeInterpreter(entry.get(),
|
||||||
// });
|
(ingredient, context) -> CapHelper.getEnergyStorage(ingredient).flatMap(storage -> {
|
||||||
// }
|
if (storage.getEnergyStored() == storage.getMaxEnergyStored()) {
|
||||||
|
return Optional.of("charged");
|
||||||
|
} else {
|
||||||
|
return Optional.of("uncharged");
|
||||||
|
}
|
||||||
|
}).orElse("uncharged"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCategories(IRecipeCategoryRegistration registry) {
|
public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
|
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||||
import net.neoforged.neoforge.items.IItemHandler;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -30,4 +31,9 @@ public class CapHelper {
|
||||||
public static Optional<IItemHandler> getItemHandler(ItemStack stack) {
|
public static Optional<IItemHandler> getItemHandler(ItemStack stack) {
|
||||||
return Optional.ofNullable(stack.getCapability(Capabilities.ItemHandler.ITEM));
|
return Optional.ofNullable(stack.getCapability(Capabilities.ItemHandler.ITEM));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static Optional<IEnergyStorage> getEnergyStorage(@Nonnull ItemStack stack) {
|
||||||
|
return Optional.ofNullable(stack.getCapability(Capabilities.EnergyStorage.ITEM));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue