mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 08:57:44 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: b75eeca0 Boost light task priority to ensure it doesnt hold up chunk loads 3d2bc848 Ensure VillagerTrades doesn't load async - fixes #3495 e470f1ef Add more information to Timing Reports f4a47db6 Improve Thread Pool usage to allow single threads for single cpu servers a4fe910f Fix sounds when using worldedit regen command 70ad51a8 Updated Upstream (Bukkit/CraftBukkit) d7cfa4fa Improve legacy format serialization more
204 lines
11 KiB
Diff
204 lines
11 KiB
Diff
From d89c8591d4ebe87d0aeadf9a92f5a9ca85a1beba 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] Campfires have regen effect
|
|
|
|
---
|
|
.../net/minecraft/server/BlockCampfire.java | 2 +-
|
|
.../net/minecraft/server/EntityLiving.java | 15 ++++++++--
|
|
.../net/minecraft/server/EntityPotion.java | 26 ++++++++++++++++
|
|
.../minecraft/server/TileEntityCampfire.java | 30 +++++++++++++++++++
|
|
.../net/pl3x/purpur/PurpurWorldConfig.java | 23 ++++++++++++++
|
|
5 files changed, 92 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockCampfire.java b/src/main/java/net/minecraft/server/BlockCampfire.java
|
|
index 6303be944c..65f8d803b8 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockCampfire.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockCampfire.java
|
|
@@ -8,7 +8,7 @@ public class BlockCampfire extends BlockTileEntity implements IBlockWaterlogged
|
|
|
|
protected static final VoxelShape a = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D);
|
|
public static final BlockStateBoolean b = BlockProperties.r;
|
|
- public static final BlockStateBoolean c = BlockProperties.y;
|
|
+ public static final BlockStateBoolean c = BlockProperties.y; public static BlockStateBoolean signalFire() { return c; } // Purpur - OBFHELPER
|
|
public static final BlockStateBoolean d = BlockProperties.C;
|
|
public static final BlockStateDirection e = BlockProperties.N;
|
|
private static final VoxelShape f = Block.a(6.0D, 0.0D, 6.0D, 10.0D, 16.0D, 10.0D);
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index ea245de18c..10c222ddb2 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -2791,10 +2791,19 @@ public abstract class EntityLiving extends Entity {
|
|
}
|
|
|
|
public boolean hasLineOfSight(Entity entity) {
|
|
- Vec3D vec3d = new Vec3D(this.locX(), this.getHeadY(), this.locZ());
|
|
- Vec3D vec3d1 = new Vec3D(entity.locX(), entity.getHeadY(), entity.locZ());
|
|
+ // Purpur start
|
|
+ return hasLineOfSight(entity.locX(), entity.getHeadY(), entity.locZ());
|
|
+ }
|
|
+
|
|
+ public boolean hasLineOfSight(TileEntity te) {
|
|
+ return hasLineOfSight(te.position.getX() + 0.5, te.position.getY() + 0.5, te.position.getZ() + 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(), getHeadY(), locZ());
|
|
+ Vec3D end = new Vec3D(x, y, z);
|
|
+ return 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/EntityPotion.java b/src/main/java/net/minecraft/server/EntityPotion.java
|
|
index b56b021b4c..fcc5a5c234 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPotion.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPotion.java
|
|
@@ -92,6 +92,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;
|
|
@@ -101,6 +102,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.getX(), te.position.getY() + 1, te.position.getZ(), 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 a1580b8c6d..618ca2d763 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityCampfire.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityCampfire.java
|
|
@@ -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 ((splashed || !world.purpurConfig.campfireRequireRegenPotion) && world.purpurConfig.campfireRegenInterval > 0 && world.getTime() % world.purpurConfig.campfireRegenInterval == 0L) {
|
|
+ boolean signalBoost = getBlock().get(BlockCampfire.signalFire());
|
|
+ int duration = signalBoost ? world.purpurConfig.campfireRegenBoostDuration : world.purpurConfig.campfireRegenDuration;
|
|
+ byte amp = (byte) (signalBoost ? world.purpurConfig.campfireRegenBoostAmp : world.purpurConfig.campfireRegenAmp);
|
|
+ int range = signalBoost ? world.purpurConfig.campfireRegenBoostRange : world.purpurConfig.campfireRegenRange;
|
|
+ MobEffect regeneration = new MobEffect(MobEffects.REGENERATION, duration, amp, true, true);
|
|
+ world.getEntitiesByClass(EntityHuman.class, new AxisAlignedBB(position).grow(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
|
|
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 94744c78ba..d8d95d787f 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -71,6 +71,29 @@ public class PurpurWorldConfig {
|
|
return PurpurConfig.config.getString("world-settings." + worldName + "." + path, PurpurConfig.config.getString("world-settings.default." + path));
|
|
}
|
|
|
|
+ public int campfireRegenInterval = 0;
|
|
+ public int campfireRegenDuration = 80;
|
|
+ public int campfireRegenRange = 5;
|
|
+ public int campfireRegenAmp = 0;
|
|
+ public boolean campfireRegenRequireLineOfSight = true;
|
|
+ public int campfireRegenBoostDuration = 0;
|
|
+ public int campfireRegenBoostRange = 10;
|
|
+ public int campfireRegenBoostAmp = 1;
|
|
+ public boolean campfireRegenBoostRequireLineOfSight = false;
|
|
+ public boolean campfireRequireRegenPotion = true;
|
|
+ private void campfireSettings() {
|
|
+ campfireRegenInterval = getInt("blocks.campfire.regen.interval", campfireRegenInterval);
|
|
+ campfireRegenDuration = getInt("blocks.campfire.regen.duration", campfireRegenDuration);
|
|
+ campfireRegenRange = getInt("blocks.campfire.regen.range", campfireRegenRange);
|
|
+ campfireRegenAmp = getInt("blocks.campfire.regen.amplifier", campfireRegenAmp);
|
|
+ campfireRegenRequireLineOfSight = getBoolean("blocks.campfire.regen.require-line-of-sight", campfireRegenRequireLineOfSight);
|
|
+ campfireRegenBoostDuration = getInt("blocks.campfire.regen.boost-duration", campfireRegenBoostDuration);
|
|
+ campfireRegenBoostRange = getInt("blocks.campfire.regen.boost-range", campfireRegenBoostRange);
|
|
+ campfireRegenBoostAmp = getInt("blocks.campfire.regen.boost-amplifier", campfireRegenBoostAmp);
|
|
+ campfireRegenBoostRequireLineOfSight = getBoolean("blocks.campfire.regen.boost-require-line-of-sight", campfireRegenBoostRequireLineOfSight);
|
|
+ campfireRequireRegenPotion = getBoolean("blocks.campfire.regen.requires-potion-to-activate", campfireRequireRegenPotion);
|
|
+ }
|
|
+
|
|
public boolean farmlandGetsMoistFromBelow = false;
|
|
private void farmlandSettings() {
|
|
farmlandGetsMoistFromBelow = getBoolean("blocks.farmland.gets-moist-from-below", farmlandGetsMoistFromBelow);
|
|
--
|
|
2.24.0
|
|
|