mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-21 19:33:29 +01:00
a lot more 1.20.4 port work
This commit is contained in:
parent
5a4a191973
commit
f2547e6555
64 changed files with 348 additions and 398 deletions
|
@ -5,6 +5,7 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
|||
import de.ellpeck.naturesaura.api.misc.ILevelData;
|
||||
import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
|
||||
import de.ellpeck.naturesaura.blocks.multi.Multiblock;
|
||||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.misc.LevelData;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -38,9 +39,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.AURA_CONTAINER_CAPABILITY) != null, player, false);
|
||||
var stack = Helper.getEquippedItem(s -> s.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY) != null, player, false);
|
||||
if (!stack.isEmpty()) {
|
||||
var container = stack.getCapability(NaturesAuraAPI.AURA_CONTAINER_CAPABILITY);
|
||||
var container = stack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
||||
if (extract) {
|
||||
return container.drainAura(amount, simulate) > 0;
|
||||
} else {
|
||||
|
@ -199,4 +200,9 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAuraChunk createAuraChunk() {
|
||||
return new AuraChunk();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.api;
|
|||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.AuraChunkProvider;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
|
||||
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||
|
@ -14,6 +15,7 @@ import de.ellpeck.naturesaura.api.misc.WeightedOre;
|
|||
import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
|
||||
import de.ellpeck.naturesaura.api.multiblock.Matcher;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
@ -24,6 +26,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.attachment.AttachmentType;
|
||||
import net.neoforged.neoforge.capabilities.BlockCapability;
|
||||
import net.neoforged.neoforge.capabilities.ItemCapability;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
|
@ -82,9 +85,13 @@ public final class NaturesAuraAPI {
|
|||
*/
|
||||
public static final Map<ItemStack, WeatherType> WEATHER_CHANGER_CONVERSIONS = new HashMap<>();
|
||||
/**
|
||||
* The capability for any item or block that stores Aura in the form of an {@link IAuraContainer}
|
||||
* The capability for any item that stores Aura in the form of an {@link IAuraContainer}
|
||||
*/
|
||||
public static final ItemCapability<IAuraContainer, Void> AURA_CONTAINER_CAPABILITY = ItemCapability.createVoid(new ResourceLocation(NaturesAuraAPI.MOD_ID, "aura_container"), IAuraContainer.class);
|
||||
public static final ItemCapability<IAuraContainer, Void> AURA_CONTAINER_ITEM_CAPABILITY = ItemCapability.createVoid(new ResourceLocation(NaturesAuraAPI.MOD_ID, "aura_container_item"), IAuraContainer.class);
|
||||
/**
|
||||
* The capability for any block that stores Aura in the form of an {@link IAuraContainer}
|
||||
*/
|
||||
public static final BlockCapability<IAuraContainer, Direction> AURA_CONTAINER_BLOCK_CAPABILITY = BlockCapability.create(new ResourceLocation(NaturesAuraAPI.MOD_ID, "aura_container_block"), IAuraContainer.class, Direction.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
|
||||
*/
|
||||
|
@ -92,7 +99,7 @@ public final class NaturesAuraAPI {
|
|||
/**
|
||||
* 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 AttachmentType<IAuraChunk> AURA_CHUNK_ATTACHMENT = AttachmentType.serializable(() -> (IAuraChunk) null).build();
|
||||
public static final AttachmentType<AuraChunkProvider> AURA_CHUNK_ATTACHMENT = AttachmentType.serializable(AuraChunkProvider::new).build();
|
||||
private static final IInternalHooks INSTANCE;
|
||||
|
||||
static {
|
||||
|
@ -253,6 +260,8 @@ public final class NaturesAuraAPI {
|
|||
|
||||
ILevelData getLevelData(Level level);
|
||||
|
||||
IAuraChunk createAuraChunk();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package de.ellpeck.naturesaura.api.aura.chunk;
|
||||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.neoforged.neoforge.common.util.INBTSerializable;
|
||||
|
||||
public class AuraChunkProvider implements INBTSerializable<CompoundTag> {
|
||||
|
||||
private IAuraChunk auraChunk;
|
||||
|
||||
public IAuraChunk get(LevelChunk chunk) {
|
||||
if (this.auraChunk == null)
|
||||
this.auraChunk = NaturesAuraAPI.instance().createAuraChunk();
|
||||
this.auraChunk.ensureInitialized(chunk);
|
||||
return this.auraChunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag serializeNBT() {
|
||||
return this.get(null).serializeNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundTag nbt) {
|
||||
this.get(null).deserializeNBT(nbt);
|
||||
}
|
||||
|
||||
}
|
|
@ -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.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT);
|
||||
return chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT).get(chunk);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,4 +160,6 @@ public interface IAuraChunk extends INBTSerializable<CompoundTag> {
|
|||
|
||||
void markDirty();
|
||||
|
||||
void ensureInitialized(LevelChunk chunk);
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,8 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
|
|||
if (rand.nextFloat() >= 0.95F && !levelIn.getBlockState(pos.below()).isCollisionShapeFullBlock(levelIn, pos)) {
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityAncientLeaves) {
|
||||
if (((BlockEntityAncientLeaves) tile).getAuraContainer().getStoredAura() > 0) {
|
||||
var container = levelIn.getCapability(NaturesAuraAPI.AURA_CONTAINER_BLOCK_CAPABILITY, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||
if (container.getStoredAura() > 0) {
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
pos.getX() + rand.nextDouble(), pos.getY(), pos.getZ() + rand.nextDouble(),
|
||||
0F, 0F, 0F, 0xCC4780,
|
||||
|
@ -72,7 +73,8 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
|
|||
if (!levelIn.isClientSide) {
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityAncientLeaves) {
|
||||
if (((BlockEntityAncientLeaves) tile).getAuraContainer().getStoredAura() <= 0) {
|
||||
var container = levelIn.getCapability(NaturesAuraAPI.AURA_CONTAINER_BLOCK_CAPABILITY, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||
if (container.getStoredAura() <= 0) {
|
||||
levelIn.setBlockAndUpdate(pos, ModBlocks.DECAYED_LEAVES.defaultBlockState());
|
||||
}
|
||||
}
|
||||
|
@ -94,4 +96,5 @@ public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorP
|
|||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
return new BlockEntityAncientLeaves(pos, state);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
||||
import de.ellpeck.naturesaura.gen.ModFeatures;
|
||||
|
@ -61,7 +62,7 @@ public class BlockAncientSapling extends BushBlock implements BonemealableBlock,
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidBonemealTarget(LevelReader p_256559_, BlockPos p_50898_, BlockState p_50899_, boolean p_50900_) {
|
||||
public boolean isValidBonemealTarget(LevelReader pLevel, BlockPos pPos, BlockState pState) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -89,4 +90,10 @@ public class BlockAncientSapling extends BushBlock implements BonemealableBlock,
|
|||
public void generateCustomItemModel(ItemModelGenerator generator) {
|
||||
generator.withExistingParent(this.getBaseName(), "item/generated").texture("layer0", "block/" + this.getBaseName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BushBlock> codec() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali
|
|||
private static final VoxelShape SHAPE = Block.box(5, 0, 5, 11, 13, 11);
|
||||
|
||||
public BlockAnimalContainer() {
|
||||
super("animal_container", BlockEntityAnimalContainer.class, Properties.copy(Blocks.STONE));
|
||||
super("animal_container", BlockEntityAnimalContainer.class, Properties.ofFullCopy(Blocks.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,4 +57,5 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali
|
|||
public void generateCustomBlockState(BlockStateGenerator generator) {
|
||||
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAuraBloom;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ITickableBlockEntity;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
|
||||
|
@ -47,6 +48,11 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
|
|||
return this.mayPlaceOn(levelIn.getBlockState(down), levelIn, down);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BushBlock> codec() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean mayPlaceOn(BlockState state, BlockGetter levelIn, BlockPos pos) {
|
||||
return Arrays.stream(this.allowedGround).anyMatch(state::is);
|
||||
|
@ -92,4 +98,5 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS
|
|||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
|
||||
return ITickableBlockEntity.createTickerHelper(type, ModBlockEntities.AURA_BLOOM);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt
|
|||
private static final VoxelShape SHAPE = Block.box(1, 0, 1, 15, 15, 15);
|
||||
|
||||
public BlockAuraTimer() {
|
||||
super("aura_timer", BlockEntityAuraTimer.class, Properties.copy(Blocks.SMOOTH_STONE));
|
||||
super("aura_timer", BlockEntityAuraTimer.class, Properties.ofFullCopy(Blocks.SMOOTH_STONE));
|
||||
this.registerDefaultState(this.defaultBlockState().setValue(BlockStateProperties.POWERED, false));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ public class BlockBlastFurnaceBooster extends BlockContainerImpl implements ICus
|
|||
private static final VoxelShape SHAPE = Shapes.create(1 / 16F, 0, 1 / 16F, 15 / 16F, 1, 15 / 16F);
|
||||
|
||||
public BlockBlastFurnaceBooster() {
|
||||
super("blast_furnace_booster", BlockEntityBlastFurnaceBooster.class, Block.Properties.copy(Blocks.BLAST_FURNACE).lightLevel(s -> 0));
|
||||
super("blast_furnace_booster", BlockEntityBlastFurnaceBooster.class, Block.Properties.ofFullCopy(Blocks.BLAST_FURNACE).lightLevel(s -> 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.minecraft.world.level.block.Blocks;
|
|||
public class BlockChorusGenerator extends BlockContainerImpl implements ICustomBlockState {
|
||||
|
||||
public BlockChorusGenerator() {
|
||||
super("chorus_generator", BlockEntityChorusGenerator.class, Properties.copy(Blocks.END_STONE));
|
||||
super("chorus_generator", BlockEntityChorusGenerator.class, Properties.ofFullCopy(Blocks.END_STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ITickableBlockEntity;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
|
@ -106,6 +107,11 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem {
|
|||
return this.baseName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BaseEntityBlock> codec() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state) {
|
||||
return RenderShape.MODEL;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
||||
import de.ellpeck.naturesaura.data.ItemModelGenerator;
|
||||
|
@ -49,7 +50,7 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust
|
|||
|
||||
@SafeVarargs
|
||||
public BlockDimensionRail(String name, ResourceKey<Level> goalDim, ResourceKey<Level>... canUseDims) {
|
||||
super(false, Properties.copy(Blocks.RAIL));
|
||||
super(false, Properties.ofFullCopy(Blocks.RAIL));
|
||||
this.name = name;
|
||||
this.goalDim = goalDim;
|
||||
this.canUseDims = canUseDims;
|
||||
|
@ -136,6 +137,11 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BaseRailBlock> codec() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"deprecation", "RedundantSuppression"})
|
||||
public Property<RailShape> getShapeProperty() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEndFlower;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ITickableBlockEntity;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
|
||||
|
@ -70,6 +71,11 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MapCodec<? extends BushBlock> codec() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSurvive(BlockState state, LevelReader levelIn, BlockPos pos) {
|
||||
return levelIn.getBlockState(pos.below()).getBlock() == Blocks.END_STONE;
|
||||
|
|
|
@ -34,7 +34,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock,
|
|||
protected static final VoxelShape[] SHAPES = {Block.box(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.box(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.box(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.box(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.box(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.box(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.box(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.box(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.box(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.box(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.box(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.box(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.box(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D)};
|
||||
|
||||
public BlockGoldPowder() {
|
||||
super("gold_powder", Properties.copy(Blocks.REDSTONE_WIRE));
|
||||
super("gold_powder", Properties.ofFullCopy(Blocks.REDSTONE_WIRE));
|
||||
this.registerDefaultState(this.defaultBlockState().setValue(BlockGoldPowder.NORTH, RedstoneSide.NONE).setValue(BlockGoldPowder.EAST, RedstoneSide.NONE).setValue(BlockGoldPowder.SOUTH, RedstoneSide.NONE).setValue(BlockGoldPowder.WEST, RedstoneSide.NONE));
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import net.minecraft.world.phys.shapes.BooleanOp;
|
|||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -122,7 +123,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
|
|||
public int getAnalogOutputSignal(BlockState blockState, Level levelIn, BlockPos pos) {
|
||||
var tile = levelIn.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityGratedChute) {
|
||||
IItemHandler handler = ((BlockEntityGratedChute) tile).getItemHandler();
|
||||
var handler = levelIn.getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||
var stack = handler.getStackInSlot(0);
|
||||
if (stack.isEmpty())
|
||||
return 0;
|
||||
|
@ -146,4 +147,5 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock
|
|||
public void generateCustomItemModel(ItemModelGenerator generator) {
|
||||
generator.withExistingParent(this.getBaseName(), generator.modLoc("block/" + this.getBaseName() + "_down"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.world.phys.BlockHitResult;
|
|||
public class BlockItemDistributor extends BlockContainerImpl implements ICustomBlockState {
|
||||
|
||||
public BlockItemDistributor() {
|
||||
super("item_distributor", BlockEntityItemDistributor.class, Properties.copy(Blocks.STONE_BRICKS));
|
||||
super("item_distributor", BlockEntityItemDistributor.class, Properties.ofFullCopy(Blocks.STONE_BRICKS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, BonemealableBlock {
|
||||
|
||||
public BlockNetherGrass() {
|
||||
super("nether_grass", Properties.copy(Blocks.NETHERRACK).randomTicks());
|
||||
super("nether_grass", Properties.ofFullCopy(Blocks.NETHERRACK).randomTicks());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,7 +36,7 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, Bo
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidBonemealTarget(LevelReader levelIn, BlockPos pos, BlockState state, boolean isClient) {
|
||||
public boolean isValidBonemealTarget(LevelReader levelIn, BlockPos pos, BlockState state) {
|
||||
return levelIn.getBlockState(pos.above()).isAir();
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, Bo
|
|||
@Override
|
||||
public void performBonemeal(ServerLevel level, RandomSource rand, BlockPos pos, BlockState state) {
|
||||
var blockpos = pos.above();
|
||||
var blockstate = Blocks.GRASS.defaultBlockState();
|
||||
var blockstate = Blocks.GRASS_BLOCK.defaultBlockState();
|
||||
|
||||
for (var i = 0; i < 128; ++i) {
|
||||
var blockpos1 = blockpos;
|
||||
|
@ -81,4 +81,5 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, Bo
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.neoforged.bus.api.SubscribeEvent;
|
|||
public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||
|
||||
public BlockSlimeSplitGenerator() {
|
||||
super("slime_split_generator", BlockEntitySlimeSplitGenerator.class, Properties.copy(Blocks.SLIME_BLOCK).strength(2));
|
||||
super("slime_split_generator", BlockEntitySlimeSplitGenerator.class, Properties.ofFullCopy(Blocks.SLIME_BLOCK).strength(2));
|
||||
NeoForge.EVENT_BUS.register(new Events());
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.neoforged.api.distmarker.OnlyIn;
|
|||
public class BlockSnowCreator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
|
||||
|
||||
public BlockSnowCreator() {
|
||||
super("snow_creator", BlockEntitySnowCreator.class, Properties.copy(Blocks.STONE_BRICKS));
|
||||
super("snow_creator", BlockEntitySnowCreator.class, Properties.ofFullCopy(Blocks.STONE_BRICKS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,13 +21,14 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class BlockSpring extends BlockContainerImpl implements ICustomBlockState, IColorProvidingBlock, IColorProvidingItem, BucketPickup {
|
||||
|
||||
public BlockSpring() {
|
||||
super("spring", BlockEntitySpring.class, Properties.copy(Blocks.STONE_BRICKS));
|
||||
super("spring", BlockEntitySpring.class, Properties.ofFullCopy(Blocks.STONE_BRICKS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,8 +58,8 @@ public class BlockSpring extends BlockContainerImpl implements ICustomBlockState
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack pickupBlock(LevelAccessor levelIn, BlockPos pos, BlockState state) {
|
||||
if (levelIn.getBlockEntity(pos) instanceof BlockEntitySpring spring && spring.tryConsumeAura(2500))
|
||||
public ItemStack pickupBlock(@Nullable Player pPlayer, LevelAccessor pLevel, BlockPos pPos, BlockState pState) {
|
||||
if (pLevel.getBlockEntity(pPos) instanceof BlockEntitySpring spring && spring.tryConsumeAura(2500))
|
||||
return new ItemStack(Items.WATER_BUCKET);
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
@ -68,4 +69,5 @@ public class BlockSpring extends BlockContainerImpl implements ICustomBlockState
|
|||
public Optional<SoundEvent> getPickupSound() {
|
||||
return Fluids.WATER.getPickupSound();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.minecraft.world.level.block.Blocks;
|
|||
public class BlockWeatherChanger extends BlockContainerImpl implements ICustomBlockState {
|
||||
|
||||
public BlockWeatherChanger() {
|
||||
super("weather_changer", BlockEntityWeatherChanger.class, Properties.copy(Blocks.STONE_BRICKS));
|
||||
super("weather_changer", BlockEntityWeatherChanger.class, Properties.ofFullCopy(Blocks.STONE_BRICKS));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,8 +62,8 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
|
|||
var saplingStack = new ItemStack(level.getBlockState(pos).getBlock());
|
||||
if (!saplingStack.isEmpty()) {
|
||||
for (var recipe : ((Level) level).getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, (Level) level)) {
|
||||
if (recipe.saplingType.test(saplingStack)) {
|
||||
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));
|
||||
if (recipe.value().saplingType.test(saplingStack)) {
|
||||
List<Ingredient> required = new ArrayList<>(recipe.value().ingredients);
|
||||
var toPick = new MutableObject<BlockEntityWoodStand>();
|
||||
|
||||
var fine = Multiblocks.TREE_RITUAL.forEach(pos, 'W', (tilePos, matcher) -> {
|
||||
|
@ -89,7 +89,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider<
|
|||
});
|
||||
|
||||
if (fine && required.isEmpty()) {
|
||||
toPick.getValue().setRitual(pos, recipe);
|
||||
toPick.getValue().setRitual(pos, recipe.value());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||
import de.ellpeck.naturesaura.api.aura.container.NaturalAuraContainer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -9,7 +8,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
|
||||
public class BlockEntityAncientLeaves extends BlockEntityImpl {
|
||||
|
||||
private final NaturalAuraContainer container = new NaturalAuraContainer(NaturesAuraAPI.TYPE_OVERWORLD, 2000, 500) {
|
||||
public final NaturalAuraContainer container = new NaturalAuraContainer(NaturesAuraAPI.TYPE_OVERWORLD, 2000, 500) {
|
||||
@Override
|
||||
public int getAuraColor() {
|
||||
return 0xCE5489;
|
||||
|
@ -29,11 +28,6 @@ public class BlockEntityAncientLeaves extends BlockEntityImpl {
|
|||
super(ModBlockEntities.ANCIENT_LEAVES, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAuraContainer getAuraContainer() {
|
||||
return this.container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||
super.writeNBT(compound, type);
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.util.Mth;
|
|||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
||||
|
@ -25,7 +26,7 @@ import java.util.List;
|
|||
|
||||
public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickableBlockEntity {
|
||||
|
||||
private AnimalSpawnerRecipe currentRecipe;
|
||||
private RecipeHolder<AnimalSpawnerRecipe> currentRecipe;
|
||||
private double spawnX;
|
||||
private double spawnZ;
|
||||
private int time;
|
||||
|
@ -50,7 +51,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
}
|
||||
|
||||
if (this.currentRecipe != null) {
|
||||
var drain = Mth.ceil(this.currentRecipe.aura / (float) this.currentRecipe.time * 10F);
|
||||
var drain = Mth.ceil(this.currentRecipe.value().aura / (float) this.currentRecipe.value().time * 10F);
|
||||
if (!this.canUseRightNow(drain))
|
||||
return;
|
||||
|
||||
|
@ -58,8 +59,8 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
IAuraChunk.getAuraChunk(this.level, spot).drainAura(spot, drain);
|
||||
|
||||
this.time += 10;
|
||||
if (this.time >= this.currentRecipe.time) {
|
||||
var entity = this.currentRecipe.makeEntity(this.level, BlockPos.containing(this.spawnX, this.worldPosition.getY() + 1, this.spawnZ));
|
||||
if (this.time >= this.currentRecipe.value().time) {
|
||||
var entity = this.currentRecipe.value().makeEntity(this.level, BlockPos.containing(this.spawnX, this.worldPosition.getY() + 1, this.spawnZ));
|
||||
this.level.addFreshEntity(entity);
|
||||
|
||||
this.currentRecipe = null;
|
||||
|
@ -71,9 +72,9 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
new AABB(this.worldPosition).inflate(2));
|
||||
|
||||
for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE, null, this.level)) {
|
||||
if (recipe.ingredients.length != items.size())
|
||||
if (recipe.value().ingredients.size() != items.size())
|
||||
continue;
|
||||
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));
|
||||
List<Ingredient> required = new ArrayList<>(recipe.value().ingredients);
|
||||
for (var item : items) {
|
||||
if (!item.isAlive() || item.hasPickUpDelay())
|
||||
break;
|
||||
|
@ -123,7 +124,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
this.level.random.nextFloat() + 0.5F);
|
||||
|
||||
if (this.entityClient == null) {
|
||||
this.entityClient = this.currentRecipe.makeEntity(this.level, BlockPos.ZERO);
|
||||
this.entityClient = this.currentRecipe.value().makeEntity(this.level, BlockPos.ZERO);
|
||||
this.entityClient.setPos(this.spawnX, this.worldPosition.getY() + 1, this.spawnZ);
|
||||
}
|
||||
var bounds = this.entityClient.getBoundingBox();
|
||||
|
@ -141,7 +142,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
super.writeNBT(compound, type);
|
||||
if (type != SaveType.BLOCK) {
|
||||
if (this.currentRecipe != null) {
|
||||
compound.putString("recipe", this.currentRecipe.name.toString());
|
||||
compound.putString("recipe", this.currentRecipe.id().toString());
|
||||
compound.putDouble("spawn_x", this.spawnX);
|
||||
compound.putDouble("spawn_z", this.spawnZ);
|
||||
compound.putInt("time", this.time);
|
||||
|
@ -149,6 +150,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void readNBT(CompoundTag compound, SaveType type) {
|
||||
super.readNBT(compound, type);
|
||||
|
@ -156,7 +158,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
if (compound.contains("recipe")) {
|
||||
if (this.hasLevel()) {
|
||||
var name = new ResourceLocation(compound.getString("recipe"));
|
||||
this.currentRecipe = (AnimalSpawnerRecipe) this.level.getRecipeManager().byKey(name).orElse(null);
|
||||
this.currentRecipe = (RecipeHolder<AnimalSpawnerRecipe>) this.level.getRecipeManager().byKey(name).orElse(null);
|
||||
}
|
||||
this.spawnX = compound.getDouble("spawn_x");
|
||||
this.spawnZ = compound.getDouble("spawn_z");
|
||||
|
@ -172,4 +174,5 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab
|
|||
public boolean allowsLowerLimiter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import net.minecraft.nbt.CompoundTag;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -22,7 +21,7 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl
|
|||
.put(NaturesAuraAPI.TYPE_OVERWORLD, 20)
|
||||
.put(NaturesAuraAPI.TYPE_NETHER, 20 * 60)
|
||||
.put(NaturesAuraAPI.TYPE_END, 20 * 60 * 60).build();
|
||||
private final ItemStackHandlerNA itemHandler = new ItemStackHandlerNA(1, this, true) {
|
||||
public final ItemStackHandlerNA itemHandler = new ItemStackHandlerNA(1, this, true) {
|
||||
@Override
|
||||
protected boolean canInsert(ItemStack stack, int slot) {
|
||||
return stack.getItem() == ModItems.AURA_BOTTLE;
|
||||
|
@ -98,11 +97,6 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl
|
|||
return this.timer / (float) this.getTotalTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandlerModifiable getItemHandler() {
|
||||
return this.itemHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||
super.writeNBT(compound, type);
|
||||
|
|
|
@ -82,7 +82,7 @@ public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickable
|
|||
if (recipe == null)
|
||||
return;
|
||||
|
||||
var result = recipe.assemble(this.crafting, this.level.registryAccess());
|
||||
var result = recipe.value().assemble(this.crafting, this.level.registryAccess());
|
||||
if (result.isEmpty())
|
||||
return;
|
||||
var resultItem = new ItemEntity(this.level,
|
||||
|
@ -90,7 +90,7 @@ public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickable
|
|||
resultItem.setDeltaMovement(0, 0, 0);
|
||||
this.level.addFreshEntity(resultItem);
|
||||
|
||||
var remainingItems = recipe.getRemainingItems(this.crafting);
|
||||
var remainingItems = recipe.value().getRemainingItems(this.crafting);
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = items[i];
|
||||
if (item == null)
|
||||
|
|
|
@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer;
|
||||
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -16,7 +15,7 @@ import net.minecraft.world.phys.AABB;
|
|||
|
||||
public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBlockEntity {
|
||||
|
||||
private final BasicAuraContainer container = new BasicAuraContainer(null, 500000) {
|
||||
public final BasicAuraContainer container = new BasicAuraContainer(null, 500000) {
|
||||
{
|
||||
this.aura = this.maxAura;
|
||||
}
|
||||
|
@ -94,11 +93,6 @@ public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBl
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAuraContainer getAuraContainer() {
|
||||
return this.container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(CompoundTag compound, SaveType type) {
|
||||
super.writeNBT(compound, type);
|
||||
|
@ -116,4 +110,5 @@ public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBl
|
|||
this.isDrainMode = compound.getBoolean("drain_mode");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import javax.annotation.Nullable;
|
|||
public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvider {
|
||||
|
||||
public String name;
|
||||
private final IItemHandlerModifiable wrappedEnderStorage = new IItemHandlerModifiable() {
|
||||
public final IItemHandlerModifiable wrappedEnderStorage = new IItemHandlerModifiable() {
|
||||
@Override
|
||||
public void setStackInSlot(int slot, @Nonnull ItemStack stack) {
|
||||
this.getStorage().setStackInSlot(slot, stack);
|
||||
|
@ -82,13 +82,6 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid
|
|||
super(ModBlockEntities.ENDER_CRATE, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandlerModifiable getItemHandler() {
|
||||
if (this.canOpen())
|
||||
return this.wrappedEnderStorage;
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canOpen() {
|
||||
return this.name != null;
|
||||
}
|
||||
|
@ -149,11 +142,12 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid
|
|||
@Nullable
|
||||
@Override
|
||||
public AbstractContainerMenu createMenu(int window, Inventory inv, Player player) {
|
||||
return new ContainerEnderCrate(ModContainers.ENDER_CRATE, window, player, this.getItemHandler());
|
||||
return new ContainerEnderCrate(ModContainers.ENDER_CRATE, window, player, this.wrappedEnderStorage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsLowerLimiter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
|||
var state = this.level.getBlockState(pos);
|
||||
if (!state.isAir() && state.getDestroySpeed(this.level, pos) >= 0F) {
|
||||
var fake = FakePlayerFactory.getMinecraft((ServerLevel) this.level);
|
||||
if (!NeoForge.EVENT_BUS.post(new BlockEvent.BreakEvent(this.level, pos, state, fake))) {
|
||||
if (!NeoForge.EVENT_BUS.post(new BlockEvent.BreakEvent(this.level, pos, state, fake)).isCanceled()) {
|
||||
var drops = state.getDrops(new LootParams.Builder((ServerLevel) this.level)
|
||||
.withParameter(LootContextParams.THIS_ENTITY, fake)
|
||||
.withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos))
|
||||
|
@ -208,4 +208,5 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl
|
|||
public boolean allowsLowerLimiter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab
|
|||
var recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(furnace), furnace, this.level).orElse(null);
|
||||
if (recipe == null)
|
||||
return false;
|
||||
var output = recipe.getResultItem(this.level.registryAccess());
|
||||
var output = recipe.value().getResultItem(this.level.registryAccess());
|
||||
var currOutput = furnace.getItem(2);
|
||||
return currOutput.isEmpty() || Helper.areItemsEqual(currOutput, output, true) && currOutput.getCount() + output.getCount() <= output.getMaxStackSize();
|
||||
} else
|
||||
|
|
|
@ -2,9 +2,6 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
|
||||
public class BlockEntityGeneratorLimitRemover extends BlockEntityImpl {
|
||||
|
||||
|
@ -12,9 +9,4 @@ public class BlockEntityGeneratorLimitRemover extends BlockEntityImpl {
|
|||
super(ModBlockEntities.GENERATOR_LIMIT_REMOVER, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AABB getRenderBoundingBox() {
|
||||
return new AABB(this.worldPosition, this.worldPosition.offset(1, 2, 1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,11 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||
|
||||
public class BlockEntityGratedChute extends BlockEntityImpl implements ITickableBlockEntity {
|
||||
|
||||
public boolean isBlacklist;
|
||||
private final ItemStackHandlerNA items = new ItemStackHandlerNA(1, this, true) {
|
||||
public final ItemStackHandlerNA items = new ItemStackHandlerNA(1, this, true) {
|
||||
@Override
|
||||
protected boolean canExtract(ItemStack stack, int slot, int amount) {
|
||||
return BlockEntityGratedChute.this.redstonePower <= 0;
|
||||
|
@ -139,9 +138,5 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandlerModifiable getItemHandler() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
|
||||
public class BlockEntityLowerLimiter extends BlockEntityImpl {
|
||||
|
||||
|
@ -12,9 +9,4 @@ public class BlockEntityLowerLimiter extends BlockEntityImpl {
|
|||
super(ModBlockEntities.LOWER_LIMITER, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AABB getRenderBoundingBox() {
|
||||
return new AABB(this.worldPosition, this.worldPosition.offset(1, 2, 1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import de.ellpeck.naturesaura.packet.PacketParticles;
|
|||
import de.ellpeck.naturesaura.recipes.AltarRecipe;
|
||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
|
@ -19,6 +20,7 @@ import net.minecraft.sounds.SoundSource;
|
|||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
|
@ -27,7 +29,7 @@ import net.neoforged.neoforge.items.ItemStackHandler;
|
|||
|
||||
public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickableBlockEntity {
|
||||
|
||||
private final BasicAuraContainer container = new BasicAuraContainer(null, 500000) {
|
||||
public final BasicAuraContainer container = new BasicAuraContainer(null, 500000) {
|
||||
@Override
|
||||
public int getAuraColor() {
|
||||
return IAuraType.forLevel(BlockEntityNatureAltar.this.level).getColor();
|
||||
|
@ -42,12 +44,12 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
|
||||
@Override
|
||||
protected boolean canInsert(ItemStack stack, int slot) {
|
||||
return BlockEntityNatureAltar.this.getRecipeForInput(stack) != null || stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).isPresent();
|
||||
return BlockEntityNatureAltar.this.getRecipeForInput(stack) != null || stack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY, null) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canExtract(ItemStack stack, int slot, int amount) {
|
||||
var cap = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).orElse(null);
|
||||
var cap = stack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
||||
if (cap != null) {
|
||||
return cap.storeAura(1, true) <= 0;
|
||||
} else {
|
||||
|
@ -59,7 +61,7 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
public int bobTimer;
|
||||
public boolean isComplete;
|
||||
|
||||
private AltarRecipe currentRecipe;
|
||||
private RecipeHolder<AltarRecipe> currentRecipe;
|
||||
private int timer;
|
||||
private int lastAura;
|
||||
private boolean firstTick = true;
|
||||
|
@ -118,7 +120,7 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
}
|
||||
|
||||
var stack = this.items.getStackInSlot(0);
|
||||
var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).orElse(null);
|
||||
var container = stack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
||||
if (!stack.isEmpty() && container != null) {
|
||||
var theoreticalDrain = this.container.drainAura(1000, true);
|
||||
if (theoreticalDrain > 0) {
|
||||
|
@ -136,11 +138,11 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
this.currentRecipe = this.getRecipeForInput(stack);
|
||||
}
|
||||
} else {
|
||||
if (stack.isEmpty() || !this.currentRecipe.input.test(stack)) {
|
||||
if (stack.isEmpty() || !this.currentRecipe.value().input.test(stack)) {
|
||||
this.currentRecipe = null;
|
||||
this.timer = 0;
|
||||
} else {
|
||||
var req = Mth.ceil(this.currentRecipe.aura / (double) this.currentRecipe.time);
|
||||
var req = Mth.ceil(this.currentRecipe.value().aura / (double) this.currentRecipe.value().time);
|
||||
if (this.container.getStoredAura() >= req) {
|
||||
this.container.drainAura(req, false);
|
||||
|
||||
|
@ -148,8 +150,8 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.ALTAR_CONVERSION, this.container.getAuraColor()));
|
||||
|
||||
this.timer++;
|
||||
if (this.timer >= this.currentRecipe.time) {
|
||||
this.items.setStackInSlot(0, this.currentRecipe.output.copy());
|
||||
if (this.timer >= this.currentRecipe.value().time) {
|
||||
this.items.setStackInSlot(0, this.currentRecipe.value().output.copy());
|
||||
this.currentRecipe = null;
|
||||
this.timer = 0;
|
||||
|
||||
|
@ -197,14 +199,15 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
}
|
||||
}
|
||||
|
||||
private AltarRecipe getRecipeForInput(ItemStack input) {
|
||||
for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ALTAR_TYPE, null, this.level)) {
|
||||
private RecipeHolder<AltarRecipe> getRecipeForInput(ItemStack input) {
|
||||
for (var holder : this.level.getRecipeManager().getRecipesFor(ModRecipes.ALTAR_TYPE, null, this.level)) {
|
||||
var recipe = holder.value();
|
||||
if (recipe.input.test(input)) {
|
||||
if (recipe.catalyst == Ingredient.EMPTY)
|
||||
return recipe;
|
||||
return holder;
|
||||
for (var stack : this.catalysts) {
|
||||
if (recipe.catalyst.test(stack))
|
||||
return recipe;
|
||||
return holder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -221,12 +224,13 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
}
|
||||
if (type == SaveType.TILE) {
|
||||
if (this.currentRecipe != null) {
|
||||
compound.putString("recipe", this.currentRecipe.name.toString());
|
||||
compound.putString("recipe", this.currentRecipe.id().toString());
|
||||
compound.putInt("timer", this.timer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void readNBT(CompoundTag compound, SaveType type) {
|
||||
super.readNBT(compound, type);
|
||||
|
@ -238,19 +242,10 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable
|
|||
if (type == SaveType.TILE) {
|
||||
if (compound.contains("recipe")) {
|
||||
if (this.hasLevel())
|
||||
this.currentRecipe = (AltarRecipe) this.level.getRecipeManager().byKey(new ResourceLocation(compound.getString("recipe"))).orElse(null);
|
||||
this.currentRecipe = (RecipeHolder<AltarRecipe>) this.level.getRecipeManager().byKey(new ResourceLocation(compound.getString("recipe"))).orElse(null);
|
||||
this.timer = compound.getInt("timer");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAuraContainer getAuraContainer() {
|
||||
return this.container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandlerModifiable getItemHandler() {
|
||||
return this.items;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import net.minecraft.world.level.block.Blocks;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||
import net.neoforged.neoforge.items.ItemStackHandler;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
|
@ -39,8 +38,8 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab
|
|||
|
||||
private OfferingRecipe getRecipe(ItemStack input) {
|
||||
for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.OFFERING_TYPE, null, this.level))
|
||||
if (recipe.input.test(input))
|
||||
return recipe;
|
||||
if (recipe.value().input.test(input))
|
||||
return recipe.value();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -114,7 +113,7 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab
|
|||
if (type != SaveType.SYNC) {
|
||||
var list = new ListTag();
|
||||
for (var stack : this.itemsToSpawn)
|
||||
list.add(stack.serializeNBT());
|
||||
list.add(stack.save(new CompoundTag()));
|
||||
compound.put("items_to_spawn", list);
|
||||
}
|
||||
}
|
||||
|
@ -135,9 +134,4 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandlerModifiable getItemHandler() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,14 +15,13 @@ import net.minecraft.tags.BlockTags;
|
|||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.neoforged.neoforge.items.IItemHandlerModifiable;
|
||||
import net.neoforged.neoforge.items.ItemStackHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBlockEntity {
|
||||
|
@ -34,7 +33,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
}
|
||||
};
|
||||
|
||||
private TreeRitualRecipe recipe;
|
||||
private RecipeHolder<TreeRitualRecipe> recipe;
|
||||
private BlockPos ritualPos;
|
||||
private int timer;
|
||||
|
||||
|
@ -42,7 +41,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
super(ModBlockEntities.WOOD_STAND, pos, state);
|
||||
}
|
||||
|
||||
public void setRitual(BlockPos pos, TreeRitualRecipe recipe) {
|
||||
public void setRitual(BlockPos pos, RecipeHolder<TreeRitualRecipe> recipe) {
|
||||
this.ritualPos = pos;
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
@ -53,9 +52,9 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
if (this.ritualPos != null && this.recipe != null) {
|
||||
if (this.level.getGameTime() % 5 == 0) {
|
||||
if (this.isRitualOkay()) {
|
||||
var wasOverHalf = this.timer >= this.recipe.time / 2;
|
||||
var wasOverHalf = this.timer >= this.recipe.value().time / 2;
|
||||
this.timer += 5;
|
||||
var isOverHalf = this.timer >= this.recipe.time / 2;
|
||||
var isOverHalf = this.timer >= this.recipe.value().time / 2;
|
||||
|
||||
if (!isOverHalf)
|
||||
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
|
||||
|
@ -75,7 +74,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
PacketHandler.sendToAllAround(this.level, this.ritualPos, 32,
|
||||
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), PacketParticles.Type.TR_GOLD_POWDER));
|
||||
|
||||
if (this.timer >= this.recipe.time) {
|
||||
if (this.timer >= this.recipe.value().time) {
|
||||
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'G', (pos, matcher) -> {
|
||||
this.level.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
||||
return true;
|
||||
|
@ -84,7 +83,7 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
|
||||
var item = new ItemEntity(this.level,
|
||||
this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5,
|
||||
this.recipe.result.copy());
|
||||
this.recipe.value().result.copy());
|
||||
this.level.addFreshEntity(item);
|
||||
|
||||
PacketHandler.sendToAllAround(this.level, this.worldPosition, 32,
|
||||
|
@ -130,8 +129,8 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
if (!state.is(BlockTags.LOGS))
|
||||
return false;
|
||||
}
|
||||
if (this.timer < this.recipe.time / 2) {
|
||||
List<Ingredient> required = new ArrayList<>(Arrays.asList(this.recipe.ingredients));
|
||||
if (this.timer < this.recipe.value().time / 2) {
|
||||
List<Ingredient> required = new ArrayList<>(this.recipe.value().ingredients);
|
||||
var fine = Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
|
||||
var tile = this.level.getBlockEntity(pos);
|
||||
if (tile instanceof BlockEntityWoodStand) {
|
||||
|
@ -164,11 +163,12 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
if (this.ritualPos != null && this.recipe != null) {
|
||||
compound.putLong("ritual_pos", this.ritualPos.asLong());
|
||||
compound.putInt("timer", this.timer);
|
||||
compound.putString("recipe", this.recipe.name.toString());
|
||||
compound.putString("recipe", this.recipe.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void readNBT(CompoundTag compound, SaveType type) {
|
||||
super.readNBT(compound, type);
|
||||
|
@ -180,14 +180,9 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl
|
|||
this.ritualPos = BlockPos.of(compound.getLong("ritual_pos"));
|
||||
this.timer = compound.getInt("timer");
|
||||
if (this.hasLevel())
|
||||
this.recipe = (TreeRitualRecipe) this.level.getRecipeManager().byKey(new ResourceLocation(compound.getString("recipe"))).orElse(null);
|
||||
this.recipe = (RecipeHolder<TreeRitualRecipe>) this.level.getRecipeManager().byKey(new ResourceLocation(compound.getString("recipe"))).orElse(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandlerModifiable getItemHandler() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,17 +33,23 @@ import java.util.function.BiConsumer;
|
|||
|
||||
public class AuraChunk implements IAuraChunk {
|
||||
|
||||
private final LevelChunk chunk;
|
||||
private final IAuraType type;
|
||||
private final Map<BlockPos, DrainSpot> drainSpots = new ConcurrentHashMap<>();
|
||||
private final Table<BlockPos, Integer, Pair<Integer, Integer>> auraAndSpotAmountCache = HashBasedTable.create();
|
||||
private final Table<BlockPos, Integer, Pair<BlockPos, Integer>[]> limitSpotCache = HashBasedTable.create();
|
||||
private final List<IDrainSpotEffect> effects = new ArrayList<>();
|
||||
|
||||
private LevelChunk chunk;
|
||||
private IAuraType type;
|
||||
private boolean needsSync;
|
||||
|
||||
public AuraChunk(LevelChunk chunk, IAuraType type) {
|
||||
@Override
|
||||
public void ensureInitialized(LevelChunk chunk) {
|
||||
// are we already initialized?
|
||||
if (this.chunk != null)
|
||||
return;
|
||||
|
||||
this.chunk = chunk;
|
||||
this.type = type;
|
||||
this.type = IAuraType.forLevel(chunk.getLevel());
|
||||
|
||||
for (var supplier : NaturesAuraAPI.DRAIN_SPOT_EFFECTS.values()) {
|
||||
var effect = supplier.get();
|
||||
|
@ -269,7 +275,7 @@ public class AuraChunk implements IAuraChunk {
|
|||
private void addOrRemoveAsActive() {
|
||||
var chunkPos = this.chunk.getPos().toLong();
|
||||
var data = (LevelData) ILevelData.getLevelData(this.chunk.getLevel());
|
||||
if (this.drainSpots.size() > 0) {
|
||||
if (!this.drainSpots.isEmpty()) {
|
||||
data.auraChunksWithSpots.put(chunkPos, this);
|
||||
} else {
|
||||
data.auraChunksWithSpots.remove(chunkPos);
|
||||
|
@ -300,5 +306,7 @@ public class AuraChunk implements IAuraChunk {
|
|||
ret.putLong("original_spread_pos", this.originalSpreadPos.asLong());
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
package de.ellpeck.naturesaura.chunk;
|
||||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
||||
import net.neoforged.neoforge.common.capabilities.ICapabilityProvider;
|
||||
import net.neoforged.neoforge.common.util.INBTSerializable;
|
||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class AuraChunkProvider implements INBTSerializable<CompoundTag> {
|
||||
|
||||
private final LevelChunk chunk;
|
||||
private IAuraChunk auraChunk;
|
||||
|
||||
public AuraChunkProvider(LevelChunk chunk) {
|
||||
this.chunk = chunk;
|
||||
}
|
||||
|
||||
private IAuraChunk getAuraChunk() {
|
||||
if (this.auraChunk == null)
|
||||
this.auraChunk = new AuraChunk(this.chunk, IAuraType.forLevel(this.chunk.getLevel()));
|
||||
return this.auraChunk;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
||||
return capability == NaturesAuraAPI.CAP_AURA_CHUNK ? this.lazyChunk.cast() : LazyOptional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag serializeNBT() {
|
||||
return this.getAuraChunk().serializeNBT();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundTag nbt) {
|
||||
this.getAuraChunk().deserializeNBT(nbt);
|
||||
}
|
||||
}
|
|
@ -79,7 +79,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
|||
var state = level.getBlockState(plantPos);
|
||||
var block = state.getBlock();
|
||||
if (block instanceof BonemealableBlock growable && !PlantBoostEffect.EXCEPTIONS.contains(block) && !(block instanceof DoublePlantBlock) && !(block instanceof TallGrassBlock)) {
|
||||
if (growable.isValidBonemealTarget(level, plantPos, state, false)) {
|
||||
if (growable.isValidBonemealTarget(level, plantPos, state)) {
|
||||
try {
|
||||
growable.performBonemeal((ServerLevel) level, level.random, plantPos, state);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -25,7 +25,7 @@ public class ReplenishingEffect implements IDrainSpotEffect {
|
|||
if (spot < 0) {
|
||||
List<ISpotDrainable> tiles = new ArrayList<>();
|
||||
Helper.getBlockEntitiesInArea(level, pos, 25, tile -> {
|
||||
var container = tile.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).orElse(null);
|
||||
var container = level.getCapability(NaturesAuraAPI.AURA_CONTAINER_BLOCK_CAPABILITY, tile.getBlockPos(), tile.getBlockState(), tile, null);
|
||||
if (container instanceof ISpotDrainable)
|
||||
tiles.add((ISpotDrainable) container);
|
||||
return false;
|
||||
|
@ -58,4 +58,5 @@ public class ReplenishingEffect implements IDrainSpotEffect {
|
|||
public ResourceLocation getName() {
|
||||
return ReplenishingEffect.NAME;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.minecraft.world.entity.Entity;
|
|||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.SpawnEggItem;
|
||||
import net.neoforged.neoforge.common.DeferredSpawnEggItem;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -103,9 +104,9 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
|
|||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayoutBuilder builder, AnimalSpawnerRecipe recipe, IFocusGroup focuses) {
|
||||
for (var i = 0; i < recipe.ingredients.length; i++)
|
||||
builder.addSlot(RecipeIngredientRole.INPUT, i * 18 + 1, 69).addItemStacks(Arrays.asList(recipe.ingredients[i].getItems()));
|
||||
builder.addInvisibleIngredients(RecipeIngredientRole.OUTPUT).addItemStack(new ItemStack(DeferredSpawnEggItem.fromEntityType(recipe.entity)));
|
||||
for (var i = 0; i < recipe.ingredients.size(); i++)
|
||||
builder.addSlot(RecipeIngredientRole.INPUT, i * 18 + 1, 69).addItemStacks(Arrays.asList(recipe.ingredients.get(i).getItems()));
|
||||
builder.addInvisibleIngredients(RecipeIngredientRole.OUTPUT).addItemStack(new ItemStack(SpawnEggItem.byId(recipe.entity)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,6 +19,7 @@ import mezz.jei.api.registration.ISubtypeRegistration;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
|
||||
@JeiPlugin
|
||||
public class JEINaturesAuraPlugin implements IModPlugin {
|
||||
|
@ -50,7 +51,7 @@ public class JEINaturesAuraPlugin implements IModPlugin {
|
|||
registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_BOTTLE, (stack, context) -> ItemAuraBottle.getType(stack).getName().toString());
|
||||
|
||||
var auraInterpreter = (IIngredientSubtypeInterpreter<ItemStack>) (stack, context) -> {
|
||||
var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null);
|
||||
var container = stack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY);
|
||||
if (container != null)
|
||||
return String.valueOf(container.getStoredAura());
|
||||
return IIngredientSubtypeInterpreter.NONE;
|
||||
|
@ -71,9 +72,10 @@ public class JEINaturesAuraPlugin implements IModPlugin {
|
|||
@Override
|
||||
public void registerRecipes(IRecipeRegistration registration) {
|
||||
var manager = Minecraft.getInstance().level.getRecipeManager();
|
||||
registration.addRecipes(JEINaturesAuraPlugin.TREE_RITUAL, manager.getAllRecipesFor(ModRecipes.TREE_RITUAL_TYPE));
|
||||
registration.addRecipes(JEINaturesAuraPlugin.ALTAR, manager.getAllRecipesFor(ModRecipes.ALTAR_TYPE));
|
||||
registration.addRecipes(JEINaturesAuraPlugin.OFFERING, manager.getAllRecipesFor(ModRecipes.OFFERING_TYPE));
|
||||
registration.addRecipes(JEINaturesAuraPlugin.SPAWNER, manager.getAllRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE));
|
||||
registration.addRecipes(JEINaturesAuraPlugin.TREE_RITUAL, manager.getAllRecipesFor(ModRecipes.TREE_RITUAL_TYPE).stream().map(RecipeHolder::value).toList());
|
||||
registration.addRecipes(JEINaturesAuraPlugin.ALTAR, manager.getAllRecipesFor(ModRecipes.ALTAR_TYPE).stream().map(RecipeHolder::value).toList());
|
||||
registration.addRecipes(JEINaturesAuraPlugin.OFFERING, manager.getAllRecipesFor(ModRecipes.OFFERING_TYPE).stream().map(RecipeHolder::value).toList());
|
||||
registration.addRecipes(JEINaturesAuraPlugin.SPAWNER, manager.getAllRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE).stream().map(RecipeHolder::value).toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,8 +48,8 @@ public class TreeRitualCategory implements IRecipeCategory<TreeRitualRecipe> {
|
|||
builder.addSlot(RecipeIngredientRole.OUTPUT, 125, 35).addItemStack(recipe.result);
|
||||
|
||||
var positions = new int[][]{{35, 1}, {35, 69}, {1, 35}, {69, 35}, {12, 12}, {58, 58}, {58, 12}, {12, 58}};
|
||||
for (var i = 0; i < recipe.ingredients.length; i++)
|
||||
builder.addSlot(RecipeIngredientRole.INPUT, positions[i][0], positions[i][1]).addItemStacks(Arrays.asList(recipe.ingredients[i].getItems()));
|
||||
for (var i = 0; i < recipe.ingredients.size(); i++)
|
||||
builder.addSlot(RecipeIngredientRole.INPUT, positions[i][0], positions[i][1]).addItemStacks(Arrays.asList(recipe.ingredients.get(i).getItems()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public class PatchouliCompat implements ICompat {
|
|||
var manager = Minecraft.getInstance().level.getRecipeManager();
|
||||
var res = new ResourceLocation(name);
|
||||
var pre = new ResourceLocation(res.getNamespace(), type + "/" + res.getPath());
|
||||
return (T) manager.byKey(pre).orElse(null);
|
||||
return (T) manager.byKey(pre).orElse(null).value();
|
||||
}
|
||||
|
||||
public static IVariable ingredientVariable(Ingredient ingredient) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.ellpeck.naturesaura.compat.patchouli;
|
||||
|
||||
import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.SpawnEggItem;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.neoforge.common.DeferredSpawnEggItem;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
import vazkii.patchouli.api.IComponentProcessor;
|
||||
import vazkii.patchouli.api.IVariable;
|
||||
import vazkii.patchouli.api.IVariableProvider;
|
||||
|
@ -24,12 +24,12 @@ public class ProcessorAnimalSpawner implements IComponentProcessor {
|
|||
return null;
|
||||
if (key.startsWith("input")) {
|
||||
var id = Integer.parseInt(key.substring(5)) - 1;
|
||||
return this.recipe.ingredients.length > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients[id]) : null;
|
||||
return this.recipe.ingredients.size() > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients.get(id)) : null;
|
||||
} else {
|
||||
return switch (key) {
|
||||
case "name" -> IVariable.wrap(this.recipe.entity.getDescription().getString());
|
||||
case "entity" -> IVariable.wrap(ForgeRegistries.ENTITY_TYPES.getKey(this.recipe.entity).toString());
|
||||
case "egg" -> IVariable.from(new ItemStack(DeferredSpawnEggItem.fromEntityType(this.recipe.entity)));
|
||||
case "entity" -> IVariable.wrap(BuiltInRegistries.ENTITY_TYPE.getKey(this.recipe.entity).toString());
|
||||
case "egg" -> IVariable.from(new ItemStack(SpawnEggItem.byId(this.recipe.entity)));
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
@ -39,4 +39,5 @@ public class ProcessorAnimalSpawner implements IComponentProcessor {
|
|||
public boolean allowRender(String group) {
|
||||
return !"seekrit".equals(group);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class ProcessorTreeRitual implements IComponentProcessor {
|
|||
return null;
|
||||
if (key.startsWith("input")) {
|
||||
var id = Integer.parseInt(key.substring(5)) - 1;
|
||||
return this.recipe.ingredients.length > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients[id]) : null;
|
||||
return this.recipe.ingredients.size() > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients.get(id)) : null;
|
||||
} else {
|
||||
return switch (key) {
|
||||
case "output" -> IVariable.from(this.recipe.result);
|
||||
|
|
|
@ -2,19 +2,17 @@ package de.ellpeck.naturesaura.data;
|
|||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.gen.ModFeatures;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.HolderSet;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
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.common.world.BiomeModifiers.AddFeaturesBiomeModifier;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
|
||||
public class BiomeModifiers {
|
||||
|
||||
|
@ -25,7 +23,7 @@ public class BiomeModifiers {
|
|||
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));
|
||||
return ResourceKey.create(NeoForgeRegistries.Keys.BIOME_MODIFIERS, new ResourceLocation(NaturesAura.MOD_ID, id));
|
||||
}
|
||||
|
||||
public static void bootstrap(BootstapContext<BiomeModifier> context) {
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
|
|||
import net.neoforged.neoforge.data.event.GatherDataEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -43,11 +43,12 @@ public final class ModData {
|
|||
final RegistrySetBuilder registryBuilder = new RegistrySetBuilder();
|
||||
registryBuilder.add(Registries.CONFIGURED_FEATURE, ModFeatures.Configured::bootstrap);
|
||||
registryBuilder.add(Registries.PLACED_FEATURE, ModFeatures.Placed::bootstrap);
|
||||
registryBuilder.add(ForgeRegistries.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
|
||||
registryBuilder.add(Registries.BIOME, context -> {
|
||||
});
|
||||
RegistryAccess.Frozen regAccess = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY);
|
||||
var regAccess = RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY);
|
||||
return registryBuilder.buildPatch(regAccess, VanillaRegistries.createLookup());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,16 +20,11 @@ public class AuraMendingEnchantment extends ModEnchantment {
|
|||
|
||||
@Override
|
||||
public boolean canEnchant(ItemStack stack) {
|
||||
return super.canEnchant(stack) && !stack.getCapability(NaturesAuraAPI.CAP_AURA_RECHARGE).isPresent();
|
||||
return super.canEnchant(stack) && stack.getCapability(NaturesAuraAPI.AURA_RECHARGE_CAPABILITY) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canApplyAtEnchantingTable(ItemStack stack) {
|
||||
return super.canApplyAtEnchantingTable(stack) && !stack.getCapability(NaturesAuraAPI.CAP_AURA_RECHARGE).isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel() {
|
||||
return 1;
|
||||
return super.canApplyAtEnchantingTable(stack) && stack.getCapability(NaturesAuraAPI.AURA_RECHARGE_CAPABILITY) == null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,17 +8,16 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
|||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.api.misc.ILevelData;
|
||||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.chunk.AuraChunkProvider;
|
||||
import de.ellpeck.naturesaura.commands.CommandAura;
|
||||
import de.ellpeck.naturesaura.misc.LevelData;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
|
@ -26,8 +25,6 @@ import net.neoforged.neoforge.event.level.ChunkEvent;
|
|||
import net.neoforged.neoforge.event.level.ChunkWatchEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.util.ObfuscationReflectionHelper;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
import net.neoforged.neoforge.event.AttachCapabilitiesEvent;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
@ -39,22 +36,11 @@ public class CommonEvents {
|
|||
private static final Method GET_LOADED_CHUNKS_METHOD = ObfuscationReflectionHelper.findMethod(ChunkMap.class, "m_140416_");
|
||||
private static final ListMultimap<UUID, ChunkPos> PENDING_AURA_CHUNKS = ArrayListMultimap.create();
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkCapsAttach(AttachCapabilitiesEvent<LevelChunk> event) {
|
||||
var chunk = event.getObject();
|
||||
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "aura"), new AuraChunkProvider(chunk));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLevelCapsAttach(AttachCapabilitiesEvent<Level> event) {
|
||||
event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "data"), new LevelData());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkUnload(ChunkEvent.Unload event) {
|
||||
var iChunk = event.getChunk();
|
||||
if (iChunk instanceof LevelChunk chunk) {
|
||||
var auraChunk = chunk.getCapability(NaturesAuraAPI.CAP_AURA_CHUNK).orElse(null);
|
||||
var auraChunk = chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT).get(chunk);
|
||||
if (auraChunk instanceof AuraChunk) {
|
||||
var data = (LevelData) ILevelData.getLevelData(chunk.getLevel());
|
||||
data.auraChunksWithSpots.remove(chunk.getPos().toLong());
|
||||
|
@ -68,7 +54,7 @@ public class CommonEvents {
|
|||
if (player.level().isClientSide)
|
||||
return;
|
||||
var held = event.getItemStack();
|
||||
if (!held.isEmpty() && ForgeRegistries.ITEMS.getKey(held.getItem()).getPath().contains("chisel")) {
|
||||
if (!held.isEmpty() && BuiltInRegistries.ITEM.getKey(held.getItem()).getPath().contains("chisel")) {
|
||||
var state = player.level().getBlockState(event.getPos());
|
||||
if (NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.containsKey(state)) {
|
||||
var data = (LevelData) ILevelData.getLevelData(player.level());
|
||||
|
@ -90,7 +76,7 @@ public class CommonEvents {
|
|||
var chunk = holder.getTickingChunk();
|
||||
if (chunk == null)
|
||||
continue;
|
||||
var auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.CAP_AURA_CHUNK, null).orElse(null);
|
||||
var auraChunk = (AuraChunk) chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT).get(chunk);
|
||||
if (auraChunk != null)
|
||||
auraChunk.update();
|
||||
}
|
||||
|
@ -130,7 +116,7 @@ public class CommonEvents {
|
|||
var chunk = Helper.getLoadedChunk(player.level(), pos.x, pos.z);
|
||||
if (!(chunk instanceof LevelChunk levelChunk))
|
||||
return false;
|
||||
var auraChunk = (AuraChunk) levelChunk.getCapability(NaturesAuraAPI.CAP_AURA_CHUNK, null).orElse(null);
|
||||
var auraChunk = (AuraChunk) levelChunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT).get(levelChunk);
|
||||
if (auraChunk == null)
|
||||
return false;
|
||||
PacketHandler.sendTo(player, auraChunk.makePacket());
|
||||
|
@ -141,4 +127,5 @@ public class CommonEvents {
|
|||
public void onCommands(RegisterCommandsEvent event) {
|
||||
CommandAura.register(event.getDispatcher());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ public class LevelGenAncientTree extends Feature<NoneFeatureConfiguration> {
|
|||
var goal = pos.offset(x, y, z);
|
||||
if (pos.distSqr(goal) <= radius * radius + rand.nextInt(3) - 1) {
|
||||
if (!level.isStateAtPosition(goal, s -> s.is(BlockTags.LEAVES))) {
|
||||
if (level.isStateAtPosition(goal, st -> !st.is(BlockTags.LOGS) && st.getBlock() != Blocks.DIRT && st.getBlock() != Blocks.GRASS))
|
||||
if (level.isStateAtPosition(goal, st -> !st.is(BlockTags.LOGS) && st.getBlock() != Blocks.DIRT && st.getBlock() != Blocks.GRASS_BLOCK))
|
||||
this.setBlock(level, goal, state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ public class GuiEnderCrate extends AbstractContainerScreen<ContainerEnderCrate>
|
|||
|
||||
@Override
|
||||
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(graphics);
|
||||
super.render(graphics, mouseX, mouseY, partialTicks);
|
||||
this.renderTooltip(graphics, mouseX, mouseY);
|
||||
}
|
||||
|
@ -38,4 +37,5 @@ public class GuiEnderCrate extends AbstractContainerScreen<ContainerEnderCrate>
|
|||
graphics.blit(GuiEnderCrate.CHEST_GUI_TEXTURE, i, j, 0, 0, this.imageWidth, 3 * 18 + 17);
|
||||
graphics.blit(GuiEnderCrate.CHEST_GUI_TEXTURE, i, j + 3 * 18 + 17, 0, 126, this.imageWidth, 96);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,10 +36,10 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu
|
|||
NeoForge.EVENT_BUS.register(new EventHandler());
|
||||
|
||||
DispenserBlock.registerBehavior(emptyBottle, (source, stack) -> {
|
||||
Level level = source.getLevel();
|
||||
var state = source.getBlockState();
|
||||
Level level = source.level();
|
||||
var state = source.state();
|
||||
var facing = state.getValue(DispenserBlock.FACING);
|
||||
var offset = source.getPos().relative(facing);
|
||||
var offset = source.pos().relative(facing);
|
||||
var offsetState = level.getBlockState(offset);
|
||||
|
||||
var dispense = stack.split(1);
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.items;
|
|||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
|
@ -9,7 +10,6 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
|
||||
public class ItemNetheriteFinder extends ItemImpl {
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class ItemNetheriteFinder extends ItemImpl {
|
|||
for (var z = -range; z <= range; z++) {
|
||||
var offset = new BlockPos(pos.getX() + x, y, pos.getZ() + z);
|
||||
var state = levelIn.getBlockState(offset);
|
||||
if (state.getBlock() == Blocks.ANCIENT_DEBRIS || ForgeRegistries.BLOCKS.getKey(state.getBlock()).toString().contains("netherite")) {
|
||||
if (state.getBlock() == Blocks.ANCIENT_DEBRIS || BuiltInRegistries.BLOCK.getKey(state.getBlock()).toString().contains("netherite")) {
|
||||
inst.spawnMagicParticle(
|
||||
offset.getX() + 0.5F, offset.getY() + 0.5F, offset.getZ() + 0.5F,
|
||||
0F, 0F, 0F, 0xab4d38, 6F, 20 * 60, 0F, false, true);
|
||||
|
@ -52,4 +52,5 @@ public class ItemNetheriteFinder extends ItemImpl {
|
|||
playerIn.getCooldowns().addCooldown(this, 20 * 60);
|
||||
return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,12 +16,10 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.neoforged.neoforge.common.NeoForgeMod;
|
||||
import net.neoforged.neoforge.common.capabilities.ICapabilityProvider;
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Comparator;
|
||||
|
|
|
@ -61,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.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT);
|
||||
var auraChunk = (AuraChunk) chunk.getData(NaturesAuraAPI.AURA_CHUNK_ATTACHMENT).get(chunk);
|
||||
if (auraChunk == null)
|
||||
return false;
|
||||
auraChunk.setSpots(this.drainSpots);
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package de.ellpeck.naturesaura.recipes;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.neoforged.neoforge.common.crafting.CraftingHelper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -20,8 +19,7 @@ public class AltarRecipe extends ModRecipe {
|
|||
public final int aura;
|
||||
public final int time;
|
||||
|
||||
public AltarRecipe(ResourceLocation name, Ingredient input, ItemStack output, Ingredient catalyst, int aura, int time) {
|
||||
super(name);
|
||||
public AltarRecipe(Ingredient input, ItemStack output, Ingredient catalyst, int aura, int time) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.catalyst = catalyst;
|
||||
|
@ -46,27 +44,23 @@ public class AltarRecipe extends ModRecipe {
|
|||
|
||||
public static class Serializer implements RecipeSerializer<AltarRecipe> {
|
||||
|
||||
private static final Codec<AltarRecipe> CODEC = RecordCodecBuilder.create(i -> i.group(
|
||||
Ingredient.CODEC.fieldOf("input").forGetter(r -> r.input),
|
||||
ItemStack.CODEC.fieldOf("output").forGetter(r -> r.output),
|
||||
Ingredient.CODEC.fieldOf("catalyst").forGetter(r -> r.catalyst),
|
||||
Codec.INT.fieldOf("aura").forGetter(r -> r.aura),
|
||||
Codec.INT.fieldOf("time").forGetter(r -> r.time)
|
||||
).apply(i, AltarRecipe::new));
|
||||
|
||||
@Override
|
||||
public AltarRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
|
||||
return new AltarRecipe(
|
||||
recipeId,
|
||||
Ingredient.fromJson(json.getAsJsonObject("input")),
|
||||
CraftingHelper.getItemStack(json.getAsJsonObject("output"), true),
|
||||
json.has("catalyst") ? Ingredient.fromJson(json.getAsJsonObject("catalyst")) : Ingredient.EMPTY,
|
||||
json.get("aura").getAsInt(),
|
||||
json.get("time").getAsInt());
|
||||
public Codec<AltarRecipe> codec() {
|
||||
return Serializer.CODEC;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public AltarRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) {
|
||||
return new AltarRecipe(
|
||||
recipeId,
|
||||
Ingredient.fromNetwork(buffer),
|
||||
buffer.readItem(),
|
||||
Ingredient.fromNetwork(buffer),
|
||||
buffer.readInt(),
|
||||
buffer.readInt());
|
||||
public AltarRecipe fromNetwork(FriendlyByteBuf buffer) {
|
||||
return new AltarRecipe(Ingredient.fromNetwork(buffer), buffer.readItem(), Ingredient.fromNetwork(buffer), buffer.readInt(), buffer.readInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,5 +71,7 @@ public class AltarRecipe extends ModRecipe {
|
|||
buffer.writeInt(recipe.aura);
|
||||
buffer.writeInt(recipe.time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package de.ellpeck.naturesaura.recipes;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
@ -14,23 +16,20 @@ import net.minecraft.world.item.crafting.Ingredient;
|
|||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.neoforge.registries.ForgeRegistries;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AnimalSpawnerRecipe extends ModRecipe {
|
||||
|
||||
public final Ingredient[] ingredients;
|
||||
public final List<Ingredient> ingredients;
|
||||
public final EntityType<?> entity;
|
||||
public final int aura;
|
||||
public final int time;
|
||||
|
||||
public AnimalSpawnerRecipe(ResourceLocation name, EntityType<?> entity, int aura, int time, Ingredient... ingredients) {
|
||||
super(name);
|
||||
public AnimalSpawnerRecipe(ResourceLocation entityType, int aura, int time, List<Ingredient> ingredients) {
|
||||
this.ingredients = ingredients;
|
||||
this.entity = entity;
|
||||
this.entity = BuiltInRegistries.ENTITY_TYPE.get(entityType);
|
||||
this.aura = aura;
|
||||
this.time = time;
|
||||
}
|
||||
|
@ -59,40 +58,36 @@ public class AnimalSpawnerRecipe extends ModRecipe {
|
|||
|
||||
public static class Serializer implements RecipeSerializer<AnimalSpawnerRecipe> {
|
||||
|
||||
private static final Codec<AnimalSpawnerRecipe> CODEC = RecordCodecBuilder.create(i -> i.group(
|
||||
ResourceLocation.CODEC.fieldOf("entity").forGetter(r -> BuiltInRegistries.ENTITY_TYPE.getKey(r.entity)),
|
||||
Codec.INT.fieldOf("aura").forGetter(r -> r.aura),
|
||||
Codec.INT.fieldOf("time").forGetter(r -> r.time),
|
||||
Ingredient.CODEC.listOf().fieldOf("ingredients").forGetter(r -> r.ingredients)
|
||||
).apply(i, AnimalSpawnerRecipe::new));
|
||||
|
||||
@Override
|
||||
public AnimalSpawnerRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
|
||||
List<Ingredient> ingredients = new ArrayList<>();
|
||||
for (var e : json.getAsJsonArray("ingredients"))
|
||||
ingredients.add(Ingredient.fromJson(e));
|
||||
return new AnimalSpawnerRecipe(recipeId,
|
||||
ForgeRegistries.ENTITY_TYPES.getValue(new ResourceLocation(json.get("entity").getAsString())),
|
||||
json.get("aura").getAsInt(),
|
||||
json.get("time").getAsInt(),
|
||||
ingredients.toArray(new Ingredient[0]));
|
||||
public Codec<AnimalSpawnerRecipe> codec() {
|
||||
return Serializer.CODEC;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public AnimalSpawnerRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) {
|
||||
var ings = new Ingredient[buffer.readInt()];
|
||||
for (var i = 0; i < ings.length; i++)
|
||||
ings[i] = Ingredient.fromNetwork(buffer);
|
||||
return new AnimalSpawnerRecipe(
|
||||
recipeId,
|
||||
ForgeRegistries.ENTITY_TYPES.getValue(buffer.readResourceLocation()),
|
||||
buffer.readInt(),
|
||||
buffer.readInt(),
|
||||
ings);
|
||||
public AnimalSpawnerRecipe fromNetwork(FriendlyByteBuf buffer) {
|
||||
var ingredients = new ArrayList<Ingredient>();
|
||||
for (var i = buffer.readInt(); i > 0; i--)
|
||||
ingredients.add(Ingredient.fromNetwork(buffer));
|
||||
return new AnimalSpawnerRecipe(buffer.readResourceLocation(), buffer.readInt(), buffer.readInt(), ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toNetwork(FriendlyByteBuf buffer, AnimalSpawnerRecipe recipe) {
|
||||
buffer.writeInt(recipe.ingredients.length);
|
||||
buffer.writeInt(recipe.ingredients.size());
|
||||
for (var ing : recipe.ingredients)
|
||||
ing.toNetwork(buffer);
|
||||
buffer.writeResourceLocation(ForgeRegistries.ENTITY_TYPES.getKey(recipe.entity));
|
||||
buffer.writeResourceLocation(BuiltInRegistries.ENTITY_TYPE.getKey(recipe.entity));
|
||||
buffer.writeInt(recipe.aura);
|
||||
buffer.writeInt(recipe.time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
package de.ellpeck.naturesaura.recipes;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import de.ellpeck.naturesaura.ModConfig;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||
import net.neoforged.neoforge.common.crafting.conditions.ICondition;
|
||||
import net.neoforged.neoforge.common.crafting.conditions.IConditionSerializer;
|
||||
import net.neoforged.neoforge.common.conditions.ICondition;
|
||||
|
||||
public class EnabledCondition implements ICondition {
|
||||
|
||||
private static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "enabled");
|
||||
private static final Codec<EnabledCondition> CODEC = RecordCodecBuilder.create(i ->
|
||||
i.group(Codec.STRING.fieldOf("name").forGetter(c -> c.name)).apply(i, EnabledCondition::new)
|
||||
);
|
||||
|
||||
private ModConfigSpec.ConfigValue<Boolean> config;
|
||||
private final String name;
|
||||
|
||||
|
@ -25,31 +26,14 @@ public class EnabledCondition implements ICondition {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID() {
|
||||
return EnabledCondition.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(IContext context) {
|
||||
return this.config != null && this.config.get();
|
||||
}
|
||||
|
||||
public static class Serializer implements IConditionSerializer<EnabledCondition> {
|
||||
|
||||
@Override
|
||||
public void write(JsonObject json, EnabledCondition value) {
|
||||
json.addProperty("config", value.name);
|
||||
public Codec<? extends ICondition> codec() {
|
||||
return EnabledCondition.CODEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnabledCondition read(JsonObject json) {
|
||||
return new EnabledCondition(GsonHelper.getAsString(json, "config"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getID() {
|
||||
return EnabledCondition.NAME;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.ellpeck.naturesaura.recipes;
|
||||
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
@ -9,12 +8,6 @@ import net.neoforged.neoforge.items.wrapper.RecipeWrapper;
|
|||
|
||||
public abstract class ModRecipe implements Recipe<RecipeWrapper> {
|
||||
|
||||
public final ResourceLocation name;
|
||||
|
||||
public ModRecipe(ResourceLocation name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(RecipeWrapper inv, Level levelIn) {
|
||||
// return true here so that we can easily get all recipes of a type from the recipe manager
|
||||
|
@ -31,9 +24,5 @@ public abstract class ModRecipe implements Recipe<RecipeWrapper> {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package de.ellpeck.naturesaura.recipes;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.neoforged.neoforge.common.crafting.CraftingHelper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -18,8 +17,7 @@ public class OfferingRecipe extends ModRecipe {
|
|||
public final Ingredient startItem;
|
||||
public final ItemStack output;
|
||||
|
||||
public OfferingRecipe(ResourceLocation name, Ingredient input, Ingredient startItem, ItemStack output) {
|
||||
super(name);
|
||||
public OfferingRecipe(Ingredient input, Ingredient startItem, ItemStack output) {
|
||||
this.input = input;
|
||||
this.startItem = startItem;
|
||||
this.output = output;
|
||||
|
@ -42,23 +40,21 @@ public class OfferingRecipe extends ModRecipe {
|
|||
|
||||
public static class Serializer implements RecipeSerializer<OfferingRecipe> {
|
||||
|
||||
private static final Codec<OfferingRecipe> CODEC = RecordCodecBuilder.create(i -> i.group(
|
||||
Ingredient.CODEC.fieldOf("input").forGetter(r -> r.input),
|
||||
Ingredient.CODEC.fieldOf("start_item").forGetter(r -> r.startItem),
|
||||
ItemStack.CODEC.fieldOf("output").forGetter(r -> r.output)
|
||||
).apply(i, OfferingRecipe::new));
|
||||
|
||||
@Override
|
||||
public OfferingRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
|
||||
return new OfferingRecipe(
|
||||
recipeId,
|
||||
Ingredient.fromJson(json.get("input")),
|
||||
Ingredient.fromJson(json.get("start_item")),
|
||||
CraftingHelper.getItemStack(json.getAsJsonObject("output"), true));
|
||||
public Codec<OfferingRecipe> codec() {
|
||||
return Serializer.CODEC;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public OfferingRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) {
|
||||
return new OfferingRecipe(
|
||||
recipeId,
|
||||
Ingredient.fromNetwork(buffer),
|
||||
Ingredient.fromNetwork(buffer),
|
||||
buffer.readItem());
|
||||
public OfferingRecipe fromNetwork(FriendlyByteBuf buffer) {
|
||||
return new OfferingRecipe(Ingredient.fromNetwork(buffer), Ingredient.fromNetwork(buffer), buffer.readItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,5 +63,7 @@ public class OfferingRecipe extends ModRecipe {
|
|||
recipe.startItem.toNetwork(buffer);
|
||||
buffer.writeItem(recipe.output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package de.ellpeck.naturesaura.recipes;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import net.neoforged.neoforge.common.crafting.CraftingHelper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
|
@ -17,12 +16,11 @@ import java.util.List;
|
|||
public class TreeRitualRecipe extends ModRecipe {
|
||||
|
||||
public final Ingredient saplingType;
|
||||
public final Ingredient[] ingredients;
|
||||
public final List<Ingredient> ingredients;
|
||||
public final ItemStack result;
|
||||
public final int time;
|
||||
|
||||
public TreeRitualRecipe(ResourceLocation name, Ingredient saplingType, ItemStack result, int time, Ingredient... ingredients) {
|
||||
super(name);
|
||||
public TreeRitualRecipe(Ingredient saplingType, ItemStack result, int time, List<Ingredient> ingredients) {
|
||||
this.saplingType = saplingType;
|
||||
this.ingredients = ingredients;
|
||||
this.result = result;
|
||||
|
@ -46,41 +44,37 @@ public class TreeRitualRecipe extends ModRecipe {
|
|||
|
||||
public static class Serializer implements RecipeSerializer<TreeRitualRecipe> {
|
||||
|
||||
private static final Codec<TreeRitualRecipe> CODEC = RecordCodecBuilder.create(i -> i.group(
|
||||
Ingredient.CODEC.fieldOf("sapling").forGetter(r -> r.saplingType),
|
||||
ItemStack.CODEC.fieldOf("result").forGetter(r -> r.result),
|
||||
Codec.INT.fieldOf("time").forGetter(r -> r.time),
|
||||
Ingredient.CODEC.listOf().fieldOf("ingredients").forGetter(recipe -> recipe.ingredients)
|
||||
).apply(i, TreeRitualRecipe::new));
|
||||
|
||||
@Override
|
||||
public TreeRitualRecipe fromJson(ResourceLocation recipeId, JsonObject json) {
|
||||
List<Ingredient> ings = new ArrayList<>();
|
||||
for (var element : json.getAsJsonArray("ingredients"))
|
||||
ings.add(Ingredient.fromJson(element));
|
||||
return new TreeRitualRecipe(
|
||||
recipeId,
|
||||
Ingredient.fromJson(json.getAsJsonObject("sapling")),
|
||||
CraftingHelper.getItemStack(json.getAsJsonObject("output"), true),
|
||||
json.get("time").getAsInt(),
|
||||
ings.toArray(new Ingredient[0]));
|
||||
public Codec<TreeRitualRecipe> codec() {
|
||||
return Serializer.CODEC;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TreeRitualRecipe fromNetwork(ResourceLocation recipeId, FriendlyByteBuf buffer) {
|
||||
var ings = new Ingredient[buffer.readInt()];
|
||||
for (var i = 0; i < ings.length; i++)
|
||||
ings[i] = Ingredient.fromNetwork(buffer);
|
||||
return new TreeRitualRecipe(
|
||||
recipeId,
|
||||
Ingredient.fromNetwork(buffer),
|
||||
buffer.readItem(),
|
||||
buffer.readInt(),
|
||||
ings);
|
||||
public TreeRitualRecipe fromNetwork(FriendlyByteBuf buffer) {
|
||||
var ingredients = new ArrayList<Ingredient>();
|
||||
for (var i = buffer.readInt(); i > 0; i--)
|
||||
ingredients.add(Ingredient.fromNetwork(buffer));
|
||||
return new TreeRitualRecipe(Ingredient.fromNetwork(buffer), buffer.readItem(), buffer.readInt(), ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toNetwork(FriendlyByteBuf buffer, TreeRitualRecipe recipe) {
|
||||
buffer.writeInt(recipe.ingredients.length);
|
||||
buffer.writeInt(recipe.ingredients.size());
|
||||
for (var ing : recipe.ingredients)
|
||||
ing.toNetwork(buffer);
|
||||
recipe.saplingType.toNetwork(buffer);
|
||||
buffer.writeItem(recipe.result);
|
||||
buffer.writeInt(recipe.time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ package de.ellpeck.naturesaura.reg;
|
|||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.misc.ILevelData;
|
||||
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;
|
||||
|
@ -22,7 +22,6 @@ import de.ellpeck.naturesaura.items.*;
|
|||
import de.ellpeck.naturesaura.items.tools.*;
|
||||
import de.ellpeck.naturesaura.potion.ModPotions;
|
||||
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;
|
||||
|
@ -40,12 +39,15 @@ import net.minecraft.world.level.block.SoundType;
|
|||
import net.minecraft.world.level.levelgen.structure.BuiltinStructures;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities.EnergyStorage;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities.FluidHandler;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities.ItemHandler;
|
||||
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.NeoForgeRegistries;
|
||||
import net.neoforged.neoforge.registries.RegisterEvent;
|
||||
import vazkii.patchouli.api.PatchouliAPI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -305,7 +307,6 @@ public final class ModRegistry {
|
|||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "animal_spawner"), ModRecipes.ANIMAL_SPAWNER_SERIALIZER);
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "offering"), ModRecipes.OFFERING_SERIALIZER);
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"), ModRecipes.TREE_RITUAL_SERIALIZER);
|
||||
CraftingHelper.register(new EnabledCondition.Serializer());
|
||||
});
|
||||
|
||||
event.register(Registries.CREATIVE_MODE_TAB, h -> {
|
||||
|
@ -326,13 +327,29 @@ public final class ModRegistry {
|
|||
.build()
|
||||
);
|
||||
});
|
||||
|
||||
event.register(NeoForgeRegistries.Keys.ATTACHMENT_TYPES, h -> {
|
||||
h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_chunk"), NaturesAuraAPI.AURA_CHUNK_ATTACHMENT);
|
||||
});
|
||||
}
|
||||
|
||||
@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());
|
||||
event.registerBlockEntity(FluidHandler.BLOCK, ModBlockEntities.SPRING, (e, c) -> e.tank);
|
||||
|
||||
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.ANCIENT_LEAVES, (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.OFFERING_TABLE, (e, c) -> e.items);
|
||||
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.GRATED_CHUTE, (e, c) -> e.items);
|
||||
event.registerBlockEntity(ItemHandler.BLOCK, ModBlockEntities.NATURE_ALTAR, (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.AURA_TIMER, (e, c) -> e.itemHandler);
|
||||
}
|
||||
|
||||
public static Block createFlowerPot(Block block) {
|
||||
|
|
Loading…
Reference in a new issue