Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -5067,7 +5067,7 @@ private void onBlockBreakStart(Vector3 pos, BlockFace face) {
}

Block block = target.getSide(face);
if (block.getId() == Block.FIRE) {
if (block.getId() == Block.FIRE || block.getId() == Block.SOUL_FIRE) {
this.level.setBlock(block, Block.get(BlockID.AIR), true);
this.level.addLevelSoundEvent(block, LevelSoundEventPacket.SOUND_EXTINGUISH_FIRE);
return;
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/cn/nukkit/block/BlockFire.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ public void onEntityCollide(Entity entity) {
return;
}

if (!entity.hasEffect(Effect.FIRE_RESISTANCE) && this.level.getGameRules().getBoolean(GameRule.FIRE_DAMAGE)) {
entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.FIRE, 1));
}

EntityCombustByBlockEvent ev = new EntityCombustByBlockEvent(this, entity, 8);
if (entity instanceof EntityArrow) {
ev.setCancelled();
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/cn/nukkit/block/BlockLava.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ public void onEntityCollide(Entity entity) {
entity.setOnFire(ev.getDuration());
}

if (!entity.hasEffect(Effect.FIRE_RESISTANCE)) {
entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.LAVA, 4));
}

super.onEntityCollide(entity);
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/cn/nukkit/block/BlockSoulFire.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public String getName() {
return "Soul Fire";
}

@Override
public int getLightLevel() {
return 10;
}

@Override
public int onUpdate(int type) {
if (type == Level.BLOCK_UPDATE_NORMAL) {
Expand Down
23 changes: 17 additions & 6 deletions src/main/java/cn/nukkit/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockFire;
import cn.nukkit.block.BlockID;
import cn.nukkit.block.BlockWater;
import cn.nukkit.block.*;
import cn.nukkit.blockentity.BlockEntityPistonArm;
import cn.nukkit.entity.custom.CustomEntity;
import cn.nukkit.entity.custom.EntityDefinition;
Expand Down Expand Up @@ -482,6 +479,8 @@ public abstract class Entity extends Location implements Metadatable {
protected boolean noFallDamage;
public float fallDistance = 0;
public int lastUpdate;
public int inLavaTicks = 0;
public int inFireTicks = 0;
public int fireTicks = 0;
public int inPortalTicks = 0;
public int freezingTicks = 0;//0 - 140
Expand Down Expand Up @@ -1877,8 +1876,10 @@ public boolean entityBaseTick(int tickDiff) {
this.fireTicks = 0;
}
} else {
if (!this.hasEffect(Effect.FIRE_RESISTANCE) && ((this.fireTicks % 20) == 0 || tickDiff > 20)) {
this.attack(new EntityDamageEvent(this, DamageCause.FIRE_TICK, 1));
if (!this.hasEffect(Effect.FIRE_RESISTANCE) && ((this.fireTicks % 20) == 0 || tickDiff > 20) && this.level.getGameRules().getBoolean(GameRule.FIRE_DAMAGE)) {
if (!isInsideOfLava() && !isInsideOfFire()){
this.attack(new EntityDamageEvent(this, DamageCause.FIRE_TICK, 1));
}
}
this.fireTicks -= tickDiff;
}
Expand Down Expand Up @@ -2422,6 +2423,16 @@ public boolean isInsideOfWater() {
return block.isWater() || block.getWaterloggingType() != Block.WaterloggingType.NO_WATERLOGGING && block.getLevelBlockAtLayer(1).isWater();
}

public boolean isInsideOfLava() {
for (Block block : this.getCollisionBlocks()) {
if (block instanceof BlockLava) {
return true;
}
}

return false;
}

public boolean isInsideOfSolid() {
double y = this.y + this.getEyeHeight();
Block block = this.level.getBlock(
Expand Down
32 changes: 29 additions & 3 deletions src/main/java/cn/nukkit/entity/EntityLiving.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockCactus;
import cn.nukkit.block.BlockMagma;
import cn.nukkit.block.*;
import cn.nukkit.entity.mob.EntityDrowned;
import cn.nukkit.entity.mob.EntityWolf;
import cn.nukkit.entity.projectile.EntityProjectile;
Expand Down Expand Up @@ -321,6 +319,34 @@ public boolean entityBaseTick(int tickDiff) {
this.resetFallDistance();
}

if (this.level.getGameRules().getBoolean(GameRule.FIRE_DAMAGE) && !this.hasEffect(Effect.FIRE_RESISTANCE)) {
if (this.isInsideOfLava()) {
this.inLavaTicks++;
if ((this.inLavaTicks % 10) == 0) {
Block lavaBlock = level.getBlock(this.getFloorX(), this.getFloorY(), this.getFloorZ());
if (!(lavaBlock instanceof BlockLava)) {
lavaBlock = lavaBlock.getLevelBlockAtLayer(1);
}
this.attack(new EntityDamageByBlockEvent(lavaBlock, this, DamageCause.LAVA, 4));
this.inLavaTicks = 0;
}
}

if (this.isInsideOfFire()) {
this.inFireTicks++;
if ((this.inFireTicks % 10) == 0) {
Block fireBlock = level.getBlock(this.getFloorX(), this.getFloorY(), this.getFloorZ());
int fireDamage = 1;
if (fireBlock instanceof BlockSoulFire) {
fireDamage = 2;
}
this.attack(new EntityDamageByBlockEvent(fireBlock, this, DamageCause.FIRE, fireDamage));
this.inFireTicks = 0;
}
}
}


if (inWater && !this.hasEffect(Effect.WATER_BREATHING)) {
if (this instanceof EntitySwimming || this.isDrowned || (this instanceof Player && (((Player) this).isCreative() || ((Player) this).isSpectator()))) {
this.setAirTicks(400);
Expand Down