mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
28 files changed
+9826
-15
No files matched your search
@@ -8,6 +8,7 @@ import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.integration.modules.NEI;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
|
||||
@@ -483,6 +484,7 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
|
||||
}
|
||||
|
||||
if (btn == this.cancel) {
|
||||
this.addMissingItemsToBookMark();
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
|
||||
}
|
||||
|
||||
@@ -509,4 +511,24 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
|
||||
public ItemStack getHoveredStack() {
|
||||
return hoveredStack;
|
||||
}
|
||||
|
||||
protected void addMissingItemsToBookMark() {
|
||||
if (!this.missing.isEmpty() && isShiftKeyDown()) {
|
||||
for (IAEItemStack iaeItemStack : this.missing) {
|
||||
NEI.instance.addItemToBookMark(iaeItemStack.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IItemList<IAEItemStack> getStorage() {
|
||||
return this.storage;
|
||||
}
|
||||
|
||||
public IItemList<IAEItemStack> getPending() {
|
||||
return this.pending;
|
||||
}
|
||||
|
||||
public IItemList<IAEItemStack> getMissing() {
|
||||
return this.missing;
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ public class GuiFluidTerminal extends GuiFluidMonitor {
|
||||
super(inventoryPlayer, te, new ContainerFluidMonitor(inventoryPlayer, te));
|
||||
this.container = new ContainerFluidMonitor(inventoryPlayer, te);
|
||||
this.player = inventoryPlayer.player;
|
||||
this.showViewBtn = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -70,6 +70,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
|
||||
protected int perRow = 9;
|
||||
protected int reservedSpace = 0;
|
||||
protected boolean customSortOrder = true;
|
||||
protected boolean showViewBtn = true;
|
||||
protected int rows = 0;
|
||||
protected int maxRows = Integer.MAX_VALUE;
|
||||
protected int standardSize;
|
||||
@@ -204,6 +205,49 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
|
||||
this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY)));
|
||||
offset += 20;
|
||||
}
|
||||
if (this.showViewBtn) {
|
||||
this.buttonList.add(
|
||||
this.ViewBox = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
offset,
|
||||
Settings.VIEW_MODE,
|
||||
this.configSrc.getSetting(Settings.VIEW_MODE)));
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
this.buttonList.add(
|
||||
this.SortDirBox = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
offset,
|
||||
Settings.SORT_DIRECTION,
|
||||
this.configSrc.getSetting(Settings.SORT_DIRECTION)));
|
||||
offset += 20;
|
||||
|
||||
this.buttonList.add(
|
||||
this.searchBoxSettings = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
offset,
|
||||
Settings.SEARCH_MODE,
|
||||
AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE)));
|
||||
offset += 20;
|
||||
|
||||
if (ModAndClassUtil.isSaveText) {
|
||||
this.buttonList.add(
|
||||
this.searchStringSave = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
offset,
|
||||
Settings.SAVE_SEARCH,
|
||||
AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO));
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
this.buttonList.add(
|
||||
this.terminalStyleBox = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
offset,
|
||||
Settings.TERMINAL_STYLE,
|
||||
AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
|
||||
offset += 20;
|
||||
|
||||
this.searchField = new FCGuiTextField(
|
||||
this.fontRendererObj, this.guiLeft + Math.max(80, this.offsetX), this.guiTop + 4, 90, 12);
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.glodblock.github.client.render;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tile.TileWalrus;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class ItemWalrusRender implements IItemRenderer {
|
||||
IModelCustom modelWalrus = AdvancedModelLoader.loadModel(FluidCraft.resource("models/walrus.obj"));
|
||||
ResourceLocation textureWalrus = FluidCraft.resource("textures/blocks/walrus.png");
|
||||
|
||||
public ItemWalrusRender() {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileWalrus.class, new RenderBlockWalrus());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ItemAndBlockHolder.WALRUS), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus);
|
||||
GL11.glPushMatrix();
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
break;
|
||||
case EQUIPPED:
|
||||
break;
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
GL11.glRotated(180, 0, 1, 0);
|
||||
GL11.glTranslatef(-1F, 0.5F, -0.5F);
|
||||
break;
|
||||
case FIRST_PERSON_MAP:
|
||||
break;
|
||||
case INVENTORY:
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.1F);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
this.modelWalrus.renderAll();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(
|
||||
IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.glodblock.github.client.render;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderBlockWalrus extends TileEntitySpecialRenderer {
|
||||
IModelCustom modelWalrus = AdvancedModelLoader.loadModel(FluidCraft.resource("models/walrus.obj"));
|
||||
ResourceLocation textureWalrus = FluidCraft.resource("textures/blocks/walrus.png");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTickTime) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y, z + 0.5);
|
||||
int orientation = tileentity.getBlockMetadata();
|
||||
if (orientation == 4) {
|
||||
GL11.glRotatef(90, 0, 1, 0);
|
||||
} else if (orientation == 5) {
|
||||
GL11.glRotatef(-90, 0, 1, 0);
|
||||
} else if (orientation == 3) {
|
||||
GL11.glRotatef(180, 0, 1, 0);
|
||||
}
|
||||
this.modelWalrus.renderAll();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.glodblock.github.common.block;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class BaseBlockContainer extends BlockContainer {
|
||||
|
||||
public BaseBlockContainer(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
}
|
||||
|
||||
public void addInformation(
|
||||
ItemStack itemStack, EntityPlayer player, List<String> toolTip, boolean advancedToolTips) {}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.glodblock.github.common.block;
|
||||
|
||||
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
|
||||
|
||||
import com.glodblock.github.common.item.BaseItemBlockContainer;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.common.tile.TileWalrus;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockWalrus extends BaseBlockContainer {
|
||||
|
||||
public BlockWalrus() {
|
||||
super(Material.clay);
|
||||
setHardness(2.0F);
|
||||
setResistance(10.0F);
|
||||
setBlockName(NameConst.BLOCK_WALRUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileWalrus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) {
|
||||
int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
|
||||
if (l == 0) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
}
|
||||
|
||||
if (l == 1) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
||||
}
|
||||
|
||||
if (l == 2) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||
}
|
||||
|
||||
if (l == 3) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int x, int y, int z) {
|
||||
switch (ForgeDirection.getOrientation(blockAccess.getBlockMetadata(x, y, z))) {
|
||||
case NORTH:
|
||||
setBlockBounds(0.0F, 0.0F, -1.0F, 1.0F, 1.0F, 1.0F);
|
||||
break;
|
||||
case EAST:
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 2.0F, 1.0F, 1.0F);
|
||||
break;
|
||||
case SOUTH:
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 2.0F);
|
||||
break;
|
||||
case WEST:
|
||||
setBlockBounds(-1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
break;
|
||||
default:
|
||||
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockWalrus register() {
|
||||
GameRegistry.registerBlock(this, BaseItemBlockContainer.class, NameConst.BLOCK_WALRUS);
|
||||
GameRegistry.registerTileEntity(TileWalrus.class, NameConst.BLOCK_WALRUS);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(
|
||||
final ItemStack itemStack,
|
||||
final EntityPlayer player,
|
||||
final List<String> toolTip,
|
||||
final boolean advancedToolTips) {
|
||||
|
||||
if (isShiftKeyDown()) {
|
||||
toolTip.add(NameConst.i18n(NameConst.TT_WALRUS_DESC));
|
||||
} else {
|
||||
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import com.glodblock.github.common.block.BaseBlockContainer;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BaseItemBlockContainer extends ItemBlock {
|
||||
private final BaseBlockContainer blockType;
|
||||
|
||||
public BaseItemBlockContainer(Block id) {
|
||||
super(id);
|
||||
this.blockType = (BaseBlockContainer) id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addInformation(
|
||||
final ItemStack itemStack, final EntityPlayer player, final List toolTip, final boolean advancedToolTips) {
|
||||
blockType.addInformation(itemStack, player, toolTip, advancedToolTips);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.parts.PartFluidConversionMonitor;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemFluidConversionMonitor extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemFluidConversionMonitor() {
|
||||
this.setMaxStackSize(64);
|
||||
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_CONVERSION_MONITOR);
|
||||
AEApi.instance().partHelper().setItemBusRenderer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(
|
||||
ItemStack stack,
|
||||
EntityPlayer player,
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float xOffset,
|
||||
float yOffset,
|
||||
float zOffset) {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidConversionMonitor register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_CONVERSION_MONITOR, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void registerIcons(IIconRegister _iconRegister) {}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PartFluidConversionMonitor createPartFromItemStack(ItemStack is) {
|
||||
return new PartFluidConversionMonitor(is);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.parts.PartFluidStorageMonitor;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemFluidStorageMonitor extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemFluidStorageMonitor() {
|
||||
this.setMaxStackSize(64);
|
||||
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_STORAGE_MONITOR);
|
||||
AEApi.instance().partHelper().setItemBusRenderer(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(
|
||||
ItemStack stack,
|
||||
EntityPlayer player,
|
||||
World world,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
int side,
|
||||
float xOffset,
|
||||
float yOffset,
|
||||
float zOffset) {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidStorageMonitor register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_STORAGE_MONITOR, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void registerIcons(IIconRegister _iconRegister) {}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PartFluidStorageMonitor createPartFromItemStack(ItemStack is) {
|
||||
return new PartFluidStorageMonitor(is);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
public class PartFluidConversionMonitor extends PartFluidStorageMonitor {
|
||||
public PartFluidConversionMonitor(ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartShiftActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
if (Platform.isClient()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this.getProxy().isActive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Platform.hasPermissions(this.getLocation(), player)) {
|
||||
return false;
|
||||
}
|
||||
FluidStack fluidStack;
|
||||
ItemStack item = player.getCurrentEquippedItem();
|
||||
if (item != null && item.getItem() instanceof ItemFluidPacket) {
|
||||
fluidStack = ItemFluidPacket.getFluidStack(item);
|
||||
} else {
|
||||
fluidStack = Util.FluidUtil.getFluidFromContainer(item);
|
||||
}
|
||||
if (this.getDisplayed() == null
|
||||
|| fluidStack == null
|
||||
|| fluidStack.getFluid() != ((IAEFluidStack) this.getDisplayed()).getFluid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!this.getProxy().isActive()) {
|
||||
return false;
|
||||
}
|
||||
final IEnergySource energy = this.getProxy().getEnergy();
|
||||
final IMEMonitor<IAEFluidStack> cell = this.getProxy().getStorage().getFluidInventory();
|
||||
final IAEFluidStack input =
|
||||
(IAEFluidStack) this.getDisplayed().copy().setStackSize(fluidStack.amount);
|
||||
final IAEFluidStack failedToInsert =
|
||||
Platform.poweredInsert(energy, cell, input, new PlayerSource(player, this));
|
||||
if (failedToInsert != null && failedToInsert.getStackSize() == input.getStackSize()) {
|
||||
return false;
|
||||
} else if (failedToInsert == null || failedToInsert.getStackSize() != input.getStackSize()) {
|
||||
if (item.getItem() instanceof ItemFluidPacket) {
|
||||
if (failedToInsert != null) {
|
||||
player.getCurrentEquippedItem()
|
||||
.setTagCompound(
|
||||
ItemFluidPacket.newStack(failedToInsert).getTagCompound());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
ItemStack tmp = item.copy();
|
||||
tmp.stackSize = 1;
|
||||
ItemStack tank = null;
|
||||
if (failedToInsert == null) {
|
||||
tank = Util.FluidUtil.clearFluid(tmp);
|
||||
} else {
|
||||
if (tmp.getItem() instanceof IFluidContainerItem) {
|
||||
tank = Util.FluidUtil.setFluidContainerAmount(tmp, (int) failedToInsert.getStackSize());
|
||||
} else if (FluidContainerRegistry.isContainer(tmp)) {
|
||||
IAEFluidStack insertedFluid = input.copy();
|
||||
insertedFluid.decStackSize(failedToInsert.getStackSize());
|
||||
this.getProxy()
|
||||
.getStorage()
|
||||
.getFluidInventory()
|
||||
.extractItems(insertedFluid, Actionable.MODULATE, new PlayerSource(player, this));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (tank != null && !player.inventory.addItemStackToInventory(tank)) {
|
||||
player.entityDropItem(tank, 0);
|
||||
}
|
||||
}
|
||||
item.stackSize--;
|
||||
if (item.stackSize <= 0) {
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void extractItem(final EntityPlayer player) {
|
||||
final IAEFluidStack input = (IAEFluidStack) this.getDisplayed();
|
||||
ItemStack eq = player.getCurrentEquippedItem();
|
||||
if (input != null && Util.FluidUtil.isFluidContainer(eq) && Util.FluidUtil.isEmpty(eq)) {
|
||||
try {
|
||||
if (!this.getProxy().isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IEnergySource energy = this.getProxy().getEnergy();
|
||||
final IMEMonitor<IAEFluidStack> cell =
|
||||
this.getProxy().getStorage().getFluidInventory();
|
||||
ItemStack tank = eq.copy();
|
||||
tank.stackSize = 1;
|
||||
MutablePair<Integer, ItemStack> fillStack = Util.FluidUtil.fillStack(tank, input.getFluidStack());
|
||||
input.setStackSize(fillStack.left);
|
||||
|
||||
final IAEFluidStack retrieved =
|
||||
Platform.poweredExtraction(energy, cell, input, new PlayerSource(player, this));
|
||||
if (retrieved != null) {
|
||||
if (!player.inventory.addItemStackToInventory(fillStack.right)) {
|
||||
player.entityDropItem(fillStack.right.copy(), 0);
|
||||
}
|
||||
eq.stackSize--;
|
||||
if (eq.stackSize <= 0) {
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
}
|
||||
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
ItemStack newItems = adaptor.addItems(
|
||||
Util.FluidUtil.setFluidContainerAmount(fillStack.right, (int) retrieved.getStackSize()));
|
||||
if (newItems != null) {
|
||||
final TileEntity te = this.getTile();
|
||||
final List<ItemStack> list = Collections.singletonList(newItems);
|
||||
Platform.spawnDrops(
|
||||
player.worldObj,
|
||||
te.xCoord + this.getSide().offsetX,
|
||||
te.yCoord + this.getSide().offsetY,
|
||||
te.zCoord + this.getSide().offsetZ,
|
||||
list);
|
||||
}
|
||||
|
||||
if (player.openContainer != null) {
|
||||
player.openContainer.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.helpers.Reflected;
|
||||
import com.glodblock.github.common.parts.base.FCPartMonitor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class PartFluidStorageMonitor extends FCPartMonitor {
|
||||
|
||||
private static final CableBusTextures FRONT_BRIGHT_ICON = CableBusTextures.PartStorageMonitor_Bright;
|
||||
private static final CableBusTextures FRONT_DARK_ICON = CableBusTextures.PartStorageMonitor_Dark;
|
||||
private static final CableBusTextures FRONT_COLORED_ICON = CableBusTextures.PartStorageMonitor_Colored;
|
||||
private static final CableBusTextures FRONT_COLORED_ICON_LOCKED =
|
||||
CableBusTextures.PartStorageMonitor_Colored_Locked;
|
||||
|
||||
@Reflected
|
||||
public PartFluidStorageMonitor(final ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableBusTextures getFrontBright() {
|
||||
return FRONT_BRIGHT_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableBusTextures getFrontColored() {
|
||||
return this.isLocked() ? FRONT_COLORED_ICON_LOCKED : FRONT_COLORED_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableBusTextures getFrontDark() {
|
||||
return FRONT_DARK_ICON;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,467 @@
|
||||
package com.glodblock.github.common.parts.base;
|
||||
|
||||
import appeng.api.implementations.parts.IPartStorageMonitor;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.storage.IStackWatcher;
|
||||
import appeng.api.networking.storage.IStackWatcherHost;
|
||||
import appeng.api.parts.IPartRenderHelper;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.reporting.AbstractPartDisplay;
|
||||
import appeng.parts.reporting.PartPanel;
|
||||
import appeng.util.IWideReadableNumberConverter;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public abstract class FCPartMonitor extends AbstractPartDisplay implements IPartStorageMonitor, IStackWatcherHost {
|
||||
private static final IWideReadableNumberConverter NUMBER_CONVERTER = ReadableNumberConverter.INSTANCE;
|
||||
|
||||
private IAEFluidStack configuredFluid;
|
||||
private String lastHumanReadableText;
|
||||
private boolean isLocked;
|
||||
private IStackWatcher myWatcher;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private boolean updateList;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private Integer dspList;
|
||||
|
||||
@Reflected
|
||||
public FCPartMonitor(ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
|
||||
this.isLocked = data.getBoolean("isLocked");
|
||||
|
||||
final NBTTagCompound myItem = data.getCompoundTag("configuredItem");
|
||||
this.configuredFluid = Util.loadFluidStackFromNBT(myItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
|
||||
data.setBoolean("isLocked", this.isLocked);
|
||||
|
||||
final NBTTagCompound myItem = new NBTTagCompound();
|
||||
if (this.configuredFluid != null) {
|
||||
this.configuredFluid.writeToNBT(myItem);
|
||||
}
|
||||
|
||||
data.setTag("configuredItem", myItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(final ByteBuf data) throws IOException {
|
||||
super.writeToStream(data);
|
||||
|
||||
data.writeBoolean(this.isLocked);
|
||||
data.writeBoolean(this.configuredFluid != null);
|
||||
if (this.configuredFluid != null) {
|
||||
this.configuredFluid.writeToPacket(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(final ByteBuf data) throws IOException {
|
||||
boolean needRedraw = super.readFromStream(data);
|
||||
|
||||
final boolean isLocked = data.readBoolean();
|
||||
needRedraw = this.isLocked != isLocked;
|
||||
|
||||
this.isLocked = isLocked;
|
||||
|
||||
final boolean val = data.readBoolean();
|
||||
if (val) {
|
||||
this.configuredFluid = AEFluidStack.loadFluidStackFromPacket(data);
|
||||
} else {
|
||||
this.configuredFluid = null;
|
||||
}
|
||||
|
||||
this.updateList = true;
|
||||
|
||||
return needRedraw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
if (Platform.isClient()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this.getProxy().isActive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Platform.hasPermissions(this.getLocation(), player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final TileEntity te = this.getTile();
|
||||
final ItemStack eq = player.getCurrentEquippedItem();
|
||||
|
||||
if (Platform.isWrench(player, eq, te.xCoord, te.yCoord, te.zCoord)) {
|
||||
this.isLocked = !this.isLocked;
|
||||
player.addChatMessage((this.isLocked ? PlayerMessages.isNowLocked : PlayerMessages.isNowUnlocked).get());
|
||||
this.getHost().markForUpdate();
|
||||
} else if (!this.isLocked) {
|
||||
this.configuredFluid = AEFluidStack.create(Util.FluidUtil.getFluidFromContainer(eq));
|
||||
this.configureWatchers();
|
||||
this.getHost().markForUpdate();
|
||||
} else {
|
||||
this.extractItem(player);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// update the system...
|
||||
private void configureWatchers() {
|
||||
if (this.myWatcher != null) {
|
||||
this.myWatcher.clear();
|
||||
}
|
||||
|
||||
try {
|
||||
if (this.configuredFluid != null) {
|
||||
if (this.myWatcher != null) {
|
||||
this.myWatcher.add(this.configuredFluid);
|
||||
}
|
||||
|
||||
this.updateReportingValue(this.getProxy().getStorage().getFluidInventory());
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
// >.>
|
||||
}
|
||||
}
|
||||
|
||||
protected void extractItem(final EntityPlayer player) {}
|
||||
|
||||
private void updateReportingValue(final IMEMonitor<IAEFluidStack> fluidInventory) {
|
||||
if (this.configuredFluid != null) {
|
||||
final IAEFluidStack result = fluidInventory.getStorageList().findPrecise(this.configuredFluid);
|
||||
if (result == null) {
|
||||
this.configuredFluid.setStackSize(0);
|
||||
} else {
|
||||
this.configuredFluid.setStackSize(result.getStackSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
|
||||
if (this.dspList != null) {
|
||||
GLAllocation.deleteDisplayLists(this.dspList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderDynamic(
|
||||
final double x, final double y, final double z, final IPartRenderHelper rh, final RenderBlocks renderer) {
|
||||
if (this.dspList == null) {
|
||||
this.dspList = GLAllocation.generateDisplayLists(1);
|
||||
}
|
||||
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
|
||||
if ((this.getClientFlags() & (PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG))
|
||||
!= (PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IAEFluidStack ais = (IAEFluidStack) this.getDisplayed();
|
||||
|
||||
if (ais != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
|
||||
if (this.updateList) {
|
||||
this.updateList = false;
|
||||
GL11.glNewList(this.dspList, GL11.GL_COMPILE_AND_EXECUTE);
|
||||
this.tesrRenderScreen(tess, ais);
|
||||
GL11.glEndList();
|
||||
} else {
|
||||
GL11.glCallList(this.dspList);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireDynamicRender() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStack<?> getDisplayed() {
|
||||
return this.configuredFluid;
|
||||
}
|
||||
|
||||
private void tesrRenderScreen(final Tessellator tess, final IAEFluidStack ais) {
|
||||
// GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
|
||||
final ForgeDirection d = this.getSide();
|
||||
|
||||
GL11.glTranslated(d.offsetX * 0.77, d.offsetY * 0.77, d.offsetZ * 0.77);
|
||||
|
||||
switch (d) {
|
||||
case UP:
|
||||
GL11.glScalef(1.0f, -1.0f, 1.0f);
|
||||
GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glRotatef(this.getSpin() * 90.0F, 0, 0, 1);
|
||||
break;
|
||||
case DOWN:
|
||||
GL11.glScalef(1.0f, -1.0f, 1.0f);
|
||||
GL11.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
|
||||
GL11.glRotatef(this.getSpin() * -90.0F, 0, 0, 1);
|
||||
break;
|
||||
case EAST:
|
||||
GL11.glScalef(-1.0f, -1.0f, -1.0f);
|
||||
GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
case WEST:
|
||||
GL11.glScalef(-1.0f, -1.0f, -1.0f);
|
||||
GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
case NORTH:
|
||||
GL11.glScalef(-1.0f, -1.0f, -1.0f);
|
||||
break;
|
||||
case SOUTH:
|
||||
GL11.glScalef(-1.0f, -1.0f, -1.0f);
|
||||
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
final ItemStack sis = ItemFluidPacket.newDisplayStack(ais.getFluidStack());
|
||||
|
||||
try {
|
||||
final int br = 16 << 20 | 16 << 4;
|
||||
final int var11 = br % 65536;
|
||||
final int var12 = br / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * 0.8F, var12 * 0.8F);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
// RenderHelper.enableGUIStandardItemLighting();
|
||||
tess.setColorOpaque_F(1.0f, 1.0f, 1.0f);
|
||||
|
||||
ClientHelper.proxy.doRenderItem(sis, this.getTile().getWorldObj());
|
||||
} catch (final Exception e) {
|
||||
AELog.debug(e);
|
||||
} finally {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
if (sis != null) {
|
||||
GL11.glTranslatef(0.0f, 0.14f, -0.24f);
|
||||
GL11.glScalef(1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f);
|
||||
|
||||
final long stackSize = ais.getStackSize();
|
||||
final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm(stackSize);
|
||||
|
||||
final FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
final int width = fr.getStringWidth(renderedStackSize);
|
||||
GL11.glTranslatef(-0.5f * width, 0.0f, -1.0f);
|
||||
fr.drawString(renderedStackSize, 0, 0, 0);
|
||||
}
|
||||
// GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocked() {
|
||||
return this.isLocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWatcher(final IStackWatcher newWatcher) {
|
||||
this.myWatcher = newWatcher;
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStackChange(
|
||||
final IItemList o,
|
||||
final IAEStack fullStack,
|
||||
final IAEStack diffStack,
|
||||
final BaseActionSource src,
|
||||
final StorageChannel chan) {
|
||||
if (this.configuredFluid != null) {
|
||||
if (fullStack == null) {
|
||||
this.configuredFluid.setStackSize(0);
|
||||
} else {
|
||||
this.configuredFluid.setStackSize(fullStack.getStackSize());
|
||||
}
|
||||
|
||||
final long stackSize = this.configuredFluid.getStackSize();
|
||||
final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm(stackSize);
|
||||
|
||||
if (!humanReadableText.equals(this.lastHumanReadableText)) {
|
||||
this.lastHumanReadableText = humanReadableText;
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showNetworkInfo(final MovingObjectPosition where) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
|
||||
rh.setBounds(2, 2, 14, 14, 14, 16);
|
||||
|
||||
final IIcon sideTexture = CableBusTextures.PartMonitorSides.getIcon();
|
||||
final IIcon backTexture = CableBusTextures.PartMonitorBack.getIcon();
|
||||
|
||||
rh.setTexture(
|
||||
sideTexture,
|
||||
sideTexture,
|
||||
backTexture,
|
||||
FCPartsTexture.PartTerminalBroad.getIcon(),
|
||||
sideTexture,
|
||||
sideTexture);
|
||||
rh.renderInventoryBox(renderer);
|
||||
|
||||
rh.setInvColor(this.getColor().whiteVariant);
|
||||
rh.renderInventoryFace(this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer);
|
||||
|
||||
rh.setInvColor(this.getColor().mediumVariant);
|
||||
rh.renderInventoryFace(this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer);
|
||||
|
||||
rh.setInvColor(this.getColor().blackVariant);
|
||||
rh.renderInventoryFace(this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer);
|
||||
|
||||
rh.setBounds(4, 4, 13, 12, 12, 14);
|
||||
rh.renderInventoryBox(renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(
|
||||
final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer) {
|
||||
this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache()));
|
||||
|
||||
final IIcon sideTexture = CableBusTextures.PartMonitorSides.getIcon();
|
||||
final IIcon backTexture = CableBusTextures.PartMonitorBack.getIcon();
|
||||
|
||||
rh.setTexture(
|
||||
sideTexture,
|
||||
sideTexture,
|
||||
backTexture,
|
||||
FCPartsTexture.PartTerminalBroad.getIcon(),
|
||||
sideTexture,
|
||||
sideTexture);
|
||||
|
||||
rh.setBounds(2, 2, 14, 14, 14, 16);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
if (this.getLightLevel() > 0) {
|
||||
final int l = 13;
|
||||
Tessellator.instance.setBrightness(l << 20 | l << 4);
|
||||
}
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth =
|
||||
renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this.getSpin();
|
||||
|
||||
Tessellator.instance.setColorOpaque_I(this.getColor().whiteVariant);
|
||||
rh.renderFace(x, y, z, this.getFrontBright().getIcon(), ForgeDirection.SOUTH, renderer);
|
||||
|
||||
Tessellator.instance.setColorOpaque_I(this.getColor().mediumVariant);
|
||||
rh.renderFace(x, y, z, this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer);
|
||||
|
||||
Tessellator.instance.setColorOpaque_I(this.getColor().blackVariant);
|
||||
rh.renderFace(x, y, z, this.getFrontColored().getIcon(), ForgeDirection.SOUTH, renderer);
|
||||
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast =
|
||||
renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
||||
|
||||
final IIcon sideStatusTexture = CableBusTextures.PartMonitorSidesStatus.getIcon();
|
||||
|
||||
rh.setTexture(
|
||||
sideStatusTexture,
|
||||
sideStatusTexture,
|
||||
backTexture,
|
||||
FCPartsTexture.PartTerminalBroad.getIcon(),
|
||||
sideStatusTexture,
|
||||
sideStatusTexture);
|
||||
|
||||
rh.setBounds(4, 4, 13, 12, 12, 14);
|
||||
rh.renderBlock(x, y, z, renderer);
|
||||
|
||||
final boolean hasChan = (this.getClientFlags() & (PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG))
|
||||
== (PartPanel.POWERED_FLAG | PartPanel.CHANNEL_FLAG);
|
||||
final boolean hasPower = (this.getClientFlags() & PartPanel.POWERED_FLAG) == PartPanel.POWERED_FLAG;
|
||||
|
||||
if (hasChan) {
|
||||
final int l = 14;
|
||||
Tessellator.instance.setBrightness(l << 20 | l << 4);
|
||||
Tessellator.instance.setColorOpaque_I(this.getColor().blackVariant);
|
||||
} else if (hasPower) {
|
||||
final int l = 9;
|
||||
Tessellator.instance.setBrightness(l << 20 | l << 4);
|
||||
Tessellator.instance.setColorOpaque_I(this.getColor().whiteVariant);
|
||||
} else {
|
||||
Tessellator.instance.setBrightness(0);
|
||||
Tessellator.instance.setColorOpaque_I(0x000000);
|
||||
}
|
||||
|
||||
final IIcon sideStatusLightTexture = CableBusTextures.PartMonitorSidesStatusLights.getIcon();
|
||||
|
||||
rh.renderFace(x, y, z, sideStatusLightTexture, ForgeDirection.EAST, renderer);
|
||||
rh.renderFace(x, y, z, sideStatusLightTexture, ForgeDirection.WEST, renderer);
|
||||
rh.renderFace(x, y, z, sideStatusLightTexture, ForgeDirection.UP, renderer);
|
||||
rh.renderFace(x, y, z, sideStatusLightTexture, ForgeDirection.DOWN, renderer);
|
||||
}
|
||||
|
||||
public IAEFluidStack getAEStoreFluidStack() {
|
||||
return this.configuredFluid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileWalrus extends TileEntity {
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.IMachineSet;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.crafting.MECraftingInventory;
|
||||
@@ -20,7 +19,6 @@ import com.glodblock.github.client.gui.GuiFluidCraftConfirm;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.storage.FluidCellInventory;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor;
|
||||
import com.glodblock.github.inventory.FluidConvertingInventoryCrafting;
|
||||
@@ -185,10 +183,4 @@ public class CoreModHooks {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static long IOPortMinSpeed(long possible, long itemsToMove, final StorageChannel chan) {
|
||||
return chan == StorageChannel.FLUIDS
|
||||
? Math.min(possible, itemsToMove * FluidCellInventory.singleByteAmount)
|
||||
: Math.min(possible, itemsToMove);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import appeng.integration.modules.waila.part.IPartWailaDataProvider;
|
||||
import appeng.integration.modules.waila.part.PartAccessor;
|
||||
import appeng.integration.modules.waila.part.Tracer;
|
||||
import com.glodblock.github.crossmod.waila.part.FluidInvWailaDataProvider;
|
||||
import com.glodblock.github.crossmod.waila.part.FluidMonitorWailaDataProvider;
|
||||
import com.glodblock.github.crossmod.waila.part.SpeedWailaDataProvider;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -27,7 +28,8 @@ public class PartWailaDataProvider implements IWailaDataProvider {
|
||||
public PartWailaDataProvider() {
|
||||
final IPartWailaDataProvider speed = new SpeedWailaDataProvider();
|
||||
final IPartWailaDataProvider fluidInv = new FluidInvWailaDataProvider();
|
||||
this.providers = Lists.newArrayList(speed, fluidInv);
|
||||
final IPartWailaDataProvider fluidMonitor = new FluidMonitorWailaDataProvider();
|
||||
this.providers = Lists.newArrayList(speed, fluidInv, fluidMonitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.glodblock.github.crossmod.waila.part;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.integration.modules.waila.part.BasePartWailaDataProvider;
|
||||
import com.glodblock.github.common.parts.base.FCPartMonitor;
|
||||
import com.glodblock.github.crossmod.waila.Tooltip;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.List;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class FluidMonitorWailaDataProvider extends BasePartWailaDataProvider {
|
||||
private final String key = "fluidStore";
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(
|
||||
final IPart part,
|
||||
final List<String> currentToolTip,
|
||||
final IWailaDataAccessor accessor,
|
||||
final IWailaConfigHandler config) {
|
||||
if (part instanceof FCPartMonitor && accessor.getNBTData().hasKey(key)) {
|
||||
IAEFluidStack iaeFluidStack =
|
||||
Util.loadFluidStackFromNBT(accessor.getNBTData().getCompoundTag(key));
|
||||
if (iaeFluidStack != null)
|
||||
currentToolTip.add(
|
||||
Tooltip.fluidFormat(iaeFluidStack.getFluid().getLocalizedName(), iaeFluidStack.getStackSize()));
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(
|
||||
final EntityPlayerMP player,
|
||||
final IPart part,
|
||||
final TileEntity te,
|
||||
final NBTTagCompound tag,
|
||||
final World world,
|
||||
final int x,
|
||||
final int y,
|
||||
final int z) {
|
||||
if (part instanceof FCPartMonitor && ((FCPartMonitor) part).getAEStoreFluidStack() != null) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
((FCPartMonitor) part).getAEStoreFluidStack().writeToNBT(data);
|
||||
tag.setTag(key, data);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public class ItemAndBlockHolder {
|
||||
public static BlockFluidBuffer FLUID_BUFFER = new BlockFluidBuffer().register();
|
||||
public static BlockLargeIngredientBuffer LARGE_BUFFER = new BlockLargeIngredientBuffer().register();
|
||||
public static BlockOCPatternEditor OC_EDITOR = new BlockOCPatternEditor().register();
|
||||
|
||||
public static BlockWalrus WALRUS = new BlockWalrus().register();
|
||||
public static ItemFluidDrop DROP = new ItemFluidDrop().register();
|
||||
public static ItemFluidEncodedPattern PATTERN = new ItemFluidEncodedPattern().register();
|
||||
public static ItemPartFluidTerminal FLUID_TERM = new ItemPartFluidTerminal().register();
|
||||
@@ -27,6 +27,8 @@ public class ItemAndBlockHolder {
|
||||
public static ItemFluidExportBus FLUID_EXPORT_BUS = new ItemFluidExportBus().register();
|
||||
public static ItemPartFluidStorageBus FLUID_STORAGE_BUS = new ItemPartFluidStorageBus().register();
|
||||
public static ItemFluidLevelEmitter FLUID_LEVEL_EMITTER = new ItemFluidLevelEmitter().register();
|
||||
public static ItemFluidStorageMonitor FLUID_STORAGE_MONITOR = new ItemFluidStorageMonitor().register();
|
||||
public static ItemFluidConversionMonitor FLUID_CONVERSION_MONITOR = new ItemFluidConversionMonitor().register();
|
||||
public static ItemFluidPacket PACKET = new ItemFluidPacket().register();
|
||||
public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 1).register();
|
||||
public static ItemBasicFluidStorageCell CELL4K = new ItemBasicFluidStorageCell(CellType.Cell4kPart, 4).register();
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.glodblock.github.loader;
|
||||
|
||||
import static com.glodblock.github.loader.ItemAndBlockHolder.*;
|
||||
import static net.minecraft.init.Blocks.redstone_torch;
|
||||
import static net.minecraft.init.Items.fish;
|
||||
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.item.ItemBasicFluidStorageCell;
|
||||
@@ -123,6 +124,25 @@ public class RecipeLoader implements Runnable {
|
||||
AE2_WORK_BENCH));
|
||||
GameRegistry.addShapelessRecipe(FLUID_STORAGE_BUS.stack(), FLUID_INTERFACE, STICKY_PISTON, PISTON);
|
||||
GameRegistry.addShapelessRecipe(FLUID_STORAGE_BUS.stack(), INTERFACE, STICKY_PISTON, PISTON);
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
FLUID_STORAGE_MONITOR.stack(),
|
||||
"EIP",
|
||||
"P ",
|
||||
'I',
|
||||
"itemIlluminatedPanel",
|
||||
'E',
|
||||
FLUID_LEVEL_EMITTER,
|
||||
'P',
|
||||
"dyeBlue"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
FLUID_CONVERSION_MONITOR.stack(),
|
||||
"ASF",
|
||||
'A',
|
||||
AE2_CORE_ANN,
|
||||
'S',
|
||||
FLUID_STORAGE_MONITOR,
|
||||
'F',
|
||||
AE2_CORE_FOM));
|
||||
GameRegistry.addShapelessRecipe(FLUID_TERMINAL.stack(), AE2_PATTERN_TERM, ENCODER);
|
||||
GameRegistry.addShapelessRecipe(
|
||||
FLUID_TERMINAL_EX.stack(), FLUID_TERMINAL.stack(), AE2_PROCESS_CAL, AE2_PROCESS_ENG, AE2_PROCESS_LOG);
|
||||
@@ -143,6 +163,7 @@ public class RecipeLoader implements Runnable {
|
||||
AE2_CORE_FOM,
|
||||
'B',
|
||||
BUCKET));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(WALRUS, "FFF", "F F", "FFF", 'F', fish));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
FLUID_LEVEL_EMITTER.stack(), "RPD", 'R', redstone_torch, 'P', AE2_PROCESS_CAL, 'D', "dyeBlue"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.glodblock.github.loader;
|
||||
|
||||
import com.glodblock.github.client.render.ItemDropRender;
|
||||
import com.glodblock.github.client.render.ItemPacketRender;
|
||||
import com.glodblock.github.client.render.ItemWalrusRender;
|
||||
|
||||
public class RenderLoader implements Runnable {
|
||||
|
||||
@@ -9,5 +10,6 @@ public class RenderLoader implements Runnable {
|
||||
public void run() {
|
||||
new ItemDropRender();
|
||||
new ItemPacketRender();
|
||||
new ItemWalrusRender();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.glodblock.github.proxy;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.IAppEngApi;
|
||||
import appeng.api.config.Upgrades;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.tile.TileWalrus;
|
||||
import com.glodblock.github.inventory.external.AEFluidInterfaceHandler;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
@@ -20,7 +22,9 @@ public class CommonProxy {
|
||||
|
||||
public void preInit(FMLPreInitializationEvent event) {}
|
||||
|
||||
public void init(FMLInitializationEvent event) {}
|
||||
public void init(FMLInitializationEvent event) {
|
||||
this.registerMovables();
|
||||
}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
if (ModAndClassUtil.isBigInterface) {
|
||||
@@ -45,4 +49,11 @@ public class CommonProxy {
|
||||
}
|
||||
AEApi.instance().registries().externalStorage().addExternalStorageInterface(new AEFluidInterfaceHandler());
|
||||
}
|
||||
|
||||
public void registerRenderers() {}
|
||||
|
||||
public void registerMovables() {
|
||||
IAppEngApi api = AEApi.instance();
|
||||
api.registries().movable().whiteListTileEntity(TileWalrus.class);
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,11 @@ public class NameConst {
|
||||
public static final String BLOCK_LARGE_INGREDIENT_BUFFER = "large_ingredient_buffer";
|
||||
public static final String BLOCK_OC_PATTERN_EDITOR = "oc_pattern_editor";
|
||||
public static final String BLOCK_LEVEL_MAINTAINER = "level_maintainer";
|
||||
|
||||
public static final String BLOCK_WALRUS = "walrus";
|
||||
public static final String ITEM_FLUID_DROP = "fluid_drop";
|
||||
public static final String ITEM_FLUID_ENCODED_PATTERN = "fluid_encoded_pattern";
|
||||
public static final String ITEM_PART_FLUID_STORAGE_MONITOR = "part_fluid_storage_monitor";
|
||||
public static final String ITEM_PART_FLUID_CONVERSION_MONITOR = "part_fluid_conversion_monitor";
|
||||
public static final String ITEM_PART_FLUID_TERMINAL = "part_fluid_terminal";
|
||||
public static final String ITEM_PART_FLUID_PATTERN_TERMINAL = "part_fluid_pattern_terminal";
|
||||
public static final String ITEM_PART_FLUID_PATTERN_TERMINAL_EX = "part_fluid_pattern_terminal_ex";
|
||||
@@ -40,6 +42,8 @@ public class NameConst {
|
||||
public static final String TT_DUMP_TANK = TT_KEY + "dump_tank";
|
||||
public static final String TT_SHIFT_FOR_MORE = TT_KEY + "shift_for_more";
|
||||
public static final String TT_CTRL_FOR_MORE = TT_KEY + "ctrl_for_more";
|
||||
public static final String TT_WALRUS = TT_KEY + "walrus.";
|
||||
public static final String TT_WALRUS_DESC = TT_WALRUS + "desc";
|
||||
public static final String TT_FLUID_BUFFER = TT_KEY + "fluid_buffer.";
|
||||
public static final String TT_FLUID_PACKET_DECODER = TT_KEY + "fluid_packet_decoder.";
|
||||
public static final String TT_FLUID_PACKET_DECODER_DESC = TT_FLUID_PACKET_DECODER + "desc";
|
||||
|
||||
@@ -150,6 +150,7 @@ public final class Util {
|
||||
public static IAEFluidStack loadFluidStackFromNBT(final NBTTagCompound i) {
|
||||
// Fuck ae2
|
||||
final FluidStack t = FluidRegistry.getFluidStack(i.getString("FluidName"), 1);
|
||||
if (t == null) return null;
|
||||
final AEFluidStack fluid = AEFluidStack.create(t);
|
||||
fluid.setStackSize(i.getLong("Cnt"));
|
||||
fluid.setCountRequestable(i.getLong("Req"));
|
||||
|
||||
Reference in new issue
Block a user