mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Campfires only give regen if splashed with regen potion
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
From c623db1c5eb0b0191712f427a5906e7dd103ab0e Mon Sep 17 00:00:00 2001
|
||||
From 9de87bb1107c394fabaf8a7e9d2b2fcbdb8ad7ac Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sun, 19 May 2019 18:11:53 -0500
|
||||
Subject: [PATCH] Add regen effect to campfires
|
||||
|
||||
---
|
||||
.../net/minecraft/server/EntityLiving.java | 15 ++++++++++---
|
||||
.../minecraft/server/TileEntityCampfire.java | 21 +++++++++++++++++++
|
||||
.../net/pl3x/purpur/PurpurWorldConfig.java | 21 +++++++++++++++++++
|
||||
3 files changed, 54 insertions(+), 3 deletions(-)
|
||||
.../net/minecraft/server/EntityLiving.java | 15 ++++++++--
|
||||
.../net/minecraft/server/EntityPotion.java | 26 ++++++++++++++++
|
||||
.../minecraft/server/TileEntityCampfire.java | 30 +++++++++++++++++++
|
||||
.../net/pl3x/purpur/PurpurWorldConfig.java | 21 +++++++++++++
|
||||
4 files changed, 89 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index d277281715..85d41714df 100644
|
||||
index d27728171..85d41714d 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -2712,10 +2712,19 @@ public abstract class EntityLiving extends Entity {
|
||||
@@ -36,16 +37,68 @@ index d277281715..85d41714df 100644
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityPotion.java b/src/main/java/net/minecraft/server/EntityPotion.java
|
||||
index 47fc8b031..dff7568d2 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityPotion.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityPotion.java
|
||||
@@ -91,6 +91,7 @@ public class EntityPotion extends EntityProjectile {
|
||||
} else {
|
||||
this.a(list, movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null);
|
||||
}
|
||||
+ splashCampfires(list); // Purpur
|
||||
}
|
||||
|
||||
int i = potionregistry.b() ? 2007 : 2002;
|
||||
@@ -100,6 +101,31 @@ public class EntityPotion extends EntityProjectile {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ private void splashCampfires(List<MobEffect> list) {
|
||||
+ AxisAlignedBB aabb = getBoundingBox().grow(4.0D, 2.0D, 4.0D);
|
||||
+ for (int x = (int) aabb.minX; x <= aabb.maxX; x++) {
|
||||
+ for (int z = (int) aabb.minZ; z <= aabb.maxZ; z++) {
|
||||
+ for (int y = (int) aabb.minY; y <= aabb.maxY; y++) {
|
||||
+ BlockPosition pos = new BlockPosition(x, y, z);
|
||||
+ TileEntity te = world.getTileEntity(pos);
|
||||
+ if (te instanceof TileEntityCampfire) {
|
||||
+ for (MobEffect effect : list) {
|
||||
+ if (effect.getMobEffect() == MobEffects.REGENERATION) {
|
||||
+ for (int i = 0; i < 6 ; i++) {
|
||||
+ ((WorldServer) world).sendParticles(((WorldServer) world).players, null, Particles.HEART, te.position.x, te.position.y + 1, te.position.z, 1, 0.5, 0.5, 0.5, 0, true);
|
||||
+ }
|
||||
+ ((TileEntityCampfire) te).splashed = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
private void splash() {
|
||||
AxisAlignedBB axisalignedbb = this.getBoundingBox().grow(4.0D, 2.0D, 4.0D);
|
||||
List<EntityLiving> list = this.world.a(EntityLiving.class, axisalignedbb, EntityPotion.e);
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntityCampfire.java b/src/main/java/net/minecraft/server/TileEntityCampfire.java
|
||||
index 2317adde44..26a5b0c021 100644
|
||||
index 2317adde4..7360e462d 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntityCampfire.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntityCampfire.java
|
||||
@@ -34,6 +34,27 @@ public class TileEntityCampfire extends TileEntity implements Clearable, ITickab
|
||||
@@ -14,6 +14,7 @@ public class TileEntityCampfire extends TileEntity implements Clearable, ITickab
|
||||
private final NonNullList<ItemStack> items;
|
||||
public final int[] cookingTimes;
|
||||
public final int[] cookingTotalTimes;
|
||||
+ public boolean splashed = false; // Purpur
|
||||
|
||||
public TileEntityCampfire() {
|
||||
super(TileEntityTypes.CAMPFIRE);
|
||||
@@ -34,6 +35,27 @@ public class TileEntityCampfire extends TileEntity implements Clearable, ITickab
|
||||
|
||||
} else {
|
||||
if (flag) {
|
||||
+ // Purpur start
|
||||
+ if (world.purpurConfig.campfireRegenInterval > 0 && world.getTime() % world.purpurConfig.campfireRegenInterval == 0L) {
|
||||
+ if (splashed && world.purpurConfig.campfireRegenInterval > 0 && world.getTime() % world.purpurConfig.campfireRegenInterval == 0L) {
|
||||
+ boolean signalBoost = getBlock().get(BlockCampfire.c);
|
||||
+ int duration = signalBoost ? world.purpurConfig.campfireRegenBoostDuration : world.purpurConfig.campfireRegenDuration;
|
||||
+ byte amp = (byte) (signalBoost ? world.purpurConfig.campfireRegenBoostAmp : world.purpurConfig.campfireRegenAmp);
|
||||
@@ -68,8 +121,37 @@ index 2317adde44..26a5b0c021 100644
|
||||
this.h();
|
||||
} else {
|
||||
for (int i = 0; i < this.items.size(); ++i) {
|
||||
@@ -41,6 +63,7 @@ public class TileEntityCampfire extends TileEntity implements Clearable, ITickab
|
||||
this.cookingTimes[i] = MathHelper.clamp(this.cookingTimes[i] - 2, 0, this.cookingTotalTimes[i]);
|
||||
}
|
||||
}
|
||||
+ splashed = false; // Purpur
|
||||
}
|
||||
|
||||
}
|
||||
@@ -137,6 +160,12 @@ public class TileEntityCampfire extends TileEntity implements Clearable, ITickab
|
||||
System.arraycopy(aint, 0, this.cookingTotalTimes, 0, Math.min(this.cookingTotalTimes.length, aint.length));
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ if (nbttagcompound.hasKey("Purpur.splashed")) {
|
||||
+ splashed = nbttagcompound.getBoolean("Purpur.splashed");
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,6 +173,7 @@ public class TileEntityCampfire extends TileEntity implements Clearable, ITickab
|
||||
this.d(nbttagcompound);
|
||||
nbttagcompound.setIntArray("CookingTimes", this.cookingTimes);
|
||||
nbttagcompound.setIntArray("CookingTotalTimes", this.cookingTotalTimes);
|
||||
+ nbttagcompound.setBoolean("Purpur.splashed", splashed); // Purpur
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
index 30f11fe261..5e9c633ac8 100644
|
||||
index 30f11fe26..5e9c633ac 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -60,4 +60,25 @@ public class PurpurWorldConfig {
|
||||
|
||||
Reference in New Issue
Block a user