How do I make a trash can block that automatically void anything hoppered in.

Started by Mymann on

Topic category: Help with Minecraft modding (Java Edition)

Active 4 months ago
Joined Jun 2024
Points:
226

User statistics:

  • Modifications: 0
  • Forum topics: 24
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 45
How do I make a trash can block that automatically void anything hoppered in.

 I want to make a container that will automatically delete anything put inside, I plan to have a single slot that gets cleared on update tick, but when I set up the procedure it doesn't seem to work at all, and the item still gets in.   

 

Some help is appreciated.

Active 1 month ago
Joined May 2013
Points:
907

User statistics:

  • Modifications: 0
  • Forum topics: 25
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 111
Triggers are not applied to…
Wed, 09/25/2024 - 02:49

Triggers are not applied to blocks
You must apply it to the GUI slot.

For the trigger, use Remove on the slot tab.

Active 4 months ago
Joined Jun 2024
Points:
226

User statistics:

  • Modifications: 0
  • Forum topics: 24
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 45
Okay so I did exactly to…
Wed, 09/25/2024 - 06:05

Okay so I did exactly to what was told and the result is the items don't get deleted if they were imported via a hopper, only when I open the GUI and the item stack amount change from being input in, that is when they got deleted, whereas I desire that the trash can is used to dump endless stacks of excess items completely automatic as well.

Active 1 month ago
Joined May 2013
Points:
907

User statistics:

  • Modifications: 0
  • Forum topics: 25
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 111
Currently, there is no way…
Wed, 09/25/2024 - 06:39

Currently, there is no way to recognize external slots in the MCreator, so you need to add custom code.

STEP1
code edit 'GUIName'Menu.java

SETP2
Find the appropriate code part.


    @Override

    public ItemStack quickMoveStack(Player playerIn, int index) {

        ItemStack itemstack = ItemStack.EMPTY;

        Slot slot = (Slot) this.slots.get(index);

        if (slot != null && slot.hasItem()) {

            ItemStack itemstack1 = slot.getItem();

            itemstack = itemstack1.copy();

            if (index < 1) {

                if (!this.moveItemStackTo(itemstack1, 1, this.slots.size(), true))

                    return ItemStack.EMPTY;

                slot.onQuickCraft(itemstack1, itemstack);

            } else if (!this.moveItemStackTo(itemstack1, 0, 1, false)) {

                if (index < 1 + 27) {

                    if (!this.moveItemStackTo(itemstack1, 1 + 27, this.slots.size(), true))

                        return ItemStack.EMPTY;

                } else {

                    if (!this.moveItemStackTo(itemstack1, 1, 1 + 27, false))

                        return ItemStack.EMPTY;

                }

                return ItemStack.EMPTY;

            }

            if (itemstack1.getCount() == 0)

                slot.set(ItemStack.EMPTY);

            else

                slot.setChanged();

            if (itemstack1.getCount() == itemstack.getCount())

                return ItemStack.EMPTY;

            slot.onTake(playerIn, itemstack1);

        }

        return itemstack;

    }

 

------------------

Change code

    @Override
   public ItemStack quickMoveStack(Player playerIn, int index) {
       ItemStack itemstack = ItemStack.EMPTY;
       Slot slot = (Slot) this.slots.get(index);
       if (slot != null && slot.hasItem()) {
           ItemStack itemstack1 = slot.getItem();
           itemstack = itemstack1.copy();
           if (index < 1) {
              if (!this.moveItemStackTo(itemstack1, 1, this.slots.size(), true))
                   return ItemStack.EMPTY;
               slot.onQuickCraft(itemstack1, itemstack);
           } else {
              if (!this.moveItemStackTo(itemstack1, 0, 1, false)) {
                   return ItemStack.EMPTY;
               }
           }
          
           if (itemstack1.isEmpty()) {
               slot.set(ItemStack.EMPTY);
           } else {
               slot.setChanged();
           }
           if (itemstack1.getCount() == itemstack.getCount()) {
               return ItemStack.EMPTY;
           }
           slot.onTake(playerIn, itemstack1);
       }
       return itemstack;
   }
 

Active 1 month ago
Joined May 2013
Points:
907

User statistics:

  • Modifications: 0
  • Forum topics: 25
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 111
Oh, I got it wrongThere was…
Wed, 09/25/2024 - 07:09

Oh, I got it wrong
There was a mistake because I was using a translator.

Without modifying the GUI's code
You need to modify the code in the procedure.

Active 1 month ago
Joined May 2013
Points:
907

User statistics:

  • Modifications: 0
  • Forum topics: 25
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 111
In the whole codepublic…
Wed, 09/25/2024 - 07:11

In the whole code

public class YOUR GUI NAMEprocedureProcedure {
    public static void execute(Entity entity) {
        if (entity == null)
            return;
        if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
            ((Slot) _slots.get(0)).remove(1);
            _player.containerMenu.broadcastChanges();
        }
    }
}



((Slot) _slots.get(0)).remove(1);


I'll erase that part
Slot slot = (Slot) _slots.get(0);
if (slot.hasItem()) {
slot.getItem().shrink(1);


Add the .

Active 4 months ago
Joined Jun 2024
Points:
226

User statistics:

  • Modifications: 0
  • Forum topics: 24
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 45
still... not working as I…
Wed, 09/25/2024 - 08:40

still... not working as I would hope for.

the result is the same, the items only get voided only when I am using the chest, here's my testing and code:

https://imgur.com/a/fI2xLBn

Active 5 months ago
Joined Jul 2022
Points:
551

User statistics:

  • Modifications: 1
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 237
You could make two identical…
Thu, 09/26/2024 - 00:38

You could make two identical blocks. One with the inventory. Each tick one replaces the other. That should destroy the item in the block with inventory but it might lag.

You could alternatively have a dispensor drop the item on the block and kill entity type item at x y z or x y+1 z.

Active 4 months ago
Joined Jun 2024
Points:
226

User statistics:

  • Modifications: 0
  • Forum topics: 24
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 45
yeah that will cause…
Thu, 09/26/2024 - 03:11

yeah that will cause tremendous lag on servers and add to the fire that is Mcreator mods are horrible, I'm not doing that.

Active 4 months ago
Joined Jun 2024
Points:
226

User statistics:

  • Modifications: 0
  • Forum topics: 24
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 45
Anyone else have any idea?…
Sat, 09/28/2024 - 09:25

Anyone else have any idea? Anyone?