-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
340 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
- move Menus into ae2 namespace | ||
- move Menus into ae2 namespace | ||
- allow Pick Block to draw items from the terminal |
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
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
33 changes: 33 additions & 0 deletions
33
src/main/java/de/mari_023/ae2wtlib/mixin/MinecraftMixin.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,33 @@ | ||
package de.mari_023.ae2wtlib.mixin; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.player.LocalPlayer; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import de.mari_023.ae2wtlib.AE2wtlibEvents; | ||
|
||
@Mixin(Minecraft.class) | ||
public abstract class MinecraftMixin { | ||
@Shadow | ||
public LocalPlayer player; | ||
|
||
@Inject(method = "pickBlock", at = { | ||
@At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/entity/player/Inventory;findSlotMatchingItem(Lnet/minecraft/world/item/ItemStack;)I") }) | ||
public void pickBlock(CallbackInfo ci, @Local ItemStack itemstack, @Local int i) { | ||
if (player.getAbilities().instabuild) | ||
return; | ||
if (player.isSpectator()) | ||
return; | ||
if (i != -1) | ||
return; | ||
AE2wtlibEvents.pickBlock(itemstack); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/de/mari_023/ae2wtlib/networking/PickBlockPacket.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,29 @@ | ||
package de.mari_023.ae2wtlib.networking; | ||
|
||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import de.mari_023.ae2wtlib.AE2wtlibEvents; | ||
import de.mari_023.ae2wtlib.api.AE2wtlibAPI; | ||
|
||
public record PickBlockPacket(ItemStack itemStack) implements AE2wtlibPacket { | ||
public static final Type<PickBlockPacket> ID = new Type<>(AE2wtlibAPI.id("pick_block")); | ||
public static final StreamCodec<RegistryFriendlyByteBuf, PickBlockPacket> STREAM_CODEC = ItemStack.STREAM_CODEC | ||
.map(PickBlockPacket::new, PickBlockPacket::itemStack); | ||
|
||
@Override | ||
public void processPacketData(Player player) { | ||
if (!(player instanceof ServerPlayer serverPlayer)) | ||
return; | ||
AE2wtlibEvents.pickBlock(serverPlayer, itemStack); | ||
} | ||
|
||
@Override | ||
public Type<? extends CustomPacketPayload> type() { | ||
return ID; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/de/mari_023/ae2wtlib/networking/TerminalSettingsPacket.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,42 @@ | ||
package de.mari_023.ae2wtlib.networking; | ||
|
||
import net.minecraft.network.RegistryFriendlyByteBuf; | ||
import net.minecraft.network.codec.ByteBufCodecs; | ||
import net.minecraft.network.codec.StreamCodec; | ||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import net.minecraft.world.entity.player.Player; | ||
|
||
import appeng.menu.locator.ItemMenuHostLocator; | ||
|
||
import de.mari_023.ae2wtlib.AE2wtlibAdditionalComponents; | ||
import de.mari_023.ae2wtlib.api.AE2wtlibAPI; | ||
import de.mari_023.ae2wtlib.api.AE2wtlibComponents; | ||
import de.mari_023.ae2wtlib.wct.magnet_card.MagnetMode; | ||
|
||
public record TerminalSettingsPacket(ItemMenuHostLocator terminal, boolean pickBlock, boolean restock, boolean magnet, | ||
boolean pickupToME) implements AE2wtlibPacket { | ||
|
||
public static final Type<TerminalSettingsPacket> ID = new Type<>(AE2wtlibAPI.id("terminal_settings")); | ||
public static final StreamCodec<RegistryFriendlyByteBuf, TerminalSettingsPacket> STREAM_CODEC = StreamCodec | ||
.composite( | ||
AE2wtlibComponents.MENU_HOST_LOCATOR_STREAM_CODEC, TerminalSettingsPacket::terminal, | ||
ByteBufCodecs.BOOL, TerminalSettingsPacket::pickBlock, | ||
ByteBufCodecs.BOOL, TerminalSettingsPacket::restock, | ||
ByteBufCodecs.BOOL, TerminalSettingsPacket::magnet, | ||
ByteBufCodecs.BOOL, TerminalSettingsPacket::pickupToME, | ||
TerminalSettingsPacket::new); | ||
@Override | ||
public void processPacketData(Player player) { | ||
var stack = terminal.locateItem(player); | ||
stack.set(AE2wtlibComponents.PICK_BLOCK, pickBlock); | ||
stack.set(AE2wtlibComponents.RESTOCK, restock); | ||
var magnetSettings = stack.getOrDefault(AE2wtlibAdditionalComponents.MAGNET_SETTINGS, MagnetMode.OFF); | ||
magnetSettings = magnetSettings.set(magnet, pickupToME); | ||
stack.set(AE2wtlibAdditionalComponents.MAGNET_SETTINGS, magnetSettings); | ||
} | ||
|
||
@Override | ||
public Type<? extends CustomPacketPayload> type() { | ||
return ID; | ||
} | ||
} |
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
Oops, something went wrong.