mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-10-26 20:35:30 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8616a74f33 | ||
|
|
b573192990 |
@@ -10,13 +10,13 @@ jobs:
|
|||||||
build-commit:
|
build-commit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v7
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v6
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: '21'
|
java-version: 21
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
- name: Set short commit hash
|
- name: Set short commit hash
|
||||||
run: fullCommit=${{ github.sha }} && echo "SHORT_SHA=${fullCommit:0:8}" >> $GITHUB_ENV
|
run: fullCommit=${{ github.sha }} && echo "SHORT_SHA=${fullCommit:0:8}" >> $GITHUB_ENV
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v4
|
||||||
- name: Build Astro page
|
- name: Build Astro page
|
||||||
uses: withastro/action@v6
|
uses: withastro/action@v4
|
||||||
with:
|
with:
|
||||||
path: ./docs
|
path: ./docs
|
||||||
node-version: '24'
|
node-version: '22'
|
||||||
deploy:
|
deploy:
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -31,4 +31,4 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
id: deployment
|
id: deployment
|
||||||
uses: actions/deploy-pages@v5
|
uses: actions/deploy-pages@v4
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default defineConfig({
|
|||||||
sidebar: [
|
sidebar: [
|
||||||
{
|
{
|
||||||
label: 'Documentation',
|
label: 'Documentation',
|
||||||
items: [{ autogenerate: { "directory": "documentation" } }]
|
autogenerate: { directory: 'documentation' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Configuration',
|
label: 'Configuration',
|
||||||
|
|||||||
Generated
+3555
-2326
File diff suppressed because it is too large
Load Diff
+3
-2
@@ -10,7 +10,8 @@
|
|||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/starlight": "^0.42.4",
|
"@astrojs/starlight": "^0.34.3",
|
||||||
"astro": "^7.2.10"
|
"astro": "^5.6.1",
|
||||||
|
"sharp": "^0.32.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,41 +4,11 @@ description: How to specify common input types in configuration
|
|||||||
---
|
---
|
||||||
|
|
||||||
## Tags
|
## Tags
|
||||||
|
There are 2 types of tags that can be used in the configuration:
|
||||||
### Items
|
- `minecraft:item_name` - For specific items, use namespaced vanilla item id. If namespace is not provided, `minecraft` is assumed.
|
||||||
|
- `#minecraft:item_tag_name` - For <a href="https://minecraft.wiki/w/Item_tag_(Java_Edition)" target="_blank">item tags</a>,
|
||||||
#### Item reference
|
use namespaced tag id. If namespace is not provided, `minecraft` is assumed. Custom tags from other plugins and
|
||||||
Example: `minecraft:stick`
|
datapacks are also supported.
|
||||||
|
|
||||||
For specific items, use namespaced vanilla item id. If namespace is not provided, `minecraft` is assumed.
|
|
||||||
|
|
||||||
#### Item tag
|
|
||||||
Example: `#minecraft:axes`
|
|
||||||
|
|
||||||
For <a href="https://minecraft.wiki/w/Item_tag_(Java_Edition)" target="_blank">item tags</a>, use namespaced tag id. If
|
|
||||||
namespace is not provided, `minecraft` is assumed. Custom tags from other plugins and datapacks are also supported.
|
|
||||||
|
|
||||||
### Blocks
|
|
||||||
|
|
||||||
#### Block reference
|
|
||||||
Example: `minecraft:dirt`
|
|
||||||
|
|
||||||
For specific items, use namespaced vanilla item id. If namespace is not provided, `minecraft` is assumed.
|
|
||||||
|
|
||||||
#### Block tag
|
|
||||||
Example: `#minecraft:planks`
|
|
||||||
|
|
||||||
For <a href="https://minecraft.wiki/w/Block_tag_(Java_Edition)" target="_blank">block tags</a>, use namespaced tag id. If
|
|
||||||
namespace is not provided, `minecraft` is assumed. Custom tags from other plugins and datapacks are also supported.
|
|
||||||
|
|
||||||
|
|
||||||
### Enchantments
|
|
||||||
|
|
||||||
#### Enchantment tag
|
|
||||||
Example: `#minecraft:in_enchanting_table`
|
|
||||||
|
|
||||||
For <a href="https://minecraft.wiki/w/Enchantment_tag_(Java_Edition)" target="_blank">enchantment tags</a>, use namespaced tag id. If
|
|
||||||
namespace is not provided, `minecraft` is assumed. Custom tags from other plugins and datapacks are also supported.
|
|
||||||
|
|
||||||
## Slot types
|
## Slot types
|
||||||
- `ANY` - Any slot.
|
- `ANY` - Any slot.
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ Cost that will be added to the item when adding the enchantment to it in anvil.
|
|||||||
|
|
||||||
- **Type**: `int`
|
- **Type**: `int`
|
||||||
|
|
||||||
Weight of the enchantment. Higher numbers mean it will come up more frequently in the enchanting table. Used if
|
Weight of the enchantment. Used if `canGetFromEnchantingTable` is set to true. Higher numbers mean it will come up more
|
||||||
`#minecraft:in_enchanting_table` is present in enchantment tags.
|
frequently in the enchanting table.
|
||||||
|
|
||||||
### minimumCost
|
### minimumCost
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ Minimum cost that will be required for the enchantment to show up in the enchant
|
|||||||
|
|
||||||
- **Type**: `int`
|
- **Type**: `int`
|
||||||
|
|
||||||
Base cost of the enchantment.
|
Base cost of the enchant.
|
||||||
|
|
||||||
#### perLevel
|
#### perLevel
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ Maximum cost that will be required for the enchantment to show up in the enchant
|
|||||||
|
|
||||||
- **Type**: `int`
|
- **Type**: `int`
|
||||||
|
|
||||||
Base cost of the enchantment.
|
Base cost of the enchant.
|
||||||
|
|
||||||
#### perLevel
|
#### perLevel
|
||||||
|
|
||||||
@@ -55,22 +55,23 @@ Cost to add per level of the enchantment.
|
|||||||
|
|
||||||
### enchantmentTags
|
### enchantmentTags
|
||||||
|
|
||||||
- **Type**: [`Enchantment Tags`](/configuration/input-types/#enchantment-tag)
|
- **Type**: `key[]`
|
||||||
|
|
||||||
This is list of tags that the enchantment will be tagged with. This can be used to put the enchantment in enchanting table,
|
This is list of [tags](/configuration/input-types#tags) that the enchantment will be tagged with. This can be used to put the enchantment in enchanting table,
|
||||||
mark it as a curse, etc.
|
mark it as a curse, etc. <a href="https://minecraft.wiki/w/Enchantment_tag_(Java_Edition)" target="_blank">All vanilla</a>
|
||||||
|
and custom tags are supported.
|
||||||
|
|
||||||
### supportedItemTags
|
### supportedItemTags
|
||||||
|
|
||||||
- **Type**: [`Item Tags`](/configuration/input-types/#items)
|
- **Type**: `key[]`
|
||||||
|
|
||||||
Items and/or item tags that the enchantment can be applied to.
|
[Items and/or item tags](/configuration/input-types#tags) that the enchantment can be applied to.
|
||||||
|
|
||||||
### activeSlots
|
### activeSlots
|
||||||
|
|
||||||
- **Type**: [`Slot types`](/configuration/input-types/#slot-types)
|
- **Type**: `string[]`
|
||||||
|
|
||||||
Inventory slots that the enchantment will be active in.
|
[Slots](/configuration/input-types#slot-types) that the enchantment will be active in.
|
||||||
|
|
||||||
|
|
||||||
### enabled
|
### enabled
|
||||||
@@ -95,11 +96,9 @@ of the enchantment does not support multiple levels.
|
|||||||
|
|
||||||
## Telepathy
|
## Telepathy
|
||||||
|
|
||||||
### onlyUserCanPickupItems
|
|
||||||
|
|
||||||
- **Type**: `boolean`
|
- **Type**: `boolean`
|
||||||
|
|
||||||
If set to true, items teleported by the enchantment will only be able to be picked up by the player that broke the block.
|
If set to true, items teleported by the enchant will only be able to be picked up by the player that broke the block.
|
||||||
|
|
||||||
## Executioner
|
## Executioner
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class TunnellingEnchant implements EnchantioEnchant {
|
|||||||
public static final Key AFFECTED_BLOCKS_KEY = Key.key("enchantio", "affected_by_tunnelling");
|
public static final Key AFFECTED_BLOCKS_KEY = Key.key("enchantio", "affected_by_tunnelling");
|
||||||
|
|
||||||
private final int anvilCost, weight, maxLevel, blocksPerLevel;
|
private final int anvilCost, weight, maxLevel, blocksPerLevel;
|
||||||
|
private final boolean canBreakToolIncompatibleBlocks;
|
||||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||||
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
|
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
|
||||||
private final Set<TagEntry<ItemType>> supportedItemTags = new HashSet<>();
|
private final Set<TagEntry<ItemType>> supportedItemTags = new HashSet<>();
|
||||||
@@ -40,7 +41,8 @@ public class TunnellingEnchant implements EnchantioEnchant {
|
|||||||
Collection<TagEntry<ItemType>> supportedItemTags,
|
Collection<TagEntry<ItemType>> supportedItemTags,
|
||||||
Map<Key, Set<TagEntry<BlockType>>> affectedBlockTags,
|
Map<Key, Set<TagEntry<BlockType>>> affectedBlockTags,
|
||||||
int maxLevel,
|
int maxLevel,
|
||||||
int blocksPerLevel
|
int blocksPerLevel,
|
||||||
|
boolean canBreakToolIncompatibleBlocks
|
||||||
) {
|
) {
|
||||||
this.anvilCost = anvilCost;
|
this.anvilCost = anvilCost;
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
@@ -48,6 +50,7 @@ public class TunnellingEnchant implements EnchantioEnchant {
|
|||||||
this.maximumCost = maximumCost;
|
this.maximumCost = maximumCost;
|
||||||
this.maxLevel = maxLevel;
|
this.maxLevel = maxLevel;
|
||||||
this.blocksPerLevel = blocksPerLevel;
|
this.blocksPerLevel = blocksPerLevel;
|
||||||
|
this.canBreakToolIncompatibleBlocks = canBreakToolIncompatibleBlocks;
|
||||||
this.supportedItemTags.addAll(supportedItemTags);
|
this.supportedItemTags.addAll(supportedItemTags);
|
||||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||||
this.affectedBlockTags.putAll(affectedBlockTags);
|
this.affectedBlockTags.putAll(affectedBlockTags);
|
||||||
@@ -112,6 +115,10 @@ public class TunnellingEnchant implements EnchantioEnchant {
|
|||||||
return blocksPerLevel;
|
return blocksPerLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canBreakToolIncompatibleBlocks() {
|
||||||
|
return canBreakToolIncompatibleBlocks;
|
||||||
|
}
|
||||||
|
|
||||||
public static TunnellingEnchant create(ConfigurationSection configurationSection) {
|
public static TunnellingEnchant create(ConfigurationSection configurationSection) {
|
||||||
TunnellingEnchant tunnellingEnchant = new TunnellingEnchant(
|
TunnellingEnchant tunnellingEnchant = new TunnellingEnchant(
|
||||||
EnchantioConfig.getInt(configurationSection, "anvilCost", 1),
|
EnchantioConfig.getInt(configurationSection, "anvilCost", 1),
|
||||||
@@ -145,18 +152,13 @@ public class TunnellingEnchant implements EnchantioEnchant {
|
|||||||
"#minecraft:base_stone_overworld",
|
"#minecraft:base_stone_overworld",
|
||||||
"#minecraft:base_stone_nether",
|
"#minecraft:base_stone_nether",
|
||||||
"#minecraft:ores",
|
"#minecraft:ores",
|
||||||
"#minecraft:terracotta",
|
"minecraft:end_stone"
|
||||||
"#minecraft:glazed_terracotta",
|
|
||||||
"#minecraft:concrete",
|
|
||||||
"#minecraft:stone_bricks",
|
|
||||||
"minecraft:end_stone",
|
|
||||||
"minecraft:cobblestone",
|
|
||||||
"minecraft:cobbled_deepslate"
|
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
),
|
),
|
||||||
EnchantioConfig.getInt(configurationSection, "maxLevel", 1),
|
EnchantioConfig.getInt(configurationSection, "maxLevel", 1),
|
||||||
EnchantioConfig.getInt(configurationSection, "blocksPerLevel", 1)
|
EnchantioConfig.getInt(configurationSection, "blocksPerLevel", 1),
|
||||||
|
EnchantioConfig.getBoolean(configurationSection, "canBreakToolIncompatibleBlocks", false)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
|
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package me.youhavetrouble.enchantio.listeners;
|
|||||||
import io.papermc.paper.registry.RegistryAccess;
|
import io.papermc.paper.registry.RegistryAccess;
|
||||||
import io.papermc.paper.registry.RegistryKey;
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
import io.papermc.paper.registry.keys.tags.BlockTypeTagKeys;
|
import io.papermc.paper.registry.keys.tags.BlockTypeTagKeys;
|
||||||
|
import me.youhavetrouble.enchantio.Enchantio;
|
||||||
import me.youhavetrouble.enchantio.EnchantioConfig;
|
import me.youhavetrouble.enchantio.EnchantioConfig;
|
||||||
import me.youhavetrouble.enchantio.enchants.EnchantioEnchant;
|
import me.youhavetrouble.enchantio.enchants.EnchantioEnchant;
|
||||||
import me.youhavetrouble.enchantio.enchants.TunnellingEnchant;
|
import me.youhavetrouble.enchantio.enchants.TunnellingEnchant;
|
||||||
@@ -21,7 +22,9 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
@@ -38,7 +41,7 @@ public class TunnellingListener implements Listener {
|
|||||||
if (event.getHand() != EquipmentSlot.HAND) return;
|
if (event.getHand() != EquipmentSlot.HAND) return;
|
||||||
if (event.getAction() != Action.LEFT_CLICK_BLOCK) return;
|
if (event.getAction() != Action.LEFT_CLICK_BLOCK) return;
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (GameMode.CREATIVE.equals(player.getGameMode())) return;
|
if (player.isSneaking() || GameMode.CREATIVE.equals(player.getGameMode())) return;
|
||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
if (!item.containsEnchantment(tunnelling)) return;
|
if (!item.containsEnchantment(tunnelling)) return;
|
||||||
@@ -71,29 +74,33 @@ public class TunnellingListener implements Listener {
|
|||||||
Set<Block> blocksToBreak = getSquare(block, blockFace, tunnellingEnchant.getBlocksPerLevel() * enchantLevel);
|
Set<Block> blocksToBreak = getSquare(block, blockFace, tunnellingEnchant.getBlocksPerLevel() * enchantLevel);
|
||||||
blockBreakSkips.addAll(blocksToBreak);
|
blockBreakSkips.addAll(blocksToBreak);
|
||||||
for (Block b : blocksToBreak) {
|
for (Block b : blocksToBreak) {
|
||||||
if (player.getInventory().getItemInMainHand().isEmpty()) {
|
BlockBreakEvent breakEvent = new BlockBreakEvent(b, player);
|
||||||
event.setCancelled(true);
|
Enchantio.getPlugin(Enchantio.class).getServer().getPluginManager().callEvent(breakEvent);
|
||||||
blockBreakSkips.removeAll(blocksToBreak);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
event.getPlayer().breakBlock(b);
|
|
||||||
blockBreakSkips.remove(b);
|
blockBreakSkips.remove(b);
|
||||||
|
breakBlock(breakEvent, tunnellingEnchant);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Block> getSquare(Block block, BlockFace face, int range) {
|
private Set<Block> getSquare(Block block, BlockFace face, int range) {
|
||||||
|
Set<Block> blocks = new HashSet<>();
|
||||||
switch (face) {
|
switch (face) {
|
||||||
case DOWN, UP -> {
|
case DOWN:
|
||||||
return getBlocksToTunnel(block.getLocation(), range, 0, range);
|
case UP:
|
||||||
}
|
blocks.addAll(getBlocksToTunnel(block.getLocation(), range, 0, range));
|
||||||
case EAST, WEST -> {
|
break;
|
||||||
return getBlocksToTunnel(block.getLocation(), 0, range, range);
|
case EAST:
|
||||||
}
|
case WEST:
|
||||||
case NORTH, SOUTH -> {
|
blocks.addAll(getBlocksToTunnel(block.getLocation(), 0, range, range));
|
||||||
return getBlocksToTunnel(block.getLocation(), range, range, 0);
|
break;
|
||||||
}
|
case NORTH:
|
||||||
|
case SOUTH:
|
||||||
|
blocks.addAll(getBlocksToTunnel(block.getLocation(), range, range, 0));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return new HashSet<>();
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,8 +108,8 @@ public class TunnellingListener implements Listener {
|
|||||||
* @param base location at the centre of selection
|
* @param base location at the centre of selection
|
||||||
* @return All blocks that will get broken
|
* @return All blocks that will get broken
|
||||||
*/
|
*/
|
||||||
private Set<Block> getBlocksToTunnel(Location base, int changeX, int changeY, int changeZ) {
|
private List<Block> getBlocksToTunnel(Location base, int changeX, int changeY, int changeZ) {
|
||||||
Set<Block> blocks = new HashSet<>();
|
List<Block> blocks = new ArrayList<>();
|
||||||
for (int x = (base.getBlockX() - changeX); x <= (base.getBlockX() + changeX); x++) {
|
for (int x = (base.getBlockX() - changeX); x <= (base.getBlockX() + changeX); x++) {
|
||||||
for (int y = (base.getBlockY() - changeY); y <= (base.getBlockY() + changeY); y++) {
|
for (int y = (base.getBlockY() - changeY); y <= (base.getBlockY() + changeY); y++) {
|
||||||
for (int z = (base.getBlockZ() - changeZ); z <= (base.getBlockZ() + changeZ); z++) {
|
for (int z = (base.getBlockZ() - changeZ); z <= (base.getBlockZ() + changeZ); z++) {
|
||||||
@@ -119,4 +126,15 @@ public class TunnellingListener implements Listener {
|
|||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void breakBlock(BlockBreakEvent event, TunnellingEnchant enchant) {
|
||||||
|
if (tunnelling == null) return;
|
||||||
|
if (event.isCancelled()) return;
|
||||||
|
Block block = event.getBlock();
|
||||||
|
ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
|
||||||
|
int enchantLevel = item.getEnchantmentLevel(tunnelling);
|
||||||
|
if (enchantLevel <= 0) return;
|
||||||
|
block.breakNaturally(item, true, event.getExpToDrop() > 0, enchant.canBreakToolIncompatibleBlocks());
|
||||||
|
item.damage(1, event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user