mirror of
https://github.com/PurpurMC/Purpur.git
synced 2025-02-23 13:09:31 +08:00
89 lines
4.5 KiB
Diff
89 lines
4.5 KiB
Diff
From a0a4abaa7e4b3ee773d5ed33d845fc743dbdf541 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Thu, 23 May 2019 16:20:21 -0500
|
|
Subject: [PATCH] Campfires should fall with gravity
|
|
|
|
---
|
|
src/main/java/net/minecraft/server/Block.java | 1 +
|
|
.../net/minecraft/server/BlockCampfire.java | 26 ++++++++++++++++++-
|
|
.../net/pl3x/purpur/PurpurWorldConfig.java | 5 ++++
|
|
3 files changed, 31 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
|
|
index 8e16162a7..47a3ddd7f 100644
|
|
--- a/src/main/java/net/minecraft/server/Block.java
|
|
+++ b/src/main/java/net/minecraft/server/Block.java
|
|
@@ -375,6 +375,7 @@ public class Block implements IMaterial {
|
|
PacketDebug.a(world, blockposition);
|
|
}
|
|
|
|
+ public int tickRate(IWorldReader world) { return this.a(world); } // Purpur - OBFHELPER
|
|
public int a(IWorldReader iworldreader) {
|
|
return 10;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/BlockCampfire.java b/src/main/java/net/minecraft/server/BlockCampfire.java
|
|
index 5cbe8e68e..eca3487b0 100644
|
|
--- a/src/main/java/net/minecraft/server/BlockCampfire.java
|
|
+++ b/src/main/java/net/minecraft/server/BlockCampfire.java
|
|
@@ -72,8 +72,32 @@ public class BlockCampfire extends BlockTileEntity implements IBlockWaterlogged
|
|
return (IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockCampfire.d, flag)).set(BlockCampfire.c, this.j(world.getType(blockposition.down())))).set(BlockCampfire.b, !flag)).set(BlockCampfire.e, blockactioncontext.f());
|
|
}
|
|
|
|
+ // Purpur start - Campfires should fall with gravity
|
|
+ @Override
|
|
+ public void onPlace(IBlockData iblockdata, World world, BlockPosition pos, IBlockData iblockdata1, boolean flag) {
|
|
+ world.getBlockTickList().a(pos, this, tickRate(world));
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void tick(IBlockData iblockdata, World world, BlockPosition pos, Random random) {
|
|
+ if (world.purpurConfig.campfireObeysGravity && BlockFalling.canFallThrough(world.getType(pos.down())) && pos.getY() >= 0) {
|
|
+ world.addEntity(new EntityFallingBlock(world, pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, world.getType(pos)));
|
|
+ }
|
|
+ if (iblockdata.get(BlockCampfire.d) && iblockdata.get(BlockCampfire.b)) {
|
|
+ world.setTypeAndData(pos, iblockdata.set(BlockCampfire.b, false), 3);
|
|
+ }
|
|
+ world.getBlockTickList().a(pos, this, tickRate(world));
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int tickRate(IWorldReader world) {
|
|
+ return 1;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Override
|
|
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
|
|
+ generatoraccess.getBlockTickList().a(blockposition, this, tickRate(generatoraccess)); // Purpur - Campfires should fall with gravity
|
|
if ((Boolean) iblockdata.get(BlockCampfire.d)) {
|
|
generatoraccess.getFluidTickList().a(blockposition, FluidTypes.WATER, FluidTypes.WATER.a((IWorldReader) generatoraccess));
|
|
}
|
|
@@ -107,7 +131,7 @@ public class BlockCampfire extends BlockTileEntity implements IBlockWaterlogged
|
|
|
|
@Override
|
|
public boolean place(GeneratorAccess generatoraccess, BlockPosition blockposition, IBlockData iblockdata, Fluid fluid) {
|
|
- if (!(Boolean) iblockdata.get(BlockProperties.C) && fluid.getType() == FluidTypes.WATER) {
|
|
+ if (!(Boolean) iblockdata.get(BlockCampfire.d) && fluid.getType() == FluidTypes.WATER) { // Purpur
|
|
boolean flag = (Boolean) iblockdata.get(BlockCampfire.b);
|
|
|
|
if (flag) {
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index cea2bcad5..dc2da586e 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -61,6 +61,11 @@ public class PurpurWorldConfig {
|
|
return config.getString("world-settings." + worldName + "." + path, config.getString("world-settings.default." + path));
|
|
}
|
|
|
|
+ public boolean campfireObeysGravity = true;
|
|
+ private void campfireObeysGravity() {
|
|
+ campfireObeysGravity = getBoolean("campfire-obeys-gravity", campfireObeysGravity);
|
|
+ }
|
|
+
|
|
public int campfireRegenInterval = 40;
|
|
public int campfireRegenDuration = 80;
|
|
public int campfireRegenRange = 5;
|
|
--
|
|
2.20.1
|
|
|