mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
options to extinguish fire blocks with snowballs (#708)
This commit is contained in:
@@ -0,0 +1,71 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: granny <granny@pl3x.net>
|
||||||
|
Date: Thu, 14 Oct 2021 02:05:52 -0700
|
||||||
|
Subject: [PATCH] options to extinguish fire blocks with snowballs
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Snowball.java b/src/main/java/net/minecraft/world/entity/projectile/Snowball.java
|
||||||
|
index d5d84893c77b4e60a19032d765d76bfd24cbbb2b..ef265cec066ef3b84c2b3a4929af518308a409c3 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/projectile/Snowball.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/Snowball.java
|
||||||
|
@@ -58,6 +58,36 @@ public class Snowball extends ThrowableItemProjectile {
|
||||||
|
entity.hurt(DamageSource.thrown(this, this.getOwner()), (float)i);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Purpur start - borrowed and modified code from ThrownPotion#onHitBlock and ThrownPotion#dowseFire
|
||||||
|
+ @Override
|
||||||
|
+ protected void onHitBlock(net.minecraft.world.phys.BlockHitResult blockHitResult) {
|
||||||
|
+ super.onHitBlock(blockHitResult);
|
||||||
|
+
|
||||||
|
+ if (!this.level.isClientSide) {
|
||||||
|
+ net.minecraft.core.BlockPos blockposition = blockHitResult.getBlockPos();
|
||||||
|
+ net.minecraft.core.BlockPos blockposition1 = blockposition.relative(blockHitResult.getDirection());
|
||||||
|
+
|
||||||
|
+ net.minecraft.world.level.block.state.BlockState iblockdata = this.level.getBlockState(blockposition);
|
||||||
|
+
|
||||||
|
+ if (this.level.purpurConfig.snowballExtinguishesFire && this.level.getBlockState(blockposition1).is(net.minecraft.world.level.block.Blocks.FIRE)) {
|
||||||
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition1, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState()).isCancelled()) {
|
||||||
|
+ this.level.removeBlock(blockposition1, false);
|
||||||
|
+ }
|
||||||
|
+ } else if (this.level.purpurConfig.snowballExtinguishesCandles && net.minecraft.world.level.block.AbstractCandleBlock.isLit(iblockdata)) {
|
||||||
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(net.minecraft.world.level.block.AbstractCandleBlock.LIT, false)).isCancelled()) {
|
||||||
|
+ net.minecraft.world.level.block.AbstractCandleBlock.extinguish(null, iblockdata, this.level, blockposition);
|
||||||
|
+ }
|
||||||
|
+ } else if (this.level.purpurConfig.snowballExtinguishesCampfires && net.minecraft.world.level.block.CampfireBlock.isLitCampfire(iblockdata)) {
|
||||||
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(net.minecraft.world.level.block.CampfireBlock.LIT, false)).isCancelled()) {
|
||||||
|
+ this.level.levelEvent(null, 1009, blockposition, 0);
|
||||||
|
+ net.minecraft.world.level.block.CampfireBlock.dowse(this.getOwner(), this.level, blockposition, iblockdata);
|
||||||
|
+ this.level.setBlockAndUpdate(blockposition, iblockdata.setValue(net.minecraft.world.level.block.CampfireBlock.LIT, false));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Purpur end
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
protected void onHit(HitResult hitResult) {
|
||||||
|
super.onHit(hitResult);
|
||||||
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||||
|
index 3fefe9ef5ee110e82c174250bf6b4c90d0a7f28f..92f76de3d6ba9b3d777e8e8e149b5aa5ef01c9e3 100644
|
||||||
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||||
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||||
|
@@ -179,6 +179,9 @@ public class PurpurWorldConfig {
|
||||||
|
public int glowBerriesEatGlowDuration = 0;
|
||||||
|
public boolean shulkerBoxItemDropContentsWhenDestroyed = true;
|
||||||
|
public boolean compassItemShowsBossBar = false;
|
||||||
|
+ public boolean snowballExtinguishesFire = false;
|
||||||
|
+ public boolean snowballExtinguishesCandles = false;
|
||||||
|
+ public boolean snowballExtinguishesCampfires = false;
|
||||||
|
private void itemSettings() {
|
||||||
|
itemImmuneToCactus.clear();
|
||||||
|
getList("gameplay-mechanics.item.immune.cactus", new ArrayList<>()).forEach(key -> {
|
||||||
|
@@ -225,6 +228,9 @@ public class PurpurWorldConfig {
|
||||||
|
glowBerriesEatGlowDuration = getInt("gameplay-mechanics.item.glow_berries.eat-glow-duration", glowBerriesEatGlowDuration);
|
||||||
|
shulkerBoxItemDropContentsWhenDestroyed = getBoolean("gameplay-mechanics.item.shulker_box.drop-contents-when-destroyed", shulkerBoxItemDropContentsWhenDestroyed);
|
||||||
|
compassItemShowsBossBar = getBoolean("gameplay-mechanics.item.compass.holding-shows-bossbar", compassItemShowsBossBar);
|
||||||
|
+ snowballExtinguishesFire = getBoolean("gameplay-mechanics.item.snowball.extinguish.fire", snowballExtinguishesFire);
|
||||||
|
+ snowballExtinguishesCandles = getBoolean("gameplay-mechanics.item.snowball.extinguish.candles", snowballExtinguishesCandles);
|
||||||
|
+ snowballExtinguishesCampfires = getBoolean("gameplay-mechanics.item.snowball.extinguish.campfires", snowballExtinguishesCampfires);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double minecartMaxSpeed = 0.4D;
|
||||||
Reference in New Issue
Block a user