Started by
Mymann
on
Topic category: Help with Minecraft modding (Java Edition)
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.
Triggers are not applied to blocks
You must apply it to the GUI slot.
For the trigger, use Remove on the slot tab.
https://imgur.com/8fsU3tW
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.
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;
}
https://imgur.com/qr5UEu5
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.
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 .
If you don't want it to go away too soon
Please add wait to the procedure.
procedure.
https://imgur.com/UELeYNM
ALL CODE
https://imgur.com/iCeVEfL
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
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.
yeah that will cause tremendous lag on servers and add to the fire that is Mcreator mods are horrible, I'm not doing that.
Anyone else have any idea? Anyone?