Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put annihilation plane on machine can cause the items to disappear #1650

Closed
2 tasks done
hinyb opened this issue Aug 6, 2024 · 3 comments · Fixed by #1873
Closed
2 tasks done

Put annihilation plane on machine can cause the items to disappear #1650

hinyb opened this issue Aug 6, 2024 · 3 comments · Fixed by #1873
Labels
type: bug Something isn't working

Comments

@hinyb
Copy link

hinyb commented Aug 6, 2024

Checked for existing issues

  • I have checked for existing issues, and have found none.

Tested latest version

  • I have checked that this occurs on the latest version.

GregTech CEu Version

1.3.1

Minecraft Version

1.20.1

Recipe Viewer Installed

EMI

Environment

Singleplayer

Cross-Mod Interaction

Yes

Other Installed Mods

Appliedenergistics2-forge-15.2.11.jar

Expected Behavior

Expected to do nothing.

Actual Behavior

The covers on the machine will drop,and items in the machine's inventory will disappear.

Steps to Reproduce

图片

Additional Information

I think there shouldn't call onDrops.

    @Override
    public List<ItemStack> getDrops(BlockState state, LootParams.Builder builder) {
        var context = builder.withParameter(LootContextParams.BLOCK_STATE, state).create(LootContextParamSets.BLOCK);
        Entity entity = context.getParamOrNull(LootContextParams.THIS_ENTITY);
        BlockEntity tileEntity = context.getParamOrNull(LootContextParams.BLOCK_ENTITY);
        var drops = super.getDrops(state, builder);
        if (tileEntity instanceof IMachineBlockEntity holder) {
            var machine = holder.getMetaMachine();
            for (Direction direction : GTUtil.DIRECTIONS) {
                machine.getCoverContainer().removeCover(direction, null);
            }
            if (machine instanceof IMachineModifyDrops machineModifyDrops && entity instanceof Player) {
                machineModifyDrops.onDrops(drops, (Player) entity);
            }
            if (machine instanceof IDropSaveMachine dropSaveMachine && dropSaveMachine.saveBreak()) {
                for (ItemStack drop : drops) {
                    if (drop.getItem() instanceof MetaMachineItem item && item.getBlock() == this) {
                        dropSaveMachine.saveToItem(drop.getOrCreateTag());
                        // break here to not dupe contents if a machine drops multiple of itself for whatever reason.
                        break;
                    }
                }
            }
        }
        return drops;
    }
@hinyb hinyb added the type: bug Something isn't working label Aug 6, 2024
@screret
Copy link
Member

screret commented Aug 16, 2024

why are you annihilation planing machines, anyway?

@Ghostipedia
Copy link
Member

why are you annihilation planing machines, anyway?

Honestly, the solution here might just be to auto-apply the tag ae2:blacklisted/annihilation_plane to GTMachines &/|| things that need it in GTM. I don't really think a what is effectively a TE should be capable of being removed by a plane for any reason.

@hinyb
Copy link
Author

hinyb commented Aug 16, 2024

I think the problem is that when getDrops is called, the inventory will be cleared even though the block didn't be destroyed.

screret added a commit that referenced this issue Aug 24, 2024
screret added a commit that referenced this issue Sep 1, 2024
screret added a commit that referenced this issue Sep 1, 2024
screret added a commit that referenced this issue Sep 26, 2024
screret added a commit that referenced this issue Sep 27, 2024
screret added a commit that referenced this issue Sep 29, 2024
screret added a commit that referenced this issue Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
3 participants