mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-21 19:33:29 +01:00
IT COMPILES???
This commit is contained in:
parent
f2547e6555
commit
f7f425d7c8
21 changed files with 181 additions and 269 deletions
|
@ -1,7 +1,6 @@
|
||||||
package de.ellpeck.naturesaura;
|
package de.ellpeck.naturesaura;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
|
||||||
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.ILevelData;
|
import de.ellpeck.naturesaura.api.misc.ILevelData;
|
||||||
|
@ -14,7 +13,6 @@ import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -45,13 +43,12 @@ import net.minecraft.world.phys.Vec3;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
|
import net.neoforged.neoforge.capabilities.ICapabilityProvider;
|
||||||
import net.neoforged.neoforge.items.IItemHandler;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||||
import top.theillusivec4.curios.api.CuriosApi;
|
import top.theillusivec4.curios.api.CuriosApi;
|
||||||
import top.theillusivec4.curios.api.SlotResult;
|
import top.theillusivec4.curios.api.SlotResult;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
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;
|
||||||
|
@ -200,21 +197,11 @@ public final class Helper {
|
||||||
return InteractionResult.CONSUME;
|
return InteractionResult.CONSUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICapabilityProvider makeRechargeProvider(ItemStack stack, boolean needsSelected) {
|
public static ICapabilityProvider<ItemStack, Void, IAuraRecharge> makeRechargeProvider(boolean needsSelected) {
|
||||||
return new ICapabilityProvider() {
|
return (stack, ctx) -> (container, containerSlot, itemSlot, isSelected) -> {
|
||||||
private final LazyOptional<IAuraRecharge> recharge = LazyOptional.of(() -> (container, containerSlot, itemSlot, isSelected) -> {
|
|
||||||
if (isSelected || !needsSelected)
|
if (isSelected || !needsSelected)
|
||||||
return Helper.rechargeAuraItem(stack, container, 300);
|
return Helper.rechargeAuraItem(stack, container, 300);
|
||||||
return false;
|
return false;
|
||||||
});
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
|
||||||
if (capability == NaturesAuraAPI.CAP_AURA_RECHARGE)
|
|
||||||
return this.recharge.cast();
|
|
||||||
return LazyOptional.empty();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,10 +300,13 @@ public final class Helper {
|
||||||
|
|
||||||
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player, boolean hotbarOnly) {
|
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player, boolean hotbarOnly) {
|
||||||
if (Compat.hasCompat("curios")) {
|
if (Compat.hasCompat("curios")) {
|
||||||
var stack = CuriosApi.getCuriosHelper().findFirstCurio(player, predicate).map(SlotResult::stack);
|
var inventory = CuriosApi.getCuriosInventory(player);
|
||||||
|
if (inventory.isPresent()) {
|
||||||
|
var stack = inventory.get().findFirstCurio(predicate).map(SlotResult::stack);
|
||||||
if (stack.isPresent())
|
if (stack.isPresent())
|
||||||
return stack.get();
|
return stack.get();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
var invSize = hotbarOnly ? 9 : player.getInventory().getContainerSize();
|
var invSize = hotbarOnly ? 9 : player.getInventory().getContainerSize();
|
||||||
for (var i = 0; i < invSize; i++) {
|
for (var i = 0; i < invSize; i++) {
|
||||||
var slot = player.getInventory().getItem(i);
|
var slot = player.getInventory().getItem(i);
|
||||||
|
|
|
@ -24,13 +24,12 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
import net.minecraft.world.phys.shapes.Shapes;
|
import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.level.SaplingGrowTreeEvent;
|
import net.neoforged.neoforge.event.level.SaplingGrowTreeEvent;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import org.apache.commons.lang3.mutable.MutableObject;
|
import org.apache.commons.lang3.mutable.MutableObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<BlockEntityWoodStand>, ICustomBlockState {
|
public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<BlockEntityWoodStand>, ICustomBlockState {
|
||||||
|
@ -89,7 +88,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
|
||||||
});
|
});
|
||||||
|
|
||||||
if (fine && required.isEmpty()) {
|
if (fine && required.isEmpty()) {
|
||||||
toPick.getValue().setRitual(pos, recipe.value());
|
toPick.getValue().setRitual(pos, recipe);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
|
|
||||||
public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer> {
|
public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer> {
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(BlockEntityAuraTimer tile, float partialTicks, PoseStack stack, MultiBufferSource buffer, int combinedLightIn, int combinedOverlayIn) {
|
public void render(BlockEntityAuraTimer tile, float partialTicks, PoseStack stack, MultiBufferSource buffer, int combinedLightIn, int combinedOverlayIn) {
|
||||||
var bottle = tile.getItemHandler().getStackInSlot(0);
|
var bottle = tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null).getStackInSlot(0);
|
||||||
if (bottle.isEmpty())
|
if (bottle.isEmpty())
|
||||||
return;
|
return;
|
||||||
stack.pushPose();
|
stack.pushPose();
|
||||||
|
@ -61,5 +62,7 @@ public class RenderAuraTimer implements BlockEntityRenderer<BlockEntityAuraTimer
|
||||||
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
|
||||||
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
|
||||||
import de.ellpeck.naturesaura.data.ItemTagProvider;
|
import de.ellpeck.naturesaura.data.ItemTagProvider;
|
||||||
import net.neoforged.fml.ModList;
|
import net.neoforged.fml.ModList;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
|
||||||
|
import net.neoforged.neoforge.data.event.GatherDataEvent;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -34,12 +36,20 @@ public final class Compat {
|
||||||
return Compat.MODULES.containsKey(mod);
|
return Compat.MODULES.containsKey(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addItemTags(ItemTagProvider provider) {
|
public static void gatherData(GatherDataEvent event) {
|
||||||
// since other mods don't get loaded in runData, just populate all modules
|
// since other mods don't get loaded in runData, just populate all modules
|
||||||
Compat.populateModules(s -> true);
|
Compat.populateModules(s -> true);
|
||||||
|
Compat.MODULES.values().forEach(m -> m.gatherData(event));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addItemTags(ItemTagProvider provider) {
|
||||||
Compat.MODULES.values().forEach(m -> m.addItemTags(provider));
|
Compat.MODULES.values().forEach(m -> m.addItemTags(provider));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addCapabilities(RegisterCapabilitiesEvent event) {
|
||||||
|
Compat.MODULES.values().forEach(c -> c.addCapabilities(event));
|
||||||
|
}
|
||||||
|
|
||||||
private static void populateModules(Predicate<String> isLoaded) {
|
private static void populateModules(Predicate<String> isLoaded) {
|
||||||
for (var entry : Compat.MODULE_TYPES.entrySet()) {
|
for (var entry : Compat.MODULE_TYPES.entrySet()) {
|
||||||
var id = entry.getKey();
|
var id = entry.getKey();
|
||||||
|
@ -49,4 +59,5 @@ public final class Compat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,28 +4,22 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.data.ItemTagProvider;
|
import de.ellpeck.naturesaura.data.ItemTagProvider;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.data.PackOutput;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.tags.ItemTags;
|
import net.minecraft.tags.ItemTags;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
import net.neoforged.neoforge.common.data.ExistingFileHelper;
|
||||||
import net.neoforged.fml.InterModComms;
|
import net.neoforged.neoforge.data.event.GatherDataEvent;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
|
||||||
import net.neoforged.fml.event.lifecycle.InterModEnqueueEvent;
|
|
||||||
import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext;
|
|
||||||
import net.neoforged.neoforge.common.capabilities.ICapabilityProvider;
|
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.event.AttachCapabilitiesEvent;
|
|
||||||
import top.theillusivec4.curios.api.CuriosCapability;
|
import top.theillusivec4.curios.api.CuriosCapability;
|
||||||
|
import top.theillusivec4.curios.api.CuriosDataProvider;
|
||||||
import top.theillusivec4.curios.api.SlotContext;
|
import top.theillusivec4.curios.api.SlotContext;
|
||||||
import top.theillusivec4.curios.api.SlotTypeMessage;
|
|
||||||
import top.theillusivec4.curios.api.type.capability.ICurio;
|
import top.theillusivec4.curios.api.type.capability.ICurio;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class CuriosCompat implements ICompat {
|
public class CuriosCompat implements ICompat {
|
||||||
|
|
||||||
|
@ -39,33 +33,17 @@ public class CuriosCompat implements ICompat {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setup(FMLCommonSetupEvent event) {
|
public void addCapabilities(RegisterCapabilitiesEvent event) {
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::sendImc);
|
for (var item : CuriosCompat.TYPES.keySet()) {
|
||||||
NeoForge.EVENT_BUS.addGenericListener(ItemStack.class, this::onCapabilitiesAttach);
|
event.registerItem(CuriosCapability.ITEM, (s, c) -> new ICurio() {
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setupClient() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendImc(InterModEnqueueEvent event) {
|
|
||||||
CuriosCompat.TYPES.values().stream().distinct().forEach(t -> InterModComms.sendTo("curios", SlotTypeMessage.REGISTER_TYPE, () -> new SlotTypeMessage.Builder(t).build()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) {
|
|
||||||
var stack = event.getObject();
|
|
||||||
if (CuriosCompat.TYPES.containsKey(stack.getItem())) {
|
|
||||||
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "curios"), new ICapabilityProvider() {
|
|
||||||
private final LazyOptional<ICurio> curio = LazyOptional.of(() -> new ICurio() {
|
|
||||||
@Override
|
@Override
|
||||||
public void curioTick(SlotContext slotContext) {
|
public void curioTick(SlotContext slotContext) {
|
||||||
stack.getItem().inventoryTick(stack, slotContext.entity().level(), slotContext.entity(), -1, false);
|
s.getItem().inventoryTick(s, slotContext.entity().level(), slotContext.entity(), -1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStack() {
|
public ItemStack getStack() {
|
||||||
return stack;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,17 +55,13 @@ public class CuriosCompat implements ICompat {
|
||||||
public boolean canSync(SlotContext slotContext) {
|
public boolean canSync(SlotContext slotContext) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
}, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
|
public void gatherData(GatherDataEvent event) {
|
||||||
if (cap != CuriosCapability.ITEM)
|
event.getGenerator().addProvider(event.includeServer(), new CuriosProvider(event.getGenerator().getPackOutput(), event.getExistingFileHelper(), event.getLookupProvider()));
|
||||||
return LazyOptional.empty();
|
|
||||||
return this.curio.cast();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,4 +71,20 @@ public class CuriosCompat implements ICompat {
|
||||||
provider.tag(tag).add(entry.getKey());
|
provider.tag(tag).add(entry.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class CuriosProvider extends CuriosDataProvider {
|
||||||
|
|
||||||
|
public CuriosProvider(PackOutput output, ExistingFileHelper fileHelper, CompletableFuture<HolderLookup.Provider> registries) {
|
||||||
|
super(NaturesAura.MOD_ID, output, fileHelper, registries);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(HolderLookup.Provider provider, ExistingFileHelper existingFileHelper) {
|
||||||
|
for (var type : CuriosCompat.TYPES.values()) {
|
||||||
|
this.createSlot(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,19 @@ package de.ellpeck.naturesaura.compat;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.data.ItemTagProvider;
|
import de.ellpeck.naturesaura.data.ItemTagProvider;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
|
||||||
|
import net.neoforged.neoforge.data.event.GatherDataEvent;
|
||||||
|
|
||||||
public interface ICompat {
|
public interface ICompat {
|
||||||
|
|
||||||
void setup(FMLCommonSetupEvent event);
|
default void setup(FMLCommonSetupEvent event) {}
|
||||||
|
|
||||||
void setupClient();
|
default void setupClient() {}
|
||||||
|
|
||||||
|
default void gatherData(GatherDataEvent event) {}
|
||||||
|
|
||||||
|
default void addItemTags(ItemTagProvider provider) {}
|
||||||
|
|
||||||
|
default void addCapabilities(RegisterCapabilitiesEvent event) {}
|
||||||
|
|
||||||
void addItemTags(ItemTagProvider provider);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package de.ellpeck.naturesaura.data;
|
package de.ellpeck.naturesaura.data;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
import de.ellpeck.naturesaura.compat.Compat;
|
||||||
import de.ellpeck.naturesaura.gen.ModFeatures;
|
import de.ellpeck.naturesaura.gen.ModFeatures;
|
||||||
import net.minecraft.core.HolderLookup;
|
import net.minecraft.core.Cloner;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.core.RegistrySetBuilder;
|
import net.minecraft.core.RegistrySetBuilder;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
|
@ -10,10 +11,11 @@ import net.minecraft.core.registries.Registries;
|
||||||
import net.minecraft.data.loot.LootTableProvider;
|
import net.minecraft.data.loot.LootTableProvider;
|
||||||
import net.minecraft.data.registries.VanillaRegistries;
|
import net.minecraft.data.registries.VanillaRegistries;
|
||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||||
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
|
|
||||||
import net.neoforged.neoforge.data.event.GatherDataEvent;
|
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
|
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
|
||||||
|
import net.neoforged.neoforge.data.event.GatherDataEvent;
|
||||||
|
import net.neoforged.neoforge.registries.DataPackRegistriesHooks;
|
||||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -30,6 +32,8 @@ public final class ModData {
|
||||||
var lookup = event.getLookupProvider();
|
var lookup = event.getLookupProvider();
|
||||||
var existing = event.getExistingFileHelper();
|
var existing = event.getExistingFileHelper();
|
||||||
|
|
||||||
|
Compat.gatherData(event);
|
||||||
|
|
||||||
var blockTags = new BlockTagProvider(out, lookup, existing);
|
var blockTags = new BlockTagProvider(out, lookup, existing);
|
||||||
gen.addProvider(event.includeServer(), blockTags);
|
gen.addProvider(event.includeServer(), blockTags);
|
||||||
gen.addProvider(event.includeServer(), new ItemTagProvider(out, lookup, blockTags.contentsGetter(), existing));
|
gen.addProvider(event.includeServer(), new ItemTagProvider(out, lookup, blockTags.contentsGetter(), existing));
|
||||||
|
@ -39,16 +43,18 @@ public final class ModData {
|
||||||
gen.addProvider(event.includeServer(), new DatapackBuiltinEntriesProvider(out, CompletableFuture.supplyAsync(ModData::getProvider), Set.of(NaturesAura.MOD_ID)));
|
gen.addProvider(event.includeServer(), new DatapackBuiltinEntriesProvider(out, CompletableFuture.supplyAsync(ModData::getProvider), Set.of(NaturesAura.MOD_ID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HolderLookup.Provider getProvider() {
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
final RegistrySetBuilder registryBuilder = new RegistrySetBuilder();
|
private static RegistrySetBuilder.PatchedRegistries getProvider() {
|
||||||
|
final var registryBuilder = new RegistrySetBuilder();
|
||||||
registryBuilder.add(Registries.CONFIGURED_FEATURE, ModFeatures.Configured::bootstrap);
|
registryBuilder.add(Registries.CONFIGURED_FEATURE, ModFeatures.Configured::bootstrap);
|
||||||
registryBuilder.add(Registries.PLACED_FEATURE, ModFeatures.Placed::bootstrap);
|
registryBuilder.add(Registries.PLACED_FEATURE, ModFeatures.Placed::bootstrap);
|
||||||
registryBuilder.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, BiomeModifiers::bootstrap);
|
registryBuilder.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, BiomeModifiers::bootstrap);
|
||||||
// We need the BIOME registry to be present, so we can use a biome tag, doesn't matter that it's empty
|
// We need the BIOME registry to be present, so we can use a biome tag, doesn't matter that it's empty
|
||||||
registryBuilder.add(Registries.BIOME, context -> {
|
registryBuilder.add(Registries.BIOME, context -> {
|
||||||
});
|
});
|
||||||
var regAccess = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY);
|
var factory = new Cloner.Factory();
|
||||||
return registryBuilder.buildPatch(regAccess, VanillaRegistries.createLookup());
|
DataPackRegistriesHooks.getDataPackRegistriesWithDimensions().forEach(data -> data.runWithArguments(factory::addCodec));
|
||||||
|
return registryBuilder.buildPatch(RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY), VanillaRegistries.createLookup(), factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,6 @@ import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.misc.LevelData;
|
import de.ellpeck.naturesaura.misc.LevelData;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.protocol.Packet;
|
|
||||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
|
@ -25,7 +23,6 @@ import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.network.NetworkHooks;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
||||||
|
@ -123,11 +120,6 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
||||||
compound.putInt("amount", this.getAmount());
|
compound.putInt("amount", this.getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Packet<ClientGamePacketListener> getAddEntityPacket() {
|
|
||||||
return NetworkHooks.getEntitySpawningPacket(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean skipAttackInteraction(Entity entity) {
|
public boolean skipAttackInteraction(Entity entity) {
|
||||||
return entity instanceof Player player && (!this.level().mayInteract(player, this.blockPosition()) || this.hurt(this.damageSources().playerAttack(player), 0.0F));
|
return entity instanceof Player player && (!this.level().mayInteract(player, this.blockPosition()) || this.hurt(this.damageSources().playerAttack(player), 0.0F));
|
||||||
|
|
|
@ -9,8 +9,6 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.ListTag;
|
import net.minecraft.nbt.ListTag;
|
||||||
import net.minecraft.nbt.LongTag;
|
import net.minecraft.nbt.LongTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.network.protocol.Packet;
|
|
||||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
|
@ -27,7 +25,6 @@ import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
import net.neoforged.neoforge.common.util.ITeleporter;
|
import net.neoforged.neoforge.common.util.ITeleporter;
|
||||||
import net.neoforged.neoforge.network.NetworkHooks;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -157,11 +154,6 @@ public class EntityMoverMinecart extends Minecart {
|
||||||
return Blocks.STONE.defaultBlockState();
|
return Blocks.STONE.defaultBlockState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type getMinecartType() {
|
|
||||||
return Type.RIDEABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getPickResult() {
|
public ItemStack getPickResult() {
|
||||||
return new ItemStack(ModItems.MOVER_CART);
|
return new ItemStack(ModItems.MOVER_CART);
|
||||||
|
@ -183,11 +175,6 @@ public class EntityMoverMinecart extends Minecart {
|
||||||
this.setDeltaMovement(motion.x * 0.99F, 0, motion.z * 0.99F);
|
this.setDeltaMovement(motion.x * 0.99F, 0, motion.z * 0.99F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Packet<ClientGamePacketListener> getAddEntityPacket() {
|
|
||||||
return NetworkHooks.getEntitySpawningPacket(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult interact(Player p_38483_, InteractionHand p_38484_) {
|
public InteractionResult interact(Player p_38483_, InteractionHand p_38484_) {
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
|
|
|
@ -40,6 +40,7 @@ import net.minecraft.world.level.block.MyceliumBlock;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent;
|
import net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent;
|
||||||
import net.neoforged.neoforge.client.event.RenderGuiOverlayEvent;
|
import net.neoforged.neoforge.client.event.RenderGuiOverlayEvent;
|
||||||
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
|
import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
|
||||||
|
@ -73,9 +74,9 @@ public class ClientEvents {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onDebugRender(CustomizeGuiOverlayEvent.DebugText event) {
|
public void onDebugRender(CustomizeGuiOverlayEvent.DebugText event) {
|
||||||
var mc = Minecraft.getInstance();
|
var mc = Minecraft.getInstance();
|
||||||
if (mc.options.renderDebug && ModConfig.instance.debugText.get()) {
|
if (mc.getDebugOverlay().showDebugScreen() && ModConfig.instance.debugText.get()) {
|
||||||
var prefix = ChatFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + ChatFormatting.RESET + " ";
|
var prefix = ChatFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + ChatFormatting.RESET + " ";
|
||||||
List<String> left = event.getLeft();
|
var left = event.getLeft();
|
||||||
if (mc.player.isCreative() || mc.player.isSpectator()) {
|
if (mc.player.isCreative() || mc.player.isSpectator()) {
|
||||||
left.add("");
|
left.add("");
|
||||||
var amount = new MutableInt(IAuraChunk.DEFAULT_AURA);
|
var amount = new MutableInt(IAuraChunk.DEFAULT_AURA);
|
||||||
|
@ -190,7 +191,7 @@ public class ClientEvents {
|
||||||
|
|
||||||
// aura spot debug
|
// aura spot debug
|
||||||
ClientEvents.hoveringAuraSpot = null;
|
ClientEvents.hoveringAuraSpot = null;
|
||||||
if (mc.options.renderDebug && (mc.player.isCreative() || mc.player.isSpectator()) && ModConfig.instance.debugLevel.get()) {
|
if (mc.getDebugOverlay().showDebugScreen() && (mc.player.isCreative() || mc.player.isSpectator()) && ModConfig.instance.debugLevel.get()) {
|
||||||
var playerEye = mc.player.getEyePosition(event.getPartialTick());
|
var playerEye = mc.player.getEyePosition(event.getPartialTick());
|
||||||
var playerView = mc.player.getViewVector(event.getPartialTick()).normalize();
|
var playerView = mc.player.getViewVector(event.getPartialTick()).normalize();
|
||||||
var range = mc.gameMode.getPickRange();
|
var range = mc.gameMode.getPickRange();
|
||||||
|
@ -259,7 +260,7 @@ public class ClientEvents {
|
||||||
var res = event.getWindow();
|
var res = event.getWindow();
|
||||||
if (mc.player != null) {
|
if (mc.player != null) {
|
||||||
if (!ClientEvents.heldCache.isEmpty()) {
|
if (!ClientEvents.heldCache.isEmpty()) {
|
||||||
var container = ClientEvents.heldCache.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).orElse(null);
|
var container = ClientEvents.heldCache.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY, null);
|
||||||
var width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
|
var width = Mth.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
|
||||||
|
|
||||||
int conf = ModConfig.instance.cacheBarLocation.get();
|
int conf = ModConfig.instance.cacheBarLocation.get();
|
||||||
|
@ -290,7 +291,7 @@ public class ClientEvents {
|
||||||
stack.pushPose();
|
stack.pushPose();
|
||||||
|
|
||||||
int conf = ModConfig.instance.auraBarLocation.get();
|
int conf = ModConfig.instance.auraBarLocation.get();
|
||||||
if (!mc.options.renderDebug && (conf != 2 || !(mc.screen instanceof ChatScreen))) {
|
if (!mc.getDebugOverlay().showDebugScreen() && (conf != 2 || !(mc.screen instanceof ChatScreen))) {
|
||||||
var color = IAuraType.forLevel(mc.level).getColor();
|
var color = IAuraType.forLevel(mc.level).getColor();
|
||||||
graphics.setColor((color >> 16 & 0xFF) / 255F, (color >> 8 & 0xFF) / 255F, (color & 0xFF) / 255F, 1);
|
graphics.setColor((color >> 16 & 0xFF) / 255F, (color >> 8 & 0xFF) / 255F, (color & 0xFF) / 255F, 1);
|
||||||
|
|
||||||
|
@ -363,16 +364,17 @@ public class ClientEvents {
|
||||||
IAuraContainer container;
|
IAuraContainer container;
|
||||||
var x = res.getGuiScaledWidth() / 2;
|
var x = res.getGuiScaledWidth() / 2;
|
||||||
var y = res.getGuiScaledHeight() / 2;
|
var y = res.getGuiScaledHeight() / 2;
|
||||||
if (tile != null && (container = tile.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).orElse(null)) != null) {
|
if (tile != null && (container = tile.getLevel().getCapability(NaturesAuraAPI.AURA_CONTAINER_BLOCK_CAPABILITY, tile.getBlockPos(), tile.getBlockState(), tile, null)) != null) {
|
||||||
var state = mc.level.getBlockState(pos);
|
var state = mc.level.getBlockState(pos);
|
||||||
var blockStack = state.getBlock().getCloneItemStack(state, blockHitResult, mc.level, pos, mc.player);
|
var blockStack = state.getBlock().getCloneItemStack(state, blockHitResult, mc.level, pos, mc.player);
|
||||||
this.drawContainerInfo(graphics, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(),
|
this.drawContainerInfo(graphics, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(),
|
||||||
mc, res, 35, blockStack.getHoverName().getString(), null);
|
mc, res, 35, blockStack.getHoverName().getString(), null);
|
||||||
|
|
||||||
if (tile instanceof BlockEntityNatureAltar) {
|
if (tile instanceof BlockEntityNatureAltar) {
|
||||||
var tileStack = ((BlockEntityNatureAltar) tile).getItemHandler().getStackInSlot(0);
|
var itemHandler = tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||||
|
var tileStack = itemHandler.getStackInSlot(0);
|
||||||
if (!tileStack.isEmpty()) {
|
if (!tileStack.isEmpty()) {
|
||||||
var stackCont = tileStack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).orElse(null);
|
var stackCont = tileStack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
||||||
if (stackCont != null) {
|
if (stackCont != null) {
|
||||||
this.drawContainerInfo(graphics, stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
|
this.drawContainerInfo(graphics, stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
|
||||||
mc, res, 55, tileStack.getHoverName().getString(), null);
|
mc, res, 55, tileStack.getHoverName().getString(), null);
|
||||||
|
@ -385,7 +387,8 @@ public class ClientEvents {
|
||||||
mc, res, 35, I18n.get("block.naturesaura.rf_converter"),
|
mc, res, 35, I18n.get("block.naturesaura.rf_converter"),
|
||||||
storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF");
|
storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF");
|
||||||
} else if (tile instanceof BlockEntityGratedChute chute) {
|
} else if (tile instanceof BlockEntityGratedChute chute) {
|
||||||
var itemStack = chute.getItemHandler().getStackInSlot(0);
|
var itemHandler = tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||||
|
var itemStack = itemHandler.getStackInSlot(0);
|
||||||
|
|
||||||
if (itemStack.isEmpty()) {
|
if (itemStack.isEmpty()) {
|
||||||
graphics.drawString(mc.font,
|
graphics.drawString(mc.font,
|
||||||
|
@ -407,7 +410,8 @@ public class ClientEvents {
|
||||||
graphics.blit(ClientEvents.OVERLAYS, x - 18, y - 18, u, 0, 16, 16, 256, 256);
|
graphics.blit(ClientEvents.OVERLAYS, x - 18, y - 18, u, 0, 16, 16, 256, 256);
|
||||||
RenderSystem.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
} else if (tile instanceof BlockEntityAuraTimer timer) {
|
} else if (tile instanceof BlockEntityAuraTimer timer) {
|
||||||
var itemStack = timer.getItemHandler().getStackInSlot(0);
|
var itemHandler = tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||||
|
var itemStack = itemHandler.getStackInSlot(0);
|
||||||
if (!itemStack.isEmpty()) {
|
if (!itemStack.isEmpty()) {
|
||||||
Helper.renderItemInGui(graphics, itemStack, x - 20, y - 20, 1);
|
Helper.renderItemInGui(graphics, itemStack, x - 20, y - 20, 1);
|
||||||
graphics.drawString(mc.font, ChatFormatting.GRAY + this.createTimeString(timer.getTotalTime()), x + 5, y - 11, 0xFFFFFF);
|
graphics.drawString(mc.font, ChatFormatting.GRAY + this.createTimeString(timer.getTotalTime()), x + 5, y - 11, 0xFFFFFF);
|
||||||
|
|
|
@ -4,15 +4,12 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import com.mojang.math.Axis;
|
import com.mojang.math.Axis;
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.container.ItemAuraContainer;
|
|
||||||
import de.ellpeck.naturesaura.api.render.ITrinketItem;
|
import de.ellpeck.naturesaura.api.render.ITrinketItem;
|
||||||
import de.ellpeck.naturesaura.enchant.ModEnchantments;
|
import de.ellpeck.naturesaura.enchant.ModEnchantments;
|
||||||
import de.ellpeck.naturesaura.reg.ICustomCreativeTab;
|
import de.ellpeck.naturesaura.reg.ICustomCreativeTab;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -21,35 +18,25 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
|
||||||
import net.neoforged.neoforge.common.capabilities.ICapabilityProvider;
|
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ItemAuraCache extends ItemImpl implements ITrinketItem, ICustomCreativeTab {
|
public class ItemAuraCache extends ItemImpl implements ITrinketItem, ICustomCreativeTab {
|
||||||
|
|
||||||
private final int capacity;
|
public ItemAuraCache(String name) {
|
||||||
|
|
||||||
public ItemAuraCache(String name, int capacity) {
|
|
||||||
super(name, new Properties().stacksTo(1));
|
super(name, new Properties().stacksTo(1));
|
||||||
this.capacity = capacity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack stackIn, Level levelIn, Entity entityIn, int itemSlot, boolean isSelected) {
|
public void inventoryTick(ItemStack stackIn, Level levelIn, Entity entityIn, int itemSlot, boolean isSelected) {
|
||||||
if (!levelIn.isClientSide && entityIn instanceof Player player) {
|
if (!levelIn.isClientSide && entityIn instanceof Player player && player.isShiftKeyDown()) {
|
||||||
if (player.isShiftKeyDown() && stackIn.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).isPresent()) {
|
var container = stackIn.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
||||||
var container = stackIn.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null);
|
if (container == null || container.getStoredAura() <= 0)
|
||||||
if (container.getStoredAura() <= 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
for (var i = 0; i < player.getInventory().getContainerSize(); i++) {
|
for (var i = 0; i < player.getInventory().getContainerSize(); i++) {
|
||||||
var stack = player.getInventory().getItem(i);
|
var stack = player.getInventory().getItem(i);
|
||||||
var recharge = stack.getCapability(NaturesAuraAPI.CAP_AURA_RECHARGE).orElse(null);
|
var recharge = stack.getCapability(NaturesAuraAPI.AURA_RECHARGE_CAPABILITY);
|
||||||
if (recharge != null) {
|
if (recharge != null) {
|
||||||
if (recharge.rechargeFromContainer(container, itemSlot, i, player.getInventory().selected == i))
|
if (recharge.rechargeFromContainer(container, itemSlot, i, player.getInventory().selected == i))
|
||||||
break;
|
break;
|
||||||
|
@ -61,7 +48,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem, ICustomCrea
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,10 +56,9 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem, ICustomCrea
|
||||||
var ret = new ArrayList<ItemStack>();
|
var ret = new ArrayList<ItemStack>();
|
||||||
ret.add(new ItemStack(this));
|
ret.add(new ItemStack(this));
|
||||||
var full = new ItemStack(this);
|
var full = new ItemStack(this);
|
||||||
full.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).ifPresent(container -> {
|
var container = full.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
||||||
container.storeAura(container.getMaxAura(), false);
|
container.storeAura(container.getMaxAura(), false);
|
||||||
ret.add(full);
|
ret.add(full);
|
||||||
});
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,37 +69,16 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem, ICustomCrea
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBarWidth(ItemStack stack) {
|
public int getBarWidth(ItemStack stack) {
|
||||||
if (stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).isPresent()) {
|
var container = stack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
||||||
var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null);
|
return container != null ? Math.round(container.getStoredAura() / (float) container.getMaxAura() * 13) : 0;
|
||||||
return Math.round(container.getStoredAura() / (float) container.getMaxAura() * 13);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBarColor(ItemStack stack) {
|
public int getBarColor(ItemStack stack) {
|
||||||
var cap = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null);
|
var cap = stack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
||||||
return cap != null ? cap.getAuraColor() : super.getBarColor(stack);
|
return cap != null ? cap.getAuraColor() : super.getBarColor(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
|
|
||||||
return new ICapabilityProvider() {
|
|
||||||
private final LazyOptional<ItemAuraContainer> container = LazyOptional.of(() -> new ItemAuraContainer(stack, null, ItemAuraCache.this.capacity));
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
|
||||||
if (capability == NaturesAuraAPI.CAP_AURA_CONTAINER) {
|
|
||||||
return this.container.cast();
|
|
||||||
} else {
|
|
||||||
return LazyOptional.empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void render(ItemStack stack, Player player, RenderType type, PoseStack matrices, MultiBufferSource buffer, int packedLight, boolean isHolding) {
|
public void render(ItemStack stack, Player player, RenderType type, PoseStack matrices, MultiBufferSource buffer, int packedLight, boolean isHolding) {
|
||||||
|
@ -126,4 +91,5 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem, ICustomCrea
|
||||||
Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemDisplayContext.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer, player.level(), 0);
|
Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemDisplayContext.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer, player.level(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.items;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
|
@ -12,8 +13,7 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
|
||||||
|
|
||||||
public class ItemLootFinder extends ItemImpl {
|
public class ItemLootFinder extends ItemImpl {
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public class ItemLootFinder extends ItemImpl {
|
||||||
|
|
||||||
var pos = playerIn.blockPosition();
|
var pos = playerIn.blockPosition();
|
||||||
Helper.getBlockEntitiesInArea(levelIn, pos, 64, tile -> {
|
Helper.getBlockEntitiesInArea(levelIn, pos, 64, tile -> {
|
||||||
if (tile.getCapability(Capabilities.ITEM_HANDLER).isPresent() || tile instanceof SpawnerBlockEntity || ForgeRegistries.BLOCK_ENTITY_TYPES.getKey(tile.getType()).getNamespace().equals("lootr")) {
|
if (tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null) != null || tile instanceof SpawnerBlockEntity || BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(tile.getType()).getNamespace().equals("lootr")) {
|
||||||
inst.spawnMagicParticle(
|
inst.spawnMagicParticle(
|
||||||
tile.getBlockPos().getX() + 0.5F, tile.getBlockPos().getY() + 0.5F, tile.getBlockPos().getZ() + 0.5F,
|
tile.getBlockPos().getX() + 0.5F, tile.getBlockPos().getY() + 0.5F, tile.getBlockPos().getZ() + 0.5F,
|
||||||
0F, 0F, 0F, 0xf5f10a, 6F, 20 * 60, 0F, false, true);
|
0F, 0F, 0F, 0xf5f10a, 6F, 20 * 60, 0F, false, true);
|
||||||
|
@ -42,7 +42,7 @@ public class ItemLootFinder extends ItemImpl {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
for (var entity : levelIn.getEntitiesOfClass(Entity.class, new AABB(pos).inflate(64))) {
|
for (var entity : levelIn.getEntitiesOfClass(Entity.class, new AABB(pos).inflate(64))) {
|
||||||
if (!(entity instanceof LivingEntity) && entity.getCapability(Capabilities.ITEM_HANDLER).isPresent()) {
|
if (!(entity instanceof LivingEntity) && entity.getCapability(Capabilities.ItemHandler.ENTITY) != null) {
|
||||||
inst.spawnMagicParticle(
|
inst.spawnMagicParticle(
|
||||||
entity.getX(), entity.getEyeY(), entity.getZ(),
|
entity.getX(), entity.getEyeY(), entity.getZ(),
|
||||||
0F, 0F, 0F, 0xf5f10a, 6F, 20 * 60, 0F, false, true);
|
0F, 0F, 0F, 0xf5f10a, 6F, 20 * 60, 0F, false, true);
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package de.ellpeck.naturesaura.items.tools;
|
package de.ellpeck.naturesaura.items.tools;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModArmorMaterial;
|
import de.ellpeck.naturesaura.reg.ModArmorMaterial;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
@ -13,15 +12,17 @@ import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.*;
|
import net.minecraft.world.item.ArmorItem;
|
||||||
|
import net.minecraft.world.item.ArmorMaterial;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.neoforge.common.NeoForgeMod;
|
import net.neoforged.neoforge.common.NeoForgeMod;
|
||||||
import net.neoforged.neoforge.event.TickEvent;
|
import net.neoforged.neoforge.event.TickEvent;
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent;
|
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
|
||||||
import net.neoforged.fml.common.Mod;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -41,7 +42,7 @@ public class ItemArmor extends ArmorItem implements IModItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFullSetEquipped(LivingEntity entity, ArmorMaterial material) {
|
public static boolean isFullSetEquipped(LivingEntity entity, ArmorMaterial material) {
|
||||||
var set = ItemArmor.SETS.computeIfAbsent(material, m -> ForgeRegistries.ITEMS.getValues().stream()
|
var set = ItemArmor.SETS.computeIfAbsent(material, m -> BuiltInRegistries.ITEM.stream()
|
||||||
.filter(i -> i instanceof ItemArmor && ((ItemArmor) i).getMaterial() == material)
|
.filter(i -> i instanceof ItemArmor && ((ItemArmor) i).getMaterial() == material)
|
||||||
.sorted(Comparator.comparingInt(i -> ((ItemArmor) i).getEquipmentSlot().ordinal()))
|
.sorted(Comparator.comparingInt(i -> ((ItemArmor) i).getEquipmentSlot().ordinal()))
|
||||||
.toArray(Item[]::new));
|
.toArray(Item[]::new));
|
||||||
|
@ -59,12 +60,6 @@ public class ItemArmor extends ArmorItem implements IModItem {
|
||||||
return this.baseName;
|
return this.baseName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
|
|
||||||
return Helper.makeRechargeProvider(stack, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
private static final class EventHandler {
|
private static final class EventHandler {
|
||||||
|
|
||||||
|
@ -89,7 +84,7 @@ public class ItemArmor extends ArmorItem implements IModItem {
|
||||||
public static void update(TickEvent.PlayerTickEvent event) {
|
public static void update(TickEvent.PlayerTickEvent event) {
|
||||||
var player = event.player;
|
var player = event.player;
|
||||||
var speed = player.getAttribute(Attributes.MOVEMENT_SPEED);
|
var speed = player.getAttribute(Attributes.MOVEMENT_SPEED);
|
||||||
var step = player.getAttribute(NeoForgeMod.STEP_HEIGHT_ADDITION.get());
|
var step = player.getAttribute(NeoForgeMod.STEP_HEIGHT.value());
|
||||||
var key = NaturesAura.MOD_ID + ":sky_equipped";
|
var key = NaturesAura.MOD_ID + ":sky_equipped";
|
||||||
var nbt = player.getPersistentData();
|
var nbt = player.getPersistentData();
|
||||||
var equipped = ItemArmor.isFullSetEquipped(player, ModArmorMaterial.SKY);
|
var equipped = ItemArmor.isFullSetEquipped(player, ModArmorMaterial.SKY);
|
||||||
|
@ -103,8 +98,8 @@ public class ItemArmor extends ArmorItem implements IModItem {
|
||||||
} else if (!equipped && nbt.getBoolean(key)) {
|
} else if (!equipped && nbt.getBoolean(key)) {
|
||||||
// we just unequipped it
|
// we just unequipped it
|
||||||
nbt.putBoolean(key, false);
|
nbt.putBoolean(key, false);
|
||||||
step.removeModifier(ItemArmor.SKY_STEP_MODIFIER);
|
step.removeModifier(ItemArmor.SKY_STEP_MODIFIER.getId());
|
||||||
speed.removeModifier(ItemArmor.SKY_MOVEMENT_MODIFIER);
|
speed.removeModifier(ItemArmor.SKY_MOVEMENT_MODIFIER.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
|
@ -17,9 +16,6 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.common.capabilities.ICapabilityProvider;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel {
|
public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel {
|
||||||
|
|
||||||
|
@ -63,12 +59,6 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel {
|
||||||
return super.use(level, player, hand);
|
return super.use(level, player, hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
|
|
||||||
return Helper.makeRechargeProvider(stack, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomItemModel(ItemModelGenerator generator) {
|
public void generateCustomItemModel(ItemModelGenerator generator) {
|
||||||
if (this == ModItems.SKY_AXE || this == ModItems.DEPTH_AXE)
|
if (this == ModItems.SKY_AXE || this == ModItems.DEPTH_AXE)
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package de.ellpeck.naturesaura.items.tools;
|
package de.ellpeck.naturesaura.items.tools;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
|
||||||
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.item.ItemEntity;
|
import net.minecraft.world.entity.item.ItemEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -21,9 +19,6 @@ import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.BushBlock;
|
import net.minecraft.world.level.block.BushBlock;
|
||||||
import net.minecraft.world.level.block.LeavesBlock;
|
import net.minecraft.world.level.block.LeavesBlock;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.neoforged.neoforge.common.capabilities.ICapabilityProvider;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel {
|
public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel {
|
||||||
|
|
||||||
|
@ -111,12 +106,6 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel {
|
||||||
return this.baseName;
|
return this.baseName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
|
|
||||||
return Helper.makeRechargeProvider(stack, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomItemModel(ItemModelGenerator generator) {
|
public void generateCustomItemModel(ItemModelGenerator generator) {
|
||||||
generator.withExistingParent(this.getBaseName(), "item/handheld").texture("layer0", "item/" + this.getBaseName());
|
generator.withExistingParent(this.getBaseName(), "item/handheld").texture("layer0", "item/" + this.getBaseName());
|
||||||
|
|
|
@ -10,7 +10,6 @@ import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
|
@ -26,9 +25,6 @@ import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.neoforged.neoforge.common.Tags;
|
import net.neoforged.neoforge.common.Tags;
|
||||||
import net.neoforged.neoforge.common.capabilities.ICapabilityProvider;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class ItemPickaxe extends PickaxeItem implements IModItem, ICustomItemModel {
|
public class ItemPickaxe extends PickaxeItem implements IModItem, ICustomItemModel {
|
||||||
|
|
||||||
|
@ -104,12 +100,6 @@ public class ItemPickaxe extends PickaxeItem implements IModItem, ICustomItemMod
|
||||||
return super.use(level, player, hand);
|
return super.use(level, player, hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
|
|
||||||
return Helper.makeRechargeProvider(stack, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomItemModel(ItemModelGenerator generator) {
|
public void generateCustomItemModel(ItemModelGenerator generator) {
|
||||||
if (this == ModItems.DEPTH_PICKAXE)
|
if (this == ModItems.DEPTH_PICKAXE)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package de.ellpeck.naturesaura.items.tools;
|
package de.ellpeck.naturesaura.items.tools;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
|
||||||
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||||
|
@ -8,23 +7,19 @@ import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import net.minecraft.world.item.ShovelItem;
|
import net.minecraft.world.item.ShovelItem;
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.neoforged.neoforge.common.capabilities.ICapabilityProvider;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel {
|
public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel {
|
||||||
|
@ -126,12 +121,6 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel
|
||||||
return this.baseName;
|
return this.baseName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
|
|
||||||
return Helper.makeRechargeProvider(stack, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomItemModel(ItemModelGenerator generator) {
|
public void generateCustomItemModel(ItemModelGenerator generator) {
|
||||||
generator.withExistingParent(this.getBaseName(), "item/handheld").texture("layer0", "item/" + this.getBaseName());
|
generator.withExistingParent(this.getBaseName(), "item/handheld").texture("layer0", "item/" + this.getBaseName());
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
package de.ellpeck.naturesaura.items.tools;
|
package de.ellpeck.naturesaura.items.tools;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
|
||||||
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
import de.ellpeck.naturesaura.reg.ICustomItemModel;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
|
@ -19,11 +17,8 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.SwordItem;
|
import net.minecraft.world.item.SwordItem;
|
||||||
import net.minecraft.world.item.Tier;
|
import net.minecraft.world.item.Tier;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.neoforged.neoforge.common.capabilities.ICapabilityProvider;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class ItemSword extends SwordItem implements IModItem, ICustomItemModel {
|
public class ItemSword extends SwordItem implements IModItem, ICustomItemModel {
|
||||||
|
|
||||||
private final String baseName;
|
private final String baseName;
|
||||||
|
@ -67,12 +62,6 @@ public class ItemSword extends SwordItem implements IModItem, ICustomItemModel {
|
||||||
return super.getSweepHitBox(stack, player, target);
|
return super.getSweepHitBox(stack, player, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundTag nbt) {
|
|
||||||
return Helper.makeRechargeProvider(stack, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCustomItemModel(ItemModelGenerator generator) {
|
public void generateCustomItemModel(ItemModelGenerator generator) {
|
||||||
generator.withExistingParent(this.getBaseName(), "item/handheld").texture("layer0", "item/" + this.getBaseName());
|
generator.withExistingParent(this.getBaseName(), "item/handheld").texture("layer0", "item/" + this.getBaseName());
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class PotionBreathless extends PotionImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDurationEffectTick(int duration, int amplifier) {
|
public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) {
|
||||||
var mod = 200 >> amplifier;
|
var mod = 200 >> amplifier;
|
||||||
return mod > 0 && duration % mod == 0 && this.random.nextBoolean();
|
return mod > 0 && duration % mod == 0 && this.random.nextBoolean();
|
||||||
}
|
}
|
||||||
|
@ -38,4 +38,5 @@ public class PotionBreathless extends PotionImpl {
|
||||||
public void applyEffectTick(LivingEntity entity, int amplifier) {
|
public void applyEffectTick(LivingEntity entity, int amplifier) {
|
||||||
entity.hurt(entity.damageSources().magic(), 1F);
|
entity.hurt(entity.damageSources().magic(), 1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,13 @@ package de.ellpeck.naturesaura.reg;
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
|
import de.ellpeck.naturesaura.api.aura.container.ItemAuraContainer;
|
||||||
import de.ellpeck.naturesaura.api.misc.ILevelData;
|
import de.ellpeck.naturesaura.api.misc.ILevelData;
|
||||||
import de.ellpeck.naturesaura.blocks.*;
|
import de.ellpeck.naturesaura.blocks.*;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom;
|
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate;
|
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
|
import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
|
||||||
|
import de.ellpeck.naturesaura.compat.Compat;
|
||||||
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
|
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
|
||||||
import de.ellpeck.naturesaura.enchant.AuraMendingEnchantment;
|
import de.ellpeck.naturesaura.enchant.AuraMendingEnchantment;
|
||||||
import de.ellpeck.naturesaura.enchant.ModEnchantments;
|
import de.ellpeck.naturesaura.enchant.ModEnchantments;
|
||||||
|
@ -170,8 +172,8 @@ public final class ModRegistry {
|
||||||
new ItemImpl("infused_iron"),
|
new ItemImpl("infused_iron"),
|
||||||
new ItemImpl("ancient_stick"),
|
new ItemImpl("ancient_stick"),
|
||||||
new ItemColorChanger(),
|
new ItemColorChanger(),
|
||||||
new ItemAuraCache("aura_cache", 400000),
|
new ItemAuraCache("aura_cache"),
|
||||||
new ItemAuraCache("aura_trove", 1200000),
|
new ItemAuraCache("aura_trove"),
|
||||||
new ItemShockwaveCreator(),
|
new ItemShockwaveCreator(),
|
||||||
new ItemMultiblockMaker(),
|
new ItemMultiblockMaker(),
|
||||||
temp = new ItemImpl("bottle_two_the_rebottling"),
|
temp = new ItemImpl("bottle_two_the_rebottling"),
|
||||||
|
@ -248,8 +250,10 @@ public final class ModRegistry {
|
||||||
event.register(Registries.MENU, h -> {
|
event.register(Registries.MENU, h -> {
|
||||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "ender_crate"), IMenuTypeExtension.create((windowId, inv, data) -> {
|
h.register(new ResourceLocation(NaturesAura.MOD_ID, "ender_crate"), IMenuTypeExtension.create((windowId, inv, data) -> {
|
||||||
var tile = inv.player.level().getBlockEntity(data.readBlockPos());
|
var tile = inv.player.level().getBlockEntity(data.readBlockPos());
|
||||||
if (tile instanceof BlockEntityEnderCrate crate)
|
if (tile instanceof BlockEntityEnderCrate) {
|
||||||
return new ContainerEnderCrate(ModContainers.ENDER_CRATE, windowId, inv.player, crate.getItemHandler());
|
var handler = tile.getLevel().getCapability(ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||||
|
return new ContainerEnderCrate(ModContainers.ENDER_CRATE, windowId, inv.player, handler);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}));
|
}));
|
||||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "ender_access"), IMenuTypeExtension.create((windowId, inv, data) -> {
|
h.register(new ResourceLocation(NaturesAura.MOD_ID, "ender_access"), IMenuTypeExtension.create((windowId, inv, data) -> {
|
||||||
|
@ -336,13 +340,10 @@ public final class ModRegistry {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void registerCapabilities(RegisterCapabilitiesEvent event) {
|
public static void registerCapabilities(RegisterCapabilitiesEvent event) {
|
||||||
event.registerBlockEntity(FluidHandler.BLOCK, ModBlockEntities.SPRING, (e, c) -> e.tank);
|
event.registerBlockEntity(FluidHandler.BLOCK, ModBlockEntities.SPRING, (e, c) -> e.tank);
|
||||||
|
|
||||||
event.registerBlockEntity(EnergyStorage.BLOCK, ModBlockEntities.RF_CONVERTER, (e, c) -> e.storage);
|
event.registerBlockEntity(EnergyStorage.BLOCK, ModBlockEntities.RF_CONVERTER, (e, c) -> e.storage);
|
||||||
|
|
||||||
event.registerBlockEntity(NaturesAuraAPI.AURA_CONTAINER_BLOCK_CAPABILITY, ModBlockEntities.NATURE_ALTAR, (e, c) -> e.container);
|
event.registerBlockEntity(NaturesAuraAPI.AURA_CONTAINER_BLOCK_CAPABILITY, ModBlockEntities.NATURE_ALTAR, (e, c) -> e.container);
|
||||||
event.registerBlockEntity(NaturesAuraAPI.AURA_CONTAINER_BLOCK_CAPABILITY, ModBlockEntities.ANCIENT_LEAVES, (e, c) -> e.container);
|
event.registerBlockEntity(NaturesAuraAPI.AURA_CONTAINER_BLOCK_CAPABILITY, ModBlockEntities.ANCIENT_LEAVES, (e, c) -> e.container);
|
||||||
event.registerBlockEntity(NaturesAuraAPI.AURA_CONTAINER_BLOCK_CAPABILITY, ModBlockEntities.END_FLOWER, (e, c) -> e.container);
|
event.registerBlockEntity(NaturesAuraAPI.AURA_CONTAINER_BLOCK_CAPABILITY, ModBlockEntities.END_FLOWER, (e, c) -> e.container);
|
||||||
|
|
||||||
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.BLAST_FURNACE_BOOSTER, (e, c) -> e.getItemHandler());
|
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.BLAST_FURNACE_BOOSTER, (e, c) -> e.getItemHandler());
|
||||||
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.OFFERING_TABLE, (e, c) -> e.items);
|
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.OFFERING_TABLE, (e, c) -> e.items);
|
||||||
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.GRATED_CHUTE, (e, c) -> e.items);
|
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.GRATED_CHUTE, (e, c) -> e.items);
|
||||||
|
@ -350,6 +351,18 @@ public final class ModRegistry {
|
||||||
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.WOOD_STAND, (e, c) -> e.items);
|
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.WOOD_STAND, (e, c) -> e.items);
|
||||||
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.ENDER_CRATE, (e, c) -> e.canOpen() ? e.wrappedEnderStorage : null);
|
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.ENDER_CRATE, (e, c) -> e.canOpen() ? e.wrappedEnderStorage : null);
|
||||||
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.AURA_TIMER, (e, c) -> e.itemHandler);
|
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.AURA_TIMER, (e, c) -> e.itemHandler);
|
||||||
|
|
||||||
|
event.registerItem(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY, (s, c) -> new ItemAuraContainer(s, null, 400000), ModItems.AURA_CACHE);
|
||||||
|
event.registerItem(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY, (s, c) -> new ItemAuraContainer(s, null, 1200000), ModItems.AURA_TROVE);
|
||||||
|
for (var item : ModRegistry.ALL_ITEMS) {
|
||||||
|
if (item instanceof ItemArmor) {
|
||||||
|
event.registerItem(NaturesAuraAPI.AURA_RECHARGE_CAPABILITY, Helper.makeRechargeProvider(false), (Item) item);
|
||||||
|
} else if (item instanceof ItemAxe || item instanceof ItemPickaxe || item instanceof ItemShovel || item instanceof ItemHoe || item instanceof ItemSword) {
|
||||||
|
event.registerItem(NaturesAuraAPI.AURA_RECHARGE_CAPABILITY, Helper.makeRechargeProvider(true), (Item) item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Compat.addCapabilities(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Block createFlowerPot(Block block) {
|
public static Block createFlowerPot(Block block) {
|
||||||
|
|
|
@ -18,7 +18,6 @@ import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.items.IItemHandler;
|
|
||||||
import top.theillusivec4.curios.api.CuriosApi;
|
import top.theillusivec4.curios.api.CuriosApi;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -61,8 +60,9 @@ public class PlayerLayerTrinkets extends RenderLayer<AbstractClientPlayer, Playe
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Compat.hasCompat("curios")) {
|
if (Compat.hasCompat("curios")) {
|
||||||
IItemHandler handler = CuriosApi.getCuriosHelper().getEquippedCurios(player).orElse(null);
|
var inventory = CuriosApi.getCuriosInventory(player).orElse(null);
|
||||||
if (handler != null) {
|
if (inventory != null) {
|
||||||
|
var handler = inventory.getEquippedCurios();
|
||||||
for (var 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);
|
this.renderStack(handler.getStackInSlot(i), player, type, main, second, matrices, buffer, packedLight);
|
||||||
}
|
}
|
||||||
|
@ -84,4 +84,5 @@ public class PlayerLayerTrinkets extends RenderLayer<AbstractClientPlayer, Playe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue