Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions omc_items/builder_wand.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
info:
namespace: omc_items
scripts:
builderwand:
enabled: true
path: iascript/builderwand
items:
builder_wand:
permission: omc_items.builder_wand
display_name: Builder Wand
lore:
- "§7Permet de poser une large zone de blocs"
resource:
material: WOODEN_SHOVEL
generate: false
model_path: items/builder_wand
blocked_enchants:
- ALL
durability:
usages: 1024
events:
interact_mainhand:
right:
cancel: true
decrement_usages:
amount: 1
script:
name: builderwand
attribute_modifiers:
mainhand:
attackDamage: 1
attackSpeed: 1
91 changes: 91 additions & 0 deletions omc_items/hammers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
info:
namespace: omc_items
items:
iron_hammer:
permission: customitems.iron_hammer
display_name: <gradient:#ffffff:#ffd08a>Marteau en fer
lore:
- "§7Permet de creuser une zone de 3x3 blocs"
resource:
material: IRON_PICKAXE
generate: false
model_path: items/hammers/iron_hammer
blocked_enchants:
- FORTUNE
- SILK_TOUCH
durability:
max_durability: 512

diamond_hammer:
permission: customitems.diamond_hammer
display_name: <gradient:#ffffff:#72f6ef>Marteau en diamant
lore:
- "§7Permet de creuser une zone de 3x3x2 blocs"
resource:
material: DIAMOND_PICKAXE
generate: false
model_path: items/hammers/diamond_hammer
blocked_enchants:
- FORTUNE
- SILK_TOUCH
durability:
max_durability: 2048

netherite_hammer:
permission: customitems.netherite_hammer
display_name: <gradient:#ffffff:#6b604f>Marteau en netherite
lore:
- "§7Permet de creuser une zone de 3x3x3 blocs"
resource:
material: NETHERITE_PICKAXE
generate: false
model_path: items/hammers/netherite_hammer
blocked_enchants:
- FORTUNE
- SILK_TOUCH
durability:
max_durability: 4096

recipes:
crafting_table:
iron_hammer:
permission: omc_items.iron_hammer
enabled: true
pattern:
- BBB
- BSB
- XSX
ingredients:
B: IRON_BLOCK
S: STICK
result:
item: omc_items:iron_hammer
amount: 1

diamond_hammer:
permission: omc_items.diamond_hammer
enabled: true
pattern:
- BBB
- BSB
- XSX
ingredients:
B: DIAMOND_BLOCK
S: STICK
result:
item: omc_items:diamond_hammer
amount: 1

netherite_hammer:
permission: omc_items.netherite_hammer
enabled: true
pattern:
- BBB
- BSB
- XSX
ingredients:
B: NETHERITE_BLOCK
S: STICK
result:
item: omc_items:netherite_hammer
amount: 1
79 changes: 79 additions & 0 deletions omc_items/iascript/builderwand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package iascript;

import org.bukkit.plugin.Plugin;
import org.bukkit.event.Event;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerInteractEvent;

import dev.lone.itemsadder.api.*;
import dev.lone.itemsadder.api.scriptinginternal.*;
import fr.openmc.core.features.city.ProtectionsManager;

public class builderwand extends ItemScript {

private static final int RADIUS = 2;

public void handleEvent(Plugin plugin, Event event, Player player, CustomStack $customStack, ItemStack $itemStack) {
if (!(event instanceof PlayerInteractEvent playerInteractEvent))
return;
playerInteractEvent.setCancelled(true);
Block origin = playerInteractEvent.getClickedBlock();
if (origin == null)
return;

BlockFace face = playerInteractEvent.getBlockFace();
Material type = origin.getType();
if (type.isAir())
return;

ItemStack wand = player.getInventory().getItemInMainHand();
CustomStack cs = CustomStack.byItemStack(wand);
if (cs == null)
return;

for (int a = -RADIUS; a <= RADIUS; a++) {
for (int b = -RADIUS; b <= RADIUS; b++) {

Block base;
switch (face) {
case UP, DOWN -> base = origin.getRelative(a, 0, b);
case NORTH, SOUTH -> base = origin.getRelative(a, b, 0);
case EAST, WEST -> base = origin.getRelative(0, b, a);
default -> base = null;
}

if (base == null)
continue;

Block toPlace = base.getRelative(face);

if (base.getType() != type)
continue;
if (!toPlace.getType().isAir())
continue;
if (!ProtectionsManager.canInteract(player, toPlace.getLocation()))
continue;
if (player.getGameMode() != org.bukkit.GameMode.CREATIVE && !player.getInventory().contains(type))
continue;

toPlace.setType(type, false);

if (player.getGameMode() != org.bukkit.GameMode.CREATIVE) {
for (ItemStack item : player.getInventory().getContents()) {
if (item == null)
continue;
if (item.getType() != type)
continue;

item.setAmount(item.getAmount() - 1);
break;
}
}
}
}
}
}
144 changes: 144 additions & 0 deletions omc_items/models/items/builder_wand.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"credit": "Made with Blockbench",
"texture_size": [32, 32],
"textures": {
"1": "omc_items:wands/builder_wand",
"particle": "omc_items:wands/builder_wand"
},
"elements": [
{
"from": [7, 0, 7],
"to": [9, 12, 9],
"rotation": {"angle": 45, "axis": "y", "origin": [8, 6, 8]},
"faces": {
"north": {"uv": [0, 0, 1, 6], "texture": "#1"},
"east": {"uv": [1, 0, 2, 6], "texture": "#1"},
"south": {"uv": [2, 0, 3, 6], "texture": "#1"},
"west": {"uv": [3, 0, 4, 6], "texture": "#1"},
"up": {"uv": [9, 3, 8, 2], "texture": "#1"},
"down": {"uv": [9, 3, 8, 4], "texture": "#1"}
}
},
{
"name": "Bas",
"from": [6, 11, 6],
"to": [10, 13, 10],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 12.5, 8]},
"faces": {
"north": {"uv": [6, 7, 8, 8], "texture": "#1"},
"east": {"uv": [8, 0, 10, 1], "texture": "#1"},
"south": {"uv": [8, 1, 10, 2], "texture": "#1"},
"west": {"uv": [2, 8, 4, 9], "texture": "#1"},
"up": {"uv": [4, 8, 2, 6], "texture": "#1"},
"down": {"uv": [8, 3, 6, 5], "texture": "#1"}
}
},
{
"name": "Nord",
"from": [6, 13, 6],
"to": [10, 15, 6],
"faces": {
"north": {"uv": [4, 2, 6, 3], "texture": "#1"},
"east": {"uv": [0, 0, 0, 3], "texture": "#1"},
"south": {"uv": [6, 2, 8, 3], "texture": "#1"},
"west": {"uv": [0, 0, 0, 3], "texture": "#1"},
"up": {"uv": [0, 0, 1, 0], "texture": "#1"},
"down": {"uv": [0, 0, 1, 0], "texture": "#1"}
}
},
{
"name": "Sud",
"from": [6, 13, 10],
"to": [10, 15, 10],
"faces": {
"north": {"uv": [0, 8, 2, 9], "texture": "#1"},
"east": {"uv": [0, 0, 0, 3], "texture": "#1"},
"south": {"uv": [4, 5, 6, 6], "texture": "#1"},
"west": {"uv": [0, 0, 0, 3], "texture": "#1"},
"up": {"uv": [0, 0, 1, 0], "texture": "#1"},
"down": {"uv": [0, 0, 1, 0], "texture": "#1"}
}
},
{
"name": "Est",
"from": [10, 13, 6],
"to": [10, 15, 10],
"faces": {
"north": {"uv": [0, 0, 0, 3], "texture": "#1"},
"east": {"uv": [0, 8, 2, 9], "texture": "#1"},
"south": {"uv": [0, 0, 0, 3], "texture": "#1"},
"west": {"uv": [4, 5, 6, 6], "texture": "#1"},
"up": {"uv": [0, 0, 0, 2], "texture": "#1"},
"down": {"uv": [0, 0, 0, 2], "texture": "#1"}
}
},
{
"name": "Ouest",
"from": [6, 13, 6],
"to": [6, 15, 10],
"faces": {
"north": {"uv": [0, 0, 0, 3], "texture": "#1"},
"east": {"uv": [4, 2, 6, 3], "texture": "#1"},
"south": {"uv": [0, 0, 0, 3], "texture": "#1"},
"west": {"uv": [6, 2, 8, 3], "texture": "#1"},
"up": {"uv": [0, 0, 0, 2], "texture": "#1"},
"down": {"uv": [0, 0, 0, 2], "texture": "#1"}
}
},
{
"name": "Diamond",
"from": [7, 15, 7],
"to": [9, 17, 9],
"rotation": {"angle": -45, "axis": "x", "origin": [8, 16, 8]},
"faces": {
"north": {"uv": [8, 4, 9, 5], "texture": "#1"},
"east": {"uv": [5, 8, 6, 9], "texture": "#1"},
"south": {"uv": [8, 5, 9, 6], "texture": "#1"},
"west": {"uv": [4, 8, 5, 9], "texture": "#1"},
"up": {"uv": [7, 9, 6, 8], "rotation": 270, "texture": "#1"},
"down": {"uv": [9, 6, 8, 7], "rotation": 90, "texture": "#1"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [0, 24, 0],
"translation": [0, 3.5, 0]
},
"thirdperson_lefthand": {
"rotation": [0, 24, 0],
"translation": [0, 3.5, 0]
},
"firstperson_righthand": {
"rotation": [0, 15, 0],
"translation": [0, 0.25, 0]
},
"firstperson_lefthand": {
"rotation": [0, 15, 0],
"translation": [0, 0.25, 0]
},
"gui": {
"rotation": [0, 40, -30],
"translation": [0.5, 0, 0]
},
"head": {
"rotation": [-57, 0, 0],
"translation": [0, 8.25, -11]
}
},
"groups": [
{
"name": "Stick",
"origin": [8, 6, 8],
"color": 0,
"children": [0]
},
{
"name": "EmeraldPart",
"origin": [8, 6, 8],
"color": 0,
"children": [1, 2, 3, 4, 5]
},
6
]
}
Loading