Portable woodcutter!!

This commit is contained in:
oitsjustjose 2022-01-16 01:22:56 -06:00
commit 7bb6a1a58e
10 changed files with 80 additions and 6 deletions

View file

@ -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

View file

@ -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] <modid>\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)",

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "corail_woodcutter:item/portable_woodcutter"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -0,0 +1,6 @@
{
"animation": {
"interpolate": false,
"frametime": 1
}
}

View file

@ -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",

View file

@ -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();
}
});

View file

@ -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()
);
}
});

View file

@ -5,5 +5,3 @@ onEvent("item.registry", (event) => {
.create("cloth_covered_windmill_blade")
.texture("kubejs:item/cloth_covered_windmill_blade");
});
// onEvent("block.registry", (event) => {});

Binary file not shown.