use of net.minecraft.block.TNTBlock in project Mekanism by mekanism.
the class EntityFlame method onHitBlock.
@Override
protected void onHitBlock(@Nonnull BlockRayTraceResult blockRayTrace) {
super.onHitBlock(blockRayTrace);
BlockPos hitPos = blockRayTrace.getBlockPos();
Direction hitSide = blockRayTrace.getDirection();
BlockState hitState = level.getBlockState(hitPos);
boolean hitFluid = !hitState.getFluidState().isEmpty();
if (!level.isClientSide && MekanismConfig.general.aestheticWorldDamage.get() && !hitFluid) {
if (mode == FlamethrowerMode.HEAT) {
Entity owner = getOwner();
if (owner instanceof PlayerEntity) {
smeltBlock((PlayerEntity) owner, hitState, hitPos, hitSide);
}
} else if (mode == FlamethrowerMode.INFERNO) {
Entity owner = getOwner();
BlockPos sidePos = hitPos.relative(hitSide);
if (CampfireBlock.canLight(hitState)) {
tryPlace(owner, hitPos, hitSide, hitState.setValue(BlockStateProperties.LIT, true));
} else if (AbstractFireBlock.canBePlacedAt(level, sidePos, hitSide)) {
tryPlace(owner, sidePos, hitSide, AbstractFireBlock.getState(level, sidePos));
} else if (hitState.isFlammable(level, hitPos, hitSide)) {
// TODO: Is there some event we should/can be firing here?
hitState.catchFire(level, hitPos, hitSide, owner instanceof LivingEntity ? (LivingEntity) owner : null);
if (hitState.getBlock() instanceof TNTBlock) {
level.removeBlock(hitPos, false);
}
}
}
}
if (hitFluid) {
spawnParticlesAt(blockPosition());
playSound(SoundEvents.FIRE_EXTINGUISH, 1.0F, 1.0F);
}
remove();
}
Aggregations