diff --git a/config/corail_woodcutter-server.toml b/config/corail_woodcutter-server.toml index 871a14d..987340a 100644 --- a/config/corail_woodcutter-server.toml +++ b/config/corail_woodcutter-server.toml @@ -2,5 +2,5 @@ #Miscellaneous options [general] #Allows to open the woodcutter in inventory with right-click while sneaking [default:true] - open_woodcutter_in_inventory = false + open_woodcutter_in_inventory = true diff --git a/kubejs/assets/corail_woodcutter/lang/en_us.json b/kubejs/assets/corail_woodcutter/lang/en_us.json index 0ac86bc..8403d9c 100644 --- a/kubejs/assets/corail_woodcutter/lang/en_us.json +++ b/kubejs/assets/corail_woodcutter/lang/en_us.json @@ -1,9 +1,10 @@ { "block.corail_woodcutter.oak_woodcutter": "Woodcutter", + "block.corail_woodcutter.acacia_woodcutter": "Portable Woodcutter", "container.corail_woodcutter.woodcutter": "Woodcutter", "item.corail_woodcutter.woodcutter.desc": "A block for wood craftsmanship being similar to the stonecutter", - "item.corail_woodcutter.woodcutter.inventory": "Right-click by sneaking to open it in inventory", - "corail_woodcutter.config.general.open_woodcutter_in_inventory": "Allows to open the woodcutter in inventory with right-click while sneaking", + "item.corail_woodcutter.woodcutter.inventory": "", + "corail_woodcutter.config.general.open_woodcutter_in_inventory": "", "stat.corail_woodcutter.interact_with_sawmill": "Interactions with Sawmill", "corail_woodcutter.command.usage": "Generate the wooden crafting recipes of a mod in the Corail Woodcutter format in your config folder\n /woodcutter info\n /woodcutter datapack [generate|apply|remove] \napply & remove are useable in singleplayer and the datapack must be generated before applying it", "corail_woodcutter.message.datapack.generate.success": "The datapack was successfully generated in your config folder (%d recipes)", diff --git a/kubejs/assets/corail_woodcutter/models/item/acacia_woodcutter.json b/kubejs/assets/corail_woodcutter/models/item/acacia_woodcutter.json new file mode 100644 index 0000000..98be60c --- /dev/null +++ b/kubejs/assets/corail_woodcutter/models/item/acacia_woodcutter.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "corail_woodcutter:item/portable_woodcutter" + } +} diff --git a/kubejs/assets/corail_woodcutter/textures/item/portable_woodcutter.png b/kubejs/assets/corail_woodcutter/textures/item/portable_woodcutter.png new file mode 100644 index 0000000..b642ced Binary files /dev/null and b/kubejs/assets/corail_woodcutter/textures/item/portable_woodcutter.png differ diff --git a/kubejs/assets/corail_woodcutter/textures/item/portable_woodcutter.png.mcmeta b/kubejs/assets/corail_woodcutter/textures/item/portable_woodcutter.png.mcmeta new file mode 100644 index 0000000..a328ca5 --- /dev/null +++ b/kubejs/assets/corail_woodcutter/textures/item/portable_woodcutter.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": false, + "frametime": 1 + } +} diff --git a/kubejs/client_scripts/HarmoniousEngineering/hideJeiItems.js b/kubejs/client_scripts/HarmoniousEngineering/hideJeiItems.js index 1969adb..1bfd0d6 100644 --- a/kubejs/client_scripts/HarmoniousEngineering/hideJeiItems.js +++ b/kubejs/client_scripts/HarmoniousEngineering/hideJeiItems.js @@ -33,7 +33,6 @@ onEvent("jei.hide.items", (event) => { "projectred-core:silver_ingot", // Keep the / - doesn't work without them to indicate regex "/appliedenergistics2:facade/", - "corail_woodcutter:acacia_woodcutter", "corail_woodcutter:light_gray_stained_woodcutter", "corail_woodcutter:birch_woodcutter", "corail_woodcutter:lime_stained_woodcutter", diff --git a/kubejs/client_scripts/portable_woodcutter.js b/kubejs/client_scripts/portable_woodcutter.js new file mode 100644 index 0000000..7008153 --- /dev/null +++ b/kubejs/client_scripts/portable_woodcutter.js @@ -0,0 +1,6 @@ +// Only needed to prevent the player's inventory from looking like this was consumed even though it wasn't. +onEvent("block.right_click", (event) => { + if (event.getItem() === "corail_woodcutter:acacia_woodcutter") { + event.cancel(); + } +}); diff --git a/kubejs/server_scripts/HarmoniousEngineering/portable_woodcutter.js b/kubejs/server_scripts/HarmoniousEngineering/portable_woodcutter.js new file mode 100644 index 0000000..53d1246 --- /dev/null +++ b/kubejs/server_scripts/HarmoniousEngineering/portable_woodcutter.js @@ -0,0 +1,58 @@ +/** + * @Author: Jose Stovall | oitsjustjose + */ + +onEvent("item.right_click", (event) => { + const entity = event.getEntity(); + const heldItem = event.getItem(); + const serverPlayerEntity = entity.minecraftPlayer; + + if (!`${serverPlayerEntity}`.includes("ServerPlayerEntity")) { + return; + } + + // Treats the Acacia woodcutter as "portable" by forcing the player to sneak + if (heldItem === "corail_woodcutter:acacia_woodcutter") { + serverPlayerEntity.func_226284_e_(true); // setSneaking + } // Prevents the user from shift-right-clicking the woodcutter as configured. + else if (heldItem === "corail_woodcutter:oak_woodcutter") { + if ( + entity.isCrouching() || + serverPlayerEntity.func_225608_bj_() /* isSneaking */ + ) { + event.cancel(); + } + } +}); + +onEvent("player.inventory.opened", (event) => { + const currentlyOpenedContainer = event.getMinecraftPlayer().field_71070_bA; + if ( + currentlyOpenedContainer + .toString() + .includes("ovh.corail.woodcutter.inventory.WoodcutterContainer") + ) { + event.getMinecraftPlayer().func_226284_e_(false); // setSneaking + } +}); + +// Prevents ever placing the acacia woodcutter. Causes item to desync out of your inv so the next event fixes that +onEvent("block.right_click", (event) => { + if (event.getItem() === "corail_woodcutter:acacia_woodcutter") { + event.cancel(); + + const player = event.getEntity(); + const playerEntity = player.minecraftPlayer; + playerEntity.func_226284_e_(true); // setSneaking + + const portableWoodcutter = Item.of("corail_woodcutter:acacia_woodcutter"); + portableWoodcutter + .getItem() + /* onItemRightClick */ + .func_77659_a( + event.getBlock().minecraftLevel, + playerEntity, + event.getHand() + ); + } +}); diff --git a/kubejs/startup_scripts/items.js b/kubejs/startup_scripts/items.js index af51ef2..5c8e2af 100644 --- a/kubejs/startup_scripts/items.js +++ b/kubejs/startup_scripts/items.js @@ -5,5 +5,3 @@ onEvent("item.registry", (event) => { .create("cloth_covered_windmill_blade") .texture("kubejs:item/cloth_covered_windmill_blade"); }); - -// onEvent("block.registry", (event) => {}); diff --git a/texture files/portable_woodcutter.afphoto b/texture files/portable_woodcutter.afphoto new file mode 100644 index 0000000..c1378d1 Binary files /dev/null and b/texture files/portable_woodcutter.afphoto differ