add bauble support

This commit is contained in:
ABKQPO committed 2026-09-07 09:03:49 +08:00
1 parent 562c2b09c1
commit 8f25745c52
10 files changed
+149 -6

No files matched your search

@@ -14,7 +14,9 @@ import appeng.core.AEConfig;
import appeng.core.CommonHelper;
import appeng.core.settings.ControllerAnimation;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketOpenPortableCellWorkbench;
import appeng.core.sync.packets.PacketPickBlock;
import appeng.server.ServerHelper;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.relauncher.Side;
@@ -31,6 +33,7 @@ public class KeyBindHandler {
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
handleControllerAnimationKey();
handlePortableCellWorkbenchKey();
if (CommonHelper.proxy.isKeyPressed(ActionKey.PICK_BLOCK) && !arePickBlockBindsEqual()) {
handlePickBlock();
}
@@ -40,6 +43,7 @@ public class KeyBindHandler {
@SubscribeEvent
public void onMouseInput(InputEvent.MouseInputEvent event) {
handleControllerAnimationKey();
handlePortableCellWorkbenchKey();
if (CommonHelper.proxy.isKeyPressed(ActionKey.PICK_BLOCK) && !arePickBlockBindsEqual()) {
handlePickBlock();
}
@@ -50,6 +54,14 @@ public class KeyBindHandler {
== CommonHelper.proxy.getKeybind(ActionKey.PICK_BLOCK);
}
public static void handlePortableCellWorkbenchKey() {
Minecraft minecraft = Minecraft.getMinecraft();
if (minecraft.currentScreen != null || minecraft.thePlayer == null || NetworkHandler.instance == null) return;
if (!ServerHelper.OPEN_PORTABLE_CELL_WORKBENCH.isKeyDown(minecraft.thePlayer)) return;
NetworkHandler.instance.sendToServer(new PacketOpenPortableCellWorkbench());
}
private static void handleControllerAnimationKey() {
if (!CommonHelper.proxy.isKeyPressed(ActionKey.CYCLE_CONTROLLER_ANIMATION)) return;
final Minecraft minecraft = Minecraft.getMinecraft();
+3
View File
@@ -96,6 +96,7 @@ public final class AppEng {
private File configDirectory;
private CustomRecipeConfig customRecipeConfig;
public static final String BAUBLESLOT = "Terminal";
public static final String PORTABLE_CELL_WORKBENCH_BAUBLE_SLOT = "PortableCellWorkbench";
/**
* Folder for recipes
@@ -135,6 +136,8 @@ public final class AppEng {
if (Loader.isModLoaded("Baubles|Expanded")) {
BaubleExpandedSlots.tryRegisterType(BAUBLESLOT);
BaubleExpandedSlots.tryAssignSlotOfType(BAUBLESLOT);
BaubleExpandedSlots.tryRegisterType(PORTABLE_CELL_WORKBENCH_BAUBLE_SLOT);
BaubleExpandedSlots.tryAssignSlotOfType(PORTABLE_CELL_WORKBENCH_BAUBLE_SLOT);
}
final Stopwatch watch = Stopwatch.createStarted();
@@ -50,6 +50,7 @@ import appeng.core.sync.packets.PacketNEIRecipe;
import appeng.core.sync.packets.PacketNetworkStatusSelected;
import appeng.core.sync.packets.PacketNetworkVisualiserData;
import appeng.core.sync.packets.PacketNewStorageDimension;
import appeng.core.sync.packets.PacketOpenPortableCellWorkbench;
import appeng.core.sync.packets.PacketOptimizePatterns;
import appeng.core.sync.packets.PacketPaintedEntity;
import appeng.core.sync.packets.PacketPartInteraction;
@@ -145,6 +146,7 @@ public class AppEngPacketHandlerBase {
PACKET_NEI_BOOKMARK(PacketNEIBookmark.class),
PACKET_INTERFACE_TERMINAL_UPDATE(PacketInterfaceTerminalUpdate.class),
PACKET_OPTIMIZE_PATTERNS(PacketOptimizePatterns.class),
PACKET_OPEN_PORTABLE_CELL_WORKBENCH(PacketOpenPortableCellWorkbench.class),
PACKET_NETWORK_STATUS_SELECTED(PacketNetworkStatusSelected.class),
PACKET_PINS_UPDATE(PacketPinsUpdate.class),
PACKET_HIGHLIGHT_BLOCKS(PacketHighlightBlockStorage.class),
@@ -0,0 +1,56 @@
package appeng.core.sync.packets;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.INetworkInfo;
import appeng.util.Platform;
import baubles.api.BaublesApi;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
public class PacketOpenPortableCellWorkbench extends AppEngPacket {
public PacketOpenPortableCellWorkbench(final ByteBuf stream) {}
public PacketOpenPortableCellWorkbench() {
final ByteBuf data = Unpooled.buffer();
data.writeInt(this.getPacketID());
this.configureWrite(data);
}
@Override
public void serverPacketData(final INetworkInfo network, final AppEngPacket packet, final EntityPlayer player) {
if (Platform.isBaublesLoaded) {
final IInventory baubles = BaublesApi.getBaubles(player);
if (baubles != null) {
for (int slot = 0; slot < baubles.getSizeInventory(); slot++) {
if (this.isPortableCellWorkbench(baubles.getStackInSlot(slot))) {
Platform.openGUI(
player,
null,
null,
GuiBridge.GUI_CELL_WORKBENCH,
Platform.baublesSlotsOffset + slot);
return;
}
}
}
}
for (int slot = 0; slot < player.inventory.getSizeInventory(); slot++) {
if (this.isPortableCellWorkbench(player.inventory.getStackInSlot(slot))) {
Platform.openGUI(player, null, null, GuiBridge.GUI_CELL_WORKBENCH, slot);
return;
}
}
}
public boolean isPortableCellWorkbench(final ItemStack stack) {
return stack != null && AEApi.instance().definitions().items().portableCellWorkbench().isSameAs(stack);
}
}
@@ -35,13 +35,20 @@ public class PortableCellWorkbenchHost
protected final IInventory playerInventory;
protected final Item workbenchItem;
protected final int inventorySlot;
protected final int inventorySlotIndex;
protected final String portableId;
protected final CellWorkbenchState state;
public PortableCellWorkbenchHost(IInventory playerInventory, Item workbenchItem, int inventorySlot) {
this(playerInventory, workbenchItem, inventorySlot, inventorySlot);
}
public PortableCellWorkbenchHost(IInventory playerInventory, Item workbenchItem, int inventorySlot,
int inventorySlotIndex) {
this.playerInventory = playerInventory;
this.workbenchItem = workbenchItem;
this.inventorySlot = inventorySlot;
this.inventorySlotIndex = inventorySlotIndex;
ItemStack stack = this.getItemStack();
if (stack == null || stack.getItem() != workbenchItem) {
@@ -62,7 +69,7 @@ public class PortableCellWorkbenchHost
@Override
public int getInventorySlot() {
return this.inventorySlot;
return this.inventorySlotIndex;
}
@Override
@@ -2,20 +2,31 @@ package appeng.items.tools;
import java.util.EnumSet;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.guiobjects.IGuiItem;
import appeng.api.implementations.guiobjects.IGuiItemObject;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.core.sync.GuiBridge;
import appeng.items.AEBaseItem;
import appeng.items.contents.PortableCellWorkbenchHost;
import appeng.util.Platform;
import baubles.api.BaubleType;
import baubles.api.BaublesApi;
import baubles.api.IBauble;
import baubles.api.expanded.IBaubleExpanded;
import cpw.mods.fml.common.Optional;
public class ToolPortableCellWorkbench extends AEBaseItem implements IGuiItem {
@Optional.InterfaceList(
value = { @Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"),
@Optional.Interface(iface = "baubles.api.expanded.IBaubleExpanded", modid = "Baubles|Expanded") })
public class ToolPortableCellWorkbench extends AEBaseItem implements IGuiItem, IBauble, IBaubleExpanded {
public ToolPortableCellWorkbench() {
this.setFeature(EnumSet.of(AEFeature.PortableCellWorkbench));
@@ -30,11 +41,56 @@ public class ToolPortableCellWorkbench extends AEBaseItem implements IGuiItem {
@Override
public IGuiItemObject getGuiObject(ItemStack stack, World world, EntityPlayer player, int x, int y, int z) {
if (player == null || x < 0
|| x >= player.inventory.getSizeInventory()
|| player.inventory.getStackInSlot(x) != stack) {
if (player == null || x < 0) {
return null;
}
return new PortableCellWorkbenchHost(player.inventory, this, x);
IInventory inventory = player.inventory;
int inventorySlot = x;
if (Platform.isBaublesLoaded && x >= Platform.baublesSlotsOffset) {
inventory = BaublesApi.getBaubles(player);
inventorySlot = x - Platform.baublesSlotsOffset;
}
if (inventory == null || inventorySlot >= inventory.getSizeInventory()
|| inventory.getStackInSlot(inventorySlot) != stack) {
return null;
}
return new PortableCellWorkbenchHost(inventory, this, inventorySlot, x);
}
@Override
@Optional.Method(modid = "Baubles")
public BaubleType getBaubleType(ItemStack itemStack) {
return BaubleType.RING;
}
@Override
@Optional.Method(modid = "Baubles|Expanded")
public String[] getBaubleTypes(ItemStack itemStack) {
return new String[] { AppEng.PORTABLE_CELL_WORKBENCH_BAUBLE_SLOT };
}
@Override
@Optional.Method(modid = "Baubles")
public void onWornTick(ItemStack itemStack, EntityLivingBase player) {}
@Override
@Optional.Method(modid = "Baubles")
public void onEquipped(ItemStack itemStack, EntityLivingBase player) {}
@Override
@Optional.Method(modid = "Baubles")
public void onUnequipped(ItemStack itemStack, EntityLivingBase player) {}
@Override
@Optional.Method(modid = "Baubles")
public boolean canEquip(ItemStack itemStack, EntityLivingBase player) {
return true;
}
@Override
@Optional.Method(modid = "Baubles")
public boolean canUnequip(ItemStack itemStack, EntityLivingBase player) {
return true;
}
}
@@ -51,6 +51,9 @@ public class ServerHelper extends CommonHelper {
public static final SyncedKeybind WIRELESS_MODE_SWITCH = SyncedKeybind
.createConfigurable("key.wireless_mode_switch.desc", ServerHelper.KEY_CATEGORY, Keyboard.KEY_TAB);
public static final SyncedKeybind OPEN_PORTABLE_CELL_WORKBENCH = SyncedKeybind
.createConfigurable("key.open_portable_cell_workbench.desc", ServerHelper.KEY_CATEGORY, Keyboard.KEY_P);
private EntityPlayer renderModeBased;
@Override
@@ -925,6 +925,7 @@ waila.appliedenergistics2.IOBusSpeed=Speed: %s %s/t
# Baubles Extended
slot.Terminal=§aTerminal§7
slot.PortableCellWorkbench=§aPortable Cell Workbench§7
waila.appliedenergistics2.wireless.connected=Connected to %s
waila.appliedenergistics2.wireless.connected.multiple=Connected to %s Wireless (shift for details)
@@ -1292,6 +1293,7 @@ key.cycle_controller_animation.desc=Cycle controller animation
key.container_interaction.desc=Container Item Interaction
key.wireless_extra_action.desc=Wireless Extra Action
key.wireless_mode_switch.desc=Wireless Mode Switch
key.open_portable_cell_workbench.desc=Open Portable Cell Workbench
# NEI
nei.options.keys.gui.pattern_view=View Pattern
@@ -689,6 +689,7 @@ waila.appliedenergistics2.Waiting=Waiting:
# Baubles Extended
slot.Terminal=§aTerminal§7
slot.PortableCellWorkbench=§a便携元件工作台§7
# Items
item.appliedenergistics2.ItemBasicStorageCell.1k.name=1k-ME存储元件
@@ -958,6 +959,7 @@ key.pick_block.desc=AE2 Pick Block
key.toggle_focus.desc=切换是否选中搜索框
key.search_connected_inventories.desc=Search network inventories for item
key.control_operation.desc=Control operation
key.open_portable_cell_workbench.desc=打开便携元件工作台
# NEI
nei.options.keys.gui.pattern_view=View Pattern
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB