mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-21 02:17:42 +01:00
Campfires regen only if line of sight
This commit is contained in:
@@ -116,6 +116,10 @@ campfire-regen
|
|||||||
- **default**: 0
|
- **default**: 0
|
||||||
- **description**: The amplifier on the regen buff. `0` for level 1, `1` for level 2
|
- **description**: The amplifier on the regen buff. `0` for level 1, `1` for level 2
|
||||||
|
|
||||||
|
* require-line-of-sight
|
||||||
|
- **default**: true
|
||||||
|
- **description**: Only players within line of sight of the campfire will receive the regen buff
|
||||||
|
|
||||||
* boost-duration
|
* boost-duration
|
||||||
- **default**: 80
|
- **default**: 80
|
||||||
- **description**: How long (in ticks) the regen buff lasts when the campfire is in smoke signal mode
|
- **description**: How long (in ticks) the regen buff lasts when the campfire is in smoke signal mode
|
||||||
@@ -127,3 +131,7 @@ campfire-regen
|
|||||||
* boost-amplifier
|
* boost-amplifier
|
||||||
- **default**: 1
|
- **default**: 1
|
||||||
- **description**: The amplifier on the regen buff when the campfire is in smoke signal mode
|
- **description**: The amplifier on the regen buff when the campfire is in smoke signal mode
|
||||||
|
|
||||||
|
* boost-require-line-of-sight
|
||||||
|
- **default**: false
|
||||||
|
- **description**: Only players within line of sight of the campfire will receive the regen buff when the campfire is in smoke signal mode
|
||||||
|
|||||||
@@ -1,18 +1,46 @@
|
|||||||
From 5f6b1226ebd2d3316469b5b9c3f301a5e4a903cf Mon Sep 17 00:00:00 2001
|
From c95c100ac2d6d0ca91afced8929e903d894bb2c0 Mon Sep 17 00:00:00 2001
|
||||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||||
Date: Sun, 19 May 2019 18:11:53 -0500
|
Date: Sun, 19 May 2019 18:11:53 -0500
|
||||||
Subject: [PATCH] Add regen effect to campfires
|
Subject: [PATCH] Add regen effect to campfires
|
||||||
|
|
||||||
---
|
---
|
||||||
.../minecraft/server/TileEntityCampfire.java | 10 ++++++++++
|
.../net/minecraft/server/EntityLiving.java | 15 ++++++++++---
|
||||||
.../java/net/pl3x/purpur/PurpurWorldConfig.java | 17 +++++++++++++++++
|
.../minecraft/server/TileEntityCampfire.java | 21 +++++++++++++++++++
|
||||||
2 files changed, 27 insertions(+)
|
.../net/pl3x/purpur/PurpurWorldConfig.java | 21 +++++++++++++++++++
|
||||||
|
3 files changed, 54 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||||
|
index 27375059f..a64639aeb 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||||
|
@@ -2706,10 +2706,19 @@ public abstract class EntityLiving extends Entity {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasLineOfSight(Entity entity) {
|
||||||
|
- Vec3D vec3d = new Vec3D(this.locX, this.locY + (double) this.getHeadHeight(), this.locZ);
|
||||||
|
- Vec3D vec3d1 = new Vec3D(entity.locX, entity.locY + (double) entity.getHeadHeight(), entity.locZ);
|
||||||
|
+ // Purpur start
|
||||||
|
+ return hasLineOfSight(entity.locX, entity.locY + (double) entity.getHeadHeight(), entity.locZ);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean hasLineOfSight(TileEntity te) {
|
||||||
|
+ return hasLineOfSight(te.position.x + 0.5, te.position.y + 0.5, te.position.z + 0.5);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- return this.world.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.COLLIDER, RayTrace.FluidCollisionOption.NONE, this)).getType() == MovingObjectPosition.EnumMovingObjectType.MISS;
|
||||||
|
+ public boolean hasLineOfSight(double x, double y, double z) {
|
||||||
|
+ Vec3D start = new Vec3D(locX, locY + (double) getHeadHeight(), locZ);
|
||||||
|
+ Vec3D end = new Vec3D(x, y, z);
|
||||||
|
+ return this.world.rayTrace(new RayTrace(start, end, RayTrace.BlockCollisionOption.COLLIDER, RayTrace.FluidCollisionOption.NONE, this)).getType() == MovingObjectPosition.EnumMovingObjectType.MISS;
|
||||||
|
+ // Purpur end
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
diff --git a/src/main/java/net/minecraft/server/TileEntityCampfire.java b/src/main/java/net/minecraft/server/TileEntityCampfire.java
|
diff --git a/src/main/java/net/minecraft/server/TileEntityCampfire.java b/src/main/java/net/minecraft/server/TileEntityCampfire.java
|
||||||
index 3a97a6571..530022248 100644
|
index 3a97a6571..e93ecc7b5 100644
|
||||||
--- a/src/main/java/net/minecraft/server/TileEntityCampfire.java
|
--- a/src/main/java/net/minecraft/server/TileEntityCampfire.java
|
||||||
+++ b/src/main/java/net/minecraft/server/TileEntityCampfire.java
|
+++ b/src/main/java/net/minecraft/server/TileEntityCampfire.java
|
||||||
@@ -34,6 +34,16 @@ public class TileEntityCampfire extends TileEntity implements Clearable, ITickab
|
@@ -34,6 +34,27 @@ public class TileEntityCampfire extends TileEntity implements Clearable, ITickab
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
@@ -23,17 +51,28 @@ index 3a97a6571..530022248 100644
|
|||||||
+ byte amp = (byte) (signalBoost ? world.purpurConfig.campfireRegenBoostAmp : world.purpurConfig.campfireRegenAmp);
|
+ byte amp = (byte) (signalBoost ? world.purpurConfig.campfireRegenBoostAmp : world.purpurConfig.campfireRegenAmp);
|
||||||
+ int range = signalBoost ? world.purpurConfig.campfireRegenBoostRange : world.purpurConfig.campfireRegenRange;
|
+ int range = signalBoost ? world.purpurConfig.campfireRegenBoostRange : world.purpurConfig.campfireRegenRange;
|
||||||
+ MobEffect regeneration = new MobEffect(MobEffects.REGENERATION, duration, amp, true, true);
|
+ MobEffect regeneration = new MobEffect(MobEffects.REGENERATION, duration, amp, true, true);
|
||||||
+ world.a(EntityHuman.class, new AxisAlignedBB(position).g(range)).forEach(p -> p.addEffect(regeneration));
|
+ world.a(EntityHuman.class, new AxisAlignedBB(position).g(range)).forEach(entityhuman -> {
|
||||||
|
+ boolean noLineOfSign = true;
|
||||||
|
+ if (!signalBoost && world.purpurConfig.campfireRegenRequireLineOfSight) {
|
||||||
|
+ noLineOfSign = false;
|
||||||
|
+ }
|
||||||
|
+ if (signalBoost && world.purpurConfig.campfireRegenBoostRequireLineOfSight) {
|
||||||
|
+ noLineOfSign = false;
|
||||||
|
+ }
|
||||||
|
+ if (noLineOfSign || entityhuman.hasLineOfSight(this)) {
|
||||||
|
+ entityhuman.addEffect(regeneration);
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
+ }
|
+ }
|
||||||
+ // Purpur end
|
+ // Purpur end
|
||||||
this.f();
|
this.f();
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < this.items.size(); ++i) {
|
for (int i = 0; i < this.items.size(); ++i) {
|
||||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||||
index 30f11fe26..becb6f3b7 100644
|
index 30f11fe26..5e9c633ac 100644
|
||||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||||
@@ -60,4 +60,21 @@ public class PurpurWorldConfig {
|
@@ -60,4 +60,25 @@ public class PurpurWorldConfig {
|
||||||
config.addDefault("world-settings.default." + path, def);
|
config.addDefault("world-settings.default." + path, def);
|
||||||
return config.getString("world-settings." + worldName + "." + path, config.getString("world-settings.default." + path));
|
return config.getString("world-settings." + worldName + "." + path, config.getString("world-settings.default." + path));
|
||||||
}
|
}
|
||||||
@@ -42,17 +81,21 @@ index 30f11fe26..becb6f3b7 100644
|
|||||||
+ public int campfireRegenDuration = 80;
|
+ public int campfireRegenDuration = 80;
|
||||||
+ public int campfireRegenRange = 5;
|
+ public int campfireRegenRange = 5;
|
||||||
+ public int campfireRegenAmp = 0;
|
+ public int campfireRegenAmp = 0;
|
||||||
|
+ public boolean campfireRegenRequireLineOfSight = true;
|
||||||
+ public int campfireRegenBoostDuration = 80;
|
+ public int campfireRegenBoostDuration = 80;
|
||||||
+ public int campfireRegenBoostRange = 10;
|
+ public int campfireRegenBoostRange = 10;
|
||||||
+ public int campfireRegenBoostAmp = 1;
|
+ public int campfireRegenBoostAmp = 1;
|
||||||
|
+ public boolean campfireRegenBoostRequireLineOfSight = false;
|
||||||
+ private void campireRegenSettings() {
|
+ private void campireRegenSettings() {
|
||||||
+ campfireRegenInterval = getInt("campfire-regen.interval", campfireRegenInterval);
|
+ campfireRegenInterval = getInt("campfire-regen.interval", campfireRegenInterval);
|
||||||
+ campfireRegenDuration = getInt("campfire-regen.duration", campfireRegenDuration);
|
+ campfireRegenDuration = getInt("campfire-regen.duration", campfireRegenDuration);
|
||||||
+ campfireRegenRange = getInt("campfire-regen.range", campfireRegenRange);
|
+ campfireRegenRange = getInt("campfire-regen.range", campfireRegenRange);
|
||||||
+ campfireRegenAmp = getInt("campfire-regen.amplifier", campfireRegenAmp);
|
+ campfireRegenAmp = getInt("campfire-regen.amplifier", campfireRegenAmp);
|
||||||
|
+ campfireRegenRequireLineOfSight = getBoolean("campfire-regen.require-line-of-sight", campfireRegenRequireLineOfSight);
|
||||||
+ campfireRegenBoostDuration = getInt("campfire-regen.boost-duration", campfireRegenBoostDuration);
|
+ campfireRegenBoostDuration = getInt("campfire-regen.boost-duration", campfireRegenBoostDuration);
|
||||||
+ campfireRegenBoostRange = getInt("campfire-regen.boost-range", campfireRegenBoostRange);
|
+ campfireRegenBoostRange = getInt("campfire-regen.boost-range", campfireRegenBoostRange);
|
||||||
+ campfireRegenBoostAmp = getInt("campfire-regen.boost-amplifier", campfireRegenBoostAmp);
|
+ campfireRegenBoostAmp = getInt("campfire-regen.boost-amplifier", campfireRegenBoostAmp);
|
||||||
|
+ campfireRegenBoostRequireLineOfSight = getBoolean("campfire-regen.boost-require-line-of-sight", campfireRegenBoostRequireLineOfSight);
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
--
|
--
|
||||||
|
|||||||
Reference in New Issue
Block a user