Search in sources :

Example 1 with AbstractFireBlock

use of net.minecraft.block.AbstractFireBlock in project bewitchment by MoriyaShiine.

the class MakeEntitiesWetRitualFunction method start.

@Override
public void start(ServerWorld world, BlockPos glyphPos, BlockPos effectivePos, Inventory inventory, boolean catFamiliar) {
    int radius = catFamiliar ? 9 : 3;
    world.getEntitiesByClass(Entity.class, new Box(effectivePos).expand(radius), Entity::isAlive).forEach(entity -> BWComponents.ADDITIONAL_WATER_DATA_COMPONENT.get(entity).setWetTimer(6000 * (catFamiliar ? 3 : 1)));
    BWUtil.getBlockPoses(effectivePos, radius, currentPos -> world.getBlockState(currentPos).getBlock() instanceof AbstractFireBlock).forEach(foundPos -> world.setBlockState(foundPos, Blocks.AIR.getDefaultState()));
    super.start(world, glyphPos, effectivePos, inventory, catFamiliar);
}
Also used : Entity(net.minecraft.entity.Entity) ParticleType(net.minecraft.particle.ParticleType) LivingEntity(net.minecraft.entity.LivingEntity) Predicate(java.util.function.Predicate) AbstractFireBlock(net.minecraft.block.AbstractFireBlock) ServerWorld(net.minecraft.server.world.ServerWorld) Box(net.minecraft.util.math.Box) BWUtil(moriyashiine.bewitchment.common.misc.BWUtil) Inventory(net.minecraft.inventory.Inventory) BlockPos(net.minecraft.util.math.BlockPos) Blocks(net.minecraft.block.Blocks) RitualFunction(moriyashiine.bewitchment.api.registry.RitualFunction) BWComponents(moriyashiine.bewitchment.common.registry.BWComponents) Entity(net.minecraft.entity.Entity) LivingEntity(net.minecraft.entity.LivingEntity) Box(net.minecraft.util.math.Box) AbstractFireBlock(net.minecraft.block.AbstractFireBlock)

Example 2 with AbstractFireBlock

use of net.minecraft.block.AbstractFireBlock in project relics by SSKirillSS.

the class BlazingFlaskItem method collectFire.

protected void collectFire(PlayerEntity player, ItemStack stack) {
    World world = player.getCommandSenderWorld();
    int fire = NBTUtils.getInt(stack, TAG_FIRE_AMOUNT, 0);
    if (player.isSpectator() || fire >= stats.capacity)
        return;
    List<BlockPos> positions = WorldUtils.getBlockSphere(player.blockPosition(), stats.consumptionRadius).stream().filter(pos -> (world.getBlockState(pos).getBlock() instanceof AbstractFireBlock)).collect(Collectors.toList());
    for (BlockPos pos : positions) {
        Vector3d blockVec = new Vector3d(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D);
        double distance = player.position().add(0, 1, 0).distanceTo(blockVec);
        Vector3d direction = player.position().add(0, 1, 0).subtract(blockVec).normalize();
        world.addParticle(new CircleTintData((world.getBlockState(pos).getBlock() instanceof SoulFireBlock) ? new Color(0, 200, 255) : new Color(255, 122, 0), (float) (distance * 0.075F), (int) distance * 5, 0.95F, false), blockVec.x(), blockVec.y(), blockVec.z(), direction.x * 0.2F, direction.y * 0.2F, direction.z * 0.2F);
        if (player.tickCount % stats.consumptionCooldown == 0) {
            world.playSound(null, pos, SoundEvents.FURNACE_FIRE_CRACKLE, SoundCategory.PLAYERS, 1.0F, 1.0F);
            NBTUtils.setInt(stack, TAG_FIRE_AMOUNT, Math.min(stats.capacity, fire + positions.size()));
        }
    }
}
Also used : AbilityTooltip(it.hurts.sskirillss.relics.client.tooltip.base.AbilityTooltip) AbstractFireBlock(net.minecraft.block.AbstractFireBlock) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) ITooltipFlag(net.minecraft.client.util.ITooltipFlag) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ItemStack(net.minecraft.item.ItemStack) RayTraceResult(net.minecraft.util.math.RayTraceResult) LivingAttackEvent(net.minecraftforge.event.entity.living.LivingAttackEvent) Minecraft(net.minecraft.client.Minecraft) Rarity(net.minecraft.item.Rarity) Mod(net.minecraftforge.fml.common.Mod) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent) SoundCategory(net.minecraft.util.SoundCategory) Nullable(javax.annotation.Nullable) it.hurts.sskirillss.relics.utils(it.hurts.sskirillss.relics.utils) SlotContext(top.theillusivec4.curios.api.SlotContext) RelicTooltip(it.hurts.sskirillss.relics.client.tooltip.base.RelicTooltip) RelicData(it.hurts.sskirillss.relics.items.relics.base.data.RelicData) SoulFireBlock(net.minecraft.block.SoulFireBlock) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) World(net.minecraft.world.World) CircleTintData(it.hurts.sskirillss.relics.client.particles.circle.CircleTintData) BlockPos(net.minecraft.util.math.BlockPos) RelicConfigData(it.hurts.sskirillss.relics.configs.data.relics.RelicConfigData) DamageSource(net.minecraft.util.DamageSource) Collectors(java.util.stream.Collectors) SoundEvents(net.minecraft.util.SoundEvents) LivingHurtEvent(net.minecraftforge.event.entity.living.LivingHurtEvent) java.awt(java.awt) ParticleTypes(net.minecraft.particles.ParticleTypes) Vector3d(net.minecraft.util.math.vector.Vector3d) List(java.util.List) RayTraceContext(net.minecraft.util.math.RayTraceContext) RelicStats(it.hurts.sskirillss.relics.items.relics.base.data.RelicStats) ItemRegistry(it.hurts.sskirillss.relics.init.ItemRegistry) RelicItem(it.hurts.sskirillss.relics.items.relics.base.RelicItem) NotNull(org.jetbrains.annotations.NotNull) Vector3d(net.minecraft.util.math.vector.Vector3d) BlockPos(net.minecraft.util.math.BlockPos) AbstractFireBlock(net.minecraft.block.AbstractFireBlock) World(net.minecraft.world.World) SoulFireBlock(net.minecraft.block.SoulFireBlock) CircleTintData(it.hurts.sskirillss.relics.client.particles.circle.CircleTintData)

Aggregations

AbstractFireBlock (net.minecraft.block.AbstractFireBlock)2 LivingEntity (net.minecraft.entity.LivingEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 CircleTintData (it.hurts.sskirillss.relics.client.particles.circle.CircleTintData)1 AbilityTooltip (it.hurts.sskirillss.relics.client.tooltip.base.AbilityTooltip)1 RelicTooltip (it.hurts.sskirillss.relics.client.tooltip.base.RelicTooltip)1 RelicConfigData (it.hurts.sskirillss.relics.configs.data.relics.RelicConfigData)1 ItemRegistry (it.hurts.sskirillss.relics.init.ItemRegistry)1 RelicItem (it.hurts.sskirillss.relics.items.relics.base.RelicItem)1 RelicData (it.hurts.sskirillss.relics.items.relics.base.data.RelicData)1 RelicStats (it.hurts.sskirillss.relics.items.relics.base.data.RelicStats)1 it.hurts.sskirillss.relics.utils (it.hurts.sskirillss.relics.utils)1 java.awt (java.awt)1 List (java.util.List)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 RitualFunction (moriyashiine.bewitchment.api.registry.RitualFunction)1 BWUtil (moriyashiine.bewitchment.common.misc.BWUtil)1 BWComponents (moriyashiine.bewitchment.common.registry.BWComponents)1