use of net.minecraft.world.level.block.CampfireBlock in project FrostRealm by baguchan.
the class FrostLivingCapability method hotSourceTick.
private void hotSourceTick(LivingEntity entity) {
if (this.hotSource != null && (!this.hotSource.closerThan(entity.blockPosition(), 3.46D) || !entity.level.getBlockState(this.hotSource).is(FrostTags.Blocks.HOT_SOURCE) || (entity.level.getBlockState(this.hotSource).getBlock() instanceof CampfireBlock && !CampfireBlock.isLitCampfire(entity.level.getBlockState(this.hotSource))))) {
this.hotSource = null;
}
if (this.hotSource == null) {
int heatRange = 2;
int entityPosX = (int) entity.getX();
int entityPosY = (int) entity.getY();
int entityPosZ = (int) entity.getZ();
if (entity.tickCount % 20 == 0)
for (int hX = entityPosX - heatRange; hX <= entityPosX + heatRange; hX++) {
for (int hY = entityPosY - 2; hY <= entityPosY; hY++) {
for (int hZ = entityPosZ - heatRange; hZ <= entityPosZ + heatRange; hZ++) {
if (entity.level.getBlockState(new BlockPos(hX, hY, hZ)).is(FrostTags.Blocks.HOT_SOURCE))
this.hotSource = new BlockPos(hX, hY, hZ);
}
}
}
}
if (this.hotSource != null && this.hotSource.closerThan(entity.blockPosition(), 3.46D) && entity.tickCount % 20 == 0) {
this.temperatureSaturation = Math.min(this.temperatureSaturation + 0.1F, 1.0F);
this.temperature = Math.min(this.temperature + 1, 20);
}
}
use of net.minecraft.world.level.block.CampfireBlock in project TinkersConstruct by SlimeKnights.
the class PathingModifier method transform.
@Override
protected boolean transform(UseOnContext context, BlockState original, boolean playSound) {
if (super.transform(context, original, playSound)) {
return true;
}
// shovel special case: campfires
if (original.getBlock() instanceof CampfireBlock && original.getValue(CampfireBlock.LIT)) {
Level level = context.getLevel();
BlockPos pos = context.getClickedPos();
if (!level.isClientSide) {
if (playSound) {
level.playSound(null, pos, SoundEvents.GENERIC_EXTINGUISH_FIRE, SoundSource.BLOCKS, 1.0F, 1.0F);
}
CampfireBlock.dowse(context.getPlayer(), level, pos, original);
}
level.setBlock(pos, original.setValue(CampfireBlock.LIT, false), Block.UPDATE_ALL_IMMEDIATE);
return true;
}
return false;
}
Aggregations