feature: add shipping label for mailbox

This commit is contained in:
nimsolated
2026-03-05 11:24:25 -08:00
parent ec2d412b36
commit e2dff17444
28 changed files with 968 additions and 620 deletions

View File

@@ -31,7 +31,7 @@ import java.util.stream.IntStream;
import io.netty.buffer.Unpooled;
public class MailboxBlockEntity extends RandomizableContainerBlockEntity implements WorldlyContainer {
private NonNullList<ItemStack> stacks = NonNullList.<ItemStack>withSize(18, ItemStack.EMPTY);
private NonNullList<ItemStack> stacks = NonNullList.<ItemStack>withSize(100, ItemStack.EMPTY);
private final LazyOptional<? extends IItemHandler>[] handlers = SidedInvWrapper.create(this, Direction.values());
public MailboxBlockEntity(BlockPos position, BlockState state) {

View File

@@ -6,10 +6,8 @@ import net.minecraft.world.entity.player.Inventory;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.network.chat.Component;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.Minecraft;
import net.mcreator.nimsrandombullshit.world.inventory.MailboxGUIMenu;
import net.mcreator.nimsrandombullshit.network.MailboxGUIButtonMessage;
@@ -24,9 +22,6 @@ public class MailboxGUIScreen extends AbstractContainerScreen<MailboxGUIMenu> {
private final Level world;
private final int x, y, z;
private final Player entity;
EditBox outbox_x_coord;
EditBox outbox_y_coord;
EditBox outbox_z_coord;
Button button_send;
public MailboxGUIScreen(MailboxGUIMenu container, Inventory inventory, Component text) {
@@ -36,7 +31,7 @@ public class MailboxGUIScreen extends AbstractContainerScreen<MailboxGUIMenu> {
this.y = container.y;
this.z = container.z;
this.entity = container.entity;
this.imageWidth = 360;
this.imageWidth = 240;
this.imageHeight = 180;
}
@@ -46,9 +41,6 @@ public class MailboxGUIScreen extends AbstractContainerScreen<MailboxGUIMenu> {
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
this.renderBackground(guiGraphics);
super.render(guiGraphics, mouseX, mouseY, partialTicks);
outbox_x_coord.render(guiGraphics, mouseX, mouseY, partialTicks);
outbox_y_coord.render(guiGraphics, mouseX, mouseY, partialTicks);
outbox_z_coord.render(guiGraphics, mouseX, mouseY, partialTicks);
this.renderTooltip(guiGraphics, mouseX, mouseY);
}
@@ -67,121 +59,24 @@ public class MailboxGUIScreen extends AbstractContainerScreen<MailboxGUIMenu> {
this.minecraft.player.closeContainer();
return true;
}
if (outbox_x_coord.isFocused())
return outbox_x_coord.keyPressed(key, b, c);
if (outbox_y_coord.isFocused())
return outbox_y_coord.keyPressed(key, b, c);
if (outbox_z_coord.isFocused())
return outbox_z_coord.keyPressed(key, b, c);
return super.keyPressed(key, b, c);
}
@Override
public void containerTick() {
super.containerTick();
outbox_x_coord.tick();
outbox_y_coord.tick();
outbox_z_coord.tick();
}
@Override
public void resize(Minecraft minecraft, int width, int height) {
String outbox_x_coordValue = outbox_x_coord.getValue();
String outbox_y_coordValue = outbox_y_coord.getValue();
String outbox_z_coordValue = outbox_z_coord.getValue();
super.resize(minecraft, width, height);
outbox_x_coord.setValue(outbox_x_coordValue);
outbox_y_coord.setValue(outbox_y_coordValue);
outbox_z_coord.setValue(outbox_z_coordValue);
}
@Override
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
guiGraphics.drawString(this.font, Component.translatable("gui.nims_random_bullshit.mailbox_gui.label_inbox"), 98, 14, -12829636, false);
guiGraphics.drawString(this.font, Component.translatable("gui.nims_random_bullshit.mailbox_gui.label_outbox"), 161, 14, -12829636, false);
guiGraphics.drawString(this.font, Component.translatable("gui.nims_random_bullshit.mailbox_gui.label_x"), 224, 19, -12829636, false);
guiGraphics.drawString(this.font, Component.translatable("gui.nims_random_bullshit.mailbox_gui.label_y"), 224, 41, -12829636, false);
guiGraphics.drawString(this.font, Component.translatable("gui.nims_random_bullshit.mailbox_gui.label_z"), 224, 64, -12829636, false);
guiGraphics.drawString(this.font, Component.translatable("gui.nims_random_bullshit.mailbox_gui.label_inbox"), 38, 14, -12829636, false);
guiGraphics.drawString(this.font, Component.translatable("gui.nims_random_bullshit.mailbox_gui.label_outbox"), 101, 14, -12829636, false);
}
@Override
public void init() {
super.init();
outbox_x_coord = new EditBox(this.font, this.leftPos + 234, this.topPos + 15, 118, 18, Component.translatable("gui.nims_random_bullshit.mailbox_gui.outbox_x_coord")) {
@Override
public void insertText(String text) {
super.insertText(text);
if (getValue().isEmpty())
setSuggestion(Component.translatable("gui.nims_random_bullshit.mailbox_gui.outbox_x_coord").getString());
else
setSuggestion(null);
}
@Override
public void moveCursorTo(int pos) {
super.moveCursorTo(pos);
if (getValue().isEmpty())
setSuggestion(Component.translatable("gui.nims_random_bullshit.mailbox_gui.outbox_x_coord").getString());
else
setSuggestion(null);
}
};
outbox_x_coord.setSuggestion(Component.translatable("gui.nims_random_bullshit.mailbox_gui.outbox_x_coord").getString());
outbox_x_coord.setMaxLength(32767);
guistate.put("text:outbox_x_coord", outbox_x_coord);
this.addWidget(this.outbox_x_coord);
outbox_y_coord = new EditBox(this.font, this.leftPos + 234, this.topPos + 38, 118, 18, Component.translatable("gui.nims_random_bullshit.mailbox_gui.outbox_y_coord")) {
@Override
public void insertText(String text) {
super.insertText(text);
if (getValue().isEmpty())
setSuggestion(Component.translatable("gui.nims_random_bullshit.mailbox_gui.outbox_y_coord").getString());
else
setSuggestion(null);
}
@Override
public void moveCursorTo(int pos) {
super.moveCursorTo(pos);
if (getValue().isEmpty())
setSuggestion(Component.translatable("gui.nims_random_bullshit.mailbox_gui.outbox_y_coord").getString());
else
setSuggestion(null);
}
};
outbox_y_coord.setSuggestion(Component.translatable("gui.nims_random_bullshit.mailbox_gui.outbox_y_coord").getString());
outbox_y_coord.setMaxLength(32767);
guistate.put("text:outbox_y_coord", outbox_y_coord);
this.addWidget(this.outbox_y_coord);
outbox_z_coord = new EditBox(this.font, this.leftPos + 234, this.topPos + 60, 118, 18, Component.translatable("gui.nims_random_bullshit.mailbox_gui.outbox_z_coord")) {
@Override
public void insertText(String text) {
super.insertText(text);
if (getValue().isEmpty())
setSuggestion(Component.translatable("gui.nims_random_bullshit.mailbox_gui.outbox_z_coord").getString());
else
setSuggestion(null);
}
@Override
public void moveCursorTo(int pos) {
super.moveCursorTo(pos);
if (getValue().isEmpty())
setSuggestion(Component.translatable("gui.nims_random_bullshit.mailbox_gui.outbox_z_coord").getString());
else
setSuggestion(null);
}
};
outbox_z_coord.setSuggestion(Component.translatable("gui.nims_random_bullshit.mailbox_gui.outbox_z_coord").getString());
outbox_z_coord.setMaxLength(32767);
guistate.put("text:outbox_z_coord", outbox_z_coord);
this.addWidget(this.outbox_z_coord);
button_send = Button.builder(Component.translatable("gui.nims_random_bullshit.mailbox_gui.button_send"), e -> {
if (true) {
NimsRandomBullshitMod.PACKET_HANDLER.sendToServer(new MailboxGUIButtonMessage(0, x, y, z));
MailboxGUIButtonMessage.handleButtonAction(entity, 0, x, y, z);
}
}).bounds(this.leftPos + 269, this.topPos + 86, 46, 20).build();
}).bounds(this.leftPos + 169, this.topPos + 55, 46, 20).build();
guistate.put("button:button_send", button_send);
this.addRenderableWidget(button_send);
}

View File

@@ -16,6 +16,7 @@ import net.minecraft.world.item.BlockItem;
import net.mcreator.nimsrandombullshit.item.StarWandItem;
import net.mcreator.nimsrandombullshit.item.StarItem;
import net.mcreator.nimsrandombullshit.item.ShitItem;
import net.mcreator.nimsrandombullshit.item.ShippingLabelItem;
import net.mcreator.nimsrandombullshit.item.SandDustItem;
import net.mcreator.nimsrandombullshit.item.NetherrackitePickaxeItem;
import net.mcreator.nimsrandombullshit.item.NetherrackiteItem;
@@ -53,6 +54,7 @@ public class NimsRandomBullshitModItems {
public static final RegistryObject<Item> STAR_WAND = REGISTRY.register("star_wand", () -> new StarWandItem());
public static final RegistryObject<Item> NETHERRACK_JUICE_BUCKET = REGISTRY.register("netherrack_juice_bucket", () -> new NetherrackJuiceItem());
public static final RegistryObject<Item> MAILBOX = block(NimsRandomBullshitModBlocks.MAILBOX);
public static final RegistryObject<Item> SHIPPING_LABEL = REGISTRY.register("shipping_label", () -> new ShippingLabelItem());
// Start of user code block custom items
// End of user code block custom items

View File

@@ -36,6 +36,7 @@ public class NimsRandomBullshitModTabs {
tabData.accept(NimsRandomBullshitModItems.GRAVEDIGGER.get());
tabData.accept(NimsRandomBullshitModItems.STAR_WAND.get());
tabData.accept(NimsRandomBullshitModItems.NETHERRACK_JUICE_BUCKET.get());
tabData.accept(NimsRandomBullshitModItems.SHIPPING_LABEL.get());
} else if (tabData.getTabKey() == CreativeModeTabs.INGREDIENTS) {
tabData.accept(NimsRandomBullshitModItems.NETHERRACKITE.get());
tabData.accept(NimsRandomBullshitModItems.SAND_DUST.get());

View File

@@ -0,0 +1,53 @@
package net.mcreator.nimsrandombullshit.item;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraft.world.level.Level;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Item;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.InteractionResult;
import net.minecraft.network.chat.Component;
import net.mcreator.nimsrandombullshit.procedures.ShippingLabelSpecialInformationProcedure;
import net.mcreator.nimsrandombullshit.procedures.ShippingLabelRightclickedOnBlockProcedure;
import net.mcreator.nimsrandombullshit.procedures.ShippingLabelHasItemGlowingEffectProcedure;
import java.util.List;
public class ShippingLabelItem extends Item {
public ShippingLabelItem() {
super(new Item.Properties().stacksTo(64).rarity(Rarity.COMMON));
}
@Override
@OnlyIn(Dist.CLIENT)
public boolean isFoil(ItemStack itemstack) {
return ShippingLabelHasItemGlowingEffectProcedure.execute(itemstack);
}
@Override
public void appendHoverText(ItemStack itemstack, Level level, List<Component> list, TooltipFlag flag) {
super.appendHoverText(itemstack, level, list, flag);
Entity entity = itemstack.getEntityRepresentation();
String hoverText = ShippingLabelSpecialInformationProcedure.execute(itemstack);
if (hoverText != null) {
for (String line : hoverText.split("\n")) {
list.add(Component.literal(line));
}
}
}
@Override
public InteractionResult useOn(UseOnContext context) {
super.useOn(context);
ShippingLabelRightclickedOnBlockProcedure.execute(context.getLevel(), context.getClickedPos().getX(), context.getClickedPos().getY(), context.getClickedPos().getZ(), context.getLevel().getBlockState(context.getClickedPos()),
context.getPlayer(), context.getItemInHand());
return InteractionResult.SUCCESS;
}
}

View File

@@ -64,7 +64,7 @@ public class MailboxGUIButtonMessage {
return;
if (buttonID == 0) {
MailboxSmartSendLogicProcedure.execute(world, x, y, z, entity, guistate);
MailboxSmartSendLogicProcedure.execute(world, x, y, z, entity);
}
}

View File

@@ -0,0 +1,14 @@
package net.mcreator.nimsrandombullshit.procedures;
import net.minecraft.world.item.ItemStack;
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModItems;
public class MailboxSlot99ShippingLabelInsertionConditionProcedure {
public static boolean execute(ItemStack itemstack) {
if (itemstack.getItem() == NimsRandomBullshitModItems.SHIPPING_LABEL.get() && itemstack.getOrCreateTag().getBoolean("connected")) {
return false;
}
return true;
}
}

View File

@@ -1,7 +1,5 @@
package net.mcreator.nimsrandombullshit.procedures;
import org.checkerframework.checker.units.qual.s;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
@@ -14,21 +12,19 @@ import net.minecraft.world.inventory.Slot;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.Entity;
import net.minecraft.core.BlockPos;
import net.minecraft.client.gui.components.EditBox;
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModItems;
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModBlocks;
import java.util.function.Supplier;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.Map;
import java.util.HashMap;
public class MailboxSmartSendLogicProcedure {
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity, HashMap guistate) {
if (entity == null || guistate == null)
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
if (entity == null)
return;
ItemStack currInboxItem = ItemStack.EMPTY;
double currInboxSlot = 0;
double currOutboxSlot = 0;
double currInboxSlotRoom = 0;
@@ -36,387 +32,41 @@ public class MailboxSmartSendLogicProcedure {
double currInboxSlot2 = 0;
double currInboxItemCount = 0;
double currInboxItemCount2 = 0;
ItemStack currInboxItem = ItemStack.EMPTY;
ItemStack shippingLabel = ItemStack.EMPTY;
if (!world.isClientSide()) {
if (!world.isClientSide()) {
BlockPos _bp = BlockPos.containing(x, y, z);
BlockEntity _blockEntity = world.getBlockEntity(_bp);
BlockState _bs = world.getBlockState(_bp);
if (_blockEntity != null)
_blockEntity.getPersistentData().putDouble("target_mailbox_x", new Object() {
double convert(String s) {
try {
return Double.parseDouble(s.trim());
} catch (Exception e) {
}
return 0;
}
}.convert(guistate.containsKey("text:outbox_x_coord") ? ((EditBox) guistate.get("text:outbox_x_coord")).getValue() : ""));
if (world instanceof Level _level)
_level.sendBlockUpdated(_bp, _bs, _bs, 3);
}
if (!world.isClientSide()) {
BlockPos _bp = BlockPos.containing(x, y, z);
BlockEntity _blockEntity = world.getBlockEntity(_bp);
BlockState _bs = world.getBlockState(_bp);
if (_blockEntity != null)
_blockEntity.getPersistentData().putDouble("target_mailbox_y", new Object() {
double convert(String s) {
try {
return Double.parseDouble(s.trim());
} catch (Exception e) {
}
return 0;
}
}.convert(guistate.containsKey("text:outbox_y_coord") ? ((EditBox) guistate.get("text:outbox_y_coord")).getValue() : ""));
if (world instanceof Level _level)
_level.sendBlockUpdated(_bp, _bs, _bs, 3);
}
if (!world.isClientSide()) {
BlockPos _bp = BlockPos.containing(x, y, z);
BlockEntity _blockEntity = world.getBlockEntity(_bp);
BlockState _bs = world.getBlockState(_bp);
if (_blockEntity != null)
_blockEntity.getPersistentData().putDouble("target_mailbox_z", new Object() {
double convert(String s) {
try {
return Double.parseDouble(s.trim());
} catch (Exception e) {
}
return 0;
}
}.convert(guistate.containsKey("text:outbox_z_coord") ? ((EditBox) guistate.get("text:outbox_z_coord")).getValue() : ""));
if (world instanceof Level _level)
_level.sendBlockUpdated(_bp, _bs, _bs, 3);
}
if ((world.getBlockState(BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
shippingLabel = (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get(99)).getItem() : ItemStack.EMPTY).copy();
if (shippingLabel.getItem() == NimsRandomBullshitModItems.SHIPPING_LABEL.get() && shippingLabel.getOrCreateTag().getBoolean("connected")) {
if (!world.isClientSide()) {
BlockPos _bp = BlockPos.containing(x, y, z);
BlockEntity _blockEntity = world.getBlockEntity(_bp);
BlockState _bs = world.getBlockState(_bp);
if (_blockEntity != null)
_blockEntity.getPersistentData().putDouble("target_mailbox_x", (shippingLabel.getOrCreateTag().getDouble("connected_mailbox_x")));
if (world instanceof Level _level)
_level.sendBlockUpdated(_bp, _bs, _bs, 3);
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
if (!world.isClientSide()) {
BlockPos _bp = BlockPos.containing(x, y, z);
BlockEntity _blockEntity = world.getBlockEntity(_bp);
BlockState _bs = world.getBlockState(_bp);
if (_blockEntity != null)
_blockEntity.getPersistentData().putDouble("target_mailbox_y", (shippingLabel.getOrCreateTag().getDouble("connected_mailbox_y")));
if (world instanceof Level _level)
_level.sendBlockUpdated(_bp, _bs, _bs, 3);
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
if (!world.isClientSide()) {
BlockPos _bp = BlockPos.containing(x, y, z);
BlockEntity _blockEntity = world.getBlockEntity(_bp);
BlockState _bs = world.getBlockState(_bp);
if (_blockEntity != null)
_blockEntity.getPersistentData().putDouble("target_mailbox_z", (shippingLabel.getOrCreateTag().getDouble("connected_mailbox_z")));
if (world instanceof Level _level)
_level.sendBlockUpdated(_bp, _bs, _bs, 3);
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")))).getBlock() == NimsRandomBullshitModBlocks.MAILBOX.get()) {
currInboxSlot = 0;
currOutboxSlot = 9;
while (currInboxSlot <= 8) {
currInboxItem = (new Object() {
public ItemStack getItemStack(LevelAccessor world, BlockPos pos, int slotid) {
AtomicReference<ItemStack> _retval = new AtomicReference<>(ItemStack.EMPTY);
BlockEntity _ent = world.getBlockEntity(pos);
if (_ent != null)
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> _retval.set(capability.getStackInSlot(slotid).copy()));
return _retval.get();
}
}.getItemStack(world, BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")), (int) currInboxSlot)).copy();
currInboxItemCount = new Object() {
public int getAmount(LevelAccessor world, BlockPos pos, int slotid) {
AtomicInteger _retval = new AtomicInteger(0);
BlockEntity _ent = world.getBlockEntity(pos);
if (_ent != null)
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> _retval.set(capability.getStackInSlot(slotid).getCount()));
return _retval.get();
}
}.getAmount(world, BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")), (int) currInboxSlot);
if (currInboxItem.getItem() == ItemStack.EMPTY.getItem()
&& !((entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get((int) currOutboxSlot)).getItem() : ItemStack.EMPTY)
.getItem() == ItemStack.EMPTY.getItem())) {
{
BlockEntity _ent = world.getBlockEntity(BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")));
if (_ent != null) {
final int _slotid = (int) currInboxSlot;
final ItemStack _setstack = (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt
? ((Slot) _slt.get((int) currOutboxSlot)).getItem()
: ItemStack.EMPTY).copy();
_setstack.setCount(new Object() {
public int getAmount(int sltid) {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
if (stack != null)
return stack.getCount();
}
return 0;
}
}.getAmount((int) currOutboxSlot));
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
if (capability instanceof IItemHandlerModifiable)
((IItemHandlerModifiable) capability).setStackInSlot(_slotid, _setstack);
});
}
}
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
((Slot) _slots.get((int) currOutboxSlot)).set(ItemStack.EMPTY);
_player.containerMenu.broadcastChanges();
}
} else {
if (currInboxItem
.getItem() == (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get((int) currOutboxSlot)).getItem() : ItemStack.EMPTY)
.getItem()
&& currInboxItemCount < currInboxItem.getMaxStackSize()) {
currInboxSlotRoom = currInboxItem.getMaxStackSize() - currInboxItemCount;
if (new Object() {
public int getAmount(int sltid) {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
if (stack != null)
return stack.getCount();
}
return 0;
}
}.getAmount((int) currOutboxSlot) <= currInboxSlotRoom) {
{
BlockEntity _ent = world.getBlockEntity(BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")));
if (_ent != null) {
final int _slotid = (int) currInboxSlot;
final ItemStack _setstack = currInboxItem.copy();
_setstack.setCount((int) (currInboxItemCount + new Object() {
public int getAmount(int sltid) {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
if (stack != null)
return stack.getCount();
}
return 0;
}
}.getAmount((int) currOutboxSlot)));
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
if (capability instanceof IItemHandlerModifiable)
((IItemHandlerModifiable) capability).setStackInSlot(_slotid, _setstack);
});
}
}
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
((Slot) _slots.get((int) currOutboxSlot)).set(ItemStack.EMPTY);
_player.containerMenu.broadcastChanges();
}
} else {
{
BlockEntity _ent = world.getBlockEntity(BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")));
if (_ent != null) {
final int _slotid = (int) currInboxSlot;
final ItemStack _setstack = currInboxItem.copy();
_setstack.setCount(currInboxItem.getMaxStackSize());
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
if (capability instanceof IItemHandlerModifiable)
((IItemHandlerModifiable) capability).setStackInSlot(_slotid, _setstack);
});
}
}
currRemainder = new Object() {
public int getAmount(int sltid) {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
if (stack != null)
return stack.getCount();
}
return 0;
}
}.getAmount((int) currOutboxSlot) - currInboxSlotRoom;
currInboxSlot2 = 0;
while (currInboxSlot2 <= 8) {
currInboxItemCount2 = new Object() {
public int getAmount(LevelAccessor world, BlockPos pos, int slotid) {
AtomicInteger _retval = new AtomicInteger(0);
BlockEntity _ent = world.getBlockEntity(pos);
if (_ent != null)
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> _retval.set(capability.getStackInSlot(slotid).getCount()));
return _retval.get();
}
}.getAmount(world, BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")), (int) currInboxSlot2);
if (currInboxItemCount2 == 0) {
{
BlockEntity _ent = world.getBlockEntity(BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")));
if (_ent != null) {
final int _slotid = (int) currInboxSlot2;
final ItemStack _setstack = currInboxItem.copy();
_setstack.setCount((int) currRemainder);
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
if (capability instanceof IItemHandlerModifiable)
((IItemHandlerModifiable) capability).setStackInSlot(_slotid, _setstack);
});
}
}
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
((Slot) _slots.get((int) currOutboxSlot)).set(ItemStack.EMPTY);
_player.containerMenu.broadcastChanges();
}
currRemainder = 0;
break;
}
currInboxSlot2 = currInboxSlot2 + 1;
}
if (currRemainder > 0) {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack _setstack = currInboxItem.copy();
_setstack.setCount((int) currRemainder);
((Slot) _slots.get((int) currOutboxSlot)).set(_setstack);
_player.containerMenu.broadcastChanges();
}
}
}
}
}
if (new Object() {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack _setstack = shippingLabel.copy();
_setstack.setCount((int) (new Object() {
public int getAmount(int sltid) {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
@@ -425,15 +75,357 @@ public class MailboxSmartSendLogicProcedure {
}
return 0;
}
}.getAmount((int) currOutboxSlot) == 0) {
currOutboxSlot = currOutboxSlot + 1;
if (currInboxItemCount == currInboxItem.getMaxStackSize()) {
}.getAmount(99) - 1));
((Slot) _slots.get(99)).set(_setstack);
_player.containerMenu.broadcastChanges();
}
if ((world.getBlockState(BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")))).getBlock() == NimsRandomBullshitModBlocks.MAILBOX.get()) {
currInboxSlot = 0;
currOutboxSlot = 9;
while (currInboxSlot <= 8) {
currInboxItem = (new Object() {
public ItemStack getItemStack(LevelAccessor world, BlockPos pos, int slotid) {
AtomicReference<ItemStack> _retval = new AtomicReference<>(ItemStack.EMPTY);
BlockEntity _ent = world.getBlockEntity(pos);
if (_ent != null)
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> _retval.set(capability.getStackInSlot(slotid).copy()));
return _retval.get();
}
}.getItemStack(world, BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")), (int) currInboxSlot)).copy();
currInboxItemCount = new Object() {
public int getAmount(LevelAccessor world, BlockPos pos, int slotid) {
AtomicInteger _retval = new AtomicInteger(0);
BlockEntity _ent = world.getBlockEntity(pos);
if (_ent != null)
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> _retval.set(capability.getStackInSlot(slotid).getCount()));
return _retval.get();
}
}.getAmount(world, BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")), (int) currInboxSlot);
if (currInboxItem.getItem() == ItemStack.EMPTY.getItem()
&& !((entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get((int) currOutboxSlot)).getItem() : ItemStack.EMPTY)
.getItem() == ItemStack.EMPTY.getItem())) {
{
BlockEntity _ent = world.getBlockEntity(BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")));
if (_ent != null) {
final int _slotid = (int) currInboxSlot;
final ItemStack _setstack = (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt
? ((Slot) _slt.get((int) currOutboxSlot)).getItem()
: ItemStack.EMPTY).copy();
_setstack.setCount(new Object() {
public int getAmount(int sltid) {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
if (stack != null)
return stack.getCount();
}
return 0;
}
}.getAmount((int) currOutboxSlot));
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
if (capability instanceof IItemHandlerModifiable)
((IItemHandlerModifiable) capability).setStackInSlot(_slotid, _setstack);
});
}
}
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
((Slot) _slots.get((int) currOutboxSlot)).set(ItemStack.EMPTY);
_player.containerMenu.broadcastChanges();
}
} else {
if (currInboxItem
.getItem() == (entity instanceof Player _plrSlotItem && _plrSlotItem.containerMenu instanceof Supplier _splr && _splr.get() instanceof Map _slt ? ((Slot) _slt.get((int) currOutboxSlot)).getItem() : ItemStack.EMPTY)
.getItem()
&& currInboxItemCount < currInboxItem.getMaxStackSize()) {
currInboxSlotRoom = currInboxItem.getMaxStackSize() - currInboxItemCount;
if (new Object() {
public int getAmount(int sltid) {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
if (stack != null)
return stack.getCount();
}
return 0;
}
}.getAmount((int) currOutboxSlot) <= currInboxSlotRoom) {
{
BlockEntity _ent = world.getBlockEntity(BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")));
if (_ent != null) {
final int _slotid = (int) currInboxSlot;
final ItemStack _setstack = currInboxItem.copy();
_setstack.setCount((int) (currInboxItemCount + new Object() {
public int getAmount(int sltid) {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
if (stack != null)
return stack.getCount();
}
return 0;
}
}.getAmount((int) currOutboxSlot)));
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
if (capability instanceof IItemHandlerModifiable)
((IItemHandlerModifiable) capability).setStackInSlot(_slotid, _setstack);
});
}
}
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
((Slot) _slots.get((int) currOutboxSlot)).set(ItemStack.EMPTY);
_player.containerMenu.broadcastChanges();
}
} else {
{
BlockEntity _ent = world.getBlockEntity(BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")));
if (_ent != null) {
final int _slotid = (int) currInboxSlot;
final ItemStack _setstack = currInboxItem.copy();
_setstack.setCount(currInboxItem.getMaxStackSize());
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
if (capability instanceof IItemHandlerModifiable)
((IItemHandlerModifiable) capability).setStackInSlot(_slotid, _setstack);
});
}
}
currRemainder = new Object() {
public int getAmount(int sltid) {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
if (stack != null)
return stack.getCount();
}
return 0;
}
}.getAmount((int) currOutboxSlot) - currInboxSlotRoom;
currInboxSlot2 = 0;
while (currInboxSlot2 <= 8) {
currInboxItemCount2 = new Object() {
public int getAmount(LevelAccessor world, BlockPos pos, int slotid) {
AtomicInteger _retval = new AtomicInteger(0);
BlockEntity _ent = world.getBlockEntity(pos);
if (_ent != null)
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> _retval.set(capability.getStackInSlot(slotid).getCount()));
return _retval.get();
}
}.getAmount(world, BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")), (int) currInboxSlot2);
if (currInboxItemCount2 == 0) {
{
BlockEntity _ent = world.getBlockEntity(BlockPos.containing(new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_x"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_y"), new Object() {
public double getValue(LevelAccessor world, BlockPos pos, String tag) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null)
return blockEntity.getPersistentData().getDouble(tag);
return -1;
}
}.getValue(world, BlockPos.containing(x, y, z), "target_mailbox_z")));
if (_ent != null) {
final int _slotid = (int) currInboxSlot2;
final ItemStack _setstack = currInboxItem.copy();
_setstack.setCount((int) currRemainder);
_ent.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
if (capability instanceof IItemHandlerModifiable)
((IItemHandlerModifiable) capability).setStackInSlot(_slotid, _setstack);
});
}
}
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
((Slot) _slots.get((int) currOutboxSlot)).set(ItemStack.EMPTY);
_player.containerMenu.broadcastChanges();
}
currRemainder = 0;
break;
}
currInboxSlot2 = currInboxSlot2 + 1;
}
if (currRemainder > 0) {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack _setstack = currInboxItem.copy();
_setstack.setCount((int) currRemainder);
((Slot) _slots.get((int) currOutboxSlot)).set(_setstack);
_player.containerMenu.broadcastChanges();
}
}
}
}
}
if (new Object() {
public int getAmount(int sltid) {
if (entity instanceof Player _player && _player.containerMenu instanceof Supplier _current && _current.get() instanceof Map _slots) {
ItemStack stack = ((Slot) _slots.get(sltid)).getItem();
if (stack != null)
return stack.getCount();
}
return 0;
}
}.getAmount((int) currOutboxSlot) == 0) {
currOutboxSlot = currOutboxSlot + 1;
if (currInboxItemCount == currInboxItem.getMaxStackSize()) {
currInboxSlot = currInboxSlot + 1;
}
} else if (currInboxItemCount == 0) {
currOutboxSlot = currOutboxSlot + 1;
} else {
currInboxSlot = currInboxSlot + 1;
}
} else if (currInboxItemCount == 0) {
currOutboxSlot = currOutboxSlot + 1;
} else {
currInboxSlot = currInboxSlot + 1;
}
}
}

View File

@@ -0,0 +1,12 @@
package net.mcreator.nimsrandombullshit.procedures;
import net.minecraft.world.item.ItemStack;
public class ShippingLabelHasItemGlowingEffectProcedure {
public static boolean execute(ItemStack itemstack) {
if (itemstack.getOrCreateTag().getBoolean("connected")) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,39 @@
package net.mcreator.nimsrandombullshit.procedures;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.Level;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.Entity;
import net.minecraft.util.RandomSource;
import net.minecraft.util.Mth;
import net.minecraft.sounds.SoundSource;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.BlockPos;
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModBlocks;
public class ShippingLabelRightclickedOnBlockProcedure {
public static void execute(LevelAccessor world, double x, double y, double z, BlockState blockstate, Entity entity, ItemStack itemstack) {
if (entity == null)
return;
if (!world.isClientSide()) {
if (blockstate.getBlock() == NimsRandomBullshitModBlocks.MAILBOX.get() && entity.isShiftKeyDown()) {
itemstack.getOrCreateTag().putDouble("connected_mailbox_x", x);
itemstack.getOrCreateTag().putDouble("connected_mailbox_y", y);
itemstack.getOrCreateTag().putDouble("connected_mailbox_z", z);
itemstack.getOrCreateTag().putBoolean("connected", true);
if (world instanceof Level _level) {
if (!_level.isClientSide()) {
_level.playSound(null, BlockPos.containing(x, y, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.player.levelup")), SoundSource.PLAYERS, (float) 0.75,
(float) Mth.nextDouble(RandomSource.create(), 0.95, 1.05));
} else {
_level.playLocalSound(x, y, z, ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.player.levelup")), SoundSource.PLAYERS, (float) 0.75, (float) Mth.nextDouble(RandomSource.create(), 0.95, 1.05), false);
}
}
}
}
}
}

View File

@@ -0,0 +1,13 @@
package net.mcreator.nimsrandombullshit.procedures;
import net.minecraft.world.item.ItemStack;
public class ShippingLabelSpecialInformationProcedure {
public static String execute(ItemStack itemstack) {
if (itemstack.getOrCreateTag().getBoolean("connected")) {
return ("Dest. Mailbox X:" + itemstack.getOrCreateTag().getDouble("connected_mailbox_x") + "\n") + "" + ("Dest. Mailbox Y:" + itemstack.getOrCreateTag().getDouble("connected_mailbox_y") + "\n")
+ ("Dest. Mailbox Z:" + itemstack.getOrCreateTag().getDouble("connected_mailbox_z") + "\n");
}
return "No assigned destination.";
}
}

View File

@@ -19,6 +19,7 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.core.BlockPos;
import net.mcreator.nimsrandombullshit.procedures.MailboxSlot99ShippingLabelInsertionConditionProcedure;
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModMenus;
import java.util.function.Supplier;
@@ -42,7 +43,7 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
super(NimsRandomBullshitModMenus.MAILBOX_GUI.get(), id);
this.entity = inv.player;
this.world = inv.player.level();
this.internal = new ItemStackHandler(18);
this.internal = new ItemStackHandler(100);
BlockPos pos = null;
if (extraData != null) {
pos = extraData.readBlockPos();
@@ -77,7 +78,7 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
});
}
}
this.customSlots.put(0, this.addSlot(new SlotItemHandler(internal, 0, 99, 29) {
this.customSlots.put(0, this.addSlot(new SlotItemHandler(internal, 0, 39, 29) {
private final int slot = 0;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
@@ -87,7 +88,7 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
return false;
}
}));
this.customSlots.put(1, this.addSlot(new SlotItemHandler(internal, 1, 117, 29) {
this.customSlots.put(1, this.addSlot(new SlotItemHandler(internal, 1, 57, 29) {
private final int slot = 1;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
@@ -97,7 +98,7 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
return false;
}
}));
this.customSlots.put(2, this.addSlot(new SlotItemHandler(internal, 2, 135, 29) {
this.customSlots.put(2, this.addSlot(new SlotItemHandler(internal, 2, 75, 29) {
private final int slot = 2;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
@@ -107,7 +108,7 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
return false;
}
}));
this.customSlots.put(3, this.addSlot(new SlotItemHandler(internal, 3, 99, 47) {
this.customSlots.put(3, this.addSlot(new SlotItemHandler(internal, 3, 39, 47) {
private final int slot = 3;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
@@ -117,7 +118,7 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
return false;
}
}));
this.customSlots.put(4, this.addSlot(new SlotItemHandler(internal, 4, 117, 47) {
this.customSlots.put(4, this.addSlot(new SlotItemHandler(internal, 4, 57, 47) {
private final int slot = 4;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
@@ -127,7 +128,7 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
return false;
}
}));
this.customSlots.put(5, this.addSlot(new SlotItemHandler(internal, 5, 135, 47) {
this.customSlots.put(5, this.addSlot(new SlotItemHandler(internal, 5, 75, 47) {
private final int slot = 5;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
@@ -137,7 +138,7 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
return false;
}
}));
this.customSlots.put(6, this.addSlot(new SlotItemHandler(internal, 6, 99, 65) {
this.customSlots.put(6, this.addSlot(new SlotItemHandler(internal, 6, 39, 65) {
private final int slot = 6;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
@@ -147,7 +148,7 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
return false;
}
}));
this.customSlots.put(7, this.addSlot(new SlotItemHandler(internal, 7, 117, 65) {
this.customSlots.put(7, this.addSlot(new SlotItemHandler(internal, 7, 57, 65) {
private final int slot = 7;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
@@ -157,7 +158,7 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
return false;
}
}));
this.customSlots.put(8, this.addSlot(new SlotItemHandler(internal, 8, 135, 65) {
this.customSlots.put(8, this.addSlot(new SlotItemHandler(internal, 8, 75, 65) {
private final int slot = 8;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
@@ -167,56 +168,66 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
return false;
}
}));
this.customSlots.put(9, this.addSlot(new SlotItemHandler(internal, 9, 162, 29) {
this.customSlots.put(9, this.addSlot(new SlotItemHandler(internal, 9, 102, 29) {
private final int slot = 9;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
}));
this.customSlots.put(10, this.addSlot(new SlotItemHandler(internal, 10, 180, 29) {
this.customSlots.put(10, this.addSlot(new SlotItemHandler(internal, 10, 120, 29) {
private final int slot = 10;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
}));
this.customSlots.put(11, this.addSlot(new SlotItemHandler(internal, 11, 198, 29) {
this.customSlots.put(11, this.addSlot(new SlotItemHandler(internal, 11, 138, 29) {
private final int slot = 11;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
}));
this.customSlots.put(12, this.addSlot(new SlotItemHandler(internal, 12, 162, 47) {
this.customSlots.put(12, this.addSlot(new SlotItemHandler(internal, 12, 102, 47) {
private final int slot = 12;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
}));
this.customSlots.put(13, this.addSlot(new SlotItemHandler(internal, 13, 180, 47) {
this.customSlots.put(13, this.addSlot(new SlotItemHandler(internal, 13, 120, 47) {
private final int slot = 13;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
}));
this.customSlots.put(14, this.addSlot(new SlotItemHandler(internal, 14, 198, 47) {
this.customSlots.put(14, this.addSlot(new SlotItemHandler(internal, 14, 138, 47) {
private final int slot = 14;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
}));
this.customSlots.put(15, this.addSlot(new SlotItemHandler(internal, 15, 162, 65) {
this.customSlots.put(15, this.addSlot(new SlotItemHandler(internal, 15, 102, 65) {
private final int slot = 15;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
}));
this.customSlots.put(16, this.addSlot(new SlotItemHandler(internal, 16, 180, 65) {
this.customSlots.put(16, this.addSlot(new SlotItemHandler(internal, 16, 120, 65) {
private final int slot = 16;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
}));
this.customSlots.put(17, this.addSlot(new SlotItemHandler(internal, 17, 198, 65) {
this.customSlots.put(17, this.addSlot(new SlotItemHandler(internal, 17, 138, 65) {
private final int slot = 17;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
}));
this.customSlots.put(99, this.addSlot(new SlotItemHandler(internal, 99, 183, 29) {
private final int slot = 99;
private int x = MailboxGUIMenu.this.x;
private int y = MailboxGUIMenu.this.y;
@Override
public boolean mayPlace(ItemStack itemstack) {
return !MailboxSlot99ShippingLabelInsertionConditionProcedure.execute(itemstack);
}
}));
for (int si = 0; si < 3; ++si)
for (int sj = 0; sj < 9; ++sj)
this.addSlot(new Slot(inv, sj + (si + 1) * 9, 92 + 8 + sj * 18, 7 + 84 + si * 18));
this.addSlot(new Slot(inv, sj + (si + 1) * 9, 32 + 8 + sj * 18, 7 + 84 + si * 18));
for (int si = 0; si < 9; ++si)
this.addSlot(new Slot(inv, si, 92 + 8 + si * 18, 7 + 142));
this.addSlot(new Slot(inv, si, 32 + 8 + si * 18, 7 + 142));
}
@Override
@@ -239,16 +250,16 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
if (slot != null && slot.hasItem()) {
ItemStack itemstack1 = slot.getItem();
itemstack = itemstack1.copy();
if (index < 18) {
if (!this.moveItemStackTo(itemstack1, 18, this.slots.size(), true))
if (index < 19) {
if (!this.moveItemStackTo(itemstack1, 19, this.slots.size(), true))
return ItemStack.EMPTY;
slot.onQuickCraft(itemstack1, itemstack);
} else if (!this.moveItemStackTo(itemstack1, 0, 18, false)) {
if (index < 18 + 27) {
if (!this.moveItemStackTo(itemstack1, 18 + 27, this.slots.size(), true))
} else if (!this.moveItemStackTo(itemstack1, 0, 19, false)) {
if (index < 19 + 27) {
if (!this.moveItemStackTo(itemstack1, 19 + 27, this.slots.size(), true))
return ItemStack.EMPTY;
} else {
if (!this.moveItemStackTo(itemstack1, 18, 18 + 27, false))
if (!this.moveItemStackTo(itemstack1, 19, 19 + 27, false))
return ItemStack.EMPTY;
}
return ItemStack.EMPTY;
@@ -366,6 +377,8 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
continue;
if (j == 9)
continue;
if (j == 99)
continue;
playerIn.drop(internal.extractItem(j, internal.getStackInSlot(j).getCount(), false), false);
}
} else {
@@ -390,6 +403,8 @@ public class MailboxGUIMenu extends AbstractContainerMenu implements Supplier<Ma
continue;
if (i == 9)
continue;
if (i == 99)
continue;
playerIn.getInventory().placeItemBackInInventory(internal.extractItem(i, internal.getStackInSlot(i).getCount(), false));
}
}

View File

@@ -22,6 +22,7 @@
"item.nims_random_bullshit.sand_dust": "Sand Dust",
"item.nims_random_bullshit.magic_flesh": "Magic Flesh",
"item.nims_random_bullshit.ghoul_spawn_egg": "Ghoul Spawn Egg",
"item.nims_random_bullshit.shipping_label": "Shipping Label",
"item.nims_random_bullshit.block_eater": "Block Eater",
"item.nims_random_bullshit.golden_berries": "Golden Berries",
"item.nims_random_bullshit.netherrack_juice_bucket": "Netherrack Juice Bucket",

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1,23 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"pattern": [
"ab",
"c "
],
"key": {
"a": {
"item": "minecraft:iron_block"
},
"b": {
"item": "minecraft:lever"
},
"c": {
"item": "minecraft:stick"
}
},
"result": {
"item": "nims_random_bullshit:mailbox",
"count": 1
}
}

View File

@@ -0,0 +1,16 @@
{
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"item": "minecraft:paper"
},
{
"item": "minecraft:ink_sac"
}
],
"result": {
"item": "nims_random_bullshit:shipping_label",
"count": 1
}
}