Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSoundEvents;

import com.simibubi.create.content.kinetics.fan.processing.AllFanProcessingTypes.HauntingType;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -46,31 +46,30 @@ public BlockState getStateForPlacement(BlockPlaceContext ctx) {

Level world = ctx.getLevel();
BlockPos pos = ctx.getClickedPos();
return tryConvert(world, pos, newState, world.getBlockState(pos.relative(Direction.DOWN)));
return tryConvert(world, pos, newState);
}

@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor world,
BlockPos currentPos, BlockPos facingPos) {
BlockState newState = super.updateShape(state, facing, facingState, world, currentPos, facingPos);
if (facing != Direction.DOWN)
if (facing != Direction.DOWN || !(world instanceof Level level))
return newState;

return tryConvert(world, currentPos, newState, facingState);
return tryConvert(level, currentPos, newState);
}

protected BlockState tryConvert(LevelAccessor world, BlockPos pos, BlockState state, BlockState underState) {
protected BlockState tryConvert(Level world, BlockPos pos, BlockState state) {
if (!AllBlocks.PECULIAR_BELL.has(state))
return state;

Block underBlock = underState.getBlock();
if (!(Blocks.SOUL_FIRE.equals(underBlock) || Blocks.SOUL_CAMPFIRE.equals(underBlock)))
if (!AllFanProcessingTypes.HAUNTING.isValidAt(world, pos.below()))
return state;

if (world.isClientSide()) {
spawnConversionParticles(world, pos);
} else if (world instanceof Level) {
AllSoundEvents.HAUNTED_BELL_CONVERT.playOnServer((Level) world, pos);
} else {
AllSoundEvents.HAUNTED_BELL_CONVERT.playOnServer(world, pos);
}

return AllBlocks.HAUNTED_BELL.getDefaultState()
Expand Down
Loading