Skip to content

Commit

Permalink
don't spawn error
Browse files Browse the repository at this point in the history
  • Loading branch information
Raycoms committed Jan 20, 2025
1 parent a5f5c87 commit 82b8f90
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/com/minecolonies/core/items/ItemCrop.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import com.minecolonies.api.util.MessageUtils;
import com.minecolonies.api.util.constant.TranslationConstants;
import com.minecolonies.core.blocks.MinecoloniesCropBlock;
import com.minecolonies.core.blocks.MinecoloniesFarmland;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.TagKey;
Expand All @@ -16,6 +18,7 @@
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.FarmBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -52,7 +55,9 @@ protected boolean canPlace(BlockPlaceContext ctx, @NotNull BlockState state)
Player player = ctx.getPlayer();
if (!player.isCreative())
{
if (ctx.getLevel().isClientSide)
final BlockPos clickedPos = ctx.getClickedPos().below();
final BlockState worldState = ctx.getLevel().getBlockState(clickedPos);
if (ctx.getLevel().isClientSide && (worldState.getBlock() instanceof MinecoloniesFarmland || worldState.getBlock() instanceof FarmBlock))
{
MessageUtils.format(Component.translatable("com.minecolonies.core.crop.cantplant")).sendTo(player);
}
Expand Down

0 comments on commit 82b8f90

Please sign in to comment.