mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 03:43:30 +01:00
a bunch more 1.20.4 work
This commit is contained in:
parent
9010b9708e
commit
5a4a191973
30 changed files with 223 additions and 269 deletions
|
@ -15,6 +15,8 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -42,12 +44,9 @@ import net.minecraft.world.phys.AABB;
|
|||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.items.IItemHandler;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
import net.neoforged.neoforge.registries.IForgeRegistry;
|
||||
import net.neoforged.neoforge.common.capabilities.ICapabilityProvider;
|
||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||
import top.theillusivec4.curios.api.CuriosApi;
|
||||
import top.theillusivec4.curios.api.SlotResult;
|
||||
|
||||
|
@ -167,7 +166,7 @@ public final class Helper {
|
|||
public static InteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) {
|
||||
var tile = player.level().getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityImpl) {
|
||||
var handler = ((BlockEntityImpl) tile).getItemHandler();
|
||||
var handler = (IItemHandlerModifiable) tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||
if (handler != null) {
|
||||
var handStack = player.getItemInHand(hand);
|
||||
if (!handStack.isEmpty()) {
|
||||
|
@ -230,7 +229,7 @@ public final class Helper {
|
|||
|
||||
public static BlockState getStateFromString(String raw) {
|
||||
var split = raw.split("\\[");
|
||||
var block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(split[0]));
|
||||
var block = BuiltInRegistries.BLOCK.get(new ResourceLocation(split[0]));
|
||||
if (block != null) {
|
||||
var state = block.defaultBlockState();
|
||||
if (split.length > 1) {
|
||||
|
@ -261,7 +260,7 @@ public final class Helper {
|
|||
public static void addAdvancement(Player player, ResourceLocation advancement, String criterion) {
|
||||
if (!(player instanceof ServerPlayer playerMp))
|
||||
return;
|
||||
var adv = playerMp.level().getServer().getAdvancements().getAdvancement(advancement);
|
||||
var adv = playerMp.level().getServer().getAdvancements().get(advancement);
|
||||
if (adv != null)
|
||||
playerMp.getAdvancements().award(adv, criterion);
|
||||
}
|
||||
|
@ -295,17 +294,17 @@ public final class Helper {
|
|||
}
|
||||
|
||||
// This is how @ObjectHolder SHOULD work...
|
||||
public static <T> void populateObjectHolders(Class<?> clazz, IForgeRegistry<T> registry) {
|
||||
public static <T> void populateObjectHolders(Class<?> clazz, Registry<T> registry) {
|
||||
for (var entry : clazz.getFields()) {
|
||||
if (!Modifier.isStatic(entry.getModifiers()))
|
||||
continue;
|
||||
var location = new ResourceLocation(NaturesAura.MOD_ID, entry.getName().toLowerCase(Locale.ROOT));
|
||||
if (!registry.containsKey(location)) {
|
||||
NaturesAura.LOGGER.fatal("Couldn't find entry named " + location + " in registry " + registry.getRegistryName());
|
||||
NaturesAura.LOGGER.fatal("Couldn't find entry named " + location + " in registry");
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
entry.set(null, registry.getValue(location));
|
||||
entry.set(null, registry.get(location));
|
||||
} catch (IllegalAccessException e) {
|
||||
NaturesAura.LOGGER.error(e);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import de.ellpeck.naturesaura.blocks.multi.Multiblock;
|
|||
import de.ellpeck.naturesaura.misc.LevelData;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -37,9 +38,9 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
private boolean auraPlayerInteraction(Player player, int amount, boolean extract, boolean simulate) {
|
||||
if (extract && player.isCreative())
|
||||
return true;
|
||||
var stack = Helper.getEquippedItem(s -> s.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).isPresent(), player, false);
|
||||
var stack = Helper.getEquippedItem(s -> s.getCapability(NaturesAuraAPI.AURA_CONTAINER_CAPABILITY) != null, player, false);
|
||||
if (!stack.isEmpty()) {
|
||||
var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null);
|
||||
var container = stack.getCapability(NaturesAuraAPI.AURA_CONTAINER_CAPABILITY);
|
||||
if (extract) {
|
||||
return container.drainAura(amount, simulate) > 0;
|
||||
} else {
|
||||
|
@ -182,4 +183,20 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
return highest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILevelData getLevelData(Level level) {
|
||||
if (level instanceof ServerLevel server) {
|
||||
var ret = server.getDataStorage().computeIfAbsent(LevelData.FACTORY, "level_data");
|
||||
if (ret.level == null)
|
||||
ret.level = level;
|
||||
return ret;
|
||||
} else {
|
||||
if (LevelData.client == null || LevelData.client.level != level) {
|
||||
LevelData.client = new LevelData();
|
||||
LevelData.client.level = level;
|
||||
}
|
||||
return LevelData.client;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ import de.ellpeck.naturesaura.api.aura.type.BasicAuraType;
|
|||
import de.ellpeck.naturesaura.api.misc.WeightedOre;
|
||||
import de.ellpeck.naturesaura.chunk.effect.OreSpawnEffect;
|
||||
import de.ellpeck.naturesaura.chunk.effect.PlantBoostEffect;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||
import net.neoforged.neoforge.common.ModConfigSpec.ConfigValue;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -239,18 +239,18 @@ public final class ModConfig {
|
|||
}
|
||||
|
||||
try {
|
||||
for (String s : this.plantBoostExceptions.get())
|
||||
PlantBoostEffect.EXCEPTIONS.add(Objects.requireNonNull(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(s))));
|
||||
for (var s : this.plantBoostExceptions.get())
|
||||
PlantBoostEffect.EXCEPTIONS.add(Objects.requireNonNull(BuiltInRegistries.BLOCK.get(new ResourceLocation(s))));
|
||||
} catch (Exception e) {
|
||||
NaturesAura.LOGGER.warn("Error parsing plantBoostExceptions", e);
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
for (String s : this.additionalProjectiles.get()) {
|
||||
for (var s : this.additionalProjectiles.get()) {
|
||||
var split = s.split("->");
|
||||
var name = new ResourceLocation(split[0]);
|
||||
var type = Objects.requireNonNull(ForgeRegistries.ENTITY_TYPES.getValue(name));
|
||||
var type = Objects.requireNonNull(BuiltInRegistries.ENTITY_TYPE.get(name));
|
||||
var amount = Integer.parseInt(split[1]);
|
||||
NaturesAuraAPI.PROJECTILE_GENERATIONS.put(type, amount);
|
||||
}
|
||||
|
@ -258,4 +258,5 @@ public final class ModConfig {
|
|||
NaturesAura.LOGGER.warn("Error parsing additionalProjectiles", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,18 +6,17 @@ 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.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.proxy.ClientProxy;
|
||||
import de.ellpeck.naturesaura.proxy.IProxy;
|
||||
import de.ellpeck.naturesaura.proxy.ServerProxy;
|
||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.fml.DistExecutor;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
@ -29,13 +28,13 @@ public final class NaturesAura {
|
|||
|
||||
public static final Logger LOGGER = LogManager.getLogger(NaturesAura.MOD_NAME);
|
||||
public static NaturesAura instance;
|
||||
// this causes a classloading issue if it's not wrapped like this
|
||||
@SuppressWarnings("Convert2MethodRef")
|
||||
public static IProxy proxy = DistExecutor.unsafeRunForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy());
|
||||
public static IProxy proxy;
|
||||
|
||||
public NaturesAura() {
|
||||
public NaturesAura(IEventBus eventBus) {
|
||||
NaturesAura.instance = this;
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||
NaturesAura.proxy = FMLEnvironment.dist.isClient() ? new ClientProxy() : new ServerProxy();
|
||||
|
||||
eventBus.addListener(this::setup);
|
||||
|
||||
var builder = new ModConfigSpec.Builder();
|
||||
ModConfig.instance = new ModConfig(builder);
|
||||
|
@ -50,7 +49,6 @@ public final class NaturesAura {
|
|||
|
||||
private void preInit(FMLCommonSetupEvent event) {
|
||||
Compat.setup(event);
|
||||
PacketHandler.init();
|
||||
new Multiblocks();
|
||||
|
||||
NeoForge.EVENT_BUS.register(new CommonEvents());
|
||||
|
|
|
@ -23,10 +23,8 @@ import net.minecraft.world.level.Level;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.common.capabilities.*;
|
||||
import net.neoforged.neoforge.common.capabilities.CapabilityToken;
|
||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
||||
import net.neoforged.neoforge.common.capabilities.CapabilityManager;
|
||||
import net.neoforged.neoforge.attachment.AttachmentType;
|
||||
import net.neoforged.neoforge.capabilities.ItemCapability;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -86,23 +84,15 @@ public final class NaturesAuraAPI {
|
|||
/**
|
||||
* The capability for any item or block that stores Aura in the form of an {@link IAuraContainer}
|
||||
*/
|
||||
public static final Capability<IAuraContainer> CAP_AURA_CONTAINER = CapabilityManager.get(new CapabilityToken<>() {
|
||||
});
|
||||
public static final ItemCapability<IAuraContainer, Void> AURA_CONTAINER_CAPABILITY = ItemCapability.createVoid(new ResourceLocation(NaturesAuraAPI.MOD_ID, "aura_container"), IAuraContainer.class);
|
||||
/**
|
||||
* The capability for any item that can be recharged from an Aura storage container like the Aura Cache in the form of {@link IAuraRecharge} by a player holding it in their hand
|
||||
*/
|
||||
public static final Capability<IAuraRecharge> CAP_AURA_RECHARGE = CapabilityManager.get(new CapabilityToken<>() {
|
||||
});
|
||||
public static final ItemCapability<IAuraRecharge, Void> AURA_RECHARGE_CAPABILITY = ItemCapability.createVoid(new ResourceLocation(NaturesAuraAPI.MOD_ID, "aura_recharge"), IAuraRecharge.class);
|
||||
/**
|
||||
* The capability that any chunk in a level has to store Aura in it. As this is only applicable to chunks and all chunks in the level automatically get assigned this capability, using it directly is not necessary for addon developers. To retrieve this capability from any chunk, use the helper method {@link IAuraChunk#getAuraChunk(net.minecraft.world.level.Level, BlockPos)}.
|
||||
*/
|
||||
public static final Capability<IAuraChunk> CAP_AURA_CHUNK = CapabilityManager.get(new CapabilityToken<>() {
|
||||
});
|
||||
/**
|
||||
* The capability that any level has to store Nature's Aura specific data in it. To retrieve this capability from any level, use the helper methods {@link ILevelData#getLevelData(net.minecraft.world.level.Level)} or {@link ILevelData#getOverworldData(net.minecraft.world.level.Level)}.
|
||||
*/
|
||||
public static final Capability<ILevelData> CAP_LEVEL_DATA = CapabilityManager.get(new CapabilityToken<>() {
|
||||
});
|
||||
public static final AttachmentType<IAuraChunk> AURA_CHUNK_ATTACHMENT = AttachmentType.serializable(() -> (IAuraChunk) null).build();
|
||||
private static final IInternalHooks INSTANCE;
|
||||
|
||||
static {
|
||||
|
@ -260,6 +250,9 @@ public final class NaturesAuraAPI {
|
|||
* @see IAuraChunk#getHighestSpot(Level, BlockPos, int, BlockPos)
|
||||
*/
|
||||
BlockPos getHighestAuraDrainSpot(Level level, BlockPos pos, int radius, BlockPos defaultSpot);
|
||||
|
||||
ILevelData getLevelData(Level level);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public interface IAuraChunk extends INBTSerializable<CompoundTag> {
|
|||
*/
|
||||
static IAuraChunk getAuraChunk(Level level, BlockPos pos) {
|
||||
var chunk = (LevelChunk) level.getChunk(pos);
|
||||
return chunk.getCapability(NaturesAuraAPI.CAP_AURA_CHUNK, null).orElse(null);
|
||||
return chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,4 +159,5 @@ public interface IAuraChunk extends INBTSerializable<CompoundTag> {
|
|||
IAuraType getType();
|
||||
|
||||
void markDirty();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
package de.ellpeck.naturesaura.api.misc;
|
||||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.neoforge.common.util.INBTSerializable;
|
||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||
import net.neoforged.neoforge.common.capabilities.ICapabilityProvider;
|
||||
|
||||
public interface ILevelData extends ICapabilityProvider, INBTSerializable<CompoundTag> {
|
||||
public interface ILevelData {
|
||||
|
||||
static ILevelData getLevelData(Level level) {
|
||||
return level.getCapability(NaturesAuraAPI.CAP_LEVEL_DATA, null).orElse(null);
|
||||
return NaturesAuraAPI.instance().getLevelData(level);
|
||||
}
|
||||
|
||||
static ILevelData getOverworldData(Level level) {
|
||||
|
@ -22,4 +19,5 @@ public interface ILevelData extends ICapabilityProvider, INBTSerializable<Compou
|
|||
IItemHandlerModifiable getEnderStorage(String name);
|
||||
|
||||
boolean isEnderStorageLocked(String name);
|
||||
|
||||
}
|
||||
|
|
|
@ -129,11 +129,11 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void playerWillDestroy(Level level, BlockPos pos, BlockState state, Player player) {
|
||||
public BlockState playerWillDestroy(Level level, BlockPos pos, BlockState state, Player player) {
|
||||
var tile = level.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityImpl impl)
|
||||
impl.dropInventory();
|
||||
super.playerWillDestroy(level, pos, state, player);
|
||||
return super.playerWillDestroy(level, pos, state, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -181,4 +181,5 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
|
|||
throw new IllegalStateException("Cannot construct block entity from class " + this.tileClass, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import net.neoforged.api.distmarker.OnlyIn;
|
|||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.AnvilUpdateEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
@ -92,7 +91,7 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
|
|||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityEnderCrate crate && crate.canOpen() && crate.canUseRightNow(2500)) {
|
||||
crate.drainAura(2500);
|
||||
NetworkHooks.openScreen((ServerPlayer) player, crate, pos);
|
||||
player.openMenu(crate, pos);
|
||||
}
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
|
@ -132,4 +131,5 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
|
|||
public void registerTESR() {
|
||||
BlockEntityRenderers.register(ModBlockEntities.ENDER_CRATE, RenderEnderCrate::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
|||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.INoItemBlock;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.FlowerPotBlock;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -20,12 +20,12 @@ public class BlockFlowerPot extends FlowerPotBlock implements ICustomBlockState,
|
|||
|
||||
@Override
|
||||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||
generator.simpleBlock(this, generator.models().withExistingParent(this.getBaseName(), "block/flower_pot_cross").texture("plant", "block/" + ForgeRegistries.BLOCKS.getKey(this.getContent()).getPath()).renderType("cutout"));
|
||||
generator.simpleBlock(this, generator.models().withExistingParent(this.getBaseName(), "block/flower_pot_cross").texture("plant", "block/" + BuiltInRegistries.BLOCK.getKey(this.getPotted()).getPath()).renderType("cutout"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseName() {
|
||||
return "potted_" + ForgeRegistries.BLOCKS.getKey(this.getContent()).getPath();
|
||||
return "potted_" + BuiltInRegistries.BLOCK.getKey(this.getPotted()).getPath();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public final class Multiblocks {
|
|||
// try-catch to prevent blocks that need to have been placed crashing here
|
||||
try {
|
||||
var stack = new ItemStack(state.getBlock());
|
||||
return !stack.isEmpty() && level.getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, level).stream().anyMatch(r -> r.saplingType.test(stack));
|
||||
return !stack.isEmpty() && level.getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, level).stream().anyMatch(r -> r.value().saplingType.test(stack));
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
@ -99,4 +99,5 @@ public final class Multiblocks {
|
|||
'R', Blocks.REDSTONE_BLOCK,
|
||||
'0', ModBlocks.RF_CONVERTER,
|
||||
' ', Matcher.any());
|
||||
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import net.minecraft.world.item.crafting.Ingredient;
|
|||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.common.Tags;
|
||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -35,7 +35,7 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I
|
|||
var below = this.level.getBlockEntity(this.worldPosition.below());
|
||||
if (!(below instanceof BlastFurnaceBlockEntity tile))
|
||||
return;
|
||||
Recipe<?> recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(tile), tile, this.level).orElse(null);
|
||||
Recipe<?> recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(tile), tile, this.level).orElse(null).value();
|
||||
if (recipe == null)
|
||||
return;
|
||||
if (!this.isApplicable(recipe.getIngredients()))
|
||||
|
@ -80,12 +80,11 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandlerModifiable getItemHandler() {
|
||||
var below = this.level.getBlockEntity(this.worldPosition.below());
|
||||
if (!(below instanceof BlastFurnaceBlockEntity))
|
||||
return null;
|
||||
var handler = below.getCapability(Capabilities.ITEM_HANDLER, Direction.UP).orElse(null);
|
||||
var handler = this.level.getCapability(Capabilities.ItemHandler.BLOCK, below.getBlockPos(), below.getBlockState(), below, Direction.UP);
|
||||
if (handler == null)
|
||||
return null;
|
||||
return new IItemHandlerModifiable() {
|
||||
|
@ -138,4 +137,5 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I
|
|||
public boolean allowsLowerLimiter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@ import de.ellpeck.naturesaura.packet.PacketHandler;
|
|||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -106,7 +106,7 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick
|
|||
var block = state.getBlock();
|
||||
|
||||
var tag = new CompoundTag();
|
||||
tag.putString("block", ForgeRegistries.BLOCKS.getKey(block).toString());
|
||||
tag.putString("block", BuiltInRegistries.BLOCK.getKey(block).toString());
|
||||
tag.putInt("amount", entry.getValue().intValue());
|
||||
list.add(tag);
|
||||
}
|
||||
|
@ -122,11 +122,12 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick
|
|||
var list = compound.getList("consumed_recently", 10);
|
||||
for (var base : list) {
|
||||
var tag = (CompoundTag) base;
|
||||
var block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString("block")));
|
||||
var block = BuiltInRegistries.BLOCK.get(new ResourceLocation(tag.getString("block")));
|
||||
if (block != null)
|
||||
this.consumedRecently.put(block.defaultBlockState(), new MutableInt(tag.getInt("amount")));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import net.minecraft.world.entity.item.ItemEntity;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||
|
||||
public class BlockEntityGratedChute extends BlockEntityImpl implements ITickableBlockEntity {
|
||||
|
@ -48,7 +48,7 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable
|
|||
var tile = this.level.getBlockEntity(this.worldPosition.relative(facing));
|
||||
if (tile == null)
|
||||
break push;
|
||||
var handler = tile.getCapability(Capabilities.ITEM_HANDLER, facing.getOpposite()).orElse(null);
|
||||
var handler = this.level.getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, facing.getOpposite());
|
||||
if (handler == null)
|
||||
break push;
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
|
@ -87,7 +87,7 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable
|
|||
var tileUp = this.level.getBlockEntity(this.worldPosition.above());
|
||||
if (tileUp == null)
|
||||
break pull;
|
||||
var handlerUp = tileUp.getCapability(Capabilities.ITEM_HANDLER, Direction.DOWN).orElse(null);
|
||||
var handlerUp = this.level.getCapability(Capabilities.ItemHandler.BLOCK, tileUp.getBlockPos(), tileUp.getBlockState(), tileUp, Direction.DOWN);
|
||||
if (handlerUp == null)
|
||||
break pull;
|
||||
for (var i = 0; i < handlerUp.getSlots(); i++) {
|
||||
|
@ -143,4 +143,5 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable
|
|||
public IItemHandlerModifiable getItemHandler() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.block.entity.HopperBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
|
||||
public class BlockEntityHopperUpgrade extends BlockEntityImpl implements ITickableBlockEntity {
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class BlockEntityHopperUpgrade extends BlockEntityImpl implements ITickab
|
|||
var tile = this.level.getBlockEntity(this.worldPosition.below());
|
||||
if (!BlockEntityHopperUpgrade.isValidHopper(tile))
|
||||
return;
|
||||
var handler = tile.getCapability(Capabilities.ITEM_HANDLER, Direction.UP).orElse(null);
|
||||
var handler = this.level.getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, Direction.UP);
|
||||
if (handler == null)
|
||||
return;
|
||||
|
||||
|
@ -82,4 +82,5 @@ public class BlockEntityHopperUpgrade extends BlockEntityImpl implements ITickab
|
|||
public boolean allowsLowerLimiter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -16,19 +14,11 @@ import net.minecraft.world.level.ChunkPos;
|
|||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
||||
import net.neoforged.neoforge.items.IItemHandler;
|
||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
|
||||
public class BlockEntityImpl extends BlockEntity {
|
||||
|
||||
public int redstonePower;
|
||||
private LazyOptional<IItemHandler> itemHandler;
|
||||
private LazyOptional<IAuraContainer> auraContainer;
|
||||
|
||||
public BlockEntityImpl(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
|
@ -97,45 +87,8 @@ public class BlockEntityImpl extends BlockEntity {
|
|||
e.connection.send(packet);
|
||||
}
|
||||
|
||||
public IItemHandlerModifiable getItemHandler() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public IAuraContainer getAuraContainer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||
if (capability == Capabilities.ITEM_HANDLER) {
|
||||
if (this.itemHandler == null) {
|
||||
IItemHandler handler = this.getItemHandler();
|
||||
this.itemHandler = handler == null ? LazyOptional.empty() : LazyOptional.of(() -> handler);
|
||||
}
|
||||
return this.itemHandler.cast();
|
||||
} else if (capability == NaturesAuraAPI.CAP_AURA_CONTAINER) {
|
||||
if (this.auraContainer == null) {
|
||||
var container = this.getAuraContainer();
|
||||
this.auraContainer = container == null ? LazyOptional.empty() : LazyOptional.of(() -> container);
|
||||
}
|
||||
return this.auraContainer.cast();
|
||||
} else {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemoved() {
|
||||
super.setRemoved();
|
||||
if (this.itemHandler != null)
|
||||
this.itemHandler.invalidate();
|
||||
if (this.auraContainer != null)
|
||||
this.auraContainer.invalidate();
|
||||
}
|
||||
|
||||
public void dropInventory() {
|
||||
IItemHandler handler = this.getItemHandler();
|
||||
var handler = this.level.getCapability(Capabilities.ItemHandler.BLOCK, this.worldPosition, this.getBlockState(), this, null);
|
||||
if (handler != null) {
|
||||
for (var i = 0; i < handler.getSlots(); i++) {
|
||||
var stack = handler.getStackInSlot(i);
|
||||
|
@ -207,4 +160,5 @@ public class BlockEntityImpl extends BlockEntity {
|
|||
public enum SaveType {
|
||||
TILE, SYNC, BLOCK
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.items.IItemHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -57,7 +57,7 @@ public class BlockEntityItemDistributor extends BlockEntityImpl implements ITick
|
|||
var tile = this.level.getBlockEntity(offset);
|
||||
if (tile == null)
|
||||
return null;
|
||||
return tile.getCapability(Capabilities.ITEM_HANDLER, direction.getOpposite()).orElse(null);
|
||||
return this.level.getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, direction.getOpposite());
|
||||
}
|
||||
|
||||
private IItemHandler getNextSide() {
|
||||
|
@ -103,4 +103,5 @@ public class BlockEntityItemDistributor extends BlockEntityImpl implements ITick
|
|||
if (type != SaveType.BLOCK)
|
||||
this.isRandomMode = compound.getBoolean("random");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ import net.minecraft.world.level.block.Blocks;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.common.CommonHooks;
|
||||
import net.neoforged.neoforge.common.util.FakePlayerFactory;
|
||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -37,7 +37,7 @@ public class BlockEntityPlacer extends BlockEntityImpl implements ITickableBlock
|
|||
var tileUp = this.level.getBlockEntity(this.worldPosition.above());
|
||||
if (tileUp == null)
|
||||
return;
|
||||
var handler = tileUp.getCapability(Capabilities.ITEM_HANDLER, Direction.DOWN).orElse(null);
|
||||
var handler = this.level.getCapability(Capabilities.ItemHandler.BLOCK, tileUp.getBlockPos(), tileUp.getBlockState(), tileUp, Direction.DOWN);
|
||||
if (handler == null)
|
||||
return;
|
||||
var frames = Helper.getAttachedItemFrames(this.level, this.worldPosition);
|
||||
|
@ -118,4 +118,5 @@ public class BlockEntityPlacer extends BlockEntityImpl implements ITickableBlock
|
|||
CommonHooks.onPlaceItemIntoWorld(new UseOnContext(fake, InteractionHand.MAIN_HAND, ray));
|
||||
return fake.getMainHandItem().copy();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
|
||||
public class BlockEntityPowderPlacer extends BlockEntityImpl {
|
||||
|
||||
|
@ -18,14 +19,14 @@ public class BlockEntityPowderPlacer extends BlockEntityImpl {
|
|||
@Override
|
||||
public void onRedstonePowerChange(int newPower) {
|
||||
if (this.redstonePower <= 0 && newPower > 0) {
|
||||
var powders = this.level.getEntitiesOfClass(EntityEffectInhibitor.class, new AABB(this.worldPosition, this.worldPosition.offset(1, 2, 1)), Entity::isAlive);
|
||||
var powders = this.level.getEntitiesOfClass(EntityEffectInhibitor.class, new AABB(Vec3.atCenterOf(this.worldPosition), Vec3.atCenterOf(this.worldPosition.offset(1, 2, 1))), Entity::isAlive);
|
||||
for (var facing : Direction.values()) {
|
||||
if (!facing.getAxis().isHorizontal())
|
||||
continue;
|
||||
var tile = this.level.getBlockEntity(this.worldPosition.relative(facing));
|
||||
if (tile == null)
|
||||
continue;
|
||||
var handler = tile.getCapability(Capabilities.ITEM_HANDLER, facing.getOpposite()).orElse(null);
|
||||
var handler = this.level.getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, facing.getOpposite());
|
||||
if (handler == null)
|
||||
continue;
|
||||
|
||||
|
@ -56,4 +57,5 @@ public class BlockEntityPowderPlacer extends BlockEntityImpl {
|
|||
}
|
||||
super.onRedstonePowerChange(newPower);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,18 +10,12 @@ import net.minecraft.core.Direction;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.energy.EnergyStorage;
|
||||
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockEntityRFConverter extends BlockEntityImpl implements ITickableBlockEntity {
|
||||
|
||||
public final RFStorage storage = new RFStorage();
|
||||
private final LazyOptional<IEnergyStorage> storageOptional = LazyOptional.of(() -> this.storage);
|
||||
private int lastEnergy;
|
||||
|
||||
public BlockEntityRFConverter(BlockPos pos, BlockState state) {
|
||||
|
@ -52,7 +46,7 @@ public class BlockEntityRFConverter extends BlockEntityImpl implements ITickable
|
|||
var tile = this.level.getBlockEntity(this.worldPosition.relative(facing));
|
||||
if (tile == null)
|
||||
continue;
|
||||
var storage = tile.getCapability(Capabilities.ENERGY, facing.getOpposite()).orElse(null);
|
||||
var storage = this.level.getCapability(Capabilities.EnergyStorage.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, facing.getOpposite());
|
||||
if (storage == null)
|
||||
continue;
|
||||
var canStore = storage.receiveEnergy(Integer.MAX_VALUE, true);
|
||||
|
@ -88,19 +82,9 @@ public class BlockEntityRFConverter extends BlockEntityImpl implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||
if (capability == Capabilities.ENERGY)
|
||||
return this.storageOptional.cast();
|
||||
else
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemoved() {
|
||||
super.setRemoved();
|
||||
this.storageOptional.invalidate();
|
||||
}
|
||||
|
||||
public static class RFStorage extends EnergyStorage {
|
||||
|
@ -112,5 +96,7 @@ public class BlockEntityRFConverter extends BlockEntityImpl implements ITickable
|
|||
public void setEnergy(int energy) {
|
||||
this.energy = energy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,18 +14,15 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.neoforged.neoforge.common.FarmlandWaterManager;
|
||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.common.ticket.AABBTicket;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.fluids.FluidStack;
|
||||
import net.neoforged.neoforge.fluids.IFluidTank;
|
||||
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
|
||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
||||
|
||||
public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlockEntity {
|
||||
|
||||
private final LazyOptional<IFluidHandler> tank = LazyOptional.of(InfiniteTank::new);
|
||||
public final IFluidHandler tank = new InfiniteTank();
|
||||
private AABBTicket waterTicket;
|
||||
|
||||
public BlockEntitySpring(BlockPos pos, BlockState state) {
|
||||
|
@ -49,7 +46,6 @@ public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlock
|
|||
this.waterTicket.invalidate();
|
||||
this.waterTicket = null;
|
||||
}
|
||||
this.tank.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,13 +111,6 @@ public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlock
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> capability, Direction facing) {
|
||||
if (capability == Capabilities.FLUID_HANDLER)
|
||||
return this.tank.cast();
|
||||
return LazyOptional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsLowerLimiter() {
|
||||
return true;
|
||||
|
@ -204,5 +193,7 @@ public class BlockEntitySpring extends BlockEntityImpl implements ITickableBlock
|
|||
public boolean isFluidValid(int tank, FluidStack stack) {
|
||||
return this.isFluidValid(stack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,10 +14,9 @@ import net.neoforged.neoforge.common.util.LazyOptional;
|
|||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class AuraChunkProvider implements ICapabilityProvider, INBTSerializable<CompoundTag> {
|
||||
public class AuraChunkProvider implements INBTSerializable<CompoundTag> {
|
||||
|
||||
private final LevelChunk chunk;
|
||||
private final LazyOptional<IAuraChunk> lazyChunk = LazyOptional.of(this::getAuraChunk);
|
||||
private IAuraChunk auraChunk;
|
||||
|
||||
public AuraChunkProvider(LevelChunk chunk) {
|
||||
|
|
|
@ -10,6 +10,8 @@ import de.ellpeck.naturesaura.api.misc.WeightedOre;
|
|||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.TagKey;
|
||||
|
@ -29,7 +31,6 @@ import net.minecraft.world.phys.AABB;
|
|||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.common.util.FakePlayerFactory;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -114,11 +115,14 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
|||
var ore = WeightedRandom.getRandomItem(level.random, ores, totalWeight).orElse(null);
|
||||
if (ore == null)
|
||||
continue;
|
||||
var tag = TagKey.create(ForgeRegistries.Keys.BLOCKS, ore.tag);
|
||||
var tag = TagKey.create(Registries.BLOCK, ore.tag);
|
||||
if (tag == null)
|
||||
continue;
|
||||
for (var toPlace : ForgeRegistries.BLOCKS.tags().getTag(tag)) {
|
||||
if (toPlace == null || toPlace == Blocks.AIR)
|
||||
for (var toPlaceHolder : BuiltInRegistries.BLOCK.getTag(tag).orElseThrow()) {
|
||||
if (toPlaceHolder == null)
|
||||
continue;
|
||||
var toPlace = toPlaceHolder.value();
|
||||
if (toPlace == Blocks.AIR)
|
||||
continue;
|
||||
|
||||
var player = FakePlayerFactory.getMinecraft((ServerLevel) level);
|
||||
|
@ -152,4 +156,5 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
|||
public ResourceLocation getName() {
|
||||
return OreSpawnEffect.NAME;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,46 +14,48 @@ import net.minecraft.world.level.levelgen.GenerationStep;
|
|||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.neoforged.neoforge.common.Tags;
|
||||
import net.neoforged.neoforge.common.world.BiomeModifier;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
import net.neoforged.neoforge.common.world.BiomeModifiers.AddFeaturesBiomeModifier;
|
||||
|
||||
public class BiomeModifiers {
|
||||
public static ResourceKey<BiomeModifier> AURA_BLOOM = createKey("aura_bloom");
|
||||
public static ResourceKey<BiomeModifier> AURA_CACTUS = createKey("aura_cactus");
|
||||
public static ResourceKey<BiomeModifier> WARPED_AURA_MUSHROOM = createKey("warped_aura_mushroom");
|
||||
public static ResourceKey<BiomeModifier> CRIMSON_AURA_MUSHROOM = createKey("crimson_aura_mushroom");
|
||||
public static ResourceKey<BiomeModifier> AURA_MUSHROOM = createKey("aura_mushroom");
|
||||
|
||||
public static final ResourceKey<BiomeModifier> AURA_BLOOM = BiomeModifiers.createKey("aura_bloom");
|
||||
public static final ResourceKey<BiomeModifier> AURA_CACTUS = BiomeModifiers.createKey("aura_cactus");
|
||||
public static final ResourceKey<BiomeModifier> WARPED_AURA_MUSHROOM = BiomeModifiers.createKey("warped_aura_mushroom");
|
||||
public static final ResourceKey<BiomeModifier> CRIMSON_AURA_MUSHROOM = BiomeModifiers.createKey("crimson_aura_mushroom");
|
||||
public static final ResourceKey<BiomeModifier> AURA_MUSHROOM = BiomeModifiers.createKey("aura_mushroom");
|
||||
|
||||
private static ResourceKey<BiomeModifier> createKey(String id) {
|
||||
return ResourceKey.create(ForgeRegistries.Keys.BIOME_MODIFIERS, new ResourceLocation(NaturesAura.MOD_ID, id));
|
||||
}
|
||||
|
||||
public static void bootstrap(BootstapContext<BiomeModifier> context) {
|
||||
HolderGetter<Biome> biomeGetter = context.lookup(Registries.BIOME);
|
||||
HolderGetter<PlacedFeature> placedGetter = context.lookup(Registries.PLACED_FEATURE);
|
||||
var biomeGetter = context.lookup(Registries.BIOME);
|
||||
var placedGetter = context.lookup(Registries.PLACED_FEATURE);
|
||||
|
||||
context.register(AURA_BLOOM, new net.neoforged.neoforge.common.world.BiomeModifiers.AddFeaturesBiomeModifier(
|
||||
context.register(BiomeModifiers.AURA_BLOOM, new AddFeaturesBiomeModifier(
|
||||
biomeGetter.getOrThrow(BiomeTags.IS_OVERWORLD),
|
||||
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.AURA_BLOOM)),
|
||||
GenerationStep.Decoration.VEGETAL_DECORATION));
|
||||
|
||||
context.register(AURA_CACTUS, new net.neoforged.neoforge.common.world.BiomeModifiers.AddFeaturesBiomeModifier(
|
||||
context.register(BiomeModifiers.AURA_CACTUS, new AddFeaturesBiomeModifier(
|
||||
biomeGetter.getOrThrow(Tags.Biomes.IS_SANDY),
|
||||
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.AURA_CACTUS)),
|
||||
GenerationStep.Decoration.VEGETAL_DECORATION));
|
||||
|
||||
context.register(AURA_MUSHROOM, new net.neoforged.neoforge.common.world.BiomeModifiers.AddFeaturesBiomeModifier(
|
||||
context.register(BiomeModifiers.AURA_MUSHROOM, new AddFeaturesBiomeModifier(
|
||||
biomeGetter.getOrThrow(Tags.Biomes.IS_MUSHROOM),
|
||||
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.AURA_MUSHROOM)),
|
||||
GenerationStep.Decoration.VEGETAL_DECORATION));
|
||||
|
||||
context.register(CRIMSON_AURA_MUSHROOM, new net.neoforged.neoforge.common.world.BiomeModifiers.AddFeaturesBiomeModifier(
|
||||
context.register(BiomeModifiers.CRIMSON_AURA_MUSHROOM, new AddFeaturesBiomeModifier(
|
||||
biomeGetter.getOrThrow(BiomeTags.IS_NETHER),
|
||||
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.CRIMSON_AURA_MUSHROOM)),
|
||||
GenerationStep.Decoration.VEGETAL_DECORATION));
|
||||
|
||||
context.register(WARPED_AURA_MUSHROOM, new net.neoforged.neoforge.common.world.BiomeModifiers.AddFeaturesBiomeModifier(
|
||||
context.register(BiomeModifiers.WARPED_AURA_MUSHROOM, new AddFeaturesBiomeModifier(
|
||||
biomeGetter.getOrThrow(BiomeTags.IS_NETHER),
|
||||
HolderSet.direct(placedGetter.getOrThrow(ModFeatures.Placed.WARPED_AURA_MUSHROOM)),
|
||||
GenerationStep.Decoration.VEGETAL_DECORATION));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import de.ellpeck.naturesaura.gui.ContainerEnderCrate;
|
|||
import de.ellpeck.naturesaura.gui.ModContainers;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
|
@ -23,7 +22,6 @@ import net.minecraft.world.level.Level;
|
|||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.neoforge.items.IItemHandler;
|
||||
import net.neoforged.neoforge.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
@ -42,7 +40,7 @@ public class ItemEnderAccess extends ItemImpl {
|
|||
var name = BlockEnderCrate.getEnderName(stack);
|
||||
if (!Strings.isNullOrEmpty(name)) {
|
||||
if (!levelIn.isClientSide && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 10000, false)) {
|
||||
NetworkHooks.openScreen((ServerPlayer) playerIn, new MenuProvider() {
|
||||
playerIn.openMenu(new MenuProvider() {
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.translatable("info." + NaturesAura.MOD_ID + ".ender_access", ChatFormatting.ITALIC + name + ChatFormatting.RESET);
|
||||
|
@ -66,4 +64,5 @@ public class ItemEnderAccess extends ItemImpl {
|
|||
public void appendHoverText(ItemStack stack, @Nullable Level levelIn, List<Component> tooltip, TooltipFlag flagIn) {
|
||||
BlockEnderCrate.addEnderNameInfo(stack, tooltip);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.ellpeck.naturesaura.misc;
|
||||
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
@ -24,7 +24,7 @@ public final class ColoredBlockHelper {
|
|||
private static List<Block> collectBlocks(String name) {
|
||||
return Arrays.stream(DyeColor.values()).sorted(Comparator.comparingInt(DyeColor::getId)).map(c -> {
|
||||
var loc = new ResourceLocation(c.getName() + '_' + name);
|
||||
var block = ForgeRegistries.BLOCKS.getValue(loc);
|
||||
var block = BuiltInRegistries.BLOCK.get(loc);
|
||||
if (block == null || block == Blocks.AIR)
|
||||
throw new IllegalStateException("Couldn't find block with name " + loc);
|
||||
return block;
|
||||
|
@ -38,4 +38,5 @@ public final class ColoredBlockHelper {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package de.ellpeck.naturesaura.misc;
|
|||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.misc.ILevelData;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntitySpawnLamp;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ItemStackHandlerNA;
|
||||
|
@ -11,40 +10,47 @@ import de.ellpeck.naturesaura.chunk.AuraChunk;
|
|||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.LongTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.saveddata.SavedData;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
public class LevelData implements ILevelData {
|
||||
public class LevelData extends SavedData implements ILevelData {
|
||||
|
||||
public static final SavedData.Factory<LevelData> FACTORY = new SavedData.Factory<>(LevelData::new, LevelData::new);
|
||||
public static LevelData client;
|
||||
|
||||
public final ListMultimap<ResourceLocation, Tuple<Vec3, Integer>> effectPowders = ArrayListMultimap.create();
|
||||
public final Long2ObjectOpenHashMap<AuraChunk> auraChunksWithSpots = new Long2ObjectOpenHashMap<>();
|
||||
public final List<BlockPos> recentlyConvertedMossStones = new ArrayList<>();
|
||||
public final Set<BlockEntitySpawnLamp> spawnLamps = new HashSet<>();
|
||||
private final Map<String, ItemStackHandlerNA> enderStorages = new HashMap<>();
|
||||
private final LazyOptional<LevelData> lazyThis = LazyOptional.of(() -> this);
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
||||
return capability == NaturesAuraAPI.CAP_LEVEL_DATA ? this.lazyThis.cast() : LazyOptional.empty();
|
||||
public Level level;
|
||||
|
||||
public LevelData() {
|
||||
|
||||
}
|
||||
|
||||
public LevelData(CompoundTag compound) {
|
||||
for (var base : compound.getList("storages", 10)) {
|
||||
var storageComp = (CompoundTag) base;
|
||||
var storage = this.getEnderStorage(storageComp.getString("name"));
|
||||
storage.deserializeNBT(storageComp);
|
||||
}
|
||||
for (var base : compound.getList("converted_moss", Tag.TAG_LONG))
|
||||
this.recentlyConvertedMossStones.add(BlockPos.of(((LongTag) base).getAsLong()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag serializeNBT() {
|
||||
var compound = new CompoundTag();
|
||||
|
||||
public CompoundTag save(CompoundTag compound) {
|
||||
var storages = new ListTag();
|
||||
for (var entry : this.enderStorages.entrySet()) {
|
||||
var handler = entry.getValue();
|
||||
|
@ -64,20 +70,6 @@ public class LevelData implements ILevelData {
|
|||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundTag compound) {
|
||||
this.enderStorages.clear();
|
||||
for (var base : compound.getList("storages", 10)) {
|
||||
var storageComp = (CompoundTag) base;
|
||||
var storage = this.getEnderStorage(storageComp.getString("name"));
|
||||
storage.deserializeNBT(storageComp);
|
||||
}
|
||||
|
||||
this.recentlyConvertedMossStones.clear();
|
||||
for (var base : compound.getList("converted_moss", Tag.TAG_LONG))
|
||||
this.recentlyConvertedMossStones.add(BlockPos.of(((LongTag) base).getAsLong()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStackHandlerNA getEnderStorage(String name) {
|
||||
return this.enderStorages.computeIfAbsent(name, n -> new ItemStackHandlerNA(27));
|
||||
|
@ -99,4 +91,5 @@ public class LevelData implements ILevelData {
|
|||
if (this.recentlyConvertedMossStones.size() > 512)
|
||||
this.recentlyConvertedMossStones.remove(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PacketAuraChunk implements CustomPacketPayload {
|
||||
|
||||
|
@ -62,7 +61,7 @@ public class PacketAuraChunk implements CustomPacketPayload {
|
|||
var chunk = level.getChunk(this.chunkX, this.chunkZ);
|
||||
if (chunk.isEmpty())
|
||||
return false;
|
||||
var auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.CAP_AURA_CHUNK).orElse(null);
|
||||
var auraChunk = (AuraChunk) chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT);
|
||||
if (auraChunk == null)
|
||||
return false;
|
||||
auraChunk.setSpots(this.drainSpots);
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.recipes;
|
|||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.misc.WeatherType;
|
||||
import de.ellpeck.naturesaura.api.misc.WeightedOre;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -10,7 +11,6 @@ import net.minecraft.world.item.Items;
|
|||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -115,11 +115,13 @@ public final class ModRecipes {
|
|||
list.add(new WeightedOre(res, weight));
|
||||
}
|
||||
|
||||
private static class RecipeType<T extends Recipe<?>> implements net.minecraft.world.item.crafting.RecipeType<T> {
|
||||
public static class RecipeType<T extends Recipe<?>> implements net.minecraft.world.item.crafting.RecipeType<T> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ForgeRegistries.RECIPE_TYPES.getKey(this).toString();
|
||||
return BuiltInRegistries.RECIPE_TYPE.getKey(this).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.blocks.*;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
|
||||
import de.ellpeck.naturesaura.chunk.AuraChunkProvider;
|
||||
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
|
||||
import de.ellpeck.naturesaura.enchant.AuraMendingEnchantment;
|
||||
import de.ellpeck.naturesaura.enchant.ModEnchantments;
|
||||
|
@ -24,6 +25,7 @@ import de.ellpeck.naturesaura.potion.PotionBreathless;
|
|||
import de.ellpeck.naturesaura.recipes.EnabledCondition;
|
||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
@ -36,14 +38,14 @@ import net.minecraft.world.level.block.Blocks;
|
|||
import net.minecraft.world.level.block.FlowerPotBlock;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.levelgen.structure.BuiltinStructures;
|
||||
import net.neoforged.neoforge.common.crafting.CraftingHelper;
|
||||
import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
|
||||
import net.neoforged.neoforge.common.crafting.CraftingHelper;
|
||||
import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;
|
||||
import net.neoforged.neoforge.items.IItemHandler;
|
||||
import net.neoforged.neoforge.registries.RegisterEvent;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
import vazkii.patchouli.api.PatchouliAPI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -56,14 +58,14 @@ public final class ModRegistry {
|
|||
|
||||
@SubscribeEvent
|
||||
public static void register(RegisterEvent event) {
|
||||
event.register(ForgeRegistries.Keys.BLOCKS, h -> {
|
||||
event.register(Registries.BLOCK, h -> {
|
||||
Block temp;
|
||||
ModRegistry.registerAll(h,
|
||||
new BlockAncientLog("ancient_log"),
|
||||
new BlockAncientLog("ancient_bark"),
|
||||
temp = new BlockImpl("ancient_planks", Block.Properties.of().sound(SoundType.WOOD).strength(2F)),
|
||||
new BlockStairsNA("ancient_stairs", "ancient_planks", temp::defaultBlockState, Block.Properties.copy(temp)),
|
||||
new Slab("ancient_slab", "ancient_planks", Block.Properties.copy(temp)),
|
||||
new BlockStairsNA("ancient_stairs", "ancient_planks", temp::defaultBlockState, Block.Properties.ofFullCopy(temp)),
|
||||
new Slab("ancient_slab", "ancient_planks", Block.Properties.ofFullCopy(temp)),
|
||||
new BlockAncientLeaves(),
|
||||
new BlockAncientSapling(),
|
||||
new BlockNatureAltar(),
|
||||
|
@ -72,11 +74,11 @@ public final class ModRegistry {
|
|||
new BlockGoldPowder(),
|
||||
new BlockWoodStand(),
|
||||
temp = new BlockImpl("infused_stone", Block.Properties.of().sound(SoundType.STONE).strength(1.75F)),
|
||||
new BlockStairsNA("infused_stairs", "infused_stone", temp::defaultBlockState, Block.Properties.copy(temp)),
|
||||
new Slab("infused_slab", "infused_stone", Block.Properties.copy(temp)),
|
||||
new BlockStairsNA("infused_stairs", "infused_stone", temp::defaultBlockState, Block.Properties.ofFullCopy(temp)),
|
||||
new Slab("infused_slab", "infused_stone", Block.Properties.ofFullCopy(temp)),
|
||||
temp = new BlockImpl("infused_brick", Block.Properties.of().sound(SoundType.STONE).strength(1.5F)),
|
||||
new BlockStairsNA("infused_brick_stairs", "infused_brick", temp::defaultBlockState, Block.Properties.copy(temp)),
|
||||
new Slab("infused_brick_slab", "infused_brick", Block.Properties.copy(temp)),
|
||||
new BlockStairsNA("infused_brick_stairs", "infused_brick", temp::defaultBlockState, Block.Properties.ofFullCopy(temp)),
|
||||
new Slab("infused_brick_slab", "infused_brick", Block.Properties.ofFullCopy(temp)),
|
||||
new BlockFurnaceHeater(),
|
||||
new BlockPotionGenerator(),
|
||||
new BlockAuraDetector(),
|
||||
|
@ -96,8 +98,8 @@ public final class ModRegistry {
|
|||
new BlockGratedChute(),
|
||||
new BlockAnimalSpawner(),
|
||||
new BlockAutoCrafter(),
|
||||
new BlockImpl("gold_brick", Block.Properties.copy(Blocks.STONE_BRICKS)),
|
||||
new BlockImpl("gold_nether_brick", Block.Properties.copy(Blocks.NETHER_BRICKS)),
|
||||
new BlockImpl("gold_brick", Block.Properties.ofFullCopy(Blocks.STONE_BRICKS)),
|
||||
new BlockImpl("gold_nether_brick", Block.Properties.ofFullCopy(Blocks.NETHER_BRICKS)),
|
||||
new BlockMossGenerator(),
|
||||
new BlockTimeChanger(),
|
||||
new BlockGeneratorLimitRemover(),
|
||||
|
@ -109,7 +111,7 @@ public final class ModRegistry {
|
|||
new BlockDimensionRail("nether", Level.NETHER, Level.OVERWORLD),
|
||||
new BlockDimensionRail("end", Level.END, Level.OVERWORLD),
|
||||
new BlockBlastFurnaceBooster(),
|
||||
new BlockImpl("nether_wart_mushroom", Block.Properties.copy(Blocks.RED_MUSHROOM_BLOCK)),
|
||||
new BlockImpl("nether_wart_mushroom", Block.Properties.ofFullCopy(Blocks.RED_MUSHROOM_BLOCK)),
|
||||
new BlockAnimalContainer(),
|
||||
new BlockSnowCreator(),
|
||||
new BlockItemDistributor(),
|
||||
|
@ -137,10 +139,10 @@ public final class ModRegistry {
|
|||
new BlockImpl("sky_ingot_block", Block.Properties.of().sound(SoundType.METAL).strength(4F)),
|
||||
new BlockImpl("depth_ingot_block", Block.Properties.of().sound(SoundType.METAL).strength(6F))
|
||||
);
|
||||
Helper.populateObjectHolders(ModBlocks.class, event.getForgeRegistry());
|
||||
Helper.populateObjectHolders(ModBlocks.class, BuiltInRegistries.BLOCK);
|
||||
});
|
||||
|
||||
event.register(ForgeRegistries.Keys.ITEMS, h -> {
|
||||
event.register(Registries.ITEM, h -> {
|
||||
for (var block : ModRegistry.ALL_ITEMS) {
|
||||
if (block instanceof Block && !(block instanceof INoItemBlock)) {
|
||||
var item = new BlockItem((Block) block, new Item.Properties());
|
||||
|
@ -222,10 +224,10 @@ public final class ModRegistry {
|
|||
new ItemArmor("depth_pants", ModArmorMaterial.DEPTH, ArmorItem.Type.LEGGINGS),
|
||||
new ItemArmor("depth_shoes", ModArmorMaterial.DEPTH, ArmorItem.Type.BOOTS)
|
||||
);
|
||||
Helper.populateObjectHolders(ModItems.class, event.getForgeRegistry());
|
||||
Helper.populateObjectHolders(ModItems.class, BuiltInRegistries.ITEM);
|
||||
});
|
||||
|
||||
event.register(ForgeRegistries.Keys.BLOCK_ENTITY_TYPES, h -> {
|
||||
event.register(Registries.BLOCK_ENTITY_TYPE, h -> {
|
||||
// add tile entities that support multiple blocks
|
||||
ModRegistry.ALL_ITEMS.add(new ModTileType<>(BlockEntityAuraBloom::new, "aura_bloom", ModRegistry.ALL_ITEMS.stream().filter(i -> i instanceof BlockAuraBloom).toArray(IModItem[]::new)));
|
||||
|
||||
|
@ -233,15 +235,15 @@ public final class ModRegistry {
|
|||
if (item instanceof ModTileType<?> type)
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, type.getBaseName()), type.type);
|
||||
}
|
||||
Helper.populateObjectHolders(ModBlockEntities.class, event.getForgeRegistry());
|
||||
Helper.populateObjectHolders(ModBlockEntities.class, BuiltInRegistries.BLOCK_ENTITY_TYPE);
|
||||
});
|
||||
|
||||
event.register(ForgeRegistries.Keys.MOB_EFFECTS, h -> {
|
||||
event.register(Registries.MOB_EFFECT, h -> {
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "breathless"), new PotionBreathless());
|
||||
Helper.populateObjectHolders(ModPotions.class, event.getForgeRegistry());
|
||||
Helper.populateObjectHolders(ModPotions.class, BuiltInRegistries.MOB_EFFECT);
|
||||
});
|
||||
|
||||
event.register(ForgeRegistries.Keys.MENU_TYPES, h -> {
|
||||
event.register(Registries.MENU, h -> {
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "ender_crate"), IMenuTypeExtension.create((windowId, inv, data) -> {
|
||||
var tile = inv.player.level().getBlockEntity(data.readBlockPos());
|
||||
if (tile instanceof BlockEntityEnderCrate crate)
|
||||
|
@ -252,15 +254,15 @@ public final class ModRegistry {
|
|||
IItemHandler handler = ILevelData.getOverworldData(inv.player.level()).getEnderStorage(data.readUtf());
|
||||
return new ContainerEnderCrate(ModContainers.ENDER_ACCESS, windowId, inv.player, handler);
|
||||
}));
|
||||
Helper.populateObjectHolders(ModContainers.class, event.getForgeRegistry());
|
||||
Helper.populateObjectHolders(ModContainers.class, BuiltInRegistries.MENU);
|
||||
});
|
||||
|
||||
event.register(ForgeRegistries.Keys.ENCHANTMENTS, h -> {
|
||||
event.register(Registries.ENCHANTMENT, h -> {
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_mending"), new AuraMendingEnchantment());
|
||||
Helper.populateObjectHolders(ModEnchantments.class, event.getForgeRegistry());
|
||||
Helper.populateObjectHolders(ModEnchantments.class, BuiltInRegistries.ENCHANTMENT);
|
||||
});
|
||||
|
||||
event.register(ForgeRegistries.Keys.ENTITY_TYPES, h -> {
|
||||
event.register(Registries.ENTITY_TYPE, h -> {
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "mover_cart"), EntityType.Builder
|
||||
.of(EntityMoverMinecart::new, MobCategory.MISC)
|
||||
.sized(1, 1).setShouldReceiveVelocityUpdates(true)
|
||||
|
@ -277,11 +279,10 @@ public final class ModRegistry {
|
|||
.of(EntityStructureFinder::new, MobCategory.MISC)
|
||||
.sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true)
|
||||
.setTrackingRange(64).setUpdateInterval(2).fireImmune().build(NaturesAura.MOD_ID + ":structure_finder"));
|
||||
Helper.populateObjectHolders(ModEntities.class, event.getForgeRegistry());
|
||||
Helper.populateObjectHolders(ModEntities.class, BuiltInRegistries.ENTITY_TYPE);
|
||||
});
|
||||
|
||||
|
||||
event.register(ForgeRegistries.Keys.FEATURES, h -> {
|
||||
event.register(Registries.FEATURE, h -> {
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_bloom"), new LevelGenAuraBloom(ModBlocks.AURA_BLOOM, 60, false));
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_cactus"), new LevelGenAuraBloom(ModBlocks.AURA_CACTUS, 60, false));
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "warped_aura_mushroom"), new LevelGenAuraBloom(ModBlocks.WARPED_AURA_MUSHROOM, 10, true));
|
||||
|
@ -289,18 +290,17 @@ public final class ModRegistry {
|
|||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_mushroom"), new LevelGenAuraBloom(ModBlocks.AURA_MUSHROOM, 20, false));
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "ancient_tree"), new LevelGenAncientTree());
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "nether_wart_mushroom"), new LevelGenNetherWartMushroom());
|
||||
Helper.populateObjectHolders(ModFeatures.class, event.getForgeRegistry());
|
||||
Helper.populateObjectHolders(ModFeatures.class, BuiltInRegistries.FEATURE);
|
||||
});
|
||||
|
||||
|
||||
event.register(ForgeRegistries.Keys.RECIPE_TYPES, h -> {
|
||||
event.register(Registries.RECIPE_TYPE, h -> {
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "altar"), ModRecipes.ALTAR_TYPE);
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "animal_spawner"), ModRecipes.ANIMAL_SPAWNER_TYPE);
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "offering"), ModRecipes.OFFERING_TYPE);
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"), ModRecipes.TREE_RITUAL_TYPE);
|
||||
});
|
||||
|
||||
event.register(ForgeRegistries.Keys.RECIPE_SERIALIZERS, h -> {
|
||||
event.register(Registries.RECIPE_SERIALIZER, h -> {
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "altar"), ModRecipes.ALTAR_SERIALIZER);
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "animal_spawner"), ModRecipes.ANIMAL_SPAWNER_SERIALIZER);
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "offering"), ModRecipes.OFFERING_SERIALIZER);
|
||||
|
@ -308,7 +308,7 @@ public final class ModRegistry {
|
|||
CraftingHelper.register(new EnabledCondition.Serializer());
|
||||
});
|
||||
|
||||
event.register(BuiltInRegistries.CREATIVE_MODE_TAB.key(), h -> {
|
||||
event.register(Registries.CREATIVE_MODE_TAB, h -> {
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "tab"), CreativeModeTab.builder()
|
||||
.title(Component.translatable("item_group." + NaturesAura.MOD_ID + ".tab"))
|
||||
.icon(() -> new ItemStack(ModItems.GOLD_LEAF))
|
||||
|
@ -328,10 +328,17 @@ public final class ModRegistry {
|
|||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerCapabilities(RegisterCapabilitiesEvent event) {
|
||||
event.registerBlockEntity(Capabilities.FluidHandler.BLOCK, ModBlockEntities.SPRING, (e, c) -> e.tank);
|
||||
event.registerBlockEntity(Capabilities.EnergyStorage.BLOCK, ModBlockEntities.RF_CONVERTER, (e, c) -> e.storage);
|
||||
event.registerBlockEntity(Capabilities.ItemHandler.BLOCK, ModBlockEntities.BLAST_FURNACE_BOOSTER, (e, c) -> e.getItemHandler());
|
||||
}
|
||||
|
||||
public static Block createFlowerPot(Block block) {
|
||||
var props = Block.Properties.of().strength(0F);
|
||||
Block potted = new BlockFlowerPot(() -> (FlowerPotBlock) Blocks.FLOWER_POT, () -> block, props);
|
||||
((FlowerPotBlock) Blocks.FLOWER_POT).addPlant(ForgeRegistries.BLOCKS.getKey(block), () -> potted);
|
||||
((FlowerPotBlock) Blocks.FLOWER_POT).addPlant(BuiltInRegistries.BLOCK.getKey(block), () -> potted);
|
||||
return potted;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue