mirror of
https://github.com/Samsuik/Sakura.git
synced 2026-01-06 15:41:49 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@a24f9b2 1.21.6 dev PaperMC/Paper@457a0a6 Bump version string and protocol version to 1.21.6 release PaperMC/Paper@245b547 Update base to 1.21.6 PaperMC/Paper@b28d77b Update Moonrise to 1.21.6 PaperMC/Paper@8318dcb Update DataConverter to 1.21.6-rc1 PaperMC/Paper@d2b1158 Set correct world access on BSL snapshots PaperMC/Paper@023e6c2 Ensure waypoints are per world PaperMC/Paper@40d5d31 Fix recursively converting JSON Text Components PaperMC/Paper@1fcc416 Implement FeatureHooks#isChunkSent for Moonrise chunk system PaperMC/Paper@e4d7178 Implement WaypointTransmitter#isChunkVisible PaperMC/Paper@8980ead Directly walk text component after converting from JSON PaperMC/Paper@5613ed6 Provide env environment variable and copy spigots sys prop for overriding default repository PaperMC/Paper@62b7f86 Avoid and discourage use of Maven Central as a CDN (#12689) PaperMC/Paper@f5534cb [ci skip] Run generators (#12691) PaperMC/Paper@4781d28 Re-add Log4j Javadocs (#12693) PaperMC/Paper@74fbcce Check type of Material in get/set stats (#12607) PaperMC/Paper@4b3f967 Improve Fix MC-44654 (#12703) PaperMC/Paper@a7dd263 Enable spigot obfuscation support (#12695) PaperMC/Paper@6a51c44 Cleanup Primed TNT Fix (#12704) PaperMC/Paper@839c6a1 Fix #11169 (#12706) PaperMC/Paper@c77d5f9 Fix MC-297591 PaperMC/Paper@219f86e Implement chunk unload delay config option PaperMC/Paper@e4eb69b Do not allow ticket level decreases to be processed asynchronously PaperMC/Paper@71b0c76 Adds support for vanilla negative explosions (#12705) PaperMC/Paper@3750927 [ci skip] Fix PermissionManager#clearPermissions() docs bad wording (#12657) PaperMC/Paper@d61a51e Add ItemType#getBurnDuration() (#12604) PaperMC/Paper@29fc853 Allow empty paths in namespaced keys (#12687) PaperMC/Paper@4419afb fix: Safely handle nanosecond overflow in ClickCallback (#12686) PaperMC/Paper@5652882 Add `isProxyEnabled` method to ServerConfiguration (#12664) PaperMC/Paper@c0dda0e Add `isForceDefaultGameMode` method (#12673) PaperMC/Paper@e714de6 Fix excess slot updates PaperMC/Paper@6d0821d [ci skip] Fix docs for Spawner class and cleanup (#12710) PaperMC/Paper@cceffe3 Release ItemType and BlockType (#12708) PaperMC/Paper@186e9e3 Relocate CommandMap#registerServerAliases() call to after lifecycle events have been run (#12601) PaperMC/Paper@5edcf6d Cleanup/command dispatching (#12713) PaperMC/Paper@803baf0 Support hidden entities in Waypoints (#12715) PaperMC/Paper@1814d8b build: publish to fill (#12717) PaperMC/Paper@e454fef Add support for private constructors in plugin main classes (#12652) PaperMC/Paper@d0e808f Move player to correct position in vehicle move packet handler PaperMC/Paper@46b4b0b Improve keepalive ping system PaperMC/Paper@38c1ddb Add and use FeatureHooks.getAllEntities PaperMC/Paper@2f083ac Ensure player entity schedulers are ticked when they are dead PaperMC/Paper@7c90c7c Optimise EntityScheduler ticking PaperMC/Paper@aa6ee44 Re-add global region scheduler tick erroneously removed in last commit PaperMC/Paper@d7510ef Fix #12722 (#12726) PaperMC/Paper@0caf75f Fix #12721 (#12725) PaperMC/Paper@bee2879 Adventure 4.23.0 (#12690) PaperMC/Paper@692e93a Fix MC-299110 PaperMC/Paper@ea10fa4 Don't mutate the position of Items for MC-4 Fix (#12702) PaperMC/Paper@aa6cd74 Remove unnecesary item check for ServerboundPlayerActionPacket RELEASE_USE_ITEM (#12668) PaperMC/Paper@c9e89f4 Expose arrow velocity in EntityShootBowEvent for mobs (#12688) PaperMC/Paper@7ec3174 Jump out of experimental phase PaperMC/Paper@4e1a255 Update try catch for command handling
104 lines
6.3 KiB
Diff
104 lines
6.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Wed, 15 Nov 2023 23:18:38 +0000
|
|
Subject: [PATCH] Explosion Durable Blocks
|
|
|
|
|
|
diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java
|
|
index b5b53168755525eccaa0a4361172006522cf4e05..56acdfc2a8d2ecd716065263c59dbcb0ec7135bf 100644
|
|
--- a/net/minecraft/world/item/BlockItem.java
|
|
+++ b/net/minecraft/world/item/BlockItem.java
|
|
@@ -38,8 +38,31 @@ public class BlockItem extends Item {
|
|
this.block = block;
|
|
}
|
|
|
|
+ // Sakura start - explosion durable blocks
|
|
+ private void sendBlockDurabilityToPlayer(UseOnContext context) {
|
|
+ Player player = context.getPlayer();
|
|
+ BlockState state = context.getLevel().getBlockState(context.getClickedPos());
|
|
+ Block block = state.getBlock();
|
|
+ me.samsuik.sakura.explosion.durable.DurableMaterial material = context.getLevel().localConfig().config(context.getClickedPos()).durableMaterials.get(block);
|
|
+
|
|
+ if (material != null) {
|
|
+ int remaining = context.getLevel().durabilityManager.durability(context.getClickedPos(), material);
|
|
+ int durability = material.durability();
|
|
+
|
|
+ player.getBukkitEntity().sendRichMessage(
|
|
+ me.samsuik.sakura.configuration.GlobalConfiguration.get().messages.durableBlockInteraction,
|
|
+ net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.unparsed("remaining", String.valueOf(remaining)),
|
|
+ net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.unparsed("durability", String.valueOf(durability))
|
|
+ );
|
|
+ }
|
|
+ }
|
|
+
|
|
@Override
|
|
public InteractionResult useOn(UseOnContext context) {
|
|
+ if (this.getBlock() == net.minecraft.world.level.block.Blocks.POTATOES && context.getPlayer() != null) {
|
|
+ this.sendBlockDurabilityToPlayer(context);
|
|
+ }
|
|
+ // Sakura end - explosion durable blocks
|
|
InteractionResult interactionResult = this.place(new BlockPlaceContext(context));
|
|
return !interactionResult.consumesAction() && context.getItemInHand().has(DataComponents.CONSUMABLE)
|
|
? super.use(context.getLevel(), context.getPlayer(), context.getHand())
|
|
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
|
index ca5e2ec53590b731aedf33dfd69e728992f52b91..5aaa3f01b7e8b55742ba46dd614f1eaa233aa5c9 100644
|
|
--- a/net/minecraft/world/level/Level.java
|
|
+++ b/net/minecraft/world/level/Level.java
|
|
@@ -830,6 +830,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
|
|
// Sakura end - track block changes and tick scheduler
|
|
public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
|
|
public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(); // Sakura - explosion density cache
|
|
+ public final me.samsuik.sakura.explosion.durable.DurableBlockManager durabilityManager = new me.samsuik.sakura.explosion.durable.DurableBlockManager(); // Sakura - explosion durable blocks
|
|
|
|
protected Level(
|
|
WritableLevelData levelData,
|
|
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
|
|
index d45582bdfc3fa837c5aa95f499183b60b877b7c2..4a6677fbc520d3f5d537f35a92dab9ec69db47a0 100644
|
|
--- a/net/minecraft/world/level/ServerExplosion.java
|
|
+++ b/net/minecraft/world/level/ServerExplosion.java
|
|
@@ -131,7 +131,7 @@ public class ServerExplosion implements Explosion {
|
|
BlockState blockState = ((ca.spottedleaf.moonrise.patches.getblock.GetBlockChunk)chunk).moonrise$getBlock(x, y, z);
|
|
FluidState fluidState = blockState.getFluidState();
|
|
|
|
- Optional<Float> resistance = !calculateResistance ? Optional.empty() : this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState);
|
|
+ Optional<Float> resistance = !calculateResistance ? Optional.empty() : this.calculateBlockResistance(blockState, fluidState, pos); // Sakura - explosion durable blocks
|
|
|
|
ret = new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache(
|
|
key, pos, blockState, fluidState,
|
|
@@ -390,6 +390,20 @@ public class ServerExplosion implements Explosion {
|
|
// Paper end - collision optimisations
|
|
}
|
|
// Sakura end - specialised explosions
|
|
+ // Sakura start - explosion durable blocks
|
|
+ private Optional<Float> calculateBlockResistance(BlockState blockState, FluidState fluidState, BlockPos pos) {
|
|
+ if (!blockState.isAir()) {
|
|
+ final Block block = blockState.getBlock();
|
|
+ final me.samsuik.sakura.explosion.durable.DurableMaterial material = this.level.localConfig().config(pos).durableMaterials.get(block);
|
|
+
|
|
+ if (material != null && material.resistance() >= 0.0f && pos.getY() > this.level.getMinY() && (!this.level.sakuraConfig().cannons.explosion.requireTntToDamageDurableMaterials || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) {
|
|
+ return Optional.of(material.resistance());
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState);
|
|
+ }
|
|
+ // Sakura end - explosion durable blocks
|
|
|
|
public ServerExplosion(
|
|
ServerLevel level,
|
|
@@ -770,6 +784,14 @@ public class ServerExplosion implements Explosion {
|
|
}
|
|
}
|
|
// CraftBukkit end
|
|
+ // Sakura start - explosion durable blocks
|
|
+ if (!this.level.sakuraConfig().cannons.explosion.requireTntToDamageDurableMaterials || this.source instanceof net.minecraft.world.entity.item.PrimedTnt) {
|
|
+ final me.samsuik.sakura.explosion.durable.DurableMaterial material = this.level.localConfig().config(blockPos).durableMaterials.get(block);
|
|
+ if (material != null && material.durability() >= 0 && !this.level.durabilityManager.damage(blockPos, material)) {
|
|
+ continue;
|
|
+ }
|
|
+ }
|
|
+ // Sakura end - explosion durable blocks
|
|
|
|
this.level
|
|
.getBlockState(blockPos)
|