diff --git a/elements/Mailbox.mod.json b/elements/Mailbox.mod.json
index 3f60c35..6f7bdd2 100644
--- a/elements/Mailbox.mod.json
+++ b/elements/Mailbox.mod.json
@@ -132,6 +132,9 @@
"isFluidTank": false,
"fluidCapacity": 8000,
"fluidRestrictions": [],
+ "onBlockPlayedBy": {
+ "name": "MailboxBlockIsPlacedBy"
+ },
"generateFeature": false,
"restrictionBiomes": [],
"blocksToReplace": [
diff --git a/elements/MailboxBlockIsPlacedBy.mod.json b/elements/MailboxBlockIsPlacedBy.mod.json
new file mode 100644
index 0000000..1f43ec3
--- /dev/null
+++ b/elements/MailboxBlockIsPlacedBy.mod.json
@@ -0,0 +1,7 @@
+{
+ "_fv": 73,
+ "_type": "procedure",
+ "definition": {
+ "procedurexml": "no_ext_triggerMailboxNameEntryGUI"
+ }
+}
\ No newline at end of file
diff --git a/elements/MailboxNameEntryButtonPressed.mod.json b/elements/MailboxNameEntryButtonPressed.mod.json
new file mode 100644
index 0000000..c17c2fa
--- /dev/null
+++ b/elements/MailboxNameEntryButtonPressed.mod.json
@@ -0,0 +1,7 @@
+{
+ "_fv": 73,
+ "_type": "procedure",
+ "definition": {
+ "procedurexml": "no_ext_triggermailbox_namemailbox_name_field"
+ }
+}
\ No newline at end of file
diff --git a/elements/MailboxNameEntryGUI.mod.json b/elements/MailboxNameEntryGUI.mod.json
new file mode 100644
index 0000000..0e1510b
--- /dev/null
+++ b/elements/MailboxNameEntryGUI.mod.json
@@ -0,0 +1,69 @@
+{
+ "_fv": 73,
+ "_type": "gui",
+ "definition": {
+ "type": 0,
+ "width": 176,
+ "height": 166,
+ "inventoryOffsetX": 0,
+ "inventoryOffsetY": 0,
+ "renderBgLayer": false,
+ "doesPauseGame": false,
+ "components": [
+ {
+ "type": "label",
+ "data": {
+ "name": "label_mailbox_name",
+ "text": {
+ "fixedValue": "Mailbox Name:"
+ },
+ "color": {
+ "value": -16724839,
+ "falpha": 0.0
+ },
+ "x": 177,
+ "y": 85,
+ "locked": false
+ }
+ },
+ {
+ "type": "textfield",
+ "data": {
+ "placeholder": "",
+ "name": "mailbox_name_field",
+ "width": 120,
+ "height": 20,
+ "x": 155,
+ "y": 98,
+ "locked": false
+ }
+ },
+ {
+ "type": "button",
+ "data": {
+ "name": "button_done",
+ "text": "Done",
+ "isUndecorated": false,
+ "onClick": {
+ "name": "MailboxNameEntryButtonPressed"
+ },
+ "width": 46,
+ "height": 20,
+ "x": 191,
+ "y": 130,
+ "locked": false
+ }
+ }
+ ],
+ "onClosed": {
+ "name": "MailboxNameEntryGUIThisGUIIsClosed"
+ },
+ "gridSettings": {
+ "sx": 9,
+ "sy": 9,
+ "ox": 11,
+ "oy": 15,
+ "snapOnGrid": true
+ }
+ }
+}
\ No newline at end of file
diff --git a/elements/MailboxNameEntryGUIThisGUIIsClosed.mod.json b/elements/MailboxNameEntryGUIThisGUIIsClosed.mod.json
new file mode 100644
index 0000000..7dbc831
--- /dev/null
+++ b/elements/MailboxNameEntryGUIThisGUIIsClosed.mod.json
@@ -0,0 +1,7 @@
+{
+ "_fv": 73,
+ "_type": "procedure",
+ "definition": {
+ "procedurexml": "no_ext_triggermailbox_name_fieldmailbox_nameUnnamedmailbox_namemailbox_name_field"
+ }
+}
\ No newline at end of file
diff --git a/elements/ShippingLabelRightclickedOnBlock.mod.json b/elements/ShippingLabelRightclickedOnBlock.mod.json
index 5781dca..c37228e 100644
--- a/elements/ShippingLabelRightclickedOnBlock.mod.json
+++ b/elements/ShippingLabelRightclickedOnBlock.mod.json
@@ -2,6 +2,6 @@
"_fv": 73,
"_type": "procedure",
"definition": {
- "procedurexml": "no_ext_triggerANDCUSTOM:Mailboxconnected_mailbox_xconnected_mailbox_yconnected_mailbox_zconnectedTRUEentity.player.levelupplayer0.750.951.05"
+ "procedurexml": "no_ext_triggerANDCUSTOM:Mailboxconnected_mailbox_xconnected_mailbox_yconnected_mailbox_zconnectedTRUEmailbox_name's Mailboxentity.player.levelupplayer0.750.951.05"
}
}
\ No newline at end of file
diff --git a/nims_random_bullshit.mcreator b/nims_random_bullshit.mcreator
index de3bd6e..bc23342 100644
--- a/nims_random_bullshit.mcreator
+++ b/nims_random_bullshit.mcreator
@@ -1585,6 +1585,130 @@
]
},
"path": "~/Mailbox"
+ },
+ {
+ "name": "MailboxNameEntryGUI",
+ "type": "gui",
+ "compiles": true,
+ "locked_code": false,
+ "registry_name": "mailbox_name_entry_gui",
+ "metadata": {
+ "files": [
+ "src/main/java/net/mcreator/nimsrandombullshit/world/inventory/MailboxNameEntryGUIMenu.java",
+ "src/main/java/net/mcreator/nimsrandombullshit/client/gui/MailboxNameEntryGUIScreen.java",
+ "src/main/java/net/mcreator/nimsrandombullshit/network/MailboxNameEntryGUIButtonMessage.java"
+ ]
+ },
+ "path": "~/Mailbox"
+ },
+ {
+ "name": "MailboxBlockIsPlacedBy",
+ "type": "procedure",
+ "compiles": true,
+ "locked_code": false,
+ "registry_name": "mailbox_block_is_placed_by",
+ "metadata": {
+ "files": [
+ "src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxBlockIsPlacedByProcedure.java"
+ ],
+ "dependencies": [
+ {
+ "name": "entity",
+ "type": "entity"
+ },
+ {
+ "name": "x",
+ "type": "number"
+ },
+ {
+ "name": "y",
+ "type": "number"
+ },
+ {
+ "name": "z",
+ "type": "number"
+ },
+ {
+ "name": "world",
+ "type": "world"
+ }
+ ]
+ },
+ "path": "~/Mailbox"
+ },
+ {
+ "name": "MailboxNameEntryButtonPressed",
+ "type": "procedure",
+ "compiles": true,
+ "locked_code": false,
+ "registry_name": "mailbox_name_entry_button_pressed",
+ "metadata": {
+ "files": [
+ "src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxNameEntryButtonPressedProcedure.java"
+ ],
+ "dependencies": [
+ {
+ "name": "entity",
+ "type": "entity"
+ },
+ {
+ "name": "guistate",
+ "type": "map"
+ },
+ {
+ "name": "x",
+ "type": "number"
+ },
+ {
+ "name": "y",
+ "type": "number"
+ },
+ {
+ "name": "z",
+ "type": "number"
+ },
+ {
+ "name": "world",
+ "type": "world"
+ }
+ ]
+ },
+ "path": "~/Mailbox"
+ },
+ {
+ "name": "MailboxNameEntryGUIThisGUIIsClosed",
+ "type": "procedure",
+ "compiles": true,
+ "locked_code": false,
+ "registry_name": "mailbox_name_entry_gui_this_gui_is_closed",
+ "metadata": {
+ "files": [
+ "src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxNameEntryGUIThisGUIIsClosedProcedure.java"
+ ],
+ "dependencies": [
+ {
+ "name": "guistate",
+ "type": "map"
+ },
+ {
+ "name": "x",
+ "type": "number"
+ },
+ {
+ "name": "y",
+ "type": "number"
+ },
+ {
+ "name": "z",
+ "type": "number"
+ },
+ {
+ "name": "world",
+ "type": "world"
+ }
+ ]
+ },
+ "path": "~/Mailbox"
}
],
"variable_elements": [],
@@ -1624,6 +1748,7 @@
"item.nims_random_bullshit.gravedigger": "Gravedigger",
"fluid.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
"item.nims_random_bullshit.star_wand": "Star Wand",
+ "gui.nims_random_bullshit.mailbox_name_entry_gui.button_done": "Done",
"block.nims_random_bullshit.quadra_condensed_netherrack": "Quadra-condensed Netherrack",
"gui.nims_random_bullshit.ore_miner_gui.button_mine": "Mine",
"gui.nims_random_bullshit.mailbox_gui.outbox_z_coord": "0",
@@ -1641,6 +1766,7 @@
"block.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
"effect.nims_random_bullshit.summoned_entity_effect": "Summoned Entity",
"item.nims_random_bullshit.sand_dust": "Sand Dust",
+ "gui.nims_random_bullshit.mailbox_name_entry_gui.mailbox_name_field": "",
"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",
@@ -1662,6 +1788,7 @@
"block.nims_random_bullshit.mailbox": "Mailbox",
"gui.nims_random_bullshit.mailbox_gui.button_send": "Send",
"gui.nims_random_bullshit.mailbox_gui.outbox_y_coord": "0",
+ "gui.nims_random_bullshit.mailbox_name_entry_gui.label_mailbox_name": "Mailbox Name:",
"gui.nims_random_bullshit.mailbox_gui.label_inbox": "Inbox",
"item.nims_random_bullshit.netherrackite": "Netherrackite Ingot"
}
diff --git a/src/main/java/net/mcreator/nimsrandombullshit/block/MailboxBlock.java b/src/main/java/net/mcreator/nimsrandombullshit/block/MailboxBlock.java
index 82139de..b98b706 100644
--- a/src/main/java/net/mcreator/nimsrandombullshit/block/MailboxBlock.java
+++ b/src/main/java/net/mcreator/nimsrandombullshit/block/MailboxBlock.java
@@ -21,9 +21,11 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.item.context.BlockPlaceContext;
+import net.minecraft.world.item.ItemStack;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.Inventory;
+import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionHand;
@@ -35,6 +37,7 @@ import net.minecraft.core.Direction;
import net.minecraft.core.BlockPos;
import net.mcreator.nimsrandombullshit.world.inventory.MailboxGUIMenu;
+import net.mcreator.nimsrandombullshit.procedures.MailboxBlockIsPlacedByProcedure;
import net.mcreator.nimsrandombullshit.block.entity.MailboxBlockEntity;
import io.netty.buffer.Unpooled;
@@ -81,6 +84,12 @@ public class MailboxBlock extends Block implements EntityBlock {
return state.rotate(mirrorIn.getRotation(state.getValue(FACING)));
}
+ @Override
+ public void setPlacedBy(Level world, BlockPos pos, BlockState blockstate, LivingEntity entity, ItemStack itemstack) {
+ super.setPlacedBy(world, pos, blockstate, entity, itemstack);
+ MailboxBlockIsPlacedByProcedure.execute(world, pos.getX(), pos.getY(), pos.getZ(), entity);
+ }
+
@Override
public InteractionResult use(BlockState blockstate, Level world, BlockPos pos, Player entity, InteractionHand hand, BlockHitResult hit) {
super.use(blockstate, world, pos, entity, hand, hit);
diff --git a/src/main/java/net/mcreator/nimsrandombullshit/client/gui/MailboxNameEntryGUIScreen.java b/src/main/java/net/mcreator/nimsrandombullshit/client/gui/MailboxNameEntryGUIScreen.java
new file mode 100644
index 0000000..3db5257
--- /dev/null
+++ b/src/main/java/net/mcreator/nimsrandombullshit/client/gui/MailboxNameEntryGUIScreen.java
@@ -0,0 +1,101 @@
+package net.mcreator.nimsrandombullshit.client.gui;
+
+import net.minecraft.world.level.Level;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.entity.player.Inventory;
+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.MailboxNameEntryGUIMenu;
+import net.mcreator.nimsrandombullshit.network.MailboxNameEntryGUIButtonMessage;
+import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
+
+import java.util.HashMap;
+
+import com.mojang.blaze3d.systems.RenderSystem;
+
+public class MailboxNameEntryGUIScreen extends AbstractContainerScreen {
+ private final static HashMap guistate = MailboxNameEntryGUIMenu.guistate;
+ private final Level world;
+ private final int x, y, z;
+ private final Player entity;
+ EditBox mailbox_name_field;
+ Button button_done;
+
+ public MailboxNameEntryGUIScreen(MailboxNameEntryGUIMenu container, Inventory inventory, Component text) {
+ super(container, inventory, text);
+ this.world = container.world;
+ this.x = container.x;
+ this.y = container.y;
+ this.z = container.z;
+ this.entity = container.entity;
+ this.imageWidth = 176;
+ this.imageHeight = 166;
+ }
+
+ @Override
+ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
+ this.renderBackground(guiGraphics);
+ super.render(guiGraphics, mouseX, mouseY, partialTicks);
+ mailbox_name_field.render(guiGraphics, mouseX, mouseY, partialTicks);
+ this.renderTooltip(guiGraphics, mouseX, mouseY);
+ }
+
+ @Override
+ protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int gx, int gy) {
+ RenderSystem.setShaderColor(1, 1, 1, 1);
+ RenderSystem.enableBlend();
+ RenderSystem.defaultBlendFunc();
+ RenderSystem.disableBlend();
+ }
+
+ @Override
+ public boolean keyPressed(int key, int b, int c) {
+ if (key == 256) {
+ this.minecraft.player.closeContainer();
+ return true;
+ }
+ if (mailbox_name_field.isFocused())
+ return mailbox_name_field.keyPressed(key, b, c);
+ return super.keyPressed(key, b, c);
+ }
+
+ @Override
+ public void containerTick() {
+ super.containerTick();
+ mailbox_name_field.tick();
+ }
+
+ @Override
+ public void resize(Minecraft minecraft, int width, int height) {
+ String mailbox_name_fieldValue = mailbox_name_field.getValue();
+ super.resize(minecraft, width, height);
+ mailbox_name_field.setValue(mailbox_name_fieldValue);
+ }
+
+ @Override
+ protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
+ guiGraphics.drawString(this.font, Component.translatable("gui.nims_random_bullshit.mailbox_name_entry_gui.label_mailbox_name"), 51, 48, -16724839, false);
+ }
+
+ @Override
+ public void init() {
+ super.init();
+ mailbox_name_field = new EditBox(this.font, this.leftPos + 30, this.topPos + 62, 118, 18, Component.translatable("gui.nims_random_bullshit.mailbox_name_entry_gui.mailbox_name_field"));
+ mailbox_name_field.setMaxLength(32767);
+ guistate.put("text:mailbox_name_field", mailbox_name_field);
+ this.addWidget(this.mailbox_name_field);
+ button_done = Button.builder(Component.translatable("gui.nims_random_bullshit.mailbox_name_entry_gui.button_done"), e -> {
+ if (true) {
+ NimsRandomBullshitMod.PACKET_HANDLER.sendToServer(new MailboxNameEntryGUIButtonMessage(0, x, y, z));
+ MailboxNameEntryGUIButtonMessage.handleButtonAction(entity, 0, x, y, z);
+ }
+ }).bounds(this.leftPos + 65, this.topPos + 93, 46, 20).build();
+ guistate.put("button:button_done", button_done);
+ this.addRenderableWidget(button_done);
+ }
+}
diff --git a/src/main/java/net/mcreator/nimsrandombullshit/init/NimsRandomBullshitModMenus.java b/src/main/java/net/mcreator/nimsrandombullshit/init/NimsRandomBullshitModMenus.java
index f3defcd..edbbc14 100644
--- a/src/main/java/net/mcreator/nimsrandombullshit/init/NimsRandomBullshitModMenus.java
+++ b/src/main/java/net/mcreator/nimsrandombullshit/init/NimsRandomBullshitModMenus.java
@@ -13,6 +13,7 @@ import net.minecraft.world.inventory.MenuType;
import net.mcreator.nimsrandombullshit.world.inventory.ShitGUIMenu;
import net.mcreator.nimsrandombullshit.world.inventory.OreMinerGUIMenu;
+import net.mcreator.nimsrandombullshit.world.inventory.MailboxNameEntryGUIMenu;
import net.mcreator.nimsrandombullshit.world.inventory.MailboxGUIMenu;
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
@@ -21,4 +22,5 @@ public class NimsRandomBullshitModMenus {
public static final RegistryObject> SHIT_GUI = REGISTRY.register("shit_gui", () -> IForgeMenuType.create(ShitGUIMenu::new));
public static final RegistryObject> ORE_MINER_GUI = REGISTRY.register("ore_miner_gui", () -> IForgeMenuType.create(OreMinerGUIMenu::new));
public static final RegistryObject> MAILBOX_GUI = REGISTRY.register("mailbox_gui", () -> IForgeMenuType.create(MailboxGUIMenu::new));
+ public static final RegistryObject> MAILBOX_NAME_ENTRY_GUI = REGISTRY.register("mailbox_name_entry_gui", () -> IForgeMenuType.create(MailboxNameEntryGUIMenu::new));
}
diff --git a/src/main/java/net/mcreator/nimsrandombullshit/init/NimsRandomBullshitModScreens.java b/src/main/java/net/mcreator/nimsrandombullshit/init/NimsRandomBullshitModScreens.java
index 80ac408..100ab7c 100644
--- a/src/main/java/net/mcreator/nimsrandombullshit/init/NimsRandomBullshitModScreens.java
+++ b/src/main/java/net/mcreator/nimsrandombullshit/init/NimsRandomBullshitModScreens.java
@@ -13,6 +13,7 @@ import net.minecraft.client.gui.screens.MenuScreens;
import net.mcreator.nimsrandombullshit.client.gui.ShitGUIScreen;
import net.mcreator.nimsrandombullshit.client.gui.OreMinerGUIScreen;
+import net.mcreator.nimsrandombullshit.client.gui.MailboxNameEntryGUIScreen;
import net.mcreator.nimsrandombullshit.client.gui.MailboxGUIScreen;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
@@ -23,6 +24,7 @@ public class NimsRandomBullshitModScreens {
MenuScreens.register(NimsRandomBullshitModMenus.SHIT_GUI.get(), ShitGUIScreen::new);
MenuScreens.register(NimsRandomBullshitModMenus.ORE_MINER_GUI.get(), OreMinerGUIScreen::new);
MenuScreens.register(NimsRandomBullshitModMenus.MAILBOX_GUI.get(), MailboxGUIScreen::new);
+ MenuScreens.register(NimsRandomBullshitModMenus.MAILBOX_NAME_ENTRY_GUI.get(), MailboxNameEntryGUIScreen::new);
});
}
}
diff --git a/src/main/java/net/mcreator/nimsrandombullshit/network/MailboxNameEntryGUIButtonMessage.java b/src/main/java/net/mcreator/nimsrandombullshit/network/MailboxNameEntryGUIButtonMessage.java
new file mode 100644
index 0000000..657c7e4
--- /dev/null
+++ b/src/main/java/net/mcreator/nimsrandombullshit/network/MailboxNameEntryGUIButtonMessage.java
@@ -0,0 +1,75 @@
+
+package net.mcreator.nimsrandombullshit.network;
+
+import net.minecraftforge.network.NetworkEvent;
+import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
+import net.minecraftforge.fml.common.Mod;
+import net.minecraftforge.eventbus.api.SubscribeEvent;
+
+import net.minecraft.world.level.Level;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.core.BlockPos;
+
+import net.mcreator.nimsrandombullshit.world.inventory.MailboxNameEntryGUIMenu;
+import net.mcreator.nimsrandombullshit.procedures.MailboxNameEntryButtonPressedProcedure;
+import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
+
+import java.util.function.Supplier;
+import java.util.HashMap;
+
+@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
+public class MailboxNameEntryGUIButtonMessage {
+ private final int buttonID, x, y, z;
+
+ public MailboxNameEntryGUIButtonMessage(FriendlyByteBuf buffer) {
+ this.buttonID = buffer.readInt();
+ this.x = buffer.readInt();
+ this.y = buffer.readInt();
+ this.z = buffer.readInt();
+ }
+
+ public MailboxNameEntryGUIButtonMessage(int buttonID, int x, int y, int z) {
+ this.buttonID = buttonID;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public static void buffer(MailboxNameEntryGUIButtonMessage message, FriendlyByteBuf buffer) {
+ buffer.writeInt(message.buttonID);
+ buffer.writeInt(message.x);
+ buffer.writeInt(message.y);
+ buffer.writeInt(message.z);
+ }
+
+ public static void handler(MailboxNameEntryGUIButtonMessage message, Supplier contextSupplier) {
+ NetworkEvent.Context context = contextSupplier.get();
+ context.enqueueWork(() -> {
+ Player entity = context.getSender();
+ int buttonID = message.buttonID;
+ int x = message.x;
+ int y = message.y;
+ int z = message.z;
+ handleButtonAction(entity, buttonID, x, y, z);
+ });
+ context.setPacketHandled(true);
+ }
+
+ public static void handleButtonAction(Player entity, int buttonID, int x, int y, int z) {
+ Level world = entity.level();
+ HashMap guistate = MailboxNameEntryGUIMenu.guistate;
+ // security measure to prevent arbitrary chunk generation
+ if (!world.hasChunkAt(new BlockPos(x, y, z)))
+ return;
+ if (buttonID == 0) {
+
+ MailboxNameEntryButtonPressedProcedure.execute(world, x, y, z, entity, guistate);
+ }
+ }
+
+ @SubscribeEvent
+ public static void registerMessage(FMLCommonSetupEvent event) {
+ NimsRandomBullshitMod.addNetworkMessage(MailboxNameEntryGUIButtonMessage.class, MailboxNameEntryGUIButtonMessage::buffer, MailboxNameEntryGUIButtonMessage::new, MailboxNameEntryGUIButtonMessage::handler);
+ }
+}
diff --git a/src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxBlockIsPlacedByProcedure.java b/src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxBlockIsPlacedByProcedure.java
new file mode 100644
index 0000000..a3b1c76
--- /dev/null
+++ b/src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxBlockIsPlacedByProcedure.java
@@ -0,0 +1,41 @@
+package net.mcreator.nimsrandombullshit.procedures;
+
+import net.minecraftforge.network.NetworkHooks;
+
+import net.minecraft.world.level.LevelAccessor;
+import net.minecraft.world.inventory.AbstractContainerMenu;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.entity.player.Inventory;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.MenuProvider;
+import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.core.BlockPos;
+
+import net.mcreator.nimsrandombullshit.world.inventory.MailboxNameEntryGUIMenu;
+
+import io.netty.buffer.Unpooled;
+
+public class MailboxBlockIsPlacedByProcedure {
+ public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
+ if (entity == null)
+ return;
+ if (!world.isClientSide()) {
+ if (entity instanceof ServerPlayer _ent) {
+ BlockPos _bpos = BlockPos.containing(x, y, z);
+ NetworkHooks.openScreen((ServerPlayer) _ent, new MenuProvider() {
+ @Override
+ public Component getDisplayName() {
+ return Component.literal("MailboxNameEntryGUI");
+ }
+
+ @Override
+ public AbstractContainerMenu createMenu(int id, Inventory inventory, Player player) {
+ return new MailboxNameEntryGUIMenu(id, inventory, new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(_bpos));
+ }
+ }, _bpos);
+ }
+ }
+ }
+}
diff --git a/src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxNameEntryButtonPressedProcedure.java b/src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxNameEntryButtonPressedProcedure.java
new file mode 100644
index 0000000..57a3bd4
--- /dev/null
+++ b/src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxNameEntryButtonPressedProcedure.java
@@ -0,0 +1,32 @@
+package net.mcreator.nimsrandombullshit.procedures;
+
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.block.entity.BlockEntity;
+import net.minecraft.world.level.LevelAccessor;
+import net.minecraft.world.level.Level;
+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 java.util.HashMap;
+
+public class MailboxNameEntryButtonPressedProcedure {
+ public static void execute(LevelAccessor world, double x, double y, double z, Entity entity, HashMap guistate) {
+ if (entity == null || guistate == null)
+ return;
+ 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().putString("mailbox_name", (guistate.containsKey("text:mailbox_name_field") ? ((EditBox) guistate.get("text:mailbox_name_field")).getValue() : ""));
+ if (world instanceof Level _level)
+ _level.sendBlockUpdated(_bp, _bs, _bs, 3);
+ }
+ if (entity instanceof Player _player)
+ _player.closeContainer();
+ }
+ }
+}
diff --git a/src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxNameEntryGUIThisGUIIsClosedProcedure.java b/src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxNameEntryGUIThisGUIIsClosedProcedure.java
new file mode 100644
index 0000000..4c60b12
--- /dev/null
+++ b/src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxNameEntryGUIThisGUIIsClosedProcedure.java
@@ -0,0 +1,40 @@
+package net.mcreator.nimsrandombullshit.procedures;
+
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.block.entity.BlockEntity;
+import net.minecraft.world.level.LevelAccessor;
+import net.minecraft.world.level.Level;
+import net.minecraft.core.BlockPos;
+import net.minecraft.client.gui.components.EditBox;
+
+import java.util.HashMap;
+
+public class MailboxNameEntryGUIThisGUIIsClosedProcedure {
+ public static void execute(LevelAccessor world, double x, double y, double z, HashMap guistate) {
+ if (guistate == null)
+ return;
+ if (!world.isClientSide()) {
+ if ((guistate.containsKey("text:mailbox_name_field") ? ((EditBox) guistate.get("text:mailbox_name_field")).getValue() : "").equals("")) {
+ 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().putString("mailbox_name", "Unnamed");
+ if (world instanceof Level _level)
+ _level.sendBlockUpdated(_bp, _bs, _bs, 3);
+ }
+ } else {
+ 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().putString("mailbox_name", (guistate.containsKey("text:mailbox_name_field") ? ((EditBox) guistate.get("text:mailbox_name_field")).getValue() : ""));
+ if (world instanceof Level _level)
+ _level.sendBlockUpdated(_bp, _bs, _bs, 3);
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/net/mcreator/nimsrandombullshit/procedures/ShippingLabelRightclickedOnBlockProcedure.java b/src/main/java/net/mcreator/nimsrandombullshit/procedures/ShippingLabelRightclickedOnBlockProcedure.java
index 9bd6951..d8df588 100644
--- a/src/main/java/net/mcreator/nimsrandombullshit/procedures/ShippingLabelRightclickedOnBlockProcedure.java
+++ b/src/main/java/net/mcreator/nimsrandombullshit/procedures/ShippingLabelRightclickedOnBlockProcedure.java
@@ -3,6 +3,7 @@ package net.mcreator.nimsrandombullshit.procedures;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.Level;
import net.minecraft.world.item.ItemStack;
@@ -11,6 +12,7 @@ import net.minecraft.util.RandomSource;
import net.minecraft.util.Mth;
import net.minecraft.sounds.SoundSource;
import net.minecraft.resources.ResourceLocation;
+import net.minecraft.network.chat.Component;
import net.minecraft.core.BlockPos;
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModBlocks;
@@ -25,6 +27,14 @@ public class ShippingLabelRightclickedOnBlockProcedure {
itemstack.getOrCreateTag().putDouble("connected_mailbox_y", y);
itemstack.getOrCreateTag().putDouble("connected_mailbox_z", z);
itemstack.getOrCreateTag().putBoolean("connected", true);
+ itemstack.setHoverName(Component.literal(((new Object() {
+ public String getValue(LevelAccessor world, BlockPos pos, String tag) {
+ BlockEntity blockEntity = world.getBlockEntity(pos);
+ if (blockEntity != null)
+ return blockEntity.getPersistentData().getString(tag);
+ return "";
+ }
+ }.getValue(world, BlockPos.containing(x, y, z), "mailbox_name")) + "'s Mailbox")));
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,
diff --git a/src/main/java/net/mcreator/nimsrandombullshit/world/inventory/MailboxNameEntryGUIMenu.java b/src/main/java/net/mcreator/nimsrandombullshit/world/inventory/MailboxNameEntryGUIMenu.java
new file mode 100644
index 0000000..dd5dc88
--- /dev/null
+++ b/src/main/java/net/mcreator/nimsrandombullshit/world/inventory/MailboxNameEntryGUIMenu.java
@@ -0,0 +1,81 @@
+
+package net.mcreator.nimsrandombullshit.world.inventory;
+
+import net.minecraftforge.items.ItemStackHandler;
+import net.minecraftforge.items.IItemHandler;
+
+import net.minecraft.world.level.block.entity.BlockEntity;
+import net.minecraft.world.level.Level;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.inventory.Slot;
+import net.minecraft.world.inventory.ContainerLevelAccess;
+import net.minecraft.world.inventory.AbstractContainerMenu;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.entity.player.Inventory;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.core.BlockPos;
+
+import net.mcreator.nimsrandombullshit.procedures.MailboxNameEntryGUIThisGUIIsClosedProcedure;
+import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModMenus;
+
+import java.util.function.Supplier;
+import java.util.Map;
+import java.util.HashMap;
+
+public class MailboxNameEntryGUIMenu extends AbstractContainerMenu implements Supplier