mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:14:40 +00:00
all done?
This commit is contained in:
1 parent
5ea7f44058
commit
8081eb2c2c
10 files changed
+172
-24
No files matched your search
@@ -1,9 +1,15 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static com.glodblock.github.loader.recipe.WirelessTerminal.getInfinityBoosterCard;
|
||||
import static com.glodblock.github.util.Util.hasInfinityBoosterCard;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -18,10 +24,15 @@ import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IItemInventory;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements IItemInventory {
|
||||
|
||||
protected GuiType type;
|
||||
public static String infinityBoosterCard = "infinityBoosterCard";
|
||||
|
||||
public ItemBaseWirelessTerminal(GuiType t) {
|
||||
super();
|
||||
@@ -30,6 +41,7 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
|
||||
if (player.isSneaking()) return removeInfinityBoosterCard(player, item);
|
||||
IWirelessTermRegistry term = AEApi.instance().registries().wireless();
|
||||
if (!term.isWirelessTerminal(item)) {
|
||||
player.addChatMessage(PlayerMessages.DeviceNotWirelessTerminal.get());
|
||||
@@ -61,6 +73,31 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
|
||||
return item;
|
||||
}
|
||||
|
||||
private ItemStack removeInfinityBoosterCard(final EntityPlayer player, ItemStack is) {
|
||||
if (hasInfinityBoosterCard(is)) {
|
||||
if (!player.inventory.addItemStackToInventory(getInfinityBoosterCard())) {
|
||||
player.entityDropItem(getInfinityBoosterCard(), 0);
|
||||
}
|
||||
is.getTagCompound().setBoolean(infinityBoosterCard, false);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines,
|
||||
boolean displayMoreInfo) {
|
||||
super.addCheckedInformation(stack, player, lines, displayMoreInfo);
|
||||
if (GuiScreen.isCtrlKeyDown()) {
|
||||
lines.add(NameConst.i18n(NameConst.TT_WIRELESS_INSTALLED));
|
||||
if (hasInfinityBoosterCard(stack)) {
|
||||
lines.add(" " + EnumChatFormatting.GOLD + getInfinityBoosterCard().getDisplayName());
|
||||
}
|
||||
} else {
|
||||
lines.add(NameConst.i18n(NameConst.TT_CTRL_FOR_MORE));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(final ItemStack is) {
|
||||
return is.getItem() == this;
|
||||
@@ -82,4 +119,5 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
|
||||
public GuiType guiGuiType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
@@ -29,15 +29,15 @@ public abstract class PartItemGuiFactory<T> extends PartGuiFactory<T> {
|
||||
@Nullable
|
||||
@Override
|
||||
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
|
||||
MutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
|
||||
ImmutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
|
||||
|
||||
if (result.left == Util.GuiHelper.GuiType.ITEM) {
|
||||
if (result.getLeft() == Util.GuiHelper.GuiType.ITEM) {
|
||||
ItemStack item = player.getHeldItem();
|
||||
if (item == null || !(item.getItem() instanceof IItemInventory)) {
|
||||
return null;
|
||||
}
|
||||
T inv = getItemInventory(
|
||||
((IItemInventory) item.getItem()).getInventory(item, world, x, result.right, z, player));
|
||||
((IItemInventory) item.getItem()).getInventory(item, world, x, result.getRight(), z, player));
|
||||
if (inv == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public abstract class PartItemGuiFactory<T> extends PartGuiFactory<T> {
|
||||
}
|
||||
return gui;
|
||||
} else {
|
||||
return super.createServerGui(player, world, x, result.right, z, face);
|
||||
return super.createServerGui(player, world, x, result.getRight(), z, face);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -61,17 +61,17 @@ public abstract class PartItemGuiFactory<T> extends PartGuiFactory<T> {
|
||||
@Nullable
|
||||
@Override
|
||||
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
|
||||
MutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
|
||||
ImmutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
|
||||
if (result.left == Util.GuiHelper.GuiType.ITEM) {
|
||||
ItemStack item = player.getHeldItem();
|
||||
if (item == null || !(item.getItem() instanceof IItemInventory)) {
|
||||
return null;
|
||||
}
|
||||
T inv = getItemInventory(
|
||||
((IItemInventory) item.getItem()).getInventory(item, world, x, result.right, z, player));
|
||||
((IItemInventory) item.getItem()).getInventory(item, world, x, result.getRight(), z, player));
|
||||
return inv != null ? createClientGui(player, inv) : null;
|
||||
} else {
|
||||
return super.createClientGui(player, world, x, result.right, z, face);
|
||||
return super.createClientGui(player, world, x, result.getRight(), z, face);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,6 +52,10 @@ public class WirelessFluidTerminal extends MEMonitorHandler<IAEFluidStack> imple
|
||||
this.channel = StorageChannel.FLUIDS;
|
||||
}
|
||||
|
||||
public StorageChannel getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
|
||||
@@ -72,6 +72,10 @@ public class WirelessPatternTerminal extends MEMonitorHandler<IAEItemStack> impl
|
||||
this.output = new ItemBiggerAppEngInventory(is, "output", 3);
|
||||
}
|
||||
|
||||
public StorageChannel getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return this.target;
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.item.ItemBasicFluidStorageCell;
|
||||
import com.glodblock.github.common.storage.CellType;
|
||||
import com.glodblock.github.loader.recipe.WirelessTerminal;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -93,6 +94,8 @@ public class RecipeLoader implements Runnable {
|
||||
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"),
|
||||
1,
|
||||
54);
|
||||
public static final ItemStack AE2_WIRELESS_TERMINAL = GameRegistry
|
||||
.findItemStack("appliedenergistics2", "item.ToolWirelessTerminal", 1);
|
||||
public static final ItemStack AE2_ME_CHEST = GameRegistry
|
||||
.findItemStack("appliedenergistics2", "tile.BlockChest", 1);
|
||||
public static final ItemStack AE2_ENERGY_CELL = GameRegistry
|
||||
@@ -128,7 +131,12 @@ public class RecipeLoader implements Runnable {
|
||||
AE2_INTERFACE));
|
||||
GameRegistry.addShapelessRecipe(FLUID_INTERFACE.stack(), INTERFACE.stack());
|
||||
GameRegistry.addShapelessRecipe(INTERFACE.stack(), FLUID_INTERFACE.stack());
|
||||
GameRegistry.addShapelessRecipe(WIRELESS_FLUID_TERM.stack(), AE2_TERMINAL, BUFFER.stack());
|
||||
GameRegistry.addShapelessRecipe(WIRELESS_FLUID_TERM.stack(), AE2_WIRELESS_TERMINAL, BUCKET);
|
||||
GameRegistry.addShapelessRecipe(WIRELESS_PATTERN_TERM.stack(), WIRELESS_FLUID_TERM, FLUID_TERMINAL);
|
||||
if (ModAndClassUtil.WCT) {
|
||||
GameRegistry.addRecipe(new WirelessTerminal(WIRELESS_PATTERN_TERM.stack()));
|
||||
GameRegistry.addRecipe(new WirelessTerminal(WIRELESS_FLUID_TERM.stack()));
|
||||
}
|
||||
GameRegistry
|
||||
.addRecipe(new ShapedOreRecipe(CERTUS_QUARTZ_TANK.stack(), "GGG", "G G", "GGG", 'G', AE2_QUARTZ_GLASS));
|
||||
GameRegistry.addShapelessRecipe(FLUID_AUTO_FILLER.stack(), FLUID_TERMINAL, ENCODER);
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.glodblock.github.loader.recipe;
|
||||
|
||||
import static com.glodblock.github.util.Util.hasInfinityBoosterCard;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
|
||||
import net.p455w0rd.wirelesscraftingterminal.items.ItemInfinityBooster;
|
||||
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
|
||||
|
||||
public class WirelessTerminal extends ShapelessRecipes {
|
||||
|
||||
private static final ItemStack infinityBoosterCard = ItemEnum.BOOSTER_CARD.getStack();
|
||||
private final ItemStack installedTerm;
|
||||
|
||||
public WirelessTerminal(ItemStack term) {
|
||||
super(term, Arrays.asList(term, infinityBoosterCard));
|
||||
this.installedTerm = installInfinityBoosterCard(term);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inv, World w) {
|
||||
ItemStack term = inv.getStackInSlot(0);
|
||||
ItemStack infinityBoosterCard = inv.getStackInSlot(1);
|
||||
return term != null && term.getItem() instanceof ItemBaseWirelessTerminal
|
||||
&& !hasInfinityBoosterCard(term)
|
||||
&& infinityBoosterCard != null
|
||||
&& infinityBoosterCard.getItem() instanceof ItemInfinityBooster;
|
||||
}
|
||||
|
||||
public static ItemStack getInfinityBoosterCard() {
|
||||
return infinityBoosterCard.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
||||
return installInfinityBoosterCard(inv.getStackInSlot(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
private ItemStack installInfinityBoosterCard(ItemStack is) {
|
||||
is = is.copy();
|
||||
NBTTagCompound data = Platform.openNbtData(is);
|
||||
data.setBoolean(ItemBaseWirelessTerminal.infinityBoosterCard, true);
|
||||
is.setTagCompound(data);
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return installedTerm;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -74,6 +74,8 @@ public class NameConst {
|
||||
public static final String TT_CELL_CONTENTS = TT_KEY + "cell_contents";
|
||||
public static final String TT_CELL_EMPTY = TT_KEY + "cell_empty";
|
||||
public static final String TT_CELL_PORTABLE = TT_KEY + "cell_portable";
|
||||
public static final String TT_WIRELESS = TT_KEY + "wireless.";
|
||||
public static final String TT_WIRELESS_INSTALLED = TT_WIRELESS + "installed";
|
||||
|
||||
public static final String WAILA_KEY = FluidCraft.MODID + ".waila.";
|
||||
public static final String WAILA_ENABLE = WAILA_KEY + "enable";
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import static com.glodblock.github.common.item.ItemBaseWirelessTerminal.infinityBoosterCard;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -11,6 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -30,8 +33,10 @@ import appeng.api.util.WorldCoord;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
@@ -42,6 +47,14 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
public final class Util {
|
||||
|
||||
public static boolean hasInfinityBoosterCard(ItemStack is) {
|
||||
if (ModAndClassUtil.WCT && is.getItem() instanceof ItemBaseWirelessTerminal) {
|
||||
NBTTagCompound data = Platform.openNbtData(is);
|
||||
return data.hasKey(infinityBoosterCard) && data.getBoolean(infinityBoosterCard);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static IGridNode getWirelessGrid(ItemStack is) {
|
||||
if (is.getItem() instanceof ToolWirelessTerminal) {
|
||||
String key = ((ToolWirelessTerminal) is.getItem()).getEncryptionKey(is);
|
||||
@@ -60,22 +73,33 @@ public final class Util {
|
||||
if (gridNode == null) return null;
|
||||
IGrid grid = gridNode.getGrid();
|
||||
if (grid == null) return null;
|
||||
for (IGridNode node : grid.getMachines(TileWireless.class)) {
|
||||
IWirelessAccessPoint accessPoint = (IWirelessAccessPoint) node.getMachine();
|
||||
WorldCoord distance = accessPoint.getLocation()
|
||||
.subtract((int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
int squaredDistance = distance.x * distance.x + distance.y * distance.y + distance.z * distance.z;
|
||||
if (squaredDistance <= accessPoint.getRange() * accessPoint.getRange()) {
|
||||
IStorageGrid gridCache = grid.getCache(IStorageGrid.class);
|
||||
if (gridCache != null) {
|
||||
if (channel == StorageChannel.FLUIDS) {
|
||||
return gridCache.getFluidInventory();
|
||||
} else {
|
||||
return gridCache.getItemInventory();
|
||||
boolean canConnect = false;
|
||||
if (hasInfinityBoosterCard(is)) {
|
||||
canConnect = true;
|
||||
} else {
|
||||
for (IGridNode node : grid.getMachines(TileWireless.class)) {
|
||||
IWirelessAccessPoint accessPoint = (IWirelessAccessPoint) node.getMachine();
|
||||
if (accessPoint.isActive() && accessPoint.getLocation().getDimension() == player.dimension) {
|
||||
WorldCoord distance = accessPoint.getLocation()
|
||||
.subtract((int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
int squaredDistance = distance.x * distance.x + distance.y * distance.y + distance.z * distance.z;
|
||||
if (squaredDistance <= accessPoint.getRange() * accessPoint.getRange()) {
|
||||
canConnect = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (canConnect) {
|
||||
IStorageGrid gridCache = grid.getCache(IStorageGrid.class);
|
||||
if (gridCache != null) {
|
||||
if (channel == StorageChannel.FLUIDS) {
|
||||
return gridCache.getFluidInventory();
|
||||
} else {
|
||||
return gridCache.getItemInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -279,11 +303,11 @@ public final class Util {
|
||||
return value | (type.ordinal() << 29) | y;
|
||||
}
|
||||
|
||||
public static MutablePair<GuiType, Integer> decodeType(int y) {
|
||||
public static ImmutablePair<GuiType, Integer> decodeType(int y) {
|
||||
if (Math.abs(y) > (1 << 28)) {
|
||||
return new MutablePair<>(GuiType.values()[y >> 29 & 1], y - (3 << 29 & y));
|
||||
return new ImmutablePair<>(GuiType.values()[y >> 29 & 1], y - (3 << 29 & y));
|
||||
} else {
|
||||
return new MutablePair<>(GuiType.TILE, y);
|
||||
return new ImmutablePair<>(GuiType.TILE, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user