mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
add wireless fluid terminal
This commit is contained in:
1 parent
482298021e
commit
a22814940b
19 files changed
+449
-23
No files matched your search
@@ -192,7 +192,7 @@ public class ItemPortableFluidCell extends AEBasePoweredItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z) {
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
return new PortableFluidCellInventory(stack, x);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.features.IWirelessTermRegistry;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IItemInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessTerminal;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemWirelessFluidTerminal extends ToolWirelessTerminal
|
||||
implements IItemInventory, IRegister<ItemWirelessFluidTerminal> {
|
||||
|
||||
public ItemWirelessFluidTerminal() {
|
||||
super();
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler(this);
|
||||
setUnlocalizedName(NameConst.ITEM_WIRELESS_FLUID_TERMINAL);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_FLUID_TERMINAL).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
|
||||
IWirelessTermRegistry term = AEApi.instance().registries().wireless();
|
||||
if (!term.isWirelessTerminal(item)) {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotWirelessTerminal.get());
|
||||
return item;
|
||||
}
|
||||
final IWirelessTermHandler handler = term.getWirelessTerminalHandler(item);
|
||||
final String unparsedKey = handler.getEncryptionKey(item);
|
||||
if (unparsedKey.isEmpty()) {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotLinked.get());
|
||||
return item;
|
||||
}
|
||||
final long parsedKey = Long.parseLong(unparsedKey);
|
||||
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey);
|
||||
if (securityStation == null) {
|
||||
player.addChatMessage(PlayerMessages.StationCanNotBeLocated.get());
|
||||
return item;
|
||||
}
|
||||
if (handler.hasPower(player, 0.5, item)) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
w,
|
||||
new BlockPos((int) player.posX, (int) player.posY, (int) player.posZ),
|
||||
ForgeDirection.UNKNOWN,
|
||||
GuiType.WIRELESS_FLUID_TERMINAL);
|
||||
} else {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotPowered.get());
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(final ItemStack is) {
|
||||
return is.getItem() == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemWirelessFluidTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_FLUID_TERMINAL, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
try {
|
||||
return new WirelessTerminal(stack, new BlockPos(x, y, z, world), player);
|
||||
} catch (Exception e) {
|
||||
player.addChatMessage(PlayerMessages.OutOfRange.get());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,6 @@ public class TileFluidAutoFiller extends AENetworkInvTile
|
||||
private final AppEngInternalInventory inventory = new AppEngInternalInventory(this, 1);
|
||||
private final BaseActionSource source = new MachineSource(this);
|
||||
private IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
|
||||
public ItemStack containerItem;
|
||||
private final Item encodedPattern = AEApi.instance().definitions().items().encodedPattern().maybeItem().orNull();
|
||||
private IAEItemStack returnStack;
|
||||
private boolean isPowered;
|
||||
@@ -74,7 +73,14 @@ public class TileFluidAutoFiller extends AENetworkInvTile
|
||||
getProxy().setIdlePowerUsage(1D);
|
||||
getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
inventory.setInventorySlotContents(0, BUCKET);
|
||||
this.containerItem = getInventory().getStackInSlot(0);
|
||||
}
|
||||
|
||||
public ItemStack getContainerItem() {
|
||||
return getInventory().getStackInSlot(0);
|
||||
}
|
||||
|
||||
public void setContainerItem(ItemStack is) {
|
||||
getInventory().setInventorySlotContents(0, is);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,8 +98,8 @@ public class TileFluidAutoFiller extends AENetworkInvTile
|
||||
|
||||
public void updatePattern() {
|
||||
ItemStack is = inventory.getStackInSlot(0);
|
||||
if (is == null || this.containerItem.isItemEqual(is)) return;
|
||||
this.containerItem = is;
|
||||
if (is == null || this.getContainerItem().isItemEqual(is)) return;
|
||||
this.setContainerItem(is);
|
||||
postEvent();
|
||||
}
|
||||
|
||||
@@ -141,12 +147,12 @@ public class TileFluidAutoFiller extends AENetworkInvTile
|
||||
for (IAEFluidStack fluidStack : fluidStorage) {
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
if (fluid == null) continue;
|
||||
int maxCapacity = Util.FluidUtil.getCapacity(this.containerItem, fluid);
|
||||
int maxCapacity = Util.FluidUtil.getCapacity(this.getContainerItem(), fluid);
|
||||
if (maxCapacity == 0) continue;
|
||||
MutablePair<Integer, ItemStack> filled = Util.FluidUtil
|
||||
.fillStack(this.containerItem.copy(), new FluidStack(fluid, maxCapacity));
|
||||
.fillStack(this.getContainerItem().copy(), new FluidStack(fluid, maxCapacity));
|
||||
if (filled.right == null) continue;
|
||||
ItemStack pattern = getPattern(this.containerItem, filled.right);
|
||||
ItemStack pattern = getPattern(this.getContainerItem(), filled.right);
|
||||
ICraftingPatternItem patter = (ICraftingPatternItem) pattern.getItem();
|
||||
craftingTracker.addCraftingOption(this, patter.getPatternForItem(pattern, getWorldObj()));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user