mirror of
https://github.com/nimsolated/Nims-Random-BS.git
synced 2026-04-02 10:20:42 -07:00
feature: finally a decent working mailbox logic
This commit is contained in:
148
elements/Mailbox.mod.json
Normal file
148
elements/Mailbox.mod.json
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
{
|
||||||
|
"_fv": 73,
|
||||||
|
"_type": "block",
|
||||||
|
"definition": {
|
||||||
|
"texture": "mailbox_base",
|
||||||
|
"textureTop": "",
|
||||||
|
"textureLeft": "",
|
||||||
|
"textureFront": "",
|
||||||
|
"textureRight": "",
|
||||||
|
"textureBack": "",
|
||||||
|
"renderType": 2,
|
||||||
|
"customModelName": "mailbox:default",
|
||||||
|
"rotationMode": 1,
|
||||||
|
"enablePitch": false,
|
||||||
|
"emissiveRendering": false,
|
||||||
|
"displayFluidOverlay": false,
|
||||||
|
"itemTexture": "",
|
||||||
|
"particleTexture": "",
|
||||||
|
"tintType": "No tint",
|
||||||
|
"isItemTinted": false,
|
||||||
|
"hasTransparency": true,
|
||||||
|
"connectedSides": false,
|
||||||
|
"transparencyType": "SOLID",
|
||||||
|
"disableOffset": false,
|
||||||
|
"boundingBoxes": [
|
||||||
|
{
|
||||||
|
"mx": 0.0,
|
||||||
|
"my": 0.0,
|
||||||
|
"mz": 0.0,
|
||||||
|
"Mx": 16.0,
|
||||||
|
"My": 16.0,
|
||||||
|
"Mz": 16.0,
|
||||||
|
"subtract": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"customProperties": [],
|
||||||
|
"name": "Mailbox",
|
||||||
|
"specialInformation": {
|
||||||
|
"fixedValue": []
|
||||||
|
},
|
||||||
|
"hardness": 1.0,
|
||||||
|
"resistance": 10.0,
|
||||||
|
"hasGravity": false,
|
||||||
|
"isWaterloggable": false,
|
||||||
|
"creativeTabs": [
|
||||||
|
{
|
||||||
|
"value": "TRANSPORTATION"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"destroyTool": "Not specified",
|
||||||
|
"customDrop": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"dropAmount": 1,
|
||||||
|
"useLootTableForDrops": false,
|
||||||
|
"requiresCorrectTool": false,
|
||||||
|
"enchantPowerBonus": 0.0,
|
||||||
|
"plantsGrowOn": false,
|
||||||
|
"canRedstoneConnect": false,
|
||||||
|
"lightOpacity": 0,
|
||||||
|
"material": {
|
||||||
|
"value": "NONE"
|
||||||
|
},
|
||||||
|
"tickRate": 0,
|
||||||
|
"tickRandomly": false,
|
||||||
|
"isReplaceable": false,
|
||||||
|
"canProvidePower": false,
|
||||||
|
"emittedRedstonePower": {
|
||||||
|
"fixedValue": 15.0
|
||||||
|
},
|
||||||
|
"colorOnMap": "DEFAULT",
|
||||||
|
"creativePickItem": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"offsetType": "NONE",
|
||||||
|
"aiPathNodeType": "DEFAULT",
|
||||||
|
"flammability": 0,
|
||||||
|
"fireSpreadSpeed": 0,
|
||||||
|
"isLadder": false,
|
||||||
|
"slipperiness": 0.6,
|
||||||
|
"speedFactor": 1.0,
|
||||||
|
"jumpFactor": 1.0,
|
||||||
|
"reactionToPushing": "NORMAL",
|
||||||
|
"isNotColidable": false,
|
||||||
|
"isCustomSoundType": false,
|
||||||
|
"soundOnStep": {
|
||||||
|
"value": "METAL"
|
||||||
|
},
|
||||||
|
"breakSound": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"fallSound": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"hitSound": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"placeSound": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"stepSound": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"luminance": 0,
|
||||||
|
"unbreakable": false,
|
||||||
|
"vanillaToolTier": "NONE",
|
||||||
|
"isBonemealable": false,
|
||||||
|
"hasInventory": true,
|
||||||
|
"guiBoundTo": "MailboxGUI",
|
||||||
|
"openGUIOnRightClick": true,
|
||||||
|
"inventorySize": 18,
|
||||||
|
"inventoryStackSize": 64,
|
||||||
|
"inventoryDropWhenDestroyed": true,
|
||||||
|
"inventoryComparatorPower": true,
|
||||||
|
"inventoryOutSlotIDs": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
4,
|
||||||
|
5,
|
||||||
|
6,
|
||||||
|
7,
|
||||||
|
8
|
||||||
|
],
|
||||||
|
"inventoryInSlotIDs": [],
|
||||||
|
"hasEnergyStorage": false,
|
||||||
|
"energyInitial": 0,
|
||||||
|
"energyCapacity": 400000,
|
||||||
|
"energyMaxReceive": 200,
|
||||||
|
"energyMaxExtract": 200,
|
||||||
|
"isFluidTank": false,
|
||||||
|
"fluidCapacity": 8000,
|
||||||
|
"fluidRestrictions": [],
|
||||||
|
"generateFeature": false,
|
||||||
|
"restrictionBiomes": [],
|
||||||
|
"blocksToReplace": [
|
||||||
|
{
|
||||||
|
"value": "TAG:stone_ore_replaceables"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"generationShape": "UNIFORM",
|
||||||
|
"frequencyPerChunks": 10,
|
||||||
|
"frequencyOnChunk": 16,
|
||||||
|
"minGenerateHeight": 0,
|
||||||
|
"maxGenerateHeight": 64
|
||||||
|
}
|
||||||
|
}
|
||||||
442
elements/MailboxGUI.mod.json
Normal file
442
elements/MailboxGUI.mod.json
Normal file
@@ -0,0 +1,442 @@
|
|||||||
|
{
|
||||||
|
"_fv": 73,
|
||||||
|
"_type": "gui",
|
||||||
|
"definition": {
|
||||||
|
"type": 1,
|
||||||
|
"width": 360,
|
||||||
|
"height": 180,
|
||||||
|
"inventoryOffsetX": 0,
|
||||||
|
"inventoryOffsetY": 0,
|
||||||
|
"renderBgLayer": true,
|
||||||
|
"doesPauseGame": false,
|
||||||
|
"components": [
|
||||||
|
{
|
||||||
|
"type": "label",
|
||||||
|
"data": {
|
||||||
|
"name": "label_inbox",
|
||||||
|
"text": {
|
||||||
|
"fixedValue": "Inbox"
|
||||||
|
},
|
||||||
|
"color": {
|
||||||
|
"value": -12829636,
|
||||||
|
"falpha": 0.0
|
||||||
|
},
|
||||||
|
"x": 132,
|
||||||
|
"y": 44,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "outputslot",
|
||||||
|
"data": {
|
||||||
|
"id": 0,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": false,
|
||||||
|
"x": 132,
|
||||||
|
"y": 58,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "outputslot",
|
||||||
|
"data": {
|
||||||
|
"id": 1,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": false,
|
||||||
|
"x": 150,
|
||||||
|
"y": 58,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "outputslot",
|
||||||
|
"data": {
|
||||||
|
"id": 2,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": false,
|
||||||
|
"x": 168,
|
||||||
|
"y": 58,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "outputslot",
|
||||||
|
"data": {
|
||||||
|
"id": 3,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": false,
|
||||||
|
"x": 132,
|
||||||
|
"y": 76,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "outputslot",
|
||||||
|
"data": {
|
||||||
|
"id": 4,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": false,
|
||||||
|
"x": 150,
|
||||||
|
"y": 76,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "outputslot",
|
||||||
|
"data": {
|
||||||
|
"id": 5,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": false,
|
||||||
|
"x": 168,
|
||||||
|
"y": 76,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "outputslot",
|
||||||
|
"data": {
|
||||||
|
"id": 6,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": false,
|
||||||
|
"x": 132,
|
||||||
|
"y": 94,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "outputslot",
|
||||||
|
"data": {
|
||||||
|
"id": 7,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": false,
|
||||||
|
"x": 150,
|
||||||
|
"y": 94,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "outputslot",
|
||||||
|
"data": {
|
||||||
|
"id": 8,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": false,
|
||||||
|
"x": 168,
|
||||||
|
"y": 94,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "label",
|
||||||
|
"data": {
|
||||||
|
"name": "label_outbox",
|
||||||
|
"text": {
|
||||||
|
"fixedValue": "Outbox"
|
||||||
|
},
|
||||||
|
"color": {
|
||||||
|
"value": -12829636,
|
||||||
|
"falpha": 0.0
|
||||||
|
},
|
||||||
|
"x": 195,
|
||||||
|
"y": 44,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "inputslot",
|
||||||
|
"data": {
|
||||||
|
"inputLimit": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"disablePlacement": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"id": 9,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": false,
|
||||||
|
"x": 195,
|
||||||
|
"y": 58,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "inputslot",
|
||||||
|
"data": {
|
||||||
|
"inputLimit": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"disablePlacement": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"id": 10,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": true,
|
||||||
|
"x": 213,
|
||||||
|
"y": 58,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "inputslot",
|
||||||
|
"data": {
|
||||||
|
"inputLimit": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"disablePlacement": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"id": 11,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": true,
|
||||||
|
"x": 231,
|
||||||
|
"y": 58,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "inputslot",
|
||||||
|
"data": {
|
||||||
|
"inputLimit": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"disablePlacement": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"id": 12,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": true,
|
||||||
|
"x": 195,
|
||||||
|
"y": 76,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "inputslot",
|
||||||
|
"data": {
|
||||||
|
"inputLimit": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"disablePlacement": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"id": 13,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": true,
|
||||||
|
"x": 213,
|
||||||
|
"y": 76,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "inputslot",
|
||||||
|
"data": {
|
||||||
|
"inputLimit": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"disablePlacement": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"id": 14,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": true,
|
||||||
|
"x": 231,
|
||||||
|
"y": 76,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "inputslot",
|
||||||
|
"data": {
|
||||||
|
"inputLimit": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"disablePlacement": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"id": 15,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": true,
|
||||||
|
"x": 195,
|
||||||
|
"y": 94,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "inputslot",
|
||||||
|
"data": {
|
||||||
|
"inputLimit": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"disablePlacement": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"id": 16,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": true,
|
||||||
|
"x": 213,
|
||||||
|
"y": 94,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "inputslot",
|
||||||
|
"data": {
|
||||||
|
"inputLimit": {
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
|
"disablePlacement": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"id": 17,
|
||||||
|
"disablePickup": {
|
||||||
|
"fixedValue": false
|
||||||
|
},
|
||||||
|
"dropItemsWhenNotBound": true,
|
||||||
|
"x": 231,
|
||||||
|
"y": 94,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "label",
|
||||||
|
"data": {
|
||||||
|
"name": "label_x",
|
||||||
|
"text": {
|
||||||
|
"fixedValue": "X:"
|
||||||
|
},
|
||||||
|
"color": {
|
||||||
|
"value": -12829636,
|
||||||
|
"falpha": 0.0
|
||||||
|
},
|
||||||
|
"x": 258,
|
||||||
|
"y": 49,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "textfield",
|
||||||
|
"data": {
|
||||||
|
"placeholder": "0",
|
||||||
|
"name": "outbox_x_coord",
|
||||||
|
"width": 120,
|
||||||
|
"height": 20,
|
||||||
|
"x": 267,
|
||||||
|
"y": 44,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "label",
|
||||||
|
"data": {
|
||||||
|
"name": "label_y",
|
||||||
|
"text": {
|
||||||
|
"fixedValue": "Y:"
|
||||||
|
},
|
||||||
|
"color": {
|
||||||
|
"value": -12829636,
|
||||||
|
"falpha": 0.0
|
||||||
|
},
|
||||||
|
"x": 258,
|
||||||
|
"y": 71,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "textfield",
|
||||||
|
"data": {
|
||||||
|
"placeholder": "0",
|
||||||
|
"name": "outbox_y_coord",
|
||||||
|
"width": 120,
|
||||||
|
"height": 20,
|
||||||
|
"x": 267,
|
||||||
|
"y": 67,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "label",
|
||||||
|
"data": {
|
||||||
|
"name": "label_z",
|
||||||
|
"text": {
|
||||||
|
"fixedValue": "Z:"
|
||||||
|
},
|
||||||
|
"color": {
|
||||||
|
"value": -12829636,
|
||||||
|
"falpha": 0.0
|
||||||
|
},
|
||||||
|
"x": 258,
|
||||||
|
"y": 94,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "textfield",
|
||||||
|
"data": {
|
||||||
|
"placeholder": "0",
|
||||||
|
"name": "outbox_z_coord",
|
||||||
|
"width": 120,
|
||||||
|
"height": 20,
|
||||||
|
"x": 267,
|
||||||
|
"y": 89,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "button",
|
||||||
|
"data": {
|
||||||
|
"name": "button_send",
|
||||||
|
"text": "Send",
|
||||||
|
"isUndecorated": false,
|
||||||
|
"onClick": {
|
||||||
|
"name": "MailboxSmartSendLogic"
|
||||||
|
},
|
||||||
|
"width": 46,
|
||||||
|
"height": 20,
|
||||||
|
"x": 303,
|
||||||
|
"y": 116,
|
||||||
|
"locked": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"gridSettings": {
|
||||||
|
"sx": 9,
|
||||||
|
"sy": 9,
|
||||||
|
"ox": 11,
|
||||||
|
"oy": 15,
|
||||||
|
"snapOnGrid": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
elements/MailboxSmartSendLogic.mod.json
Normal file
7
elements/MailboxSmartSendLogic.mod.json
Normal file
File diff suppressed because one or more lines are too long
90
models/mailbox.json
Normal file
90
models/mailbox.json
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
{
|
||||||
|
"format_version": "1.21.11",
|
||||||
|
"credit": "Made with Blockbench",
|
||||||
|
"textures": {
|
||||||
|
"0": "3",
|
||||||
|
"1": "2",
|
||||||
|
"2": "1",
|
||||||
|
"particle": "3"
|
||||||
|
},
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"from": [7, 0, 7],
|
||||||
|
"to": [9, 7, 9],
|
||||||
|
"rotation": {"angle": 0, "axis": "y", "origin": [7, 0, 7]},
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [0, 9, 2, 16], "texture": "#0"},
|
||||||
|
"east": {"uv": [0, 9, 2, 16], "texture": "#0"},
|
||||||
|
"south": {"uv": [0, 9, 2, 16], "texture": "#0"},
|
||||||
|
"west": {"uv": [0, 9, 2, 16], "texture": "#0"},
|
||||||
|
"up": {"uv": [0, 0, 2, 2], "texture": "#0"},
|
||||||
|
"down": {"uv": [0, 0, 2, 2], "texture": "#0"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [4, 7, 0],
|
||||||
|
"to": [12, 13, 16],
|
||||||
|
"rotation": {"angle": 0, "axis": "y", "origin": [7, 7, 7]},
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [0, 2, 8, 8], "texture": "#2"},
|
||||||
|
"east": {"uv": [0, 2, 16, 8], "texture": "#2"},
|
||||||
|
"south": {"uv": [0, 2, 8, 8], "texture": "#2"},
|
||||||
|
"west": {"uv": [0, 2, 16, 8], "texture": "#2"},
|
||||||
|
"up": {"uv": [0, 0, 8, 16], "texture": "#2"},
|
||||||
|
"down": {"uv": [0, 0, 8, 16], "texture": "#2"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [5, 13, 0],
|
||||||
|
"to": [11, 14, 16],
|
||||||
|
"rotation": {"angle": 0, "axis": "y", "origin": [7, 13, 7]},
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [1, 1, 7, 2], "texture": "#2"},
|
||||||
|
"east": {"uv": [0, 1, 16, 2], "texture": "#2"},
|
||||||
|
"south": {"uv": [0, 1, 6, 2], "texture": "#2"},
|
||||||
|
"west": {"uv": [0, 1, 16, 2], "texture": "#2"},
|
||||||
|
"up": {"uv": [0, 0, 6, 16], "texture": "#2"},
|
||||||
|
"down": {"uv": [0, 0, 6, 16], "texture": "#2"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [6, 14, 0],
|
||||||
|
"to": [10, 15, 16],
|
||||||
|
"rotation": {"angle": 0, "axis": "y", "origin": [7, 14, 7]},
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [2, 1, 6, 2], "texture": "#2"},
|
||||||
|
"east": {"uv": [0, 1, 16, 2], "texture": "#2"},
|
||||||
|
"south": {"uv": [1, 1, 5, 2], "texture": "#2"},
|
||||||
|
"west": {"uv": [0, 1, 16, 2], "texture": "#2"},
|
||||||
|
"up": {"uv": [1, 0, 5, 16], "texture": "#2"},
|
||||||
|
"down": {"uv": [1, 0, 5, 16], "texture": "#2"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [7, 15, 0],
|
||||||
|
"to": [9, 16, 16],
|
||||||
|
"rotation": {"angle": 0, "axis": "y", "origin": [7, 15, 7]},
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [3, 1, 5, 2], "texture": "#2"},
|
||||||
|
"east": {"uv": [0, 1, 16, 2], "texture": "#2"},
|
||||||
|
"south": {"uv": [2, 1, 4, 2], "texture": "#2"},
|
||||||
|
"west": {"uv": [0, 1, 16, 2], "texture": "#2"},
|
||||||
|
"up": {"uv": [2, 0, 4, 16], "texture": "#2"},
|
||||||
|
"down": {"uv": [2, 0, 4, 16], "texture": "#2"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [3, 11, 2],
|
||||||
|
"to": [4, 16, 4],
|
||||||
|
"rotation": {"angle": 0, "axis": "y", "origin": [2, 11, 2]},
|
||||||
|
"faces": {
|
||||||
|
"north": {"uv": [0, 3, 1, 8], "texture": "#1"},
|
||||||
|
"east": {"uv": [0, 3, 2, 8], "texture": "#1"},
|
||||||
|
"south": {"uv": [1, 3, 2, 8], "texture": "#1"},
|
||||||
|
"west": {"uv": [0, 3, 2, 8], "texture": "#1"},
|
||||||
|
"up": {"uv": [1, 0, 2, 2], "texture": "#1"},
|
||||||
|
"down": {"uv": [1, 0, 2, 2], "texture": "#1"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
12
models/mailbox.json.textures
Normal file
12
models/mailbox.json.textures
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"mappings": {
|
||||||
|
"default": {
|
||||||
|
"map": {
|
||||||
|
"0": "mailbox_rod",
|
||||||
|
"1": "mailbox_flag",
|
||||||
|
"2": "mailbox_base"
|
||||||
|
},
|
||||||
|
"name": "default"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1374,6 +1374,78 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"path": "~/Other"
|
"path": "~/Other"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Mailbox",
|
||||||
|
"type": "block",
|
||||||
|
"compiles": true,
|
||||||
|
"locked_code": false,
|
||||||
|
"registry_name": "mailbox",
|
||||||
|
"metadata": {
|
||||||
|
"files": [
|
||||||
|
"src/main/resources/assets/nims_random_bullshit/blockstates/mailbox.json",
|
||||||
|
"src/main/java/net/mcreator/nimsrandombullshit/block/MailboxBlock.java",
|
||||||
|
"src/main/java/net/mcreator/nimsrandombullshit/block/entity/MailboxBlockEntity.java",
|
||||||
|
"src/main/resources/assets/nims_random_bullshit/models/item/mailbox.json",
|
||||||
|
"src/main/resources/assets/nims_random_bullshit/models/block/mailbox.json",
|
||||||
|
"src/main/resources/data/nims_random_bullshit/loot_tables/blocks/mailbox.json"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"path": "~/Mailbox"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "MailboxGUI",
|
||||||
|
"type": "gui",
|
||||||
|
"compiles": true,
|
||||||
|
"locked_code": false,
|
||||||
|
"registry_name": "mailbox_gui",
|
||||||
|
"metadata": {
|
||||||
|
"files": [
|
||||||
|
"src/main/java/net/mcreator/nimsrandombullshit/world/inventory/MailboxGUIMenu.java",
|
||||||
|
"src/main/java/net/mcreator/nimsrandombullshit/network/MailboxGUIButtonMessage.java",
|
||||||
|
"src/main/java/net/mcreator/nimsrandombullshit/client/gui/MailboxGUIScreen.java"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"path": "~/Mailbox"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "MailboxSmartSendLogic",
|
||||||
|
"type": "procedure",
|
||||||
|
"compiles": true,
|
||||||
|
"locked_code": false,
|
||||||
|
"registry_name": "mailbox_smart_send_logic",
|
||||||
|
"metadata": {
|
||||||
|
"files": [
|
||||||
|
"src/main/java/net/mcreator/nimsrandombullshit/procedures/MailboxSmartSendLogicProcedure.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"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"variable_elements": [],
|
"variable_elements": [],
|
||||||
@@ -1415,15 +1487,18 @@
|
|||||||
"item.nims_random_bullshit.star_wand": "Star Wand",
|
"item.nims_random_bullshit.star_wand": "Star Wand",
|
||||||
"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",
|
||||||
"block.nims_random_bullshit.penta_condensed_netherrack": "Penta-condensed Netherrack",
|
"block.nims_random_bullshit.penta_condensed_netherrack": "Penta-condensed Netherrack",
|
||||||
"item.nims_random_bullshit.magic_dust": "Magic Dust",
|
"item.nims_random_bullshit.magic_dust": "Magic Dust",
|
||||||
"enchantment.nims_random_bullshit.passive_income_enchantment": "Passive Income",
|
"enchantment.nims_random_bullshit.passive_income_enchantment": "Passive Income",
|
||||||
"item.nims_random_bullshit.netherrackite_pickaxe.description_0": "Non-condensed netherracks broken by this pickaxe drop themselves an additional time.",
|
"item.nims_random_bullshit.netherrackite_pickaxe.description_0": "Non-condensed netherracks broken by this pickaxe drop themselves an additional time.",
|
||||||
"item.nims_random_bullshit.netherrackite_pickaxe": "Netherrackite Pickaxe",
|
"item.nims_random_bullshit.netherrackite_pickaxe": "Netherrackite Pickaxe",
|
||||||
"effect.nims_random_bullshit.stinky_effect": "Stinky",
|
"effect.nims_random_bullshit.stinky_effect": "Stinky",
|
||||||
|
"gui.nims_random_bullshit.mailbox_gui.outbox_x_coord": "0",
|
||||||
"block.nims_random_bullshit.broken_glass": "Broken Glass",
|
"block.nims_random_bullshit.broken_glass": "Broken Glass",
|
||||||
"block.nims_random_bullshit.hexa_condensed_netherrack": "Hexa-condensed Netherrack",
|
"block.nims_random_bullshit.hexa_condensed_netherrack": "Hexa-condensed Netherrack",
|
||||||
"block.nims_random_bullshit.ore_miner": "Ore Miner",
|
"block.nims_random_bullshit.ore_miner": "Ore Miner",
|
||||||
|
"gui.nims_random_bullshit.mailbox_gui.label_outbox": "Outbox",
|
||||||
"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",
|
||||||
@@ -1432,7 +1507,10 @@
|
|||||||
"item.nims_random_bullshit.block_eater": "Block Eater",
|
"item.nims_random_bullshit.block_eater": "Block Eater",
|
||||||
"item.nims_random_bullshit.golden_berries": "Golden Berries",
|
"item.nims_random_bullshit.golden_berries": "Golden Berries",
|
||||||
"item.nims_random_bullshit.netherrack_juice_bucket": "Netherrack Juice Bucket",
|
"item.nims_random_bullshit.netherrack_juice_bucket": "Netherrack Juice Bucket",
|
||||||
|
"gui.nims_random_bullshit.mailbox_gui.label_y": "Y:",
|
||||||
|
"gui.nims_random_bullshit.mailbox_gui.label_z": "Z:",
|
||||||
"block.nims_random_bullshit.condensed_condensed_condensed_netherrack": "Condensed Condensed Condensed Netherrack",
|
"block.nims_random_bullshit.condensed_condensed_condensed_netherrack": "Condensed Condensed Condensed Netherrack",
|
||||||
|
"gui.nims_random_bullshit.mailbox_gui.label_x": "X:",
|
||||||
"entity.nims_random_bullshit.ghoul": "Ghoul",
|
"entity.nims_random_bullshit.ghoul": "Ghoul",
|
||||||
"item.nims_random_bullshit.star": "Star",
|
"item.nims_random_bullshit.star": "Star",
|
||||||
"gui.nims_random_bullshit.shit_gui.label_uh_ohh_stinky": "UH OHH!!! STINKY!!! UH OHH!!! STINKY!!! UH OHH!!! STINKY!!! UH OHH!!! STINKY!!! ",
|
"gui.nims_random_bullshit.shit_gui.label_uh_ohh_stinky": "UH OHH!!! STINKY!!! UH OHH!!! STINKY!!! UH OHH!!! STINKY!!! UH OHH!!! STINKY!!! ",
|
||||||
@@ -1441,6 +1519,10 @@
|
|||||||
"item.nims_random_bullshit.gravedigger.description_0": "Right-Click on soul sand or soul soil to use them, summoning a ghoul that attacks hostile mobs.",
|
"item.nims_random_bullshit.gravedigger.description_0": "Right-Click on soul sand or soul soil to use them, summoning a ghoul that attacks hostile mobs.",
|
||||||
"item.nims_random_bullshit.shit": "Shit",
|
"item.nims_random_bullshit.shit": "Shit",
|
||||||
"block.nims_random_bullshit.condensed_netherrack": "Condensed Netherrack",
|
"block.nims_random_bullshit.condensed_netherrack": "Condensed Netherrack",
|
||||||
|
"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_gui.label_inbox": "Inbox",
|
||||||
"item.nims_random_bullshit.netherrackite": "Netherrackite Ingot"
|
"item.nims_random_bullshit.netherrackite": "Netherrackite Ingot"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1474,6 +1556,10 @@
|
|||||||
{
|
{
|
||||||
"name": "OreMiner",
|
"name": "OreMiner",
|
||||||
"children": []
|
"children": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Mailbox",
|
||||||
|
"children": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,146 @@
|
|||||||
|
|
||||||
|
package net.mcreator.nimsrandombullshit.block;
|
||||||
|
|
||||||
|
import net.minecraftforge.network.NetworkHooks;
|
||||||
|
|
||||||
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
import net.minecraft.world.phys.shapes.Shapes;
|
||||||
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||||
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
|
import net.minecraft.world.level.block.state.StateDefinition;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.SoundType;
|
||||||
|
import net.minecraft.world.level.block.Rotation;
|
||||||
|
import net.minecraft.world.level.block.Mirror;
|
||||||
|
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||||
|
import net.minecraft.world.level.block.EntityBlock;
|
||||||
|
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.inventory.AbstractContainerMenu;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
import net.minecraft.world.MenuProvider;
|
||||||
|
import net.minecraft.world.InteractionResult;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.Containers;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
|
import net.mcreator.nimsrandombullshit.world.inventory.MailboxGUIMenu;
|
||||||
|
import net.mcreator.nimsrandombullshit.block.entity.MailboxBlockEntity;
|
||||||
|
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
|
||||||
|
public class MailboxBlock extends Block implements EntityBlock {
|
||||||
|
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||||
|
|
||||||
|
public MailboxBlock() {
|
||||||
|
super(BlockBehaviour.Properties.of().sound(SoundType.METAL).strength(1f, 10f).noOcclusion().isRedstoneConductor((bs, br, bp) -> false));
|
||||||
|
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLightBlock(BlockState state, BlockGetter worldIn, BlockPos pos) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VoxelShape getVisualShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
|
||||||
|
return Shapes.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||||
|
super.createBlockStateDefinition(builder);
|
||||||
|
builder.add(FACING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||||
|
return super.getStateForPlacement(context).setValue(FACING, context.getHorizontalDirection().getOpposite());
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState rotate(BlockState state, Rotation rot) {
|
||||||
|
return state.setValue(FACING, rot.rotate(state.getValue(FACING)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState mirror(BlockState state, Mirror mirrorIn) {
|
||||||
|
return state.rotate(mirrorIn.getRotation(state.getValue(FACING)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InteractionResult use(BlockState blockstate, Level world, BlockPos pos, Player entity, InteractionHand hand, BlockHitResult hit) {
|
||||||
|
super.use(blockstate, world, pos, entity, hand, hit);
|
||||||
|
if (entity instanceof ServerPlayer player) {
|
||||||
|
NetworkHooks.openScreen(player, new MenuProvider() {
|
||||||
|
@Override
|
||||||
|
public Component getDisplayName() {
|
||||||
|
return Component.literal("Mailbox");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AbstractContainerMenu createMenu(int id, Inventory inventory, Player player) {
|
||||||
|
return new MailboxGUIMenu(id, inventory, new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(pos));
|
||||||
|
}
|
||||||
|
}, pos);
|
||||||
|
}
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MenuProvider getMenuProvider(BlockState state, Level worldIn, BlockPos pos) {
|
||||||
|
BlockEntity tileEntity = worldIn.getBlockEntity(pos);
|
||||||
|
return tileEntity instanceof MenuProvider menuProvider ? menuProvider : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
return new MailboxBlockEntity(pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean triggerEvent(BlockState state, Level world, BlockPos pos, int eventID, int eventParam) {
|
||||||
|
super.triggerEvent(state, world, pos, eventID, eventParam);
|
||||||
|
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||||
|
return blockEntity == null ? false : blockEntity.triggerEvent(eventID, eventParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||||
|
if (state.getBlock() != newState.getBlock()) {
|
||||||
|
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||||
|
if (blockEntity instanceof MailboxBlockEntity be) {
|
||||||
|
Containers.dropContents(world, pos, be);
|
||||||
|
world.updateNeighbourForOutputSignal(pos, this);
|
||||||
|
}
|
||||||
|
super.onRemove(state, world, pos, newState, isMoving);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasAnalogOutputSignal(BlockState state) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAnalogOutputSignal(BlockState blockState, Level world, BlockPos pos) {
|
||||||
|
BlockEntity tileentity = world.getBlockEntity(pos);
|
||||||
|
if (tileentity instanceof MailboxBlockEntity be)
|
||||||
|
return AbstractContainerMenu.getRedstoneSignalFromContainer(be);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
package net.mcreator.nimsrandombullshit.block.entity;
|
||||||
|
|
||||||
|
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
import net.minecraft.world.WorldlyContainer;
|
||||||
|
import net.minecraft.world.ContainerHelper;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
|
import net.mcreator.nimsrandombullshit.world.inventory.MailboxGUIMenu;
|
||||||
|
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModBlockEntities;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
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 final LazyOptional<? extends IItemHandler>[] handlers = SidedInvWrapper.create(this, Direction.values());
|
||||||
|
|
||||||
|
public MailboxBlockEntity(BlockPos position, BlockState state) {
|
||||||
|
super(NimsRandomBullshitModBlockEntities.MAILBOX.get(), position, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(CompoundTag compound) {
|
||||||
|
super.load(compound);
|
||||||
|
if (!this.tryLoadLootTable(compound))
|
||||||
|
this.stacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||||
|
ContainerHelper.loadAllItems(compound, this.stacks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveAdditional(CompoundTag compound) {
|
||||||
|
super.saveAdditional(compound);
|
||||||
|
if (!this.trySaveLootTable(compound)) {
|
||||||
|
ContainerHelper.saveAllItems(compound, this.stacks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientboundBlockEntityDataPacket getUpdatePacket() {
|
||||||
|
return ClientboundBlockEntityDataPacket.create(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getUpdateTag() {
|
||||||
|
return this.saveWithFullMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getContainerSize() {
|
||||||
|
return stacks.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
for (ItemStack itemstack : this.stacks)
|
||||||
|
if (!itemstack.isEmpty())
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getDefaultName() {
|
||||||
|
return Component.literal("mailbox");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxStackSize() {
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AbstractContainerMenu createMenu(int id, Inventory inventory) {
|
||||||
|
return new MailboxGUIMenu(id, inventory, new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(this.worldPosition));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getDisplayName() {
|
||||||
|
return Component.literal("Mailbox");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected NonNullList<ItemStack> getItems() {
|
||||||
|
return this.stacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setItems(NonNullList<ItemStack> stacks) {
|
||||||
|
this.stacks = stacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlaceItem(int index, ItemStack stack) {
|
||||||
|
if (index == 0)
|
||||||
|
return false;
|
||||||
|
if (index == 1)
|
||||||
|
return false;
|
||||||
|
if (index == 2)
|
||||||
|
return false;
|
||||||
|
if (index == 3)
|
||||||
|
return false;
|
||||||
|
if (index == 4)
|
||||||
|
return false;
|
||||||
|
if (index == 5)
|
||||||
|
return false;
|
||||||
|
if (index == 6)
|
||||||
|
return false;
|
||||||
|
if (index == 7)
|
||||||
|
return false;
|
||||||
|
if (index == 8)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getSlotsForFace(Direction side) {
|
||||||
|
return IntStream.range(0, this.getContainerSize()).toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlaceItemThroughFace(int index, ItemStack stack, @Nullable Direction direction) {
|
||||||
|
return this.canPlaceItem(index, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canTakeItemThroughFace(int index, ItemStack stack, Direction direction) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||||
|
if (!this.remove && facing != null && capability == ForgeCapabilities.ITEM_HANDLER)
|
||||||
|
return handlers[facing.ordinal()].cast();
|
||||||
|
return super.getCapability(capability, facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRemoved() {
|
||||||
|
super.setRemoved();
|
||||||
|
for (LazyOptional<? extends IItemHandler> handler : handlers)
|
||||||
|
handler.invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
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.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;
|
||||||
|
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
public class MailboxGUIScreen extends AbstractContainerScreen<MailboxGUIMenu> {
|
||||||
|
private final static HashMap<String, Object> guistate = MailboxGUIMenu.guistate;
|
||||||
|
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) {
|
||||||
|
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 = 360;
|
||||||
|
this.imageHeight = 180;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final ResourceLocation texture = new ResourceLocation("nims_random_bullshit:textures/screens/mailbox_gui.png");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int gx, int gy) {
|
||||||
|
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||||
|
RenderSystem.enableBlend();
|
||||||
|
RenderSystem.defaultBlendFunc();
|
||||||
|
guiGraphics.blit(texture, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight, this.imageWidth, this.imageHeight);
|
||||||
|
RenderSystem.disableBlend();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyPressed(int key, int b, int c) {
|
||||||
|
if (key == 256) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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();
|
||||||
|
guistate.put("button:button_send", button_send);
|
||||||
|
this.addRenderableWidget(button_send);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,11 +12,13 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
|||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
|
||||||
import net.mcreator.nimsrandombullshit.block.entity.OreMinerBlockEntity;
|
import net.mcreator.nimsrandombullshit.block.entity.OreMinerBlockEntity;
|
||||||
|
import net.mcreator.nimsrandombullshit.block.entity.MailboxBlockEntity;
|
||||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||||
|
|
||||||
public class NimsRandomBullshitModBlockEntities {
|
public class NimsRandomBullshitModBlockEntities {
|
||||||
public static final DeferredRegister<BlockEntityType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, NimsRandomBullshitMod.MODID);
|
public static final DeferredRegister<BlockEntityType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, NimsRandomBullshitMod.MODID);
|
||||||
public static final RegistryObject<BlockEntityType<?>> ORE_MINER = register("ore_miner", NimsRandomBullshitModBlocks.ORE_MINER, OreMinerBlockEntity::new);
|
public static final RegistryObject<BlockEntityType<?>> ORE_MINER = register("ore_miner", NimsRandomBullshitModBlocks.ORE_MINER, OreMinerBlockEntity::new);
|
||||||
|
public static final RegistryObject<BlockEntityType<?>> MAILBOX = register("mailbox", NimsRandomBullshitModBlocks.MAILBOX, MailboxBlockEntity::new);
|
||||||
|
|
||||||
// Start of user code block custom block entities
|
// Start of user code block custom block entities
|
||||||
// End of user code block custom block entities
|
// End of user code block custom block entities
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import net.mcreator.nimsrandombullshit.block.QuadraCondensedNetherrackBlock;
|
|||||||
import net.mcreator.nimsrandombullshit.block.PentaCondensedNetherrackBlock;
|
import net.mcreator.nimsrandombullshit.block.PentaCondensedNetherrackBlock;
|
||||||
import net.mcreator.nimsrandombullshit.block.OreMinerBlock;
|
import net.mcreator.nimsrandombullshit.block.OreMinerBlock;
|
||||||
import net.mcreator.nimsrandombullshit.block.NetherrackJuiceBlock;
|
import net.mcreator.nimsrandombullshit.block.NetherrackJuiceBlock;
|
||||||
|
import net.mcreator.nimsrandombullshit.block.MailboxBlock;
|
||||||
import net.mcreator.nimsrandombullshit.block.HexaCondensedNetherrackBlock;
|
import net.mcreator.nimsrandombullshit.block.HexaCondensedNetherrackBlock;
|
||||||
import net.mcreator.nimsrandombullshit.block.CondensedNetherrackBlock;
|
import net.mcreator.nimsrandombullshit.block.CondensedNetherrackBlock;
|
||||||
import net.mcreator.nimsrandombullshit.block.CondensedCondensedNetherrackBlock;
|
import net.mcreator.nimsrandombullshit.block.CondensedCondensedNetherrackBlock;
|
||||||
@@ -32,6 +33,7 @@ public class NimsRandomBullshitModBlocks {
|
|||||||
public static final RegistryObject<Block> HEXA_CONDENSED_NETHERRACK = REGISTRY.register("hexa_condensed_netherrack", () -> new HexaCondensedNetherrackBlock());
|
public static final RegistryObject<Block> HEXA_CONDENSED_NETHERRACK = REGISTRY.register("hexa_condensed_netherrack", () -> new HexaCondensedNetherrackBlock());
|
||||||
public static final RegistryObject<Block> ORE_MINER = REGISTRY.register("ore_miner", () -> new OreMinerBlock());
|
public static final RegistryObject<Block> ORE_MINER = REGISTRY.register("ore_miner", () -> new OreMinerBlock());
|
||||||
public static final RegistryObject<Block> NETHERRACK_JUICE = REGISTRY.register("netherrack_juice", () -> new NetherrackJuiceBlock());
|
public static final RegistryObject<Block> NETHERRACK_JUICE = REGISTRY.register("netherrack_juice", () -> new NetherrackJuiceBlock());
|
||||||
|
public static final RegistryObject<Block> MAILBOX = REGISTRY.register("mailbox", () -> new MailboxBlock());
|
||||||
// Start of user code block custom blocks
|
// Start of user code block custom blocks
|
||||||
// End of user code block custom blocks
|
// End of user code block custom blocks
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class NimsRandomBullshitModItems {
|
|||||||
public static final RegistryObject<Item> STAR = REGISTRY.register("star", () -> new StarItem());
|
public static final RegistryObject<Item> STAR = REGISTRY.register("star", () -> new StarItem());
|
||||||
public static final RegistryObject<Item> STAR_WAND = REGISTRY.register("star_wand", () -> new StarWandItem());
|
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> NETHERRACK_JUICE_BUCKET = REGISTRY.register("netherrack_juice_bucket", () -> new NetherrackJuiceItem());
|
||||||
|
public static final RegistryObject<Item> MAILBOX = block(NimsRandomBullshitModBlocks.MAILBOX);
|
||||||
|
|
||||||
// Start of user code block custom items
|
// Start of user code block custom items
|
||||||
// End of user code block custom items
|
// End of user code block custom items
|
||||||
|
|||||||
@@ -13,10 +13,12 @@ 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.MailboxGUIMenu;
|
||||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||||
|
|
||||||
public class NimsRandomBullshitModMenus {
|
public class NimsRandomBullshitModMenus {
|
||||||
public static final DeferredRegister<MenuType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.MENU_TYPES, NimsRandomBullshitMod.MODID);
|
public static final DeferredRegister<MenuType<?>> REGISTRY = DeferredRegister.create(ForgeRegistries.MENU_TYPES, NimsRandomBullshitMod.MODID);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.MailboxGUIScreen;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||||
public class NimsRandomBullshitModScreens {
|
public class NimsRandomBullshitModScreens {
|
||||||
@@ -21,6 +22,7 @@ public class NimsRandomBullshitModScreens {
|
|||||||
event.enqueueWork(() -> {
|
event.enqueueWork(() -> {
|
||||||
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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public class NimsRandomBullshitModTabs {
|
|||||||
tabData.accept(NimsRandomBullshitModItems.GOLDEN_BERRIES.get());
|
tabData.accept(NimsRandomBullshitModItems.GOLDEN_BERRIES.get());
|
||||||
} else if (tabData.getTabKey() == CreativeModeTabs.FUNCTIONAL_BLOCKS) {
|
} else if (tabData.getTabKey() == CreativeModeTabs.FUNCTIONAL_BLOCKS) {
|
||||||
tabData.accept(NimsRandomBullshitModBlocks.ORE_MINER.get().asItem());
|
tabData.accept(NimsRandomBullshitModBlocks.ORE_MINER.get().asItem());
|
||||||
|
tabData.accept(NimsRandomBullshitModBlocks.MAILBOX.get().asItem());
|
||||||
} else if (tabData.getTabKey() == CreativeModeTabs.SPAWN_EGGS) {
|
} else if (tabData.getTabKey() == CreativeModeTabs.SPAWN_EGGS) {
|
||||||
tabData.accept(NimsRandomBullshitModItems.GHOUL_SPAWN_EGG.get());
|
tabData.accept(NimsRandomBullshitModItems.GHOUL_SPAWN_EGG.get());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.MailboxGUIMenu;
|
||||||
|
import net.mcreator.nimsrandombullshit.procedures.MailboxSmartSendLogicProcedure;
|
||||||
|
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
|
public class MailboxGUIButtonMessage {
|
||||||
|
private final int buttonID, x, y, z;
|
||||||
|
|
||||||
|
public MailboxGUIButtonMessage(FriendlyByteBuf buffer) {
|
||||||
|
this.buttonID = buffer.readInt();
|
||||||
|
this.x = buffer.readInt();
|
||||||
|
this.y = buffer.readInt();
|
||||||
|
this.z = buffer.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MailboxGUIButtonMessage(int buttonID, int x, int y, int z) {
|
||||||
|
this.buttonID = buttonID;
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void buffer(MailboxGUIButtonMessage message, FriendlyByteBuf buffer) {
|
||||||
|
buffer.writeInt(message.buttonID);
|
||||||
|
buffer.writeInt(message.x);
|
||||||
|
buffer.writeInt(message.y);
|
||||||
|
buffer.writeInt(message.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handler(MailboxGUIButtonMessage 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 = MailboxGUIMenu.guistate;
|
||||||
|
// security measure to prevent arbitrary chunk generation
|
||||||
|
if (!world.hasChunkAt(new BlockPos(x, y, z)))
|
||||||
|
return;
|
||||||
|
if (buttonID == 0) {
|
||||||
|
|
||||||
|
MailboxSmartSendLogicProcedure.execute(world, x, y, z, entity, guistate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void registerMessage(FMLCommonSetupEvent event) {
|
||||||
|
NimsRandomBullshitMod.addNetworkMessage(MailboxGUIButtonMessage.class, MailboxGUIButtonMessage::buffer, MailboxGUIButtonMessage::new, MailboxGUIButtonMessage::handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,442 @@
|
|||||||
|
package net.mcreator.nimsrandombullshit.procedures;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.units.qual.s;
|
||||||
|
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
|
|
||||||
|
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;
|
||||||
|
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.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)
|
||||||
|
return;
|
||||||
|
ItemStack currInboxItem = ItemStack.EMPTY;
|
||||||
|
double currInboxSlot = 0;
|
||||||
|
double currOutboxSlot = 0;
|
||||||
|
double currInboxSlotRoom = 0;
|
||||||
|
double currRemainder = 0;
|
||||||
|
double currInboxSlot2 = 0;
|
||||||
|
double currInboxItemCount = 0;
|
||||||
|
double currInboxItemCount2 = 0;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,402 @@
|
|||||||
|
|
||||||
|
package net.mcreator.nimsrandombullshit.world.inventory;
|
||||||
|
|
||||||
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
|
|
||||||
|
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.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
|
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModMenus;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class MailboxGUIMenu 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 MailboxGUIMenu(int id, Inventory inv, FriendlyByteBuf extraData) {
|
||||||
|
super(NimsRandomBullshitModMenus.MAILBOX_GUI.get(), id);
|
||||||
|
this.entity = inv.player;
|
||||||
|
this.world = inv.player.level();
|
||||||
|
this.internal = new ItemStackHandler(18);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
if (pos != null) {
|
||||||
|
if (extraData.readableBytes() == 1) { // bound to item
|
||||||
|
byte hand = extraData.readByte();
|
||||||
|
ItemStack itemstack = hand == 0 ? this.entity.getMainHandItem() : this.entity.getOffhandItem();
|
||||||
|
this.boundItemMatcher = () -> itemstack == (hand == 0 ? this.entity.getMainHandItem() : this.entity.getOffhandItem());
|
||||||
|
itemstack.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
|
||||||
|
this.internal = capability;
|
||||||
|
this.bound = true;
|
||||||
|
});
|
||||||
|
} else if (extraData.readableBytes() > 1) { // bound to entity
|
||||||
|
extraData.readByte(); // drop padding
|
||||||
|
boundEntity = world.getEntity(extraData.readVarInt());
|
||||||
|
if (boundEntity != null)
|
||||||
|
boundEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
|
||||||
|
this.internal = capability;
|
||||||
|
this.bound = true;
|
||||||
|
});
|
||||||
|
} else { // might be bound to block
|
||||||
|
boundBlockEntity = this.world.getBlockEntity(pos);
|
||||||
|
if (boundBlockEntity != null)
|
||||||
|
boundBlockEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, null).ifPresent(capability -> {
|
||||||
|
this.internal = capability;
|
||||||
|
this.bound = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.customSlots.put(0, this.addSlot(new SlotItemHandler(internal, 0, 99, 29) {
|
||||||
|
private final int slot = 0;
|
||||||
|
private int x = MailboxGUIMenu.this.x;
|
||||||
|
private int y = MailboxGUIMenu.this.y;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mayPlace(ItemStack stack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
this.customSlots.put(1, this.addSlot(new SlotItemHandler(internal, 1, 117, 29) {
|
||||||
|
private final int slot = 1;
|
||||||
|
private int x = MailboxGUIMenu.this.x;
|
||||||
|
private int y = MailboxGUIMenu.this.y;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mayPlace(ItemStack stack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
this.customSlots.put(2, this.addSlot(new SlotItemHandler(internal, 2, 135, 29) {
|
||||||
|
private final int slot = 2;
|
||||||
|
private int x = MailboxGUIMenu.this.x;
|
||||||
|
private int y = MailboxGUIMenu.this.y;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mayPlace(ItemStack stack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
this.customSlots.put(3, this.addSlot(new SlotItemHandler(internal, 3, 99, 47) {
|
||||||
|
private final int slot = 3;
|
||||||
|
private int x = MailboxGUIMenu.this.x;
|
||||||
|
private int y = MailboxGUIMenu.this.y;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mayPlace(ItemStack stack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
this.customSlots.put(4, this.addSlot(new SlotItemHandler(internal, 4, 117, 47) {
|
||||||
|
private final int slot = 4;
|
||||||
|
private int x = MailboxGUIMenu.this.x;
|
||||||
|
private int y = MailboxGUIMenu.this.y;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mayPlace(ItemStack stack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
this.customSlots.put(5, this.addSlot(new SlotItemHandler(internal, 5, 135, 47) {
|
||||||
|
private final int slot = 5;
|
||||||
|
private int x = MailboxGUIMenu.this.x;
|
||||||
|
private int y = MailboxGUIMenu.this.y;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mayPlace(ItemStack stack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
this.customSlots.put(6, this.addSlot(new SlotItemHandler(internal, 6, 99, 65) {
|
||||||
|
private final int slot = 6;
|
||||||
|
private int x = MailboxGUIMenu.this.x;
|
||||||
|
private int y = MailboxGUIMenu.this.y;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mayPlace(ItemStack stack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
this.customSlots.put(7, this.addSlot(new SlotItemHandler(internal, 7, 117, 65) {
|
||||||
|
private final int slot = 7;
|
||||||
|
private int x = MailboxGUIMenu.this.x;
|
||||||
|
private int y = MailboxGUIMenu.this.y;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mayPlace(ItemStack stack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
this.customSlots.put(8, this.addSlot(new SlotItemHandler(internal, 8, 135, 65) {
|
||||||
|
private final int slot = 8;
|
||||||
|
private int x = MailboxGUIMenu.this.x;
|
||||||
|
private int y = MailboxGUIMenu.this.y;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mayPlace(ItemStack stack) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
this.customSlots.put(9, this.addSlot(new SlotItemHandler(internal, 9, 162, 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) {
|
||||||
|
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) {
|
||||||
|
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) {
|
||||||
|
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) {
|
||||||
|
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) {
|
||||||
|
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) {
|
||||||
|
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) {
|
||||||
|
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) {
|
||||||
|
private final int slot = 17;
|
||||||
|
private int x = MailboxGUIMenu.this.x;
|
||||||
|
private int y = MailboxGUIMenu.this.y;
|
||||||
|
}));
|
||||||
|
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));
|
||||||
|
for (int si = 0; si < 9; ++si)
|
||||||
|
this.addSlot(new Slot(inv, si, 92 + 8 + si * 18, 7 + 142));
|
||||||
|
}
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
ItemStack itemstack = ItemStack.EMPTY;
|
||||||
|
Slot slot = (Slot) this.slots.get(index);
|
||||||
|
if (slot != null && slot.hasItem()) {
|
||||||
|
ItemStack itemstack1 = slot.getItem();
|
||||||
|
itemstack = itemstack1.copy();
|
||||||
|
if (index < 18) {
|
||||||
|
if (!this.moveItemStackTo(itemstack1, 18, 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))
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
} else {
|
||||||
|
if (!this.moveItemStackTo(itemstack1, 18, 18 + 27, false))
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
if (itemstack1.getCount() == 0)
|
||||||
|
slot.set(ItemStack.EMPTY);
|
||||||
|
else
|
||||||
|
slot.setChanged();
|
||||||
|
if (itemstack1.getCount() == itemstack.getCount())
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
slot.onTake(playerIn, itemstack1);
|
||||||
|
}
|
||||||
|
return itemstack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean moveItemStackTo(ItemStack p_38904_, int p_38905_, int p_38906_, boolean p_38907_) {
|
||||||
|
boolean flag = false;
|
||||||
|
int i = p_38905_;
|
||||||
|
if (p_38907_) {
|
||||||
|
i = p_38906_ - 1;
|
||||||
|
}
|
||||||
|
if (p_38904_.isStackable()) {
|
||||||
|
while (!p_38904_.isEmpty()) {
|
||||||
|
if (p_38907_) {
|
||||||
|
if (i < p_38905_) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (i >= p_38906_) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Slot slot = this.slots.get(i);
|
||||||
|
ItemStack itemstack = slot.getItem();
|
||||||
|
if (slot.mayPlace(itemstack) && !itemstack.isEmpty() && ItemStack.isSameItemSameTags(p_38904_, itemstack)) {
|
||||||
|
int j = itemstack.getCount() + p_38904_.getCount();
|
||||||
|
int maxSize = Math.min(slot.getMaxStackSize(), p_38904_.getMaxStackSize());
|
||||||
|
if (j <= maxSize) {
|
||||||
|
p_38904_.setCount(0);
|
||||||
|
itemstack.setCount(j);
|
||||||
|
slot.set(itemstack);
|
||||||
|
flag = true;
|
||||||
|
} else if (itemstack.getCount() < maxSize) {
|
||||||
|
p_38904_.shrink(maxSize - itemstack.getCount());
|
||||||
|
itemstack.setCount(maxSize);
|
||||||
|
slot.set(itemstack);
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (p_38907_) {
|
||||||
|
--i;
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!p_38904_.isEmpty()) {
|
||||||
|
if (p_38907_) {
|
||||||
|
i = p_38906_ - 1;
|
||||||
|
} else {
|
||||||
|
i = p_38905_;
|
||||||
|
}
|
||||||
|
while (true) {
|
||||||
|
if (p_38907_) {
|
||||||
|
if (i < p_38905_) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else if (i >= p_38906_) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Slot slot1 = this.slots.get(i);
|
||||||
|
ItemStack itemstack1 = slot1.getItem();
|
||||||
|
if (itemstack1.isEmpty() && slot1.mayPlace(p_38904_)) {
|
||||||
|
if (p_38904_.getCount() > slot1.getMaxStackSize()) {
|
||||||
|
slot1.setByPlayer(p_38904_.split(slot1.getMaxStackSize()));
|
||||||
|
} else {
|
||||||
|
slot1.setByPlayer(p_38904_.split(p_38904_.getCount()));
|
||||||
|
}
|
||||||
|
slot1.setChanged();
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (p_38907_) {
|
||||||
|
--i;
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removed(Player playerIn) {
|
||||||
|
super.removed(playerIn);
|
||||||
|
if (!bound && playerIn instanceof ServerPlayer serverPlayer) {
|
||||||
|
if (!serverPlayer.isAlive() || serverPlayer.hasDisconnected()) {
|
||||||
|
for (int j = 0; j < internal.getSlots(); ++j) {
|
||||||
|
if (j == 0)
|
||||||
|
continue;
|
||||||
|
if (j == 1)
|
||||||
|
continue;
|
||||||
|
if (j == 2)
|
||||||
|
continue;
|
||||||
|
if (j == 3)
|
||||||
|
continue;
|
||||||
|
if (j == 4)
|
||||||
|
continue;
|
||||||
|
if (j == 5)
|
||||||
|
continue;
|
||||||
|
if (j == 6)
|
||||||
|
continue;
|
||||||
|
if (j == 7)
|
||||||
|
continue;
|
||||||
|
if (j == 8)
|
||||||
|
continue;
|
||||||
|
if (j == 9)
|
||||||
|
continue;
|
||||||
|
playerIn.drop(internal.extractItem(j, internal.getStackInSlot(j).getCount(), false), false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < internal.getSlots(); ++i) {
|
||||||
|
if (i == 0)
|
||||||
|
continue;
|
||||||
|
if (i == 1)
|
||||||
|
continue;
|
||||||
|
if (i == 2)
|
||||||
|
continue;
|
||||||
|
if (i == 3)
|
||||||
|
continue;
|
||||||
|
if (i == 4)
|
||||||
|
continue;
|
||||||
|
if (i == 5)
|
||||||
|
continue;
|
||||||
|
if (i == 6)
|
||||||
|
continue;
|
||||||
|
if (i == 7)
|
||||||
|
continue;
|
||||||
|
if (i == 8)
|
||||||
|
continue;
|
||||||
|
if (i == 9)
|
||||||
|
continue;
|
||||||
|
playerIn.getInventory().placeItemBackInInventory(internal.extractItem(i, internal.getStackInSlot(i).getCount(), false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, Slot> get() {
|
||||||
|
return customSlots;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"facing=north": {
|
||||||
|
"model": "nims_random_bullshit:block/mailbox"
|
||||||
|
},
|
||||||
|
"facing=east": {
|
||||||
|
"model": "nims_random_bullshit:block/mailbox",
|
||||||
|
"y": 90
|
||||||
|
},
|
||||||
|
"facing=south": {
|
||||||
|
"model": "nims_random_bullshit:block/mailbox",
|
||||||
|
"y": 180
|
||||||
|
},
|
||||||
|
"facing=west": {
|
||||||
|
"model": "nims_random_bullshit:block/mailbox",
|
||||||
|
"y": 270
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,15 +5,18 @@
|
|||||||
"item.nims_random_bullshit.star_wand": "Star Wand",
|
"item.nims_random_bullshit.star_wand": "Star Wand",
|
||||||
"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",
|
||||||
"block.nims_random_bullshit.penta_condensed_netherrack": "Penta-condensed Netherrack",
|
"block.nims_random_bullshit.penta_condensed_netherrack": "Penta-condensed Netherrack",
|
||||||
"item.nims_random_bullshit.magic_dust": "Magic Dust",
|
"item.nims_random_bullshit.magic_dust": "Magic Dust",
|
||||||
"enchantment.nims_random_bullshit.passive_income_enchantment": "Passive Income",
|
"enchantment.nims_random_bullshit.passive_income_enchantment": "Passive Income",
|
||||||
"item.nims_random_bullshit.netherrackite_pickaxe.description_0": "Non-condensed netherracks broken by this pickaxe drop themselves an additional time.",
|
"item.nims_random_bullshit.netherrackite_pickaxe.description_0": "Non-condensed netherracks broken by this pickaxe drop themselves an additional time.",
|
||||||
"item.nims_random_bullshit.netherrackite_pickaxe": "Netherrackite Pickaxe",
|
"item.nims_random_bullshit.netherrackite_pickaxe": "Netherrackite Pickaxe",
|
||||||
"effect.nims_random_bullshit.stinky_effect": "Stinky",
|
"effect.nims_random_bullshit.stinky_effect": "Stinky",
|
||||||
|
"gui.nims_random_bullshit.mailbox_gui.outbox_x_coord": "0",
|
||||||
"block.nims_random_bullshit.broken_glass": "Broken Glass",
|
"block.nims_random_bullshit.broken_glass": "Broken Glass",
|
||||||
"block.nims_random_bullshit.hexa_condensed_netherrack": "Hexa-condensed Netherrack",
|
"block.nims_random_bullshit.hexa_condensed_netherrack": "Hexa-condensed Netherrack",
|
||||||
"block.nims_random_bullshit.ore_miner": "Ore Miner",
|
"block.nims_random_bullshit.ore_miner": "Ore Miner",
|
||||||
|
"gui.nims_random_bullshit.mailbox_gui.label_outbox": "Outbox",
|
||||||
"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",
|
||||||
@@ -22,7 +25,10 @@
|
|||||||
"item.nims_random_bullshit.block_eater": "Block Eater",
|
"item.nims_random_bullshit.block_eater": "Block Eater",
|
||||||
"item.nims_random_bullshit.golden_berries": "Golden Berries",
|
"item.nims_random_bullshit.golden_berries": "Golden Berries",
|
||||||
"item.nims_random_bullshit.netherrack_juice_bucket": "Netherrack Juice Bucket",
|
"item.nims_random_bullshit.netherrack_juice_bucket": "Netherrack Juice Bucket",
|
||||||
|
"gui.nims_random_bullshit.mailbox_gui.label_y": "Y:",
|
||||||
|
"gui.nims_random_bullshit.mailbox_gui.label_z": "Z:",
|
||||||
"block.nims_random_bullshit.condensed_condensed_condensed_netherrack": "Condensed Condensed Condensed Netherrack",
|
"block.nims_random_bullshit.condensed_condensed_condensed_netherrack": "Condensed Condensed Condensed Netherrack",
|
||||||
|
"gui.nims_random_bullshit.mailbox_gui.label_x": "X:",
|
||||||
"entity.nims_random_bullshit.ghoul": "Ghoul",
|
"entity.nims_random_bullshit.ghoul": "Ghoul",
|
||||||
"item.nims_random_bullshit.star": "Star",
|
"item.nims_random_bullshit.star": "Star",
|
||||||
"gui.nims_random_bullshit.shit_gui.label_uh_ohh_stinky": "UH OHH!!! STINKY!!! UH OHH!!! STINKY!!! UH OHH!!! STINKY!!! UH OHH!!! STINKY!!! ",
|
"gui.nims_random_bullshit.shit_gui.label_uh_ohh_stinky": "UH OHH!!! STINKY!!! UH OHH!!! STINKY!!! UH OHH!!! STINKY!!! UH OHH!!! STINKY!!! ",
|
||||||
@@ -31,5 +37,9 @@
|
|||||||
"item.nims_random_bullshit.gravedigger.description_0": "Right-Click on soul sand or soul soil to use them, summoning a ghoul that attacks hostile mobs.",
|
"item.nims_random_bullshit.gravedigger.description_0": "Right-Click on soul sand or soul soil to use them, summoning a ghoul that attacks hostile mobs.",
|
||||||
"item.nims_random_bullshit.shit": "Shit",
|
"item.nims_random_bullshit.shit": "Shit",
|
||||||
"block.nims_random_bullshit.condensed_netherrack": "Condensed Netherrack",
|
"block.nims_random_bullshit.condensed_netherrack": "Condensed Netherrack",
|
||||||
|
"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_gui.label_inbox": "Inbox",
|
||||||
"item.nims_random_bullshit.netherrackite": "Netherrackite Ingot"
|
"item.nims_random_bullshit.netherrackite": "Netherrackite Ingot"
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"parent": "nims_random_bullshit:custom/mailbox",
|
||||||
|
"textures": {
|
||||||
|
"all": "nims_random_bullshit:block/mailbox_base",
|
||||||
|
"particle": "nims_random_bullshit:block/mailbox_base",
|
||||||
|
"0": "nims_random_bullshit:block/mailbox_rod",
|
||||||
|
"1": "nims_random_bullshit:block/mailbox_flag",
|
||||||
|
"2": "nims_random_bullshit:block/mailbox_base"
|
||||||
|
},
|
||||||
|
"render_type": "solid"
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 424 B |
Binary file not shown.
|
After Width: | Height: | Size: 358 B |
Binary file not shown.
|
After Width: | Height: | Size: 441 B |
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:block",
|
||||||
|
"random_sequence": "nims_random_bullshit:blocks/mailbox",
|
||||||
|
"pools": [
|
||||||
|
{
|
||||||
|
"rolls": 1.0,
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"condition": "minecraft:survives_explosion"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "nims_random_bullshit:mailbox"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user