-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add modifier key for placing cable parts on the opposite side (#7864)
Closes #7661 --------- Co-authored-by: Sebastian Hartte <[email protected]>
- Loading branch information
Showing
8 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/appeng/core/definitions/AEAttachmentTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package appeng.core.definitions; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.neoforge.attachment.AttachmentType; | ||
import net.neoforged.neoforge.registries.DeferredRegister; | ||
import net.neoforged.neoforge.registries.NeoForgeRegistries; | ||
|
||
import appeng.core.AppEng; | ||
|
||
public final class AEAttachmentTypes { | ||
private static final DeferredRegister<AttachmentType<?>> ATTACHMENT_TYPES = DeferredRegister | ||
.create(NeoForgeRegistries.ATTACHMENT_TYPES, AppEng.MOD_ID); | ||
|
||
public static final Supplier<AttachmentType<Boolean>> HOLDING_CTRL = ATTACHMENT_TYPES.register("ctrl", | ||
() -> AttachmentType.builder(() -> false).build()); | ||
|
||
public static void register(IEventBus modEventBus) { | ||
ATTACHMENT_TYPES.register(modEventBus); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/appeng/core/network/serverbound/UpdateHoldingCtrlPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package appeng.core.network.serverbound; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.server.level.ServerPlayer; | ||
|
||
import appeng.core.definitions.AEAttachmentTypes; | ||
import appeng.core.network.CustomAppEngPayload; | ||
import appeng.core.network.ServerboundPacket; | ||
|
||
public record UpdateHoldingCtrlPacket(boolean keyDown) implements ServerboundPacket { | ||
public static final StreamCodec<RegistryFriendlyByteBuf, UpdateHoldingCtrlPacket> STREAM_CODEC = StreamCodec | ||
.ofMember(UpdateHoldingCtrlPacket::write, UpdateHoldingCtrlPacket::decode); | ||
|
||
public static final Type<UpdateHoldingCtrlPacket> TYPE = CustomAppEngPayload.createType("toggle_ctrl_down"); | ||
|
||
@NotNull | ||
@Override | ||
public Type<UpdateHoldingCtrlPacket> type() { | ||
return TYPE; | ||
} | ||
|
||
public static UpdateHoldingCtrlPacket decode(RegistryFriendlyByteBuf buf) { | ||
var keyDown = buf.readBoolean(); | ||
return new UpdateHoldingCtrlPacket(keyDown); | ||
} | ||
|
||
public void write(RegistryFriendlyByteBuf data) { | ||
data.writeBoolean(keyDown); | ||
} | ||
|
||
@Override | ||
public void handleOnServer(ServerPlayer player) { | ||
player.setData(AEAttachmentTypes.HOLDING_CTRL, keyDown); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters