forked from ethanicusss/AstralAdditions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeyserBlock.java
More file actions
61 lines (49 loc) · 2.65 KB
/
GeyserBlock.java
File metadata and controls
61 lines (49 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.github.ethanicuss.astraladditions.blocks;
import com.github.ethanicuss.astraladditions.registry.ModEntities;
import com.github.ethanicuss.astraladditions.entities.prismatic_geyser.PrismaticGeyserEntity;
import com.github.ethanicuss.astraladditions.util.ModUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import java.util.List;
public class GeyserBlock extends Block {
public GeyserBlock(Settings settings) {
super(settings);
}
public ActionResult onUse(BlockState blockState, World world, BlockPos pos, PlayerEntity placedBy, Hand hand, BlockHitResult blockHitResult) {
if (!world.isClient) {
world.playSound(pos.getX(), pos.getY() + 1, pos.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 1, 0.5f, true);
}
return ActionResult.PASS;
}
public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity) {
Box box = new Box(pos.getX(), pos.getY(), pos.getZ(), pos.getX()+1, pos.getY()+1.5, pos.getZ()+1);
List<Entity> ls = world.getOtherEntities(entity, box);
for (Entity p : ls) {
if (p instanceof PrismaticGeyserEntity) {
return;
}
}
PrismaticGeyserEntity geyser = new PrismaticGeyserEntity(ModEntities.PRISMATIC_GEYSER, world);
geyser.setPosition(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5);
geyser.refreshPositionAndAngles(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5, 0.0f, 0.0f);
world.spawnEntity(geyser);
if (world instanceof ServerWorld) {
ModUtils.spawnForcedParticles((ServerWorld)world, ParticleTypes.CLOUD, pos.getX() + 0.5, pos.getY() + 1.1, pos.getZ() + 0.5, 10, 0.2, 0.2, 0.2, 0.1);
ModUtils.spawnForcedParticles((ServerWorld)world, ParticleTypes.SNOWFLAKE, entity.getX(), (double)(pos.getY() + 1), entity.getZ(), 1, (double)(MathHelper.nextBetween(world.random, -1.0F, 1.0F) * 0.083333336F), 0.05000000074505806D, (double)(MathHelper.nextBetween(world.random, -1.0F, 1.0F) * 0.083333336F), 0);
}
super.onSteppedOn(world, pos, state, entity);
}
}