mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: 8ce3dd5f [CI-SKIP] Fix Mojang API Brigadier dep - THIS IS NOT A NEW BUILD 00d760a5 Fix build due to spigot changing the build timestamp process 842e040c Updated Upstream (Bukkit/CraftBukkit/Spigot) c03260a2 Add getter and setter for villager's numberOfRestocksToday (#3231) fe366fbe null check tracker for entity metadata update - Fixes #3070 fdf41b74 Implement Brigadier Mojang API e0ea2e0e Entity Activation Range 2.0! Major improvements to restoring behavior 10396d28 Fix Tracking Range mismatch on Vehicle/Passenger checks
204 lines
11 KiB
Diff
204 lines
11 KiB
Diff
From 0df012f549c0e7424ebd2f19a31c43f8a995a651 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 6303be944..65f8d803b 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 ea245de18..10c222ddb 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 2f9a73ea3..2398499bc 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.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 a1580b8c6..618ca2d76 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 94744c78b..d8d95d787 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
|
|
|