use of net.minecraft.world.level.block.LiquidBlock in project Tropicraft by Tropicraft.
the class TropicraftSpawnEgg method use.
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
ItemStack heldItem = player.getItemInHand(hand);
if (world.isClientSide) {
return InteractionResultHolder.pass(heldItem);
} else {
HitResult rayTraceResult = getPlayerPOVHitResult(world, player, ClipContext.Fluid.SOURCE_ONLY);
if (rayTraceResult.getType() != HitResult.Type.BLOCK) {
return InteractionResultHolder.pass(heldItem);
} else {
BlockHitResult traceResult = (BlockHitResult) rayTraceResult;
BlockPos tracePos = traceResult.getBlockPos();
if (!(world.getBlockState(tracePos).getBlock() instanceof LiquidBlock)) {
return InteractionResultHolder.pass(heldItem);
} else if (world.mayInteract(player, tracePos) && player.mayUseItemAt(tracePos, traceResult.getDirection(), heldItem)) {
EntityType<?> type = typeIn.get();
if (type.spawn((ServerLevel) world, heldItem, player, tracePos, MobSpawnType.SPAWN_EGG, false, false) == null) {
return InteractionResultHolder.pass(heldItem);
} else {
if (!player.getAbilities().instabuild) {
heldItem.shrink(1);
}
player.awardStat(Stats.ITEM_USED.get(this));
return InteractionResultHolder.success(heldItem);
}
} else {
return InteractionResultHolder.fail(heldItem);
}
}
}
}
use of net.minecraft.world.level.block.LiquidBlock in project SpongeCommon by SpongePowered.
the class BlockTickContext method source.
@Override
public BlockTickContext source(final Object owner) {
super.source(owner);
if (owner instanceof LocatableBlock) {
final LocatableBlock locatableBlock = (LocatableBlock) owner;
final Block block = ((BlockState) locatableBlock.blockState()).getBlock();
this.tickingBlock = (BlockBridge) block;
this.providesModifier = !(block instanceof LiquidBlock);
this.world = locatableBlock.world();
if (block instanceof TrackableBridge) {
final TrackableBridge trackable = (TrackableBridge) block;
this.setBlockEvents(trackable.bridge$allowsBlockEventCreation()).setBulkBlockCaptures(trackable.bridge$allowsBlockBulkCaptures()).setEntitySpawnEvents(trackable.bridge$allowsEntityEventCreation()).setBulkEntityCaptures(trackable.bridge$allowsEntityBulkCaptures());
}
}
return this;
}
use of net.minecraft.world.level.block.LiquidBlock in project SpongeCommon by SpongePowered.
the class FluidTickContext method source.
@Override
public FluidTickContext source(final Object owner) {
super.source(owner);
if (owner instanceof LocatableBlock) {
final LocatableBlock locatableBlock = (LocatableBlock) owner;
final Block block = ((BlockState) locatableBlock.blockState()).getBlock();
this.providesModifier = !(block instanceof LiquidBlock);
this.world = locatableBlock.world();
if (block instanceof TrackableBridge) {
final TrackableBridge trackable = (TrackableBridge) block;
this.setBlockEvents(trackable.bridge$allowsBlockEventCreation()).setBulkBlockCaptures(trackable.bridge$allowsBlockBulkCaptures()).setEntitySpawnEvents(trackable.bridge$allowsEntityEventCreation()).setBulkEntityCaptures(trackable.bridge$allowsEntityBulkCaptures());
}
}
return this;
}
Aggregations