mirror of
https://github.com/nimsolated/Nims-Random-BS.git
synced 2026-04-02 10:20:42 -07:00
feature: add mailbox naming for shipping labels
This commit is contained in:
@@ -132,6 +132,9 @@
|
|||||||
"isFluidTank": false,
|
"isFluidTank": false,
|
||||||
"fluidCapacity": 8000,
|
"fluidCapacity": 8000,
|
||||||
"fluidRestrictions": [],
|
"fluidRestrictions": [],
|
||||||
|
"onBlockPlayedBy": {
|
||||||
|
"name": "MailboxBlockIsPlacedBy"
|
||||||
|
},
|
||||||
"generateFeature": false,
|
"generateFeature": false,
|
||||||
"restrictionBiomes": [],
|
"restrictionBiomes": [],
|
||||||
"blocksToReplace": [
|
"blocksToReplace": [
|
||||||
|
|||||||
7
elements/MailboxBlockIsPlacedBy.mod.json
Normal file
7
elements/MailboxBlockIsPlacedBy.mod.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"_fv": 73,
|
||||||
|
"_type": "procedure",
|
||||||
|
"definition": {
|
||||||
|
"procedurexml": "<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"event_trigger\" deletable=\"false\" x=\"158\" y=\"139\"><field name=\"trigger\">no_ext_trigger</field><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_negate\"><value name=\"BOOL\"><block type=\"world_data_isremote\"></block></value></block></value><statement name=\"DO0\"><block type=\"entity_open_gui\"><field name=\"guiname\">MailboxNameEntryGUI</field><value name=\"entity\"><block type=\"entity_from_deps\"></block></value><value name=\"x\"><block type=\"coord_x\"></block></value><value name=\"y\"><block type=\"coord_y\"></block></value><value name=\"z\"><block type=\"coord_z\"></block></value></block></statement></block></next></block></xml>"
|
||||||
|
}
|
||||||
|
}
|
||||||
7
elements/MailboxNameEntryButtonPressed.mod.json
Normal file
7
elements/MailboxNameEntryButtonPressed.mod.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"_fv": 73,
|
||||||
|
"_type": "procedure",
|
||||||
|
"definition": {
|
||||||
|
"procedurexml": "<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"event_trigger\" deletable=\"false\" x=\"40\" y=\"40\"><field name=\"trigger\">no_ext_trigger</field><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_negate\"><value name=\"BOOL\"><block type=\"world_data_isremote\"></block></value></block></value><statement name=\"DO0\"><block type=\"block_nbt_text_set\"><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">mailbox_name</field></block></value><value name=\"x\"><block type=\"coord_x\"></block></value><value name=\"y\"><block type=\"coord_y\"></block></value><value name=\"z\"><block type=\"coord_z\"></block></value><value name=\"tagValue\"><block type=\"gui_get_text_textfield\"><field name=\"textfield\">mailbox_name_field</field></block></value><next><block type=\"entity_close_gui\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></next></block></statement></block></next></block></xml>"
|
||||||
|
}
|
||||||
|
}
|
||||||
69
elements/MailboxNameEntryGUI.mod.json
Normal file
69
elements/MailboxNameEntryGUI.mod.json
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
elements/MailboxNameEntryGUIThisGUIIsClosed.mod.json
Normal file
7
elements/MailboxNameEntryGUIThisGUIIsClosed.mod.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"_fv": 73,
|
||||||
|
"_type": "procedure",
|
||||||
|
"definition": {
|
||||||
|
"procedurexml": "<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"event_trigger\" deletable=\"false\" x=\"200\" y=\"161\"><field name=\"trigger\">no_ext_trigger</field><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_negate\"><value name=\"BOOL\"><block type=\"world_data_isremote\"></block></value></block></value><statement name=\"DO0\"><block type=\"controls_if\"><mutation else=\"1\"></mutation><value name=\"IF0\"><block type=\"text_binary_ops\"><value name=\"A\"><block type=\"gui_get_text_textfield\"><field name=\"textfield\">mailbox_name_field</field></block></value><value name=\"B\"><block type=\"text\"><field name=\"TEXT\"></field></block></value></block></value><statement name=\"DO0\"><block type=\"block_nbt_text_set\"><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">mailbox_name</field></block></value><value name=\"x\"><block type=\"coord_x\"></block></value><value name=\"y\"><block type=\"coord_y\"></block></value><value name=\"z\"><block type=\"coord_z\"></block></value><value name=\"tagValue\"><block type=\"text\"><field name=\"TEXT\">Unnamed</field></block></value></block></statement><statement name=\"ELSE\"><block type=\"block_nbt_text_set\"><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">mailbox_name</field></block></value><value name=\"x\"><block type=\"coord_x\"></block></value><value name=\"y\"><block type=\"coord_y\"></block></value><value name=\"z\"><block type=\"coord_z\"></block></value><value name=\"tagValue\"><block type=\"gui_get_text_textfield\"><field name=\"textfield\">mailbox_name_field</field></block></value></block></statement></block></statement></block></next></block></xml>"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,6 @@
|
|||||||
"_fv": 73,
|
"_fv": 73,
|
||||||
"_type": "procedure",
|
"_type": "procedure",
|
||||||
"definition": {
|
"definition": {
|
||||||
"procedurexml": "<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"event_trigger\" deletable=\"false\" x=\"40\" y=\"40\"><field name=\"trigger\">no_ext_trigger</field><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_negate\"><value name=\"BOOL\"><block type=\"world_data_isremote\"></block></value></block></value><statement name=\"DO0\"><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_binary_ops\" inline=\"false\"><field name=\"OP\">AND</field><value name=\"A\"><block type=\"compare_mcblocks\"><value name=\"a\"><block type=\"blockstate_from_deps\"></block></value><value name=\"b\"><block type=\"mcitem_allblocks\"><field name=\"value\">CUSTOM:Mailbox</field></block></value></block></value><value name=\"B\"><block type=\"entity_issneaking\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value></block></value><statement name=\"DO0\"><block type=\"item_nbt_num_set\"><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">connected_mailbox_x</field></block></value><value name=\"item\"><block type=\"itemstack_to_mcitem\"></block></value><value name=\"tagValue\"><block type=\"coord_x\"></block></value><next><block type=\"item_nbt_num_set\"><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">connected_mailbox_y</field></block></value><value name=\"item\"><block type=\"itemstack_to_mcitem\"></block></value><value name=\"tagValue\"><block type=\"coord_y\"></block></value><next><block type=\"item_nbt_num_set\"><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">connected_mailbox_z</field></block></value><value name=\"item\"><block type=\"itemstack_to_mcitem\"></block></value><value name=\"tagValue\"><block type=\"coord_z\"></block></value><next><block type=\"item_nbt_logic_set\"><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">connected</field></block></value><value name=\"item\"><block type=\"itemstack_to_mcitem\"></block></value><value name=\"tagValue\"><block type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></block></value><next><block type=\"play_sound\"><field name=\"sound\">entity.player.levelup</field><field name=\"soundcategory\">player</field><value name=\"x\"><block type=\"coord_x\"></block></value><value name=\"y\"><block type=\"coord_y\"></block></value><value name=\"z\"><block type=\"coord_z\"></block></value><value name=\"level\"><block type=\"math_number\"><field name=\"NUM\">0.75</field></block></value><value name=\"pitch\"><block type=\"math_random_number_between\"><value name=\"min\"><block type=\"math_number\"><field name=\"NUM\">0.95</field></block></value><value name=\"max\"><block type=\"math_number\"><field name=\"NUM\">1.05</field></block></value></block></value></block></next></block></next></block></next></block></next></block></statement></block></statement></block></next></block></xml>"
|
"procedurexml": "<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"event_trigger\" deletable=\"false\" x=\"40\" y=\"40\"><field name=\"trigger\">no_ext_trigger</field><next><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_negate\"><value name=\"BOOL\"><block type=\"world_data_isremote\"></block></value></block></value><statement name=\"DO0\"><block type=\"controls_if\"><value name=\"IF0\"><block type=\"logic_binary_ops\" inline=\"false\"><field name=\"OP\">AND</field><value name=\"A\"><block type=\"compare_mcblocks\"><value name=\"a\"><block type=\"blockstate_from_deps\"></block></value><value name=\"b\"><block type=\"mcitem_allblocks\"><field name=\"value\">CUSTOM:Mailbox</field></block></value></block></value><value name=\"B\"><block type=\"entity_issneaking\"><value name=\"entity\"><block type=\"entity_from_deps\"></block></value></block></value></block></value><statement name=\"DO0\"><block type=\"item_nbt_num_set\"><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">connected_mailbox_x</field></block></value><value name=\"item\"><block type=\"itemstack_to_mcitem\"></block></value><value name=\"tagValue\"><block type=\"coord_x\"></block></value><next><block type=\"item_nbt_num_set\"><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">connected_mailbox_y</field></block></value><value name=\"item\"><block type=\"itemstack_to_mcitem\"></block></value><value name=\"tagValue\"><block type=\"coord_y\"></block></value><next><block type=\"item_nbt_num_set\"><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">connected_mailbox_z</field></block></value><value name=\"item\"><block type=\"itemstack_to_mcitem\"></block></value><value name=\"tagValue\"><block type=\"coord_z\"></block></value><next><block type=\"item_nbt_logic_set\"><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">connected</field></block></value><value name=\"item\"><block type=\"itemstack_to_mcitem\"></block></value><value name=\"tagValue\"><block type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></block></value><next><block type=\"item_set_display_name\"><value name=\"item\"><block type=\"itemstack_to_mcitem\"></block></value><value name=\"displayname\"><block type=\"text_join\"><mutation items=\"2\"></mutation><value name=\"ADD0\"><block type=\"block_nbt_text_get\"><value name=\"tagName\"><block type=\"text\"><field name=\"TEXT\">mailbox_name</field></block></value><value name=\"x\"><block type=\"coord_x\"></block></value><value name=\"y\"><block type=\"coord_y\"></block></value><value name=\"z\"><block type=\"coord_z\"></block></value></block></value><value name=\"ADD1\"><block type=\"text\"><field name=\"TEXT\">'s Mailbox</field></block></value></block></value><next><block type=\"play_sound\"><field name=\"sound\">entity.player.levelup</field><field name=\"soundcategory\">player</field><value name=\"x\"><block type=\"coord_x\"></block></value><value name=\"y\"><block type=\"coord_y\"></block></value><value name=\"z\"><block type=\"coord_z\"></block></value><value name=\"level\"><block type=\"math_number\"><field name=\"NUM\">0.75</field></block></value><value name=\"pitch\"><block type=\"math_random_number_between\"><value name=\"min\"><block type=\"math_number\"><field name=\"NUM\">0.95</field></block></value><value name=\"max\"><block type=\"math_number\"><field name=\"NUM\">1.05</field></block></value></block></value></block></next></block></next></block></next></block></next></block></next></block></statement></block></statement></block></next></block></xml>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1585,6 +1585,130 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"path": "~/Mailbox"
|
"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": [],
|
"variable_elements": [],
|
||||||
@@ -1624,6 +1748,7 @@
|
|||||||
"item.nims_random_bullshit.gravedigger": "Gravedigger",
|
"item.nims_random_bullshit.gravedigger": "Gravedigger",
|
||||||
"fluid.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
|
"fluid.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
|
||||||
"item.nims_random_bullshit.star_wand": "Star Wand",
|
"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",
|
"block.nims_random_bullshit.quadra_condensed_netherrack": "Quadra-condensed Netherrack",
|
||||||
"gui.nims_random_bullshit.ore_miner_gui.button_mine": "Mine",
|
"gui.nims_random_bullshit.ore_miner_gui.button_mine": "Mine",
|
||||||
"gui.nims_random_bullshit.mailbox_gui.outbox_z_coord": "0",
|
"gui.nims_random_bullshit.mailbox_gui.outbox_z_coord": "0",
|
||||||
@@ -1641,6 +1766,7 @@
|
|||||||
"block.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
|
"block.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
|
||||||
"effect.nims_random_bullshit.summoned_entity_effect": "Summoned Entity",
|
"effect.nims_random_bullshit.summoned_entity_effect": "Summoned Entity",
|
||||||
"item.nims_random_bullshit.sand_dust": "Sand Dust",
|
"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.magic_flesh": "Magic Flesh",
|
||||||
"item.nims_random_bullshit.ghoul_spawn_egg": "Ghoul Spawn Egg",
|
"item.nims_random_bullshit.ghoul_spawn_egg": "Ghoul Spawn Egg",
|
||||||
"item.nims_random_bullshit.shipping_label": "Shipping Label",
|
"item.nims_random_bullshit.shipping_label": "Shipping Label",
|
||||||
@@ -1662,6 +1788,7 @@
|
|||||||
"block.nims_random_bullshit.mailbox": "Mailbox",
|
"block.nims_random_bullshit.mailbox": "Mailbox",
|
||||||
"gui.nims_random_bullshit.mailbox_gui.button_send": "Send",
|
"gui.nims_random_bullshit.mailbox_gui.button_send": "Send",
|
||||||
"gui.nims_random_bullshit.mailbox_gui.outbox_y_coord": "0",
|
"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",
|
"gui.nims_random_bullshit.mailbox_gui.label_inbox": "Inbox",
|
||||||
"item.nims_random_bullshit.netherrackite": "Netherrackite Ingot"
|
"item.nims_random_bullshit.netherrackite": "Netherrackite Ingot"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,11 @@ import net.minecraft.world.level.block.Block;
|
|||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
@@ -35,6 +37,7 @@ import net.minecraft.core.Direction;
|
|||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
import net.mcreator.nimsrandombullshit.world.inventory.MailboxGUIMenu;
|
import net.mcreator.nimsrandombullshit.world.inventory.MailboxGUIMenu;
|
||||||
|
import net.mcreator.nimsrandombullshit.procedures.MailboxBlockIsPlacedByProcedure;
|
||||||
import net.mcreator.nimsrandombullshit.block.entity.MailboxBlockEntity;
|
import net.mcreator.nimsrandombullshit.block.entity.MailboxBlockEntity;
|
||||||
|
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
@@ -81,6 +84,12 @@ public class MailboxBlock extends Block implements EntityBlock {
|
|||||||
return state.rotate(mirrorIn.getRotation(state.getValue(FACING)));
|
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
|
@Override
|
||||||
public InteractionResult use(BlockState blockstate, Level world, BlockPos pos, Player entity, InteractionHand hand, BlockHitResult hit) {
|
public InteractionResult use(BlockState blockstate, Level world, BlockPos pos, Player entity, InteractionHand hand, BlockHitResult hit) {
|
||||||
super.use(blockstate, world, pos, entity, hand, hit);
|
super.use(blockstate, world, pos, entity, hand, hit);
|
||||||
|
|||||||
@@ -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<MailboxNameEntryGUIMenu> {
|
||||||
|
private final static HashMap<String, Object> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import net.minecraft.world.inventory.MenuType;
|
|||||||
|
|
||||||
import net.mcreator.nimsrandombullshit.world.inventory.ShitGUIMenu;
|
import net.mcreator.nimsrandombullshit.world.inventory.ShitGUIMenu;
|
||||||
import net.mcreator.nimsrandombullshit.world.inventory.OreMinerGUIMenu;
|
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.world.inventory.MailboxGUIMenu;
|
||||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||||
|
|
||||||
@@ -21,4 +22,5 @@ public class NimsRandomBullshitModMenus {
|
|||||||
public static final RegistryObject<MenuType<ShitGUIMenu>> SHIT_GUI = REGISTRY.register("shit_gui", () -> IForgeMenuType.create(ShitGUIMenu::new));
|
public static final RegistryObject<MenuType<ShitGUIMenu>> SHIT_GUI = REGISTRY.register("shit_gui", () -> IForgeMenuType.create(ShitGUIMenu::new));
|
||||||
public static final RegistryObject<MenuType<OreMinerGUIMenu>> ORE_MINER_GUI = REGISTRY.register("ore_miner_gui", () -> IForgeMenuType.create(OreMinerGUIMenu::new));
|
public static final RegistryObject<MenuType<OreMinerGUIMenu>> ORE_MINER_GUI = REGISTRY.register("ore_miner_gui", () -> IForgeMenuType.create(OreMinerGUIMenu::new));
|
||||||
public static final RegistryObject<MenuType<MailboxGUIMenu>> MAILBOX_GUI = REGISTRY.register("mailbox_gui", () -> IForgeMenuType.create(MailboxGUIMenu::new));
|
public static final RegistryObject<MenuType<MailboxGUIMenu>> MAILBOX_GUI = REGISTRY.register("mailbox_gui", () -> IForgeMenuType.create(MailboxGUIMenu::new));
|
||||||
|
public static final RegistryObject<MenuType<MailboxNameEntryGUIMenu>> MAILBOX_NAME_ENTRY_GUI = REGISTRY.register("mailbox_name_entry_gui", () -> IForgeMenuType.create(MailboxNameEntryGUIMenu::new));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import net.minecraft.client.gui.screens.MenuScreens;
|
|||||||
|
|
||||||
import net.mcreator.nimsrandombullshit.client.gui.ShitGUIScreen;
|
import net.mcreator.nimsrandombullshit.client.gui.ShitGUIScreen;
|
||||||
import net.mcreator.nimsrandombullshit.client.gui.OreMinerGUIScreen;
|
import net.mcreator.nimsrandombullshit.client.gui.OreMinerGUIScreen;
|
||||||
|
import net.mcreator.nimsrandombullshit.client.gui.MailboxNameEntryGUIScreen;
|
||||||
import net.mcreator.nimsrandombullshit.client.gui.MailboxGUIScreen;
|
import net.mcreator.nimsrandombullshit.client.gui.MailboxGUIScreen;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
@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.SHIT_GUI.get(), ShitGUIScreen::new);
|
||||||
MenuScreens.register(NimsRandomBullshitModMenus.ORE_MINER_GUI.get(), OreMinerGUIScreen::new);
|
MenuScreens.register(NimsRandomBullshitModMenus.ORE_MINER_GUI.get(), OreMinerGUIScreen::new);
|
||||||
MenuScreens.register(NimsRandomBullshitModMenus.MAILBOX_GUI.get(), MailboxGUIScreen::new);
|
MenuScreens.register(NimsRandomBullshitModMenus.MAILBOX_GUI.get(), MailboxGUIScreen::new);
|
||||||
|
MenuScreens.register(NimsRandomBullshitModMenus.MAILBOX_NAME_ENTRY_GUI.get(), MailboxNameEntryGUIScreen::new);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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<NetworkEvent.Context> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package net.mcreator.nimsrandombullshit.procedures;
|
|||||||
import net.minecraftforge.registries.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
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.LevelAccessor;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@@ -11,6 +12,7 @@ import net.minecraft.util.RandomSource;
|
|||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModBlocks;
|
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_y", y);
|
||||||
itemstack.getOrCreateTag().putDouble("connected_mailbox_z", z);
|
itemstack.getOrCreateTag().putDouble("connected_mailbox_z", z);
|
||||||
itemstack.getOrCreateTag().putBoolean("connected", true);
|
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 (world instanceof Level _level) {
|
||||||
if (!_level.isClientSide()) {
|
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,
|
_level.playSound(null, BlockPos.containing(x, y, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.player.levelup")), SoundSource.PLAYERS, (float) 0.75,
|
||||||
|
|||||||
@@ -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<Map<Integer, Slot>> {
|
||||||
|
public final static HashMap<String, Object> guistate = new HashMap<>();
|
||||||
|
public final Level world;
|
||||||
|
public final Player entity;
|
||||||
|
public int x, y, z;
|
||||||
|
private ContainerLevelAccess access = ContainerLevelAccess.NULL;
|
||||||
|
private IItemHandler internal;
|
||||||
|
private final Map<Integer, Slot> customSlots = new HashMap<>();
|
||||||
|
private boolean bound = false;
|
||||||
|
private Supplier<Boolean> boundItemMatcher = null;
|
||||||
|
private Entity boundEntity = null;
|
||||||
|
private BlockEntity boundBlockEntity = null;
|
||||||
|
|
||||||
|
public MailboxNameEntryGUIMenu(int id, Inventory inv, FriendlyByteBuf extraData) {
|
||||||
|
super(NimsRandomBullshitModMenus.MAILBOX_NAME_ENTRY_GUI.get(), id);
|
||||||
|
this.entity = inv.player;
|
||||||
|
this.world = inv.player.level();
|
||||||
|
this.internal = new ItemStackHandler(0);
|
||||||
|
BlockPos pos = null;
|
||||||
|
if (extraData != null) {
|
||||||
|
pos = extraData.readBlockPos();
|
||||||
|
this.x = pos.getX();
|
||||||
|
this.y = pos.getY();
|
||||||
|
this.z = pos.getZ();
|
||||||
|
access = ContainerLevelAccess.create(world, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stillValid(Player player) {
|
||||||
|
if (this.bound) {
|
||||||
|
if (this.boundItemMatcher != null)
|
||||||
|
return this.boundItemMatcher.get();
|
||||||
|
else if (this.boundBlockEntity != null)
|
||||||
|
return AbstractContainerMenu.stillValid(this.access, player, this.boundBlockEntity.getBlockState().getBlock());
|
||||||
|
else if (this.boundEntity != null)
|
||||||
|
return this.boundEntity.isAlive();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removed(Player playerIn) {
|
||||||
|
super.removed(playerIn);
|
||||||
|
MailboxNameEntryGUIThisGUIIsClosedProcedure.execute(world, x, y, z, guistate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, Slot> get() {
|
||||||
|
return customSlots;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
"item.nims_random_bullshit.gravedigger": "Gravedigger",
|
"item.nims_random_bullshit.gravedigger": "Gravedigger",
|
||||||
"fluid.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
|
"fluid.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
|
||||||
"item.nims_random_bullshit.star_wand": "Star Wand",
|
"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",
|
"block.nims_random_bullshit.quadra_condensed_netherrack": "Quadra-condensed Netherrack",
|
||||||
"gui.nims_random_bullshit.ore_miner_gui.button_mine": "Mine",
|
"gui.nims_random_bullshit.ore_miner_gui.button_mine": "Mine",
|
||||||
"gui.nims_random_bullshit.mailbox_gui.outbox_z_coord": "0",
|
"gui.nims_random_bullshit.mailbox_gui.outbox_z_coord": "0",
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
"block.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
|
"block.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
|
||||||
"effect.nims_random_bullshit.summoned_entity_effect": "Summoned Entity",
|
"effect.nims_random_bullshit.summoned_entity_effect": "Summoned Entity",
|
||||||
"item.nims_random_bullshit.sand_dust": "Sand Dust",
|
"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.magic_flesh": "Magic Flesh",
|
||||||
"item.nims_random_bullshit.ghoul_spawn_egg": "Ghoul Spawn Egg",
|
"item.nims_random_bullshit.ghoul_spawn_egg": "Ghoul Spawn Egg",
|
||||||
"item.nims_random_bullshit.shipping_label": "Shipping Label",
|
"item.nims_random_bullshit.shipping_label": "Shipping Label",
|
||||||
@@ -41,6 +43,7 @@
|
|||||||
"block.nims_random_bullshit.mailbox": "Mailbox",
|
"block.nims_random_bullshit.mailbox": "Mailbox",
|
||||||
"gui.nims_random_bullshit.mailbox_gui.button_send": "Send",
|
"gui.nims_random_bullshit.mailbox_gui.button_send": "Send",
|
||||||
"gui.nims_random_bullshit.mailbox_gui.outbox_y_coord": "0",
|
"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",
|
"gui.nims_random_bullshit.mailbox_gui.label_inbox": "Inbox",
|
||||||
"item.nims_random_bullshit.netherrackite": "Netherrackite Ingot"
|
"item.nims_random_bullshit.netherrackite": "Netherrackite Ingot"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user