place sulfor on lava
This commit is contained in:
parent
e56ec4c88c
commit
5396cefbb3
@ -12,15 +12,13 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.CropBlock;
|
import net.minecraft.block.CropBlock;
|
||||||
import net.minecraft.block.IceBlock;
|
|
||||||
import net.minecraft.block.ShapeContext;
|
import net.minecraft.block.ShapeContext;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.ai.pathing.NavigationType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.fluid.FluidState;
|
|
||||||
import net.minecraft.fluid.Fluids;
|
|
||||||
import net.minecraft.item.ItemConvertible;
|
import net.minecraft.item.ItemConvertible;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
import net.minecraft.loot.context.LootContextParameterSet.Builder;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.ItemScatterer;
|
import net.minecraft.util.ItemScatterer;
|
||||||
@ -31,6 +29,7 @@ import net.minecraft.util.math.random.Random;
|
|||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -41,12 +40,18 @@ public class BlockSulforpad extends CropBlock {
|
|||||||
|
|
||||||
public BlockSulforpad(AbstractBlock.Settings settings) {
|
public BlockSulforpad(AbstractBlock.Settings settings) {
|
||||||
super(settings.nonOpaque().blockVision(Blocks::never).solidBlock(Blocks::never));
|
super(settings.nonOpaque().blockVision(Blocks::never).solidBlock(Blocks::never));
|
||||||
|
setDefaultState(getDefaultState().with(this.getAgeProperty(), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BlockSulforpad() {
|
protected BlockSulforpad() {
|
||||||
super(FabricBlockSettings.create());
|
super(FabricBlockSettings.create());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
public List<ItemStack> getDroppedStacks(BlockState state, Builder builder) {
|
||||||
Integer age = this.getAge(state);
|
Integer age = this.getAge(state);
|
||||||
@ -83,11 +88,22 @@ public class BlockSulforpad extends CropBlock {
|
|||||||
BlockHitResult hitResult) {
|
BlockHitResult hitResult) {
|
||||||
if (!world.isClient && isMature(state)) {
|
if (!world.isClient && isMature(state)) {
|
||||||
spawnHarvested(world, pos, state);
|
spawnHarvested(world, pos, state);
|
||||||
world.setBlockState(pos, state.with(AGE, 0));
|
Random random = world.getRandom();
|
||||||
|
world.setBlockState(pos, state.with(AGE, random.nextInt(6)));
|
||||||
}
|
}
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
|
||||||
|
// do nothing here
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getPickStack(WorldView world, BlockPos pos, BlockState state) {
|
||||||
|
return new ItemStack(QuickieItems.SULPHOR, 1);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MapCodec<? extends BlockSulforpad> getCodec() {
|
public MapCodec<? extends BlockSulforpad> getCodec() {
|
||||||
return BlockSulforpad.createCodec(BlockSulforpad::new);
|
return BlockSulforpad.createCodec(BlockSulforpad::new);
|
||||||
|
@ -4,10 +4,18 @@ import de.jottyfan.minecraft.quickiefabric.blocks.QuickieBlocks;
|
|||||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.BoatItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.ItemUsageContext;
|
import net.minecraft.item.ItemUsageContext;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.TypedActionResult;
|
||||||
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
|
import net.minecraft.util.hit.HitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.RaycastContext;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,17 +29,37 @@ public class ItemSulphor extends Item {
|
|||||||
super(new FabricItemSettings());
|
super(new FabricItemSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult useOnBlock(ItemUsageContext context) {
|
public ActionResult useOnBlock(ItemUsageContext context) {
|
||||||
World world = context.getWorld();
|
World world = context.getWorld();
|
||||||
BlockPos pos = context.getBlockPos();
|
BlockPos pos = context.getBlockPos();
|
||||||
Block block = world.getBlockState(pos).getBlock();
|
Block block = world.getBlockState(pos).getBlock();
|
||||||
if (Blocks.LAVA_CAULDRON.equals(block)) {
|
if (Blocks.LAVA_CAULDRON.equals(block)) {
|
||||||
if (world.getBlockState(pos.up()).isAir()) {
|
if (world.getBlockState(pos.up()).isAir()) {
|
||||||
world.setBlockState(pos.up(), QuickieBlocks.SULFORPAD.getDefaultState());
|
world.setBlockState(pos.up(), QuickieBlocks.SULFORPAD.getDefaultState());
|
||||||
context.getStack().decrement(1);
|
context.getStack().decrement(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
|
||||||
|
ItemStack itemStack = user.getStackInHand(hand);
|
||||||
|
BlockHitResult hitResult = BoatItem.raycast(world, user, RaycastContext.FluidHandling.SOURCE_ONLY);
|
||||||
|
if (((HitResult) hitResult).getType() == HitResult.Type.MISS) {
|
||||||
|
return TypedActionResult.pass(itemStack);
|
||||||
|
}
|
||||||
|
if (((HitResult) hitResult).getType() == HitResult.Type.BLOCK) {
|
||||||
|
if (!world.isClient) {
|
||||||
|
BlockPos pos = hitResult.getBlockPos();
|
||||||
|
if (world.getBlockState(pos).getBlock().equals(Blocks.LAVA) && world.getBlockState(pos.up()).isAir()) {
|
||||||
|
world.setBlockState(pos.up(), QuickieBlocks.SULFORPAD.getDefaultState());
|
||||||
|
itemStack.decrement(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TypedActionResult.success(itemStack, world.isClient());
|
||||||
|
}
|
||||||
|
return TypedActionResult.pass(itemStack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,30 @@
|
|||||||
{
|
{
|
||||||
"type": "minecraft:ore",
|
"type": "minecraft:random_patch",
|
||||||
"config": {
|
"config": {
|
||||||
"discard_chance_on_air_exposure": 0.0,
|
"feature": {
|
||||||
"size": 3,
|
"feature": {
|
||||||
"targets": [
|
"type": "minecraft:simple_block",
|
||||||
{
|
"config": {
|
||||||
"state": {
|
"to_place": {
|
||||||
"Name": "quickiefabric:sulforpad"
|
"type": "minecraft:simple_state_provider",
|
||||||
},
|
"state": {
|
||||||
"target": {
|
"Name": "quickiefabric:sulforpad"
|
||||||
"predicate_type": "minecraft:block_match",
|
}
|
||||||
"block": "minecraft:lava"
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
]
|
"placement": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:block_predicate_filter",
|
||||||
|
"predicate": {
|
||||||
|
"type": "minecraft:matching_blocks",
|
||||||
|
"blocks": "minecraft:air"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"tries": 10,
|
||||||
|
"xz_spread": 7,
|
||||||
|
"y_spread": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,18 +1,20 @@
|
|||||||
{
|
{
|
||||||
"feature": "quickiefabric:sulforpad",
|
"feature": "quickiefabric:sulforpad",
|
||||||
"placement": [
|
"placement": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:count",
|
||||||
|
"count": 4
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "minecraft:environment_scan",
|
"type": "minecraft:environment_scan",
|
||||||
"direction_of_search": "up",
|
"direction_of_search": "down",
|
||||||
"max_steps": 1,
|
"max_steps": 1,
|
||||||
"target_condition": {
|
"target_condition": {
|
||||||
|
"type": "minecraft:true"
|
||||||
|
},
|
||||||
|
"allowed_search_condition": {
|
||||||
"type": "minecraft:matching_blocks",
|
"type": "minecraft:matching_blocks",
|
||||||
"offset": [
|
"blocks": "minecraft:lava"
|
||||||
0,
|
|
||||||
1,
|
|
||||||
0
|
|
||||||
],
|
|
||||||
"blocks": "minecraft:air"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user