Search in sources :

Example 1 with SoulFireBlock

use of net.minecraft.block.SoulFireBlock 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

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 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 AbstractFireBlock (net.minecraft.block.AbstractFireBlock)1 SoulFireBlock (net.minecraft.block.SoulFireBlock)1 Minecraft (net.minecraft.client.Minecraft)1 ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)1 ITooltipFlag (net.minecraft.client.util.ITooltipFlag)1 LivingEntity (net.minecraft.entity.LivingEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1