package me.parsell.wireddust.common; import java.util.Random; import me.parsell.wireddust.core.WiredDustGamerules; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.block.BlockState; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleTypes; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction.Axis; import net.minecraft.world.World; public class WDBlazePowderWireBlock extends WDWireBlock{ public WDBlazePowderWireBlock(Settings settings) { super(settings); } @Override public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { if(world.getGameRules().getBoolean(WiredDustGamerules.DO_BLAZE_POWDER_WIRE_DAMAGE)) if (!entity.isFireImmune() && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity)entity)) entity.damage(DamageSource.HOT_FLOOR, 1.0F); } @Environment(EnvType.CLIENT) public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { if (random.nextDouble() < 0.32F){ // get random double, within bounds x_min and x_max double x_min = super.STATE_TO_VOXELSHAPE.get(state).getMin(Axis.X); double z_min = super.STATE_TO_VOXELSHAPE.get(state).getMin(Axis.Z); double x_max = super.STATE_TO_VOXELSHAPE.get(state).getMax(Axis.X); double z_max = super.STATE_TO_VOXELSHAPE.get(state).getMax(Axis.Z); double x_rand = x_min + (x_max - x_min) * random.nextDouble(); double z_rand = z_min + (z_max - z_min) * random.nextDouble(); // determine what particle I should show ParticleEffect blaze_powder_particle = ParticleTypes.FLAME; if(world.getBiomeAccess().getBiome(pos).getDownfall() > 0.0F) // Todo: this isn't correct blaze_powder_particle = ParticleTypes.SMOKE; world.addParticle(blaze_powder_particle, pos.getX() + x_rand, pos.getY() + 0.1D, pos.getZ() + z_rand, 0.0, 0.0, 0.0); super.randomDisplayTick(state, world, pos, random); } } }