Pipez

Pipez

49M Downloads

Energy does not get pulled in 1.21.4

AEAEAEAE4343 opened this issue ยท 1 comments

commented

Bug description

Continuation of #252. After further testing, it seems that the only reason why I 'fixed' my issue, is that I made it so that my energy block actively pushed energy into the pipe.

I have created the simplest possible energy block to be sure that I was not at fault here. To show this, I will provide the relevant code at the bottom of this bug report.

The reason I closed the last issue was that I am a bit new to mod development. But after reading tons of documentation, seeing my blocks work with other mods like WAILA, and seeing that all other capabilities in my blocks work fine with Pipez, I definitely conclude that there is an issue with the mod in 1.21.4.

Minecraft version

1.21.4

Mod version

1.21.4-1.2.19

Mod loader and version

NeoForge 21.4.40

Steps to reproduce

Create a basic energy block (one that does NOT push) and try to extract energy. It won't work.

Expected behavior

I expect energy to get extracted from a block without the block needing to 'push' it into the pipe.

My code (compacted slightly)

TestEnergyBlock.java

package com.leetftw.test_mod.block.test;

import ...;

public class TestEnergyBlock extends BaseEntityBlock {
    public TestEnergyBlock(Properties properties) {
        super(properties);
    }

    @Override
    protected MapCodec<? extends BaseEntityBlock> codec() {
        return null;
    }

    @Override
    public @Nullable BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
        return new TestEnergyBlockEntity(ModBlockEntities.TEST_ENERGY_BE.get(), blockPos, blockState);
    }
}

TestEnergyBlockEntity.java

package com.leetftw.test_mod.block.test;

import ...;

public class TestEnergyBlockEntity extends BlockEntity {
    IEnergyStorage storage = null;

    public TestEnergyBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState blockState) {
        super(type, pos, blockState);
    }

    public IEnergyStorage getEnergyStorage() {
        if (storage == null) {
           storage = new EnergyStorage(10000, 100, 100, 5000);
        }
        return storage;
    }
}

ModBlocks.java

...
public static final DeferredBlock<TestEnergyBlock> TEST_ENERGY_BLOCK = BLOCKS.registerBlock("energy_test", TestEnergyBlock::new);
    public static final DeferredItem<BlockItem> TEST_ENERGY_BLOCK_ITEM = ModItems.ITEMS.registerSimpleBlockItem(TEST_ENERGY_BLOCK);
...

ModBlockEntities.java

    ...
    public static final Supplier<BlockEntityType<TestEnergyBlockEntity>> TEST_ENERGY_BE = BLOCK_ENTITY_TYPES.register(
            "test_energy_be",
            () -> new BlockEntityType<>(
                    new BlockEntityType.BlockEntitySupplier<>() {
                        @Override
                        @ParametersAreNonnullByDefault
                        public @NotNull TestEnergyBlockEntity create(BlockPos blockPos, BlockState blockState) {
                            return new TestEnergyBlockEntity(TEST_ENERGY_BE.get(), blockPos, blockState);
                        }
                    },
                    ModBlocks.TEST_ENERGY_BLOCK.get()
            ));
    ...
    @SubscribeEvent
    public static void registerCapabilities(RegisterCapabilitiesEvent event)
    {
        ...
        event.registerBlockEntity(
                Capabilities.EnergyStorage.BLOCK,
                ModBlockEntities.TEST_ENERGY_BE.get(),
                (blockEntity, side) -> blockEntity.getEnergyStorage()
        );
        ...
    }

Log files

https://gist.github.com/AEAEAEAE4343/d14bce3806f9910da9a071e79882a275

Screenshots

No response

commented

image