enhanced lava hoarder

This commit is contained in:
Jörg Henke 2020-11-07 01:11:45 +01:00
parent 6e67d3f422
commit 71730f3172
2 changed files with 19 additions and 6 deletions

View File

@ -1,11 +1,14 @@
package de.jottyfan.minecraft.quickiefabric.blockentity; package de.jottyfan.minecraft.quickiefabric.blockentity;
import org.apache.logging.log4j.LogManager; import java.util.Random;
import org.apache.logging.log4j.Logger;
import de.jottyfan.minecraft.quickiefabric.blocks.QuickieBlocks; import de.jottyfan.minecraft.quickiefabric.blocks.QuickieBlocks;
import de.jottyfan.minecraft.quickiefabric.items.QuickieItems;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Tickable; import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -17,11 +20,8 @@ import net.minecraft.world.World;
*/ */
public class EmptyLavaHoarderBlockEntity extends BlockEntity implements Tickable { public class EmptyLavaHoarderBlockEntity extends BlockEntity implements Tickable {
private final Logger LOGGER = LogManager.getLogger(EmptyLavaHoarderBlockEntity.class);
public EmptyLavaHoarderBlockEntity() { public EmptyLavaHoarderBlockEntity() {
super(QuickieFabricBlockEntity.EMPTYLAVAHOARDER); super(QuickieFabricBlockEntity.EMPTYLAVAHOARDER);
LOGGER.error("created empty lava hoarder block entity");
} }
/** /**
@ -36,6 +36,19 @@ public class EmptyLavaHoarderBlockEntity extends BlockEntity implements Tickable
return false; return false;
} else if (Blocks.LAVA.equals(world.getBlockState(pos).getBlock())) { } else if (Blocks.LAVA.equals(world.getBlockState(pos).getBlock())) {
world.setBlockState(pos, Blocks.AIR.getDefaultState()); world.setBlockState(pos, Blocks.AIR.getDefaultState());
BlockPos up = pos.up();
world.spawnEntity(new ItemEntity(world, up.getX(), up.getY(), up.getZ(),
new ItemStack(QuickieItems.SULPHOR, new Random().nextInt(4))));
world.spawnEntity(new ItemEntity(world, up.getX(), up.getY(), up.getZ(),
new ItemStack(Items.DIAMOND, new Random().nextInt(2))));
world.spawnEntity(new ItemEntity(world, up.getX(), up.getY(), up.getZ(),
new ItemStack(Items.EMERALD, new Random().nextInt(2))));
world.spawnEntity(new ItemEntity(world, up.getX(), up.getY(), up.getZ(),
new ItemStack(Items.GOLD_NUGGET, new Random().nextInt(10))));
world.spawnEntity(new ItemEntity(world, up.getX(), up.getY(), up.getZ(),
new ItemStack(Items.IRON_NUGGET, new Random().nextInt(6))));
world.spawnEntity(new ItemEntity(world, up.getX(), up.getY(), up.getZ(),
new ItemStack(Items.LAPIS_LAZULI, new Random().nextInt(5))));
return true; return true;
} }
return false; return false;

View File

@ -30,7 +30,7 @@ import net.minecraft.world.World;
public class BlockLavahoarder extends Block implements BlockEntityProvider { public class BlockLavahoarder extends Block implements BlockEntityProvider {
public BlockLavahoarder() { public BlockLavahoarder() {
super(FabricBlockSettings.of(Material.STONE).hardness(2.5f).lightLevel(16)); super(FabricBlockSettings.of(Material.STONE).hardness(2.5f).luminance(16));
} }
@Override @Override