Skip to content
Merged
Show file tree
Hide file tree
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 @@ -37,6 +37,7 @@
import plus.dragons.createintegratedfarming.common.farming.harvest.GlowBerryHarvestBehaviour;
import plus.dragons.createintegratedfarming.common.fishing.net.FishingNetCatchProviders;
import plus.dragons.createintegratedfarming.common.fishing.net.FishingNetMedium;
import plus.dragons.createintegratedfarming.common.fishing.net.FishingNetSailAttachment;
import plus.dragons.createintegratedfarming.common.network.CIFPackets;
import plus.dragons.createintegratedfarming.common.ranching.roost.display.RoostingDisplaySync;
import plus.dragons.createintegratedfarming.common.registry.CIFArmInteractionPoints;
Expand Down Expand Up @@ -108,6 +109,7 @@ public CIFCommon(IEventBus modBus, ModContainer modContainer) {
REGISTRATE.registerEventListeners(modBus);
CIFCreativeModeTabs.register(modBus);
CIFBlocks.register(modBus);
FishingNetSailAttachment.register();
CIFBlockEntities.register(modBus);
CIFArmInteractionPoints.register(modBus);
CIFDataMaps.register(modBus);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (C) 2025 DragonsPlus
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package plus.dragons.createintegratedfarming.common.fishing.net;

import com.simibubi.create.api.contraption.BlockMovementChecks;
import com.simibubi.create.api.contraption.BlockMovementChecks.CheckResult;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.DirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;

/** Allows fishing nets to attach to contraptions like windmill sails, without needing super glue. */
public final class FishingNetSailAttachment {
private FishingNetSailAttachment() {}

public static void register() {
BlockMovementChecks.registerAttachedCheck(FishingNetSailAttachment::isAttachedTowards);
BlockMovementChecks.registerNotSupportiveCheck(FishingNetSailAttachment::isNotSupportive);
}

private static CheckResult isAttachedTowards(BlockState state, Level level, BlockPos pos, Direction direction) {
if (!isFishingNet(state))
return CheckResult.PASS;
return CheckResult.of(direction.getAxis() != state.getValue(DirectionalBlock.FACING).getAxis());
}

private static CheckResult isNotSupportive(BlockState state, Direction direction) {
if (!isFishingNet(state))
return CheckResult.PASS;
return CheckResult.of(direction.getAxis() == state.getValue(DirectionalBlock.FACING).getAxis());
}

private static boolean isFishingNet(BlockState state) {
return state.getBlock() instanceof FishingNetBlock || state.getBlock() instanceof LavaFishingNetBlock;
}
}
Loading