mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-10-26 12:25:28 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8616a74f33 | ||
|
|
b573192990 |
@@ -14,7 +14,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: 21
|
java-version: 21
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
uses: withastro/action@v4
|
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
|
||||||
|
|||||||
@@ -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,16 +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:glazed_terracotta",
|
|
||||||
"#minecraft:concrete",
|
|
||||||
"#minecraft:stone_bricks",
|
|
||||||
"minecraft:end_stone"
|
"minecraft:end_stone"
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
),
|
),
|
||||||
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)) {
|
||||||
|
|||||||
@@ -74,8 +74,10 @@ 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) {
|
||||||
event.getPlayer().breakBlock(b);
|
BlockBreakEvent breakEvent = new BlockBreakEvent(b, player);
|
||||||
|
Enchantio.getPlugin(Enchantio.class).getServer().getPluginManager().callEvent(breakEvent);
|
||||||
blockBreakSkips.remove(b);
|
blockBreakSkips.remove(b);
|
||||||
|
breakBlock(breakEvent, tunnellingEnchant);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -124,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