mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 08:17:44 +01:00
#1169: Add damage methods to FallingBlock
By: Parker Hawke <hawkeboyz2@hotmail.com>
This commit is contained in:
parent
aa099d8420
commit
5d28a95165
@ -9,6 +9,17 @@
|
||||
public class EntityFallingBlock extends Entity {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -57,8 +59,8 @@
|
||||
public boolean dropItem;
|
||||
private boolean cancelDrop;
|
||||
public boolean hurtEntities;
|
||||
- private int fallDamageMax;
|
||||
- private float fallDamagePerDistance;
|
||||
+ public int fallDamageMax;
|
||||
+ public float fallDamagePerDistance;
|
||||
@Nullable
|
||||
public NBTTagCompound blockData;
|
||||
protected static final DataWatcherObject<BlockPosition> DATA_START_POS = DataWatcher.defineId(EntityFallingBlock.class, DataWatcherRegistry.BLOCK_POS);
|
||||
@@ -83,10 +85,17 @@
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.world.entity.item.EntityFallingBlock;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@ -66,4 +67,34 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock {
|
||||
// Second field for EntityFallingBlock
|
||||
getHandle().time = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDamagePerBlock() {
|
||||
return getHandle().fallDamagePerDistance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDamagePerBlock(float damage) {
|
||||
Preconditions.checkArgument(damage >= 0.0, "damage must be >= 0.0, given %s", damage);
|
||||
|
||||
getHandle().fallDamagePerDistance = damage;
|
||||
if (damage > 0.0) {
|
||||
this.setHurtEntities(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage() {
|
||||
return getHandle().fallDamageMax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxDamage(int damage) {
|
||||
Preconditions.checkArgument(damage >= 0, "damage must be >= 0, given %s", damage);
|
||||
|
||||
getHandle().fallDamageMax = damage;
|
||||
if (damage > 0) {
|
||||
this.setHurtEntities(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user