mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
refactor 6
This commit is contained in:
1 parent
5b62c4fdc8
commit
8d072f0c89
78 files changed
+525
-882
No files matched your search
@@ -54,6 +54,7 @@ public class BlockFluidBuffer extends FCBaseBlock {
|
||||
return fs != null || (player.isSneaking() && itemStack == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFluidBuffer register() {
|
||||
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_BUFFER);
|
||||
GameRegistry.registerTileEntity(TileFluidBuffer.class, NameConst.BLOCK_FLUID_BUFFER);
|
||||
@@ -67,17 +68,8 @@ public class BlockFluidBuffer extends FCBaseBlock {
|
||||
return new RenderBlockFluidBuffer();
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addInformation(
|
||||
final ItemStack itemStack,
|
||||
final EntityPlayer player,
|
||||
|
||||
@@ -23,6 +23,7 @@ public class BlockFluidDiscretizer extends FCBaseBlock {
|
||||
setTileEntity(TileFluidDiscretizer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFluidDiscretizer register() {
|
||||
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_DISCRETIZER);
|
||||
GameRegistry.registerTileEntity(TileFluidDiscretizer.class, NameConst.BLOCK_FLUID_DISCRETIZER);
|
||||
@@ -30,17 +31,8 @@ public class BlockFluidDiscretizer extends FCBaseBlock {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addInformation(
|
||||
final ItemStack itemStack,
|
||||
final EntityPlayer player,
|
||||
|
||||
@@ -18,8 +18,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -57,7 +55,11 @@ public class BlockFluidInterface extends FCBaseBlock {
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
InventoryHandler.openGui(
|
||||
player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.DUAL_INTERFACE);
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.DUAL_INTERFACE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -76,18 +78,11 @@ public class BlockFluidInterface extends FCBaseBlock {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFluidInterface register() {
|
||||
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_INTERFACE);
|
||||
GameRegistry.registerTileEntity(TileFluidInterface.class, NameConst.BLOCK_FLUID_INTERFACE);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,8 @@ import java.util.List;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockFluidPacketDecoder extends FCBaseBlock {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
EnumFacing.getFront(facing),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.FLUID_PACKET_DECODER);
|
||||
}
|
||||
return true;
|
||||
@@ -49,6 +49,7 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFluidPacketDecoder register() {
|
||||
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_PACKET_DECODER);
|
||||
GameRegistry.registerTileEntity(TileFluidPacketDecoder.class, NameConst.BLOCK_FLUID_PACKET_DECODER);
|
||||
@@ -56,17 +57,8 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addInformation(
|
||||
final ItemStack itemStack,
|
||||
final EntityPlayer player,
|
||||
|
||||
@@ -10,9 +10,8 @@ import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockFluidPatternEncoder extends FCBaseBlock {
|
||||
|
||||
@@ -36,7 +35,7 @@ public class BlockFluidPatternEncoder extends FCBaseBlock {
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
EnumFacing.getFront(facing),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.FLUID_PATTERN_ENCODER);
|
||||
}
|
||||
return true;
|
||||
@@ -44,18 +43,11 @@ public class BlockFluidPatternEncoder extends FCBaseBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFluidPatternEncoder register() {
|
||||
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_PATTERN_ENCODER);
|
||||
GameRegistry.registerTileEntity(TileFluidPatternEncoder.class, NameConst.BLOCK_FLUID_PATTERN_ENCODER);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,8 @@ import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockIngredientBuffer extends FCBaseBlock {
|
||||
|
||||
@@ -34,25 +33,22 @@ public class BlockIngredientBuffer extends FCBaseBlock {
|
||||
if (tile != null) {
|
||||
if (!world.isRemote) {
|
||||
InventoryHandler.openGui(
|
||||
player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.INGREDIENT_BUFFER);
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.INGREDIENT_BUFFER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockIngredientBuffer register() {
|
||||
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_INGREDIENT_BUFFER);
|
||||
GameRegistry.registerTileEntity(TileIngredientBuffer.class, NameConst.BLOCK_INGREDIENT_BUFFER);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,8 @@ import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockLargeIngredientBuffer extends FCBaseBlock {
|
||||
|
||||
@@ -37,7 +36,7 @@ public class BlockLargeIngredientBuffer extends FCBaseBlock {
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
EnumFacing.getFront(facing),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.LARGE_INGREDIENT_BUFFER);
|
||||
}
|
||||
return true;
|
||||
@@ -45,18 +44,11 @@ public class BlockLargeIngredientBuffer extends FCBaseBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockLargeIngredientBuffer register() {
|
||||
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_LARGE_INGREDIENT_BUFFER);
|
||||
GameRegistry.registerTileEntity(TileLargeIngredientBuffer.class, NameConst.BLOCK_LARGE_INGREDIENT_BUFFER);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,8 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockLevelMaintainer extends FCBaseBlock {
|
||||
|
||||
@@ -34,6 +34,7 @@ public class BlockLevelMaintainer extends FCBaseBlock {
|
||||
setTileEntity(TileLevelMaintainer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockLevelMaintainer register() {
|
||||
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_LEVEL_MAINTAINER);
|
||||
GameRegistry.registerTileEntity(TileLevelMaintainer.class, NameConst.BLOCK_LEVEL_MAINTAINER);
|
||||
@@ -61,7 +62,7 @@ public class BlockLevelMaintainer extends FCBaseBlock {
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
EnumFacing.getFront(facing),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.LEVEL_MAINTAINER);
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||
@@ -72,17 +73,8 @@ public class BlockLevelMaintainer extends FCBaseBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addInformation(
|
||||
final ItemStack itemStack,
|
||||
final EntityPlayer player,
|
||||
|
||||
@@ -11,9 +11,8 @@ import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockOCPatternEditor extends FCBaseBlock {
|
||||
|
||||
@@ -34,13 +33,18 @@ public class BlockOCPatternEditor extends FCBaseBlock {
|
||||
if (tile != null) {
|
||||
if (!world.isRemote) {
|
||||
InventoryHandler.openGui(
|
||||
player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.OC_PATTERN_EDITOR);
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.OC_PATTERN_EDITOR);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockOCPatternEditor register() {
|
||||
if (ModAndClassUtil.OC) {
|
||||
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_OC_PATTERN_EDITOR);
|
||||
@@ -50,12 +54,4 @@ public class BlockOCPatternEditor extends FCBaseBlock {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.glodblock.github.common.block;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.EnumSet;
|
||||
@@ -13,7 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class FCBaseBlock extends AEBaseTileBlock {
|
||||
public abstract class FCBaseBlock extends AEBaseTileBlock implements IRegister<FCBaseBlock> {
|
||||
|
||||
public FCBaseBlock(Material mat, String name) {
|
||||
super(mat);
|
||||
@@ -39,7 +40,6 @@ public class FCBaseBlock extends AEBaseTileBlock {
|
||||
super.setFeature(f);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(
|
||||
final ItemStack itemStack,
|
||||
@@ -47,7 +47,8 @@ public class FCBaseBlock extends AEBaseTileBlock {
|
||||
final List<String> toolTip,
|
||||
final boolean advancedToolTips) {}
|
||||
|
||||
protected final List listFormattedStringToWidth(String str) {
|
||||
@SuppressWarnings("unchecked")
|
||||
protected final List<String> listFormattedStringToWidth(String str) {
|
||||
return Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(str, 150);
|
||||
}
|
||||
|
||||
@@ -55,4 +56,12 @@ public class FCBaseBlock extends AEBaseTileBlock {
|
||||
ItemStack itemStack, EntityPlayer player, List<String> toolTip, boolean advancedToolTips) {
|
||||
this.addInformation(itemStack, player, toolTip, advancedToolTips);
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class FCBaseItem extends Item implements IRegister<FCBaseItem> {
|
||||
|
||||
public ItemStack stack(int size, int meta) {
|
||||
return new ItemStack(this, size, meta);
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ public class FCBaseItemBlock extends AEBaseItemBlock {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addCheckedInformation(
|
||||
final ItemStack itemStack,
|
||||
final EntityPlayer player,
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.glodblock.github.common.storage.IFluidCellInventory;
|
||||
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.google.common.base.Optional;
|
||||
@@ -46,7 +47,8 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFluidCell {
|
||||
public class ItemBasicFluidStorageCell extends AEBaseItem
|
||||
implements IStorageFluidCell, IRegister<ItemBasicFluidStorageCell> {
|
||||
private final CellType component;
|
||||
private final int totalBytes;
|
||||
private final int perType;
|
||||
@@ -151,7 +153,11 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
format.toWideReadableForm(fluid.getStackSize())));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
|
||||
}
|
||||
|
||||
if (handler.isPreformatted()) {
|
||||
@@ -167,6 +173,8 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
if (aeFluidStack != null)
|
||||
lines.add(" " + aeFluidStack.getFluidStack().getLocalizedName());
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_SHIFT_FOR_MORE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,6 +263,7 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
return stack;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) {
|
||||
if (player.isSneaking()) {
|
||||
if (Platform.isClient()) {
|
||||
@@ -297,11 +306,9 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
player.dropPlayerItemWithRandomChoice(extraA, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (player.inventoryContainer != null) {
|
||||
player.inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -322,7 +329,6 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
final float hitY,
|
||||
final float hitZ) {
|
||||
if (ForgeEventFactory.onItemUseStart(player, stack, 1) <= 0) return true;
|
||||
|
||||
return this.disassembleDrive(stack, world, player);
|
||||
}
|
||||
|
||||
@@ -336,7 +342,6 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
.asSet()) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
throw new MissingDefinition("Tried to use empty storage cells while basic storage cells are defined.");
|
||||
}
|
||||
|
||||
@@ -345,6 +350,7 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
return AEConfig.instance.isFeatureEnabled(AEFeature.EnableDisassemblyCrafting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBasicFluidStorageCell register() {
|
||||
if (!Config.fluidCells) return null;
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_STORAGE + this.totalBytes / 1024, FluidCraft.MODID);
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ItemBasicFluidStoragePart extends Item {
|
||||
public class ItemBasicFluidStoragePart extends FCBaseItem {
|
||||
|
||||
public static final int types = 7;
|
||||
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
|
||||
@@ -56,6 +56,7 @@ public class ItemBasicFluidStoragePart extends Item {
|
||||
return icon.get(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBasicFluidStoragePart register() {
|
||||
if (!Config.fluidCells) return null;
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_PART, FluidCraft.MODID);
|
||||
|
||||
@@ -27,7 +27,7 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class ItemFluidDrop extends Item {
|
||||
public class ItemFluidDrop extends FCBaseItem {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon shape;
|
||||
@@ -96,22 +96,14 @@ public class ItemFluidDrop extends Item {
|
||||
}
|
||||
|
||||
public static boolean isFluidStack(ItemStack stack) {
|
||||
if (getFluidStack(stack) != null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return getFluidStack(stack) != null;
|
||||
}
|
||||
|
||||
public static boolean isFluidStack(@Nullable IAEItemStack stack) {
|
||||
if (stack == null) {
|
||||
return false;
|
||||
}
|
||||
if (getFluidStack(stack.getItemStack()) != null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return getFluidStack(stack.getItemStack()) != null;
|
||||
}
|
||||
|
||||
public static FluidStack getFluidStack(ItemStack stack) {
|
||||
@@ -169,6 +161,7 @@ public class ItemFluidDrop extends Item {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidDrop register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_DROP, FluidCraft.MODID);
|
||||
return this;
|
||||
|
||||
@@ -3,13 +3,14 @@ package com.glodblock.github.common.item;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.FluidPatternDetails;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemFluidEncodedPattern extends ItemEncodedPattern {
|
||||
public class ItemFluidEncodedPattern extends ItemEncodedPattern implements IRegister<ItemFluidEncodedPattern> {
|
||||
|
||||
public ItemFluidEncodedPattern() {
|
||||
super();
|
||||
@@ -23,6 +24,7 @@ public class ItemFluidEncodedPattern extends ItemEncodedPattern {
|
||||
return pattern.readFromStack() ? pattern : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidEncodedPattern register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_ENCODED_PATTERN, FluidCraft.MODID);
|
||||
return this;
|
||||
|
||||
@@ -13,11 +13,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemFluidExportBus extends Item implements IPartItem {
|
||||
public class ItemFluidExportBus extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemFluidExportBus() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -46,6 +45,7 @@ public class ItemFluidExportBus extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidExportBus register() {
|
||||
if (!Config.fluidIOBus) return null;
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_EXPORT, FluidCraft.MODID);
|
||||
@@ -61,12 +61,4 @@ public class ItemFluidExportBus extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemFluidImportBus extends Item implements IPartItem {
|
||||
public class ItemFluidImportBus extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemFluidImportBus() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -46,6 +45,7 @@ public class ItemFluidImportBus extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidImportBus register() {
|
||||
if (!Config.fluidIOBus) return null;
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_IMPORT, FluidCraft.MODID);
|
||||
@@ -61,12 +61,4 @@ public class ItemFluidImportBus extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -12,13 +12,12 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ItemFluidLevelEmitter extends Item implements IPartItem {
|
||||
public class ItemFluidLevelEmitter extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemFluidLevelEmitter() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -47,6 +46,7 @@ public class ItemFluidLevelEmitter extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidLevelEmitter register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_LEVEL_EMITTER, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
@@ -63,12 +63,4 @@ public class ItemFluidLevelEmitter extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
@@ -24,7 +23,7 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class ItemFluidPacket extends Item {
|
||||
public class ItemFluidPacket extends FCBaseItem {
|
||||
|
||||
public ItemFluidPacket() {
|
||||
setUnlocalizedName(NameConst.ITEM_FLUID_PACKET);
|
||||
@@ -141,12 +140,9 @@ public class ItemFluidPacket extends Item {
|
||||
return tFluid == null ? 16777215 : tFluid.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidPacket register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_PACKET, FluidCraft.MODID);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemPartFluidInterface extends Item implements IPartItem {
|
||||
public class ItemPartFluidInterface extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemPartFluidInterface() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -45,6 +44,7 @@ public class ItemPartFluidInterface extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPartFluidInterface register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_INTERFACE, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
@@ -59,12 +59,4 @@ public class ItemPartFluidInterface extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
|
||||
public class ItemPartFluidPatternTerminal extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemPartFluidPatternTerminal() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -45,6 +44,7 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPartFluidPatternTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_PATTERN_TERMINAL, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
@@ -59,12 +59,4 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
|
||||
public class ItemPartFluidPatternTerminalEx extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemPartFluidPatternTerminalEx() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -45,6 +44,7 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPartFluidPatternTerminalEx register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_PATTERN_TERMINAL_EX, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
@@ -59,12 +59,4 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemPartFluidStorageBus extends Item implements IPartItem {
|
||||
public class ItemPartFluidStorageBus extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemPartFluidStorageBus() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -45,6 +44,7 @@ public class ItemPartFluidStorageBus extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPartFluidStorageBus register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_STORAGE_BUS, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
@@ -59,12 +59,4 @@ public class ItemPartFluidStorageBus extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,11 @@ import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemPartFluidTerminal extends Item implements IPartItem {
|
||||
public class ItemPartFluidTerminal extends FCBaseItem implements IPartItem {
|
||||
public ItemPartFluidTerminal() {
|
||||
this.setMaxStackSize(64);
|
||||
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_TERMINAL);
|
||||
@@ -55,6 +54,7 @@ public class ItemPartFluidTerminal extends Item implements IPartItem {
|
||||
if (isShiftKeyDown()) tooltip.add(StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_TERMINAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPartFluidTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_TERMINAL, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
@@ -69,12 +69,4 @@ public class ItemPartFluidTerminal extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -230,8 +229,7 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
|
||||
|
||||
protected InventoryAdaptor getHandler(TileEntity target) {
|
||||
return target != null
|
||||
? FluidConvertingInventoryAdaptor.wrap(
|
||||
target, Util.from(this.getSide().getOpposite()))
|
||||
? FluidConvertingInventoryAdaptor.wrap(target, this.getSide().getOpposite())
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(Util.from(this.getSide())),
|
||||
Objects.requireNonNull(this.getSide()),
|
||||
GuiType.DUAL_INTERFACE_PART);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -570,7 +570,7 @@ public class PartFluidLevelEmitter extends PartUpgradeable
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(Util.from(getSide())),
|
||||
Objects.requireNonNull(getSide()),
|
||||
GuiType.FLUID_LEVEL_EMITTER);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ import com.glodblock.github.inventory.*;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import extracells.tileentity.TileEntityFluidInterface;
|
||||
@@ -305,7 +304,7 @@ public class PartFluidStorageBus extends PartUpgradeable
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(Util.from(this.getSide())),
|
||||
Objects.requireNonNull(this.getSide()),
|
||||
GuiType.FLUID_STORAGE_BUS);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -224,8 +224,7 @@ public abstract class FCPart extends AEBasePart
|
||||
if (Platform.isServer()) {
|
||||
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this)
|
||||
|| Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
|
||||
InventoryHandler.openGui(
|
||||
player, te.getWorldObj(), tePos, Objects.requireNonNull(Util.from(getSide())), getGui());
|
||||
InventoryHandler.openGui(player, te.getWorldObj(), tePos, Objects.requireNonNull(getSide()), getGui());
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -75,7 +74,7 @@ public abstract class FCSharedFluidBus extends PartUpgradeable implements IGridT
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(Util.from(this.getSide())),
|
||||
Objects.requireNonNull(this.getSide()),
|
||||
GuiType.FLUID_BUS_IO);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,15 +31,14 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
private static String[] fluidSlotCount;
|
||||
private final ItemStack cellItem;
|
||||
private final ISaveProvider container;
|
||||
private static final int MAX_TYPE = 1;
|
||||
private final int MAX_TYPE = 1;
|
||||
private long storedFluidCount;
|
||||
private short storedFluids;
|
||||
private IItemList<IAEFluidStack> cellItems;
|
||||
private IItemList<IAEFluidStack> cellFluids;
|
||||
private final NBTTagCompound tagCompound;
|
||||
public static final int singleByteAmount = 256 * 8;
|
||||
|
||||
public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException {
|
||||
|
||||
if (fluidSlots == null) {
|
||||
fluidSlots = new String[MAX_TYPE];
|
||||
fluidSlotCount = new String[MAX_TYPE];
|
||||
@@ -75,7 +74,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
this.tagCompound = Platform.openNbtData(o);
|
||||
this.storedFluids = this.tagCompound.getShort(FLUID_TYPE_TAG);
|
||||
this.storedFluidCount = this.tagCompound.getLong(FLUID_COUNT_TAG);
|
||||
this.cellItems = null;
|
||||
this.cellFluids = null;
|
||||
}
|
||||
|
||||
public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, final ISaveProvider container2) {
|
||||
@@ -90,13 +89,10 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
if (itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Item type = itemStack.getItem();
|
||||
|
||||
if (type instanceof IStorageFluidCell) {
|
||||
return ((IStorageFluidCell) type).isStorageCell(itemStack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -122,7 +118,10 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
@Override
|
||||
public boolean canHoldNewFluid() {
|
||||
return this.getRemainingFluidCount() > 0 && getRemainingFluidTypes() > 0;
|
||||
final long bytesFree = this.getFreeBytes();
|
||||
return (bytesFree > this.getBytesPerType()
|
||||
|| (bytesFree == this.getBytesPerType() && this.getUnusedFluidCount() > 0))
|
||||
&& this.getRemainingFluidTypes() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,10 +136,8 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
@Override
|
||||
public long getUsedBytes() {
|
||||
long bytesForItemCount = this.getStoredFluidCount() / singleByteAmount;
|
||||
long tmp = (this.getStoredFluidTypes() * this.getBytesPerType()) + bytesForItemCount;
|
||||
if (this.getUnusedFluidCount() > 0 && tmp < this.getTotalBytes()) tmp++;
|
||||
return tmp;
|
||||
final long bytesForFluidCount = (this.getStoredFluidCount() + this.getUnusedFluidCount()) / singleByteAmount;
|
||||
return this.getStoredFluidTypes() * this.getBytesPerType() + bytesForFluidCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,22 +155,26 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
return this.storedFluids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingFluidTypes() {
|
||||
final long basedOnStorage = this.getFreeBytes() / this.getBytesPerType();
|
||||
final long baseOnTotal = this.getTotalFluidTypes() - this.getStoredFluidTypes();
|
||||
|
||||
return Math.min(basedOnStorage, baseOnTotal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingFluidCount() {
|
||||
final long remaining = this.getTotalBytes() * singleByteAmount - this.getStoredFluidCount();
|
||||
final long remaining = this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount();
|
||||
return remaining > 0 ? remaining : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnusedFluidCount() {
|
||||
return (int) (this.getStoredFluidCount() % singleByteAmount);
|
||||
final int div = (int) (this.getStoredFluidCount() % singleByteAmount);
|
||||
if (div == 0) {
|
||||
return 0;
|
||||
}
|
||||
return singleByteAmount - div;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,35 +188,29 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
return 3;
|
||||
}
|
||||
|
||||
private void loadCellItems() {
|
||||
if (this.cellItems == null) {
|
||||
this.cellItems = AEApi.instance().storage().createFluidList();
|
||||
private void loadCellFluids() {
|
||||
if (this.cellFluids == null) {
|
||||
this.cellFluids = AEApi.instance().storage().createFluidList();
|
||||
}
|
||||
|
||||
this.cellItems.resetStatus(); // clears totals and stuff.
|
||||
|
||||
this.cellFluids.resetStatus(); // clears totals and stuff.
|
||||
final int types = (int) this.getStoredFluidTypes();
|
||||
|
||||
for (int x = 0; x < types; x++) {
|
||||
final FluidStack t = FluidStack.loadFluidStackFromNBT(this.tagCompound.getCompoundTag(fluidSlots[x]));
|
||||
final AEFluidStack aet = AEFluidStack.create(t);
|
||||
|
||||
if (aet != null) {
|
||||
aet.setStackSize(this.tagCompound.getLong(fluidSlotCount[x]));
|
||||
|
||||
if (aet.getStackSize() > 0) {
|
||||
this.cellItems.add(aet);
|
||||
this.cellFluids.add(aet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IItemList<IAEFluidStack> getCellItems() {
|
||||
if (this.cellItems == null) {
|
||||
this.loadCellItems();
|
||||
private IItemList<IAEFluidStack> getCellFluids() {
|
||||
if (this.cellFluids == null) {
|
||||
this.loadCellFluids();
|
||||
}
|
||||
|
||||
return this.cellItems;
|
||||
return this.cellFluids;
|
||||
}
|
||||
|
||||
private void updateFluidCount(final long delta) {
|
||||
@@ -224,15 +219,12 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
}
|
||||
|
||||
private void saveChanges() {
|
||||
long itemCount = 0;
|
||||
|
||||
long fluidCount = 0;
|
||||
int x = 0;
|
||||
|
||||
for (final IAEFluidStack v : this.cellItems) {
|
||||
itemCount += v.getStackSize();
|
||||
|
||||
for (final IAEFluidStack v : this.cellFluids) {
|
||||
fluidCount += v.getStackSize();
|
||||
final NBTBase c = this.tagCompound.getTag(fluidSlots[x]);
|
||||
|
||||
if (c instanceof NBTTagCompound) {
|
||||
v.writeToNBT((NBTTagCompound) c);
|
||||
} else {
|
||||
@@ -240,45 +232,29 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
v.writeToNBT(g);
|
||||
this.tagCompound.setTag(fluidSlots[x], g);
|
||||
}
|
||||
|
||||
/*
|
||||
* NBTBase tagSlotCount = tagCompound.getTag( itemSlotCount[x] ); if ( tagSlotCount instanceof
|
||||
* NBTTagInt ) ((NBTTagInt) tagSlotCount).data = (int) v.getStackSize(); else
|
||||
*/
|
||||
this.tagCompound.setLong(fluidSlotCount[x], v.getStackSize());
|
||||
|
||||
x++;
|
||||
}
|
||||
|
||||
// NBTBase tagType = tagCompound.getTag( ITEM_TYPE_TAG );
|
||||
// NBTBase tagCount = tagCompound.getTag( ITEM_COUNT_TAG );
|
||||
final short oldStoredItems = this.storedFluids;
|
||||
final short oldStoredFluids = this.storedFluids;
|
||||
this.storedFluids = (short) this.cellFluids.size();
|
||||
|
||||
/*
|
||||
* if ( tagType instanceof NBTTagShort ) ((NBTTagShort) tagType).data = storedItems = (short) cellItems.size();
|
||||
* else
|
||||
*/
|
||||
this.storedFluids = (short) this.cellItems.size();
|
||||
|
||||
if (this.cellItems.isEmpty()) {
|
||||
if (this.cellFluids.isEmpty()) {
|
||||
this.tagCompound.removeTag(FLUID_TYPE_TAG);
|
||||
} else {
|
||||
this.tagCompound.setShort(FLUID_TYPE_TAG, this.storedFluids);
|
||||
}
|
||||
|
||||
/*
|
||||
* if ( tagCount instanceof NBTTagInt ) ((NBTTagInt) tagCount).data = storedItemCount = itemCount; else
|
||||
*/
|
||||
this.storedFluidCount = itemCount;
|
||||
this.storedFluidCount = fluidCount;
|
||||
|
||||
if (itemCount == 0) {
|
||||
if (fluidCount == 0) {
|
||||
this.tagCompound.removeTag(FLUID_COUNT_TAG);
|
||||
} else {
|
||||
this.tagCompound.setLong(FLUID_COUNT_TAG, itemCount);
|
||||
this.tagCompound.setLong(FLUID_COUNT_TAG, fluidCount);
|
||||
}
|
||||
|
||||
// clean any old crusty stuff...
|
||||
for (; x < oldStoredItems && x < MAX_TYPE; x++) {
|
||||
for (; x < oldStoredFluids && x < MAX_TYPE; x++) {
|
||||
this.tagCompound.removeTag(fluidSlots[x]);
|
||||
this.tagCompound.removeTag(fluidSlotCount[x]);
|
||||
}
|
||||
@@ -293,32 +269,27 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (input.getStackSize() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.cellType.isBlackListed(this.cellItem, input)) {
|
||||
return input;
|
||||
}
|
||||
|
||||
final IAEFluidStack l = this.getCellItems().findPrecise(input);
|
||||
final IAEFluidStack l = this.getCellFluids().findPrecise(input);
|
||||
|
||||
if (l != null) {
|
||||
final long remainingItemSlots =
|
||||
this.getRemainingFluidCount() - (long) this.getBytesPerType() * singleByteAmount;
|
||||
final long remainingFluidSlots = this.getRemainingFluidCount();
|
||||
|
||||
if (remainingItemSlots < 0) {
|
||||
if (remainingFluidSlots < 0) {
|
||||
return input;
|
||||
}
|
||||
|
||||
if (input.getStackSize() > remainingItemSlots) {
|
||||
if (input.getStackSize() > remainingFluidSlots) {
|
||||
final IAEFluidStack r = input.copy();
|
||||
r.setStackSize(r.getStackSize() - remainingItemSlots);
|
||||
|
||||
r.setStackSize(r.getStackSize() - remainingFluidSlots);
|
||||
if (mode == Actionable.MODULATE) {
|
||||
l.setStackSize(l.getStackSize() + remainingItemSlots);
|
||||
this.updateFluidCount(remainingItemSlots);
|
||||
l.setStackSize(l.getStackSize() + remainingFluidSlots);
|
||||
this.updateFluidCount(remainingFluidSlots);
|
||||
this.saveChanges();
|
||||
}
|
||||
return r;
|
||||
@@ -328,40 +299,33 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
this.updateFluidCount(input.getStackSize());
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.canHoldNewFluid()) // room for new type, and for at least one item!
|
||||
{
|
||||
final long remainingItemCount =
|
||||
final long remainingFluidCount =
|
||||
this.getRemainingFluidCount() - ((long) this.getBytesPerType() * singleByteAmount);
|
||||
|
||||
if (remainingItemCount > 0) {
|
||||
if (input.getStackSize() > remainingItemCount) {
|
||||
if (remainingFluidCount > 0) {
|
||||
if (input.getStackSize() > remainingFluidCount) {
|
||||
final IAEFluidStack toReturn = input.copy();
|
||||
toReturn.decStackSize(remainingItemCount);
|
||||
|
||||
toReturn.decStackSize(remainingFluidCount);
|
||||
if (mode == Actionable.MODULATE) {
|
||||
IAEFluidStack toWrite = input.copy();
|
||||
toWrite.setStackSize(remainingItemCount);
|
||||
|
||||
this.cellItems.add(toWrite);
|
||||
toWrite.setStackSize(remainingFluidCount);
|
||||
this.cellFluids.add(toWrite);
|
||||
this.updateFluidCount(toWrite.getStackSize());
|
||||
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
if (mode == Actionable.MODULATE) {
|
||||
this.updateFluidCount(input.getStackSize());
|
||||
this.cellItems.add(input);
|
||||
this.cellFluids.add(input);
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -379,7 +343,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
IAEFluidStack results = null;
|
||||
|
||||
final IAEFluidStack l = this.getCellItems().findPrecise(request);
|
||||
final IAEFluidStack l = this.getCellFluids().findPrecise(request);
|
||||
|
||||
if (l != null) {
|
||||
results = l.copy();
|
||||
@@ -408,7 +372,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
@Override
|
||||
public IItemList<IAEFluidStack> getAvailableItems(IItemList<IAEFluidStack> out) {
|
||||
for (final IAEFluidStack i : this.getCellItems()) {
|
||||
for (final IAEFluidStack i : this.getCellFluids()) {
|
||||
out.add(i);
|
||||
}
|
||||
return out;
|
||||
@@ -417,7 +381,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
@Override
|
||||
public List<IAEFluidStack> getContents() {
|
||||
List<IAEFluidStack> ret = new ArrayList<>();
|
||||
for (IAEFluidStack fluid : this.getCellItems()) {
|
||||
for (IAEFluidStack fluid : this.getCellFluids()) {
|
||||
ret.add(fluid);
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
|
||||
AEApi.instance().storage().createFluidList();
|
||||
for (int x = 0; x < config.getSizeInventory(); x++) {
|
||||
final ItemStack is = config.getStackInSlot(x);
|
||||
if (is != null && Util.getFluidFromItem(is) != null) {
|
||||
if (Util.getFluidFromItem(is) != null) {
|
||||
priorityList.add(AEFluidStack.create(Util.getFluidFromItem(is)));
|
||||
break;
|
||||
}
|
||||
@@ -43,15 +43,14 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
|
||||
@Override
|
||||
public IFluidCellInventory getCellInv() {
|
||||
Object o = this.getInternal();
|
||||
|
||||
if (o instanceof MEPassThrough) {
|
||||
o = Ae2Reflect.getInternal((MEPassThrough) o);
|
||||
o = Ae2Reflect.getInternal((MEPassThrough<?>) o);
|
||||
}
|
||||
|
||||
return (IFluidCellInventory) (o instanceof IFluidCellInventory ? o : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Iterable<IAEFluidStack> getPartitionInv() {
|
||||
return (Iterable<IAEFluidStack>) Ae2Reflect.getPartitionList(this).getItems();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
|
||||
int getBytesPerType();
|
||||
|
||||
/**
|
||||
* @return true if a new item type can be added.
|
||||
* @return true if a new fluid type can be added.
|
||||
*/
|
||||
boolean canHoldNewFluid();
|
||||
|
||||
@@ -49,17 +49,22 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
|
||||
long getUsedBytes();
|
||||
|
||||
/**
|
||||
* @return how many items are stored.
|
||||
* @return how many fluids are stored.
|
||||
*/
|
||||
long getStoredFluidCount();
|
||||
|
||||
/**
|
||||
* @return how many more items can be stored.
|
||||
* @return how many more fluids can be stored.
|
||||
*/
|
||||
long getRemainingFluidCount();
|
||||
|
||||
/**
|
||||
* @return how many items can be added without consuming another byte.
|
||||
* @return how many fluid types remain.
|
||||
*/
|
||||
long getRemainingFluidTypes();
|
||||
|
||||
/**
|
||||
* @return how many fluids can be added without consuming another byte.
|
||||
*/
|
||||
int getUnusedFluidCount();
|
||||
|
||||
@@ -68,8 +73,14 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
|
||||
*/
|
||||
int getStatusForCell();
|
||||
|
||||
/**
|
||||
* @return how many items types are currently stored.
|
||||
*/
|
||||
long getStoredFluidTypes();
|
||||
|
||||
/**
|
||||
* @return max number of types.
|
||||
*/
|
||||
long getTotalFluidTypes();
|
||||
|
||||
List<IAEFluidStack> getContents();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
@@ -134,7 +135,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
|
||||
implements IMEInventory<IAEItemStack>, IMEMonitorHandlerReceiver<IAEFluidStack> {
|
||||
|
||||
private final MEInventoryHandler<IAEItemStack> invHandler = new MEInventoryHandler<>(this, getChannel());
|
||||
private List<IAEItemStack> itemCache = null;
|
||||
private IItemList<IAEItemStack> itemCache = null;
|
||||
|
||||
FluidDiscretizingInventory() {
|
||||
invHandler.setPriority(Integer.MAX_VALUE);
|
||||
@@ -185,7 +186,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out) {
|
||||
if (itemCache == null) {
|
||||
itemCache = new ArrayList<>();
|
||||
itemCache = AEApi.instance().storage().createItemList();
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid != null) {
|
||||
for (IAEFluidStack fluid : fluidGrid.getStorageList()) {
|
||||
|
||||
@@ -66,7 +66,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
|
||||
@Override
|
||||
public ImmutableSet<ICraftingLink> getRequestedJobs() {
|
||||
return ImmutableSet.copyOf(new NonNullArrayIterator<ICraftingLink>(this.requests.getLinks()));
|
||||
return ImmutableSet.copyOf(new NonNullArrayIterator<>(this.requests.getLinks()));
|
||||
}
|
||||
|
||||
private IAEItemStack setState(ICraftingLink link, IAEItemStack items) {
|
||||
@@ -176,8 +176,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
} catch (final GridAccessException ignore) {
|
||||
}
|
||||
return didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
}
|
||||
@@ -245,8 +244,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
if (!this.requests.isDone(i)) this.requests.setState(i, State.Crafting);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// :P You don't have job to do XD
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,6 +329,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
private final ICraftingLink[] links;
|
||||
private final State[] state = new State[REQ_COUNT];
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public InventoryRequest(TileLevelMaintainer tile) {
|
||||
this.requestStacks = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile);
|
||||
this.requestBatches = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile);
|
||||
|
||||
Reference in new issue
Block a user