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 @@ -30,7 +30,10 @@
import aztech.modern_industrialization.pipes.electricity.ElectricityNetworkData;
import aztech.modern_industrialization.pipes.fluid.FluidNetworkData;
import aztech.modern_industrialization.pipes.item.ItemNetworkData;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -154,6 +157,13 @@ private boolean tryPlaceAt(UseOnContext context, BlockPos pos) {
}

private static boolean canPlace(UseOnContext ctx, BlockPos pos) {
if(!ctx.getLevel().isInWorldBounds(pos)) {
int worldHeightLimit = ctx.getLevel().getMaxBuildHeight();
if(ctx.getPlayer() instanceof ServerPlayer player && pos.getY() >= worldHeightLimit) {
player.sendSystemMessage(Component.translatable("build.tooHigh", worldHeightLimit - 1).withStyle(ChatFormatting.RED), true);
}
return false;
}
BlockState state = MIPipes.BLOCK_PIPE.get().defaultBlockState();
CollisionContext shapeContext = ctx.getPlayer() == null ? CollisionContext.empty() : CollisionContext.of(ctx.getPlayer());
return ctx.getLevel().getBlockState(pos).canBeReplaced(new BlockPlaceContext(ctx)) && state.canSurvive(ctx.getLevel(), pos)
Expand Down
Loading