This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
EnergonRelics/src/main/java/com/thebrokenrail/energonrelics/block/entity/infuser/InfuserAction.java

48 lines
1.5 KiB
Java

package com.thebrokenrail.energonrelics.block.entity.infuser;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;
interface InfuserAction {
void run(World world, BlockPos pos);
class ItemAction implements InfuserAction {
private final ItemStack stack;
ItemAction(ItemStack stack) {
this.stack = stack;
}
ItemAction(Item item) {
this(new ItemStack(item));
}
@Override
public void run(World world, BlockPos pos) {
Block.dropStack(world, pos, stack);
}
}
class ExplosionAction implements InfuserAction {
@Override
public void run(World world, BlockPos pos) {
world.setBlockState(pos, Blocks.AIR.getDefaultState());
world.createExplosion(null, pos.getX() + 0.5d, pos.getY() + 0.5d, pos.getZ() + 0.5d, 3f, true, Explosion.DestructionType.DESTROY);
}
}
class ParticleAction implements InfuserAction {
@Override
public void run(World world, BlockPos pos) {
((ServerWorld) world).spawnParticles(ParticleTypes.SMOKE, pos.getX() + 0.5d, pos.getY() + 0.5d, pos.getZ() + 0.5d, 28, 0.31f, 0.31f, 0.31f, 0f);
}
}
}