spotless apply

This commit is contained in:
asdflj committed 2022-12-05 14:41:36 +08:00
1 parent 6acf2bace1
commit 5e31096c7e
191 files changed
+5046 -5165

No files matched your search

@@ -1,13 +1,13 @@
package com.glodblock.github.common;
import cpw.mods.fml.relauncher.FMLInjectionData;
import net.minecraftforge.common.config.Configuration;
import java.io.File;
import net.minecraftforge.common.config.Configuration;
public class Config {
private static final Configuration Config = new Configuration(new File(new File((File) FMLInjectionData.data()[6], "config"), "ae2fc.cfg"));
private static final Configuration Config =
new Configuration(new File(new File((File) FMLInjectionData.data()[6], "config"), "ae2fc.cfg"));
public static boolean fluidCells;
public static boolean noFluidPacket;
@@ -21,14 +21,30 @@ public class Config {
}
private static void loadProperty() {
fluidCells = Config.getBoolean("Enable Fluid Storage Cell", "Fluid Craft for AE2", true, "Enable this to generate the fluid storage cells. If you are playing with EC2, you can turn it off.");
noFluidPacket = Config.getBoolean("No Fluid Packet", "Fluid Craft for AE2", false, "Enable this to make normal ME Interface can emit fluid with fluid pattern, like the ME Dual Interface.");
fluidIOBus = Config.getBoolean("Enable AE2FC's Fluid I/O Bus", "Fluid Craft for AE2", true, "Enable this to add Fluid Import/Export Bus like EC2's one.");
removeRecipe = Config.getBoolean("Disable all recipes", "Fluid Craft for AE2", false, "Disable all recipes, for quick tweaker.");
blacklistEssentiaGas = Config.getBoolean("Blacklist Essentia Gas", "Fluid Craft for AE2", true, "Blacklist Essentia Gas from Thaumic Energistics, so they won't be stored in Fluid Storage Cells.");
fluidCells = Config.getBoolean(
"Enable Fluid Storage Cell",
"Fluid Craft for AE2",
true,
"Enable this to generate the fluid storage cells. If you are playing with EC2, you can turn it off.");
noFluidPacket = Config.getBoolean(
"No Fluid Packet",
"Fluid Craft for AE2",
false,
"Enable this to make normal ME Interface can emit fluid with fluid pattern, like the ME Dual Interface.");
fluidIOBus = Config.getBoolean(
"Enable AE2FC's Fluid I/O Bus",
"Fluid Craft for AE2",
true,
"Enable this to add Fluid Import/Export Bus like EC2's one.");
removeRecipe = Config.getBoolean(
"Disable all recipes", "Fluid Craft for AE2", false, "Disable all recipes, for quick tweaker.");
blacklistEssentiaGas = Config.getBoolean(
"Blacklist Essentia Gas",
"Fluid Craft for AE2",
true,
"Blacklist Essentia Gas from Thaumic Energistics, so they won't be stored in Fluid Storage Cells.");
if (Config.hasChanged())
Config.save();
if (Config.hasChanged()) Config.save();
}
private static void loadCategory() {
@@ -31,5 +31,4 @@ public class BlockFluidDiscretizer extends FCBaseBlock {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -15,6 +15,7 @@ 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.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -22,8 +23,6 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.EnumSet;
public class BlockFluidInterface extends FCBaseBlock {
public BlockFluidInterface() {
@@ -31,29 +30,34 @@ public class BlockFluidInterface extends FCBaseBlock {
setFullBlock(true);
setOpaque(true);
setTileEntity(TileFluidInterface.class);
setFeature( EnumSet.of( AEFeature.Core ) );
setFeature(EnumSet.of(AEFeature.Core));
}
@Override
@SideOnly( Side.CLIENT )
protected RenderBlockFluidInterface getRenderer()
{
@SideOnly(Side.CLIENT)
protected RenderBlockFluidInterface getRenderer() {
return new RenderBlockFluidInterface();
}
@Override
public boolean onActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int facing, final float hitX, final float hitY, final float hitZ )
{
if( player.isSneaking() )
{
public boolean onActivated(
final World world,
final int x,
final int y,
final int z,
final EntityPlayer player,
final int facing,
final float hitX,
final float hitY,
final float hitZ) {
if (player.isSneaking()) {
return false;
}
final TileInterface tg = this.getTileEntity( world, x, y, z );
if( tg != null )
{
if( Platform.isServer() )
{
InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.DUAL_INTERFACE);
final TileInterface tg = this.getTileEntity(world, x, y, z);
if (tg != null) {
if (Platform.isServer()) {
InventoryHandler.openGui(
player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.DUAL_INTERFACE);
}
return true;
}
@@ -61,17 +65,14 @@ public class BlockFluidInterface extends FCBaseBlock {
}
@Override
protected boolean hasCustomRotation()
{
protected boolean hasCustomRotation() {
return true;
}
@Override
protected void customRotateBlock(final IOrientable rotatable, final ForgeDirection axis )
{
if( rotatable instanceof TileInterface )
{
( (TileInterface) rotatable ).setSide( axis );
protected void customRotateBlock(final IOrientable rotatable, final ForgeDirection axis) {
if (rotatable instanceof TileInterface) {
((TileInterface) rotatable).setSide(axis);
}
}
@@ -89,5 +90,4 @@ public class BlockFluidInterface extends FCBaseBlock {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -24,14 +24,20 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
}
@Override
public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
public boolean onActivated(
World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
return false;
}
TileFluidPacketDecoder tile = getTileEntity(world, x, y, z);
if (tile != null) {
if (!world.isRemote) {
InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.FLUID_PACKET_DECODER);
InventoryHandler.openGui(
player,
world,
new BlockPos(x, y, z),
EnumFacing.getFront(facing),
GuiType.FLUID_PACKET_DECODER);
}
return true;
}
@@ -52,5 +58,4 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -24,14 +24,20 @@ public class BlockFluidPatternEncoder extends FCBaseBlock {
}
@Override
public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
public boolean onActivated(
World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
return false;
}
TileFluidPatternEncoder tile = getTileEntity(world, x, y, z);
if (tile != null) {
if (!world.isRemote) {
InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.FLUID_PATTERN_ENCODER);
InventoryHandler.openGui(
player,
world,
new BlockPos(x, y, z),
EnumFacing.getFront(facing),
GuiType.FLUID_PATTERN_ENCODER);
}
return true;
}
@@ -52,5 +58,4 @@ public class BlockFluidPatternEncoder extends FCBaseBlock {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -25,14 +25,16 @@ public class BlockIngredientBuffer extends FCBaseBlock {
}
@Override
public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
public boolean onActivated(
World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
return false;
}
TileIngredientBuffer tile = getTileEntity(world, x, y, z);
if (tile != null) {
if (!world.isRemote) {
InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.INGREDIENT_BUFFER);
InventoryHandler.openGui(
player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.INGREDIENT_BUFFER);
}
return true;
}
@@ -53,5 +55,4 @@ public class BlockIngredientBuffer extends FCBaseBlock {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -25,14 +25,20 @@ public class BlockLargeIngredientBuffer extends FCBaseBlock {
}
@Override
public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
public boolean onActivated(
World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
return false;
}
TileLargeIngredientBuffer tile = getTileEntity(world, x, y, z);
if (tile != null) {
if (!world.isRemote) {
InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.LARGE_INGREDIENT_BUFFER);
InventoryHandler.openGui(
player,
world,
new BlockPos(x, y, z),
EnumFacing.getFront(facing),
GuiType.LARGE_INGREDIENT_BUFFER);
}
return true;
}
@@ -53,5 +59,4 @@ public class BlockLargeIngredientBuffer extends FCBaseBlock {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -44,7 +44,8 @@ public class BlockLevelMaintainer extends FCBaseBlock {
}
@Override
public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
public boolean onActivated(
World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
return false;
}
@@ -52,7 +53,12 @@ public class BlockLevelMaintainer extends FCBaseBlock {
if (tile != null) {
if (Platform.isServer()) {
if (Util.hasPermission(player, SecurityPermissions.CRAFT, tile)) {
InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.LEVEL_MAINTAINER);
InventoryHandler.openGui(
player,
world,
new BlockPos(x, y, z),
EnumFacing.getFront(facing),
GuiType.LEVEL_MAINTAINER);
} else {
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
}
@@ -25,14 +25,16 @@ public class BlockOCPatternEditor extends FCBaseBlock {
}
@Override
public boolean onActivated(World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
public boolean onActivated(
World world, int x, int y, int z, EntityPlayer player, int facing, float hitX, float hitY, float hitZ) {
if (player.isSneaking()) {
return false;
}
TileOCPatternEditor tile = getTileEntity(world, x, y, z);
if (tile != null) {
if (!world.isRemote) {
InventoryHandler.openGui(player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.OC_PATTERN_EDITOR);
InventoryHandler.openGui(
player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.OC_PATTERN_EDITOR);
}
return true;
}
@@ -56,5 +58,4 @@ public class BlockOCPatternEditor extends FCBaseBlock {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -3,11 +3,10 @@ package com.glodblock.github.common.block;
import appeng.block.AEBaseTileBlock;
import appeng.core.features.AEFeature;
import com.glodblock.github.FluidCraft;
import java.util.EnumSet;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import java.util.EnumSet;
public class FCBaseBlock extends AEBaseTileBlock {
public FCBaseBlock(Material mat, String name) {
@@ -17,7 +16,7 @@ public class FCBaseBlock extends AEBaseTileBlock {
}
@Override
public void setTileEntity( final Class<? extends TileEntity> clazz ) {
public void setTileEntity(final Class<? extends TileEntity> clazz) {
super.setTileEntity(clazz);
}
@@ -30,8 +29,7 @@ public class FCBaseBlock extends AEBaseTileBlock {
}
@Override
public void setFeature( final EnumSet<AEFeature> f ) {
public void setFeature(final EnumSet<AEFeature> f) {
super.setFeature(f);
}
}
@@ -30,6 +30,9 @@ import com.google.common.base.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@@ -42,29 +45,22 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFluidCell
{
public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFluidCell {
private final CellType component;
private final int totalBytes;
private final int perType;
private final double idleDrain;
private final static HashMap<Integer, IIcon> icon = new HashMap<>();
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
public ItemBasicFluidStorageCell( final CellType whichCell, final int kilobytes )
{
super( Optional.of( kilobytes + "k" ) );
public ItemBasicFluidStorageCell(final CellType whichCell, final int kilobytes) {
super(Optional.of(kilobytes + "k"));
setUnlocalizedName(NameConst.ITEM_FLUID_STORAGE + kilobytes);
this.setFeature( EnumSet.of( AEFeature.StorageCells ) );
this.setMaxStackSize( 1 );
this.setFeature(EnumSet.of(AEFeature.StorageCells));
this.setMaxStackSize(1);
this.totalBytes = kilobytes * 1024;
this.component = whichCell;
switch( this.component )
{
switch (this.component) {
case Cell1kPart:
this.idleDrain = 0.5;
this.perType = 8;
@@ -111,7 +107,10 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
icon.put(this.totalBytes / 1024, iconRegister.registerIcon(NameConst.RES_KEY + NameConst.ITEM_FLUID_STORAGE + "." + this.totalBytes / 1024));
icon.put(
this.totalBytes / 1024,
iconRegister.registerIcon(
NameConst.RES_KEY + NameConst.ITEM_FLUID_STORAGE + "." + this.totalBytes / 1024));
}
@Override
@@ -122,31 +121,34 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
}
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines, final boolean displayMoreInfo )
{
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.FLUIDS );
public void addCheckedInformation(
final ItemStack stack, final EntityPlayer player, final List<String> lines, final boolean displayMoreInfo) {
final IMEInventoryHandler<?> inventory =
AEApi.instance().registries().cell().getCellInventory(stack, null, StorageChannel.FLUIDS);
if( inventory instanceof IFluidCellInventoryHandler)
{
if (inventory instanceof IFluidCellInventoryHandler) {
final IFluidCellInventoryHandler handler = (IFluidCellInventoryHandler) inventory;
final IFluidCellInventory cellInventory = handler.getCellInv();
if( cellInventory != null )
{
lines.add( cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + ' ' + cellInventory.getTotalBytes() + ' ' + GuiText.BytesUsed.getLocal() );
if (cellInventory != null) {
lines.add(cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + ' '
+ cellInventory.getTotalBytes() + ' ' + GuiText.BytesUsed.getLocal());
lines.add( cellInventory.getStoredFluidTypes() + " " + GuiText.Of.getLocal() + ' ' + cellInventory.getTotalFluidTypes() + ' ' + GuiText.Types.getLocal() );
lines.add(cellInventory.getStoredFluidTypes() + " " + GuiText.Of.getLocal() + ' '
+ cellInventory.getTotalFluidTypes() + ' ' + GuiText.Types.getLocal());
if( handler.isPreformatted() )
{
final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded).getLocal();
if (handler.isPreformatted()) {
final String list = (handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST
? GuiText.Included
: GuiText.Excluded)
.getLocal();
lines.add(GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal());
if (GuiScreen.isShiftKeyDown())
{
if (GuiScreen.isShiftKeyDown()) {
lines.add(GuiText.Filter.getLocal() + ": ");
for (IAEFluidStack aeFluidStack : handler.getPartitionInv()) {
if (aeFluidStack != null) lines.add(" " + aeFluidStack.getFluidStack().getLocalizedName());
if (aeFluidStack != null)
lines.add(" " + aeFluidStack.getFluidStack().getLocalizedName());
}
}
}
@@ -155,14 +157,12 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
}
@Override
public int getBytes( final ItemStack cellItem )
{
public int getBytes(final ItemStack cellItem) {
return this.totalBytes;
}
@Override
public int getBytesPerType( final ItemStack cellItem )
{
public int getBytesPerType(final ItemStack cellItem) {
return this.perType;
}
@@ -175,131 +175,113 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
}
@Override
public int getTotalTypes( final ItemStack cellItem )
{
public int getTotalTypes(final ItemStack cellItem) {
return 1;
}
@Override
public boolean storableInStorageCell()
{
public boolean storableInStorageCell() {
return false;
}
@Override
public boolean isStorageCell( final ItemStack i )
{
public boolean isStorageCell(final ItemStack i) {
return true;
}
@Override
public double getIdleDrain()
{
public double getIdleDrain() {
return this.idleDrain;
}
@Override
public boolean isEditable( final ItemStack is )
{
public boolean isEditable(final ItemStack is) {
return true;
}
@Override
public IInventory getUpgradesInventory(final ItemStack is )
{
return new CellUpgrades( is, 0 );
public IInventory getUpgradesInventory(final ItemStack is) {
return new CellUpgrades(is, 0);
}
@Override
public IInventory getConfigInventory( final ItemStack is )
{
return new CellConfig( is );
public IInventory getConfigInventory(final ItemStack is) {
return new CellConfig(is);
}
@Override
public FuzzyMode getFuzzyMode(final ItemStack is )
{
final String fz = Platform.openNbtData( is ).getString( "FuzzyMode" );
try
{
return FuzzyMode.valueOf( fz );
}
catch( final Throwable t )
{
public FuzzyMode getFuzzyMode(final ItemStack is) {
final String fz = Platform.openNbtData(is).getString("FuzzyMode");
try {
return FuzzyMode.valueOf(fz);
} catch (final Throwable t) {
return FuzzyMode.IGNORE_ALL;
}
}
@Override
public void setFuzzyMode( final ItemStack is, final FuzzyMode fzMode )
{
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
public void setFuzzyMode(final ItemStack is, final FuzzyMode fzMode) {
Platform.openNbtData(is).setString("FuzzyMode", fzMode.name());
}
public String getOreFilter(ItemStack is) {
return Platform.openNbtData( is ).getString( "OreFilter" );
return Platform.openNbtData(is).getString("OreFilter");
}
public void setOreFilter(ItemStack is, String filter) {
Platform.openNbtData( is ).setString("OreFilter", filter);
Platform.openNbtData(is).setString("OreFilter", filter);
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player )
{
this.disassembleDrive( stack, world, player );
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player) {
this.disassembleDrive(stack, world, player);
return stack;
}
private boolean disassembleDrive( final ItemStack stack, final World world, final EntityPlayer player )
{
if( player.isSneaking() )
{
if( Platform.isClient() )
{
private boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) {
if (player.isSneaking()) {
if (Platform.isClient()) {
return false;
}
final InventoryPlayer playerInventory = player.inventory;
final IMEInventoryHandler<?> inv = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.FLUIDS );
if( inv != null && playerInventory.getCurrentItem() == stack )
{
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player, ForgeDirection.UNKNOWN );
final IItemList<IAEFluidStack> list = inv.getAvailableItems( StorageChannel.FLUIDS.createList() );
if( list.isEmpty() && ia != null )
{
playerInventory.setInventorySlotContents( playerInventory.currentItem, null );
final IMEInventoryHandler<?> inv =
AEApi.instance().registries().cell().getCellInventory(stack, null, StorageChannel.FLUIDS);
if (inv != null && playerInventory.getCurrentItem() == stack) {
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
final IItemList<IAEFluidStack> list = inv.getAvailableItems(StorageChannel.FLUIDS.createList());
if (list.isEmpty() && ia != null) {
playerInventory.setInventorySlotContents(playerInventory.currentItem, null);
// drop core
final ItemStack extraB = ia.addItems( this.component.stack( 1 ) );
if( extraB != null )
{
player.dropPlayerItemWithRandomChoice( extraB, false );
final ItemStack extraB = ia.addItems(this.component.stack(1));
if (extraB != null) {
player.dropPlayerItemWithRandomChoice(extraB, false);
}
// drop upgrades
final IInventory upgradesInventory = this.getUpgradesInventory( stack );
for( int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSizeInventory(); upgradeIndex++ )
{
final ItemStack upgradeStack = upgradesInventory.getStackInSlot( upgradeIndex );
final ItemStack leftStack = ia.addItems( upgradeStack );
if( leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule)
{
player.dropPlayerItemWithRandomChoice( upgradeStack, false );
final IInventory upgradesInventory = this.getUpgradesInventory(stack);
for (int upgradeIndex = 0; upgradeIndex < upgradesInventory.getSizeInventory(); upgradeIndex++) {
final ItemStack upgradeStack = upgradesInventory.getStackInSlot(upgradeIndex);
final ItemStack leftStack = ia.addItems(upgradeStack);
if (leftStack != null && upgradeStack.getItem() instanceof IUpgradeModule) {
player.dropPlayerItemWithRandomChoice(upgradeStack, false);
}
}
// drop empty storage cell case
for( final ItemStack storageCellStack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).asSet() )
{
final ItemStack extraA = ia.addItems( storageCellStack );
if( extraA != null )
{
player.dropPlayerItemWithRandomChoice( extraA, false );
for (final ItemStack storageCellStack : AEApi.instance()
.definitions()
.materials()
.emptyStorageCell()
.maybeStack(1)
.asSet()) {
final ItemStack extraA = ia.addItems(storageCellStack);
if (extraA != null) {
player.dropPlayerItemWithRandomChoice(extraA, false);
}
}
if( player.inventoryContainer != null )
{
if (player.inventoryContainer != null) {
player.inventoryContainer.detectAndSendChanges();
}
@@ -311,34 +293,44 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
}
@Override
public boolean onItemUseFirst( final ItemStack stack, final EntityPlayer player, final World world, final int x, final int y, final int z, final int side, final float hitX, final float hitY, final float hitZ )
{
if( ForgeEventFactory.onItemUseStart( player, stack, 1 ) <= 0 )
return true;
public boolean onItemUseFirst(
final ItemStack stack,
final EntityPlayer player,
final World world,
final int x,
final int y,
final int z,
final int side,
final float hitX,
final float hitY,
final float hitZ) {
if (ForgeEventFactory.onItemUseStart(player, stack, 1) <= 0) return true;
return this.disassembleDrive( stack, world, player );
return this.disassembleDrive(stack, world, player);
}
@Override
public ItemStack getContainerItem( final ItemStack itemStack )
{
for( final ItemStack stack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).asSet() )
{
public ItemStack getContainerItem(final ItemStack itemStack) {
for (final ItemStack stack : AEApi.instance()
.definitions()
.materials()
.emptyStorageCell()
.maybeStack(1)
.asSet()) {
return stack;
}
throw new MissingDefinition( "Tried to use empty storage cells while basic storage cells are defined." );
throw new MissingDefinition("Tried to use empty storage cells while basic storage cells are defined.");
}
@Override
public boolean hasContainerItem( final ItemStack stack )
{
return AEConfig.instance.isFeatureEnabled( AEFeature.EnableDisassemblyCrafting );
public boolean hasContainerItem(final ItemStack stack) {
return AEConfig.instance.isFeatureEnabled(AEFeature.EnableDisassemblyCrafting);
}
public ItemBasicFluidStorageCell register() {
if (!Config.fluidCells) return null;
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_STORAGE + this.totalBytes / 1024 , FluidCraft.MODID);
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_STORAGE + this.totalBytes / 1024, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@@ -350,5 +342,4 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -7,6 +7,8 @@ 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.HashMap;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
@@ -14,13 +16,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import java.util.HashMap;
import java.util.List;
public class ItemBasicFluidStoragePart extends Item {
public static final int types = 7;
private final static HashMap<Integer, IIcon> icon = new HashMap<>();
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
public ItemBasicFluidStoragePart() {
super();
@@ -46,7 +45,7 @@ public class ItemBasicFluidStoragePart extends Item {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister) {
for (int i = 0; i < types; i ++) {
for (int i = 0; i < types; i++) {
icon.put(i, iconRegister.registerIcon(NameConst.RES_KEY + NameConst.ITEM_FLUID_PART + "." + i));
}
}
@@ -63,5 +62,4 @@ public class ItemBasicFluidStoragePart extends Item {
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
}
@@ -10,6 +10,9 @@ 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 java.util.Objects;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@@ -24,10 +27,6 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Objects;
public class ItemFluidDrop extends Item {
@SideOnly(Side.CLIENT)
@@ -49,7 +48,8 @@ public class ItemFluidDrop extends Item {
if (ItemFluidPacket.isDisplay(stack)) {
return fluid != null ? fluid.getLocalizedName() : StatCollector.translateToLocalFormatted("error.unknown");
}
return StatCollector.translateToLocalFormatted("item.fluid_drop.name", fluid == null ? "???" : fluid.getLocalizedName());
return StatCollector.translateToLocalFormatted(
"item.fluid_drop.name", fluid == null ? "???" : fluid.getLocalizedName());
}
@Override
@@ -173,5 +173,4 @@ public class ItemFluidDrop extends Item {
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_DROP, FluidCraft.MODID);
return this;
}
}
@@ -1,18 +1,16 @@
package com.glodblock.github.common.item;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.core.localization.GuiText;
import appeng.items.misc.ItemEncodedPattern;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import java.util.List;
public class ItemFluidEncodedPattern extends ItemEncodedPattern {
@@ -34,14 +32,16 @@ public class ItemFluidEncodedPattern extends ItemEncodedPattern {
}
@Override
public void addCheckedInformation(final ItemStack stack, final EntityPlayer player, final List<String> lines, final boolean displayMoreInfo )
{
public void addCheckedInformation(
final ItemStack stack, final EntityPlayer player, final List<String> lines, final boolean displayMoreInfo) {
NBTTagCompound data = stack.getTagCompound();
final boolean combine = data.getBoolean("combine");
final boolean prio = data.getBoolean("prioritize");
super.addCheckedInformation(stack, player, lines, displayMoreInfo);
// lines.add(String.format("%s: %s",combine ? StatCollector.translateToLocal(NameConst.TT_KEY+"combine"):StatCollector.translateToLocal(NameConst.TT_KEY+"not_combine"),combine ? GuiText.Yes.getLocal() : GuiText.No.getLocal()));
// lines.add(String.format("%s: %s",prio ? StatCollector.translateToLocal(NameConst.TT_KEY+"prio"):StatCollector.translateToLocal(NameConst.TT_KEY+"not_prio"),prio ? GuiText.Yes.getLocal() : GuiText.No.getLocal()));
// lines.add(String.format("%s: %s",combine ?
// StatCollector.translateToLocal(NameConst.TT_KEY+"combine"):StatCollector.translateToLocal(NameConst.TT_KEY+"not_combine"),combine ? GuiText.Yes.getLocal() : GuiText.No.getLocal()));
// lines.add(String.format("%s: %s",prio ?
// StatCollector.translateToLocal(NameConst.TT_KEY+"prio"):StatCollector.translateToLocal(NameConst.TT_KEY+"not_prio"),prio ? GuiText.Yes.getLocal() : GuiText.No.getLocal()));
}
public ItemStack stack() {
@@ -10,14 +10,13 @@ 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 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;
import javax.annotation.Nullable;
public class ItemFluidExportBus extends Item implements IPartItem {
public ItemFluidExportBus() {
@@ -33,7 +32,17 @@ public class ItemFluidExportBus extends Item implements IPartItem {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
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);
}
@@ -45,8 +54,7 @@ public class ItemFluidExportBus extends Item implements IPartItem {
}
@Override
public void registerIcons(IIconRegister _iconRegister) {
}
public void registerIcons(IIconRegister _iconRegister) {}
@Override
@SideOnly(Side.CLIENT)
@@ -61,6 +69,4 @@ public class ItemFluidExportBus extends Item implements IPartItem {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -10,14 +10,13 @@ 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 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;
import javax.annotation.Nullable;
public class ItemFluidImportBus extends Item implements IPartItem {
public ItemFluidImportBus() {
@@ -33,7 +32,17 @@ public class ItemFluidImportBus extends Item implements IPartItem {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
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);
}
@@ -45,8 +54,7 @@ public class ItemFluidImportBus extends Item implements IPartItem {
}
@Override
public void registerIcons(IIconRegister _iconRegister) {
}
public void registerIcons(IIconRegister _iconRegister) {}
@Override
@SideOnly(Side.CLIENT)
@@ -61,5 +69,4 @@ public class ItemFluidImportBus extends Item implements IPartItem {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -8,6 +8,9 @@ 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 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;
@@ -20,10 +23,6 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Objects;
public class ItemFluidPacket extends Item {
public ItemFluidPacket() {
@@ -31,6 +30,15 @@ public class ItemFluidPacket extends Item {
setMaxStackSize(1);
}
public static FluidStack getFluidStack(ItemStack stack) {
if (stack == null || !stack.hasTagCompound()) {
return null;
}
FluidStack fluid = FluidStack.loadFluidStackFromNBT(
Objects.requireNonNull(stack.getTagCompound()).getCompoundTag("FluidStack"));
return (fluid != null && fluid.amount > 0) ? fluid : null;
}
@Override
public String getItemStackDisplayName(ItemStack stack) {
FluidStack fluid = getFluidStack(stack);
@@ -38,23 +46,9 @@ public class ItemFluidPacket extends Item {
if (display) {
return fluid != null ? fluid.getLocalizedName() : super.getItemStackDisplayName(stack);
}
return fluid != null ? String.format("%s, %,d mB", fluid.getLocalizedName(), fluid.amount)
: super.getItemStackDisplayName(stack);
}
@Override
@SuppressWarnings("unchecked")
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flags) {
FluidStack fluid = getFluidStack(stack);
boolean display = isDisplay(stack);
if (display) return;
if (fluid != null) {
for (String line : StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_PACKET).split("\\\\n")) {
tooltip.add(EnumChatFormatting.GRAY + line);
}
} else {
tooltip.add(EnumChatFormatting.RED + StatCollector.translateToLocalFormatted(NameConst.TT_INVALID_FLUID));
}
return fluid != null
? String.format("%s, %,d mB", fluid.getLocalizedName(), fluid.amount)
: super.getItemStackDisplayName(stack);
}
public static boolean isDisplay(ItemStack stack) {
@@ -64,12 +58,20 @@ public class ItemFluidPacket extends Item {
return stack.getTagCompound().getBoolean("DisplayOnly");
}
public static FluidStack getFluidStack(ItemStack stack) {
if (stack == null || !stack.hasTagCompound()) {
return null;
@Override
@SuppressWarnings("unchecked")
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean flags) {
FluidStack fluid = getFluidStack(stack);
boolean display = isDisplay(stack);
if (display) return;
if (fluid != null) {
for (String line : StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_PACKET)
.split("\\\\n")) {
tooltip.add(EnumChatFormatting.GRAY + line);
}
} else {
tooltip.add(EnumChatFormatting.RED + StatCollector.translateToLocalFormatted(NameConst.TT_INVALID_FLUID));
}
FluidStack fluid = FluidStack.loadFluidStackFromNBT(Objects.requireNonNull(stack.getTagCompound()).getCompoundTag("FluidStack"));
return (fluid != null && fluid.amount > 0) ? fluid : null;
}
public static FluidStack getFluidStack(@Nullable IAEItemStack stack) {
@@ -117,8 +119,7 @@ public class ItemFluidPacket extends Item {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister aIconRegister) {
}
public void registerIcons(IIconRegister aIconRegister) {}
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int p_77617_1_) {
@@ -9,14 +9,13 @@ 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 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;
import javax.annotation.Nullable;
public class ItemPartFluidInterface extends Item implements IPartItem {
public ItemPartFluidInterface() {
@@ -32,7 +31,17 @@ public class ItemPartFluidInterface extends Item implements IPartItem {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
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);
}
@@ -43,8 +52,7 @@ public class ItemPartFluidInterface extends Item implements IPartItem {
}
@Override
public void registerIcons(IIconRegister _iconRegister) {
}
public void registerIcons(IIconRegister _iconRegister) {}
@Override
@SideOnly(Side.CLIENT)
@@ -59,5 +67,4 @@ public class ItemPartFluidInterface extends Item implements IPartItem {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -9,14 +9,13 @@ 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 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;
import javax.annotation.Nullable;
public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
public ItemPartFluidPatternTerminal() {
@@ -32,7 +31,17 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
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);
}
@@ -43,8 +52,7 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
}
@Override
public void registerIcons(IIconRegister _iconRegister) {
}
public void registerIcons(IIconRegister _iconRegister) {}
@Override
@SideOnly(Side.CLIENT)
@@ -59,5 +67,4 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -9,14 +9,13 @@ 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 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;
import javax.annotation.Nullable;
public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
public ItemPartFluidPatternTerminalEx() {
@@ -32,7 +31,17 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
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);
}
@@ -43,8 +52,7 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
}
@Override
public void registerIcons(IIconRegister _iconRegister) {
}
public void registerIcons(IIconRegister _iconRegister) {}
@Override
@SideOnly(Side.CLIENT)
@@ -59,5 +67,4 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -1,5 +1,7 @@
package com.glodblock.github.common.item;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import appeng.api.AEApi;
import appeng.api.parts.IPartItem;
import com.glodblock.github.FluidCraft;
@@ -9,6 +11,8 @@ 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 javax.annotation.Nullable;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@@ -16,12 +20,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.util.List;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
public class ItemPartFluidTerminal extends Item implements IPartItem {
public ItemPartFluidTerminal() {
this.setMaxStackSize(64);
@@ -36,7 +34,17 @@ public class ItemPartFluidTerminal extends Item implements IPartItem {
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
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);
}
@@ -54,8 +62,7 @@ public class ItemPartFluidTerminal extends Item implements IPartItem {
}
@Override
public void registerIcons(IIconRegister _iconRegister) {
}
public void registerIcons(IIconRegister _iconRegister) {}
@Override
@SideOnly(Side.CLIENT)
@@ -70,5 +77,4 @@ public class ItemPartFluidTerminal extends Item implements IPartItem {
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -31,6 +31,8 @@ import com.glodblock.github.client.textures.FCPartsTexture;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import java.util.List;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.EntityPlayer;
@@ -43,10 +45,8 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
import java.io.IOException;
import java.util.List;
public abstract class FCBasePart extends AEBasePart implements IPowerChannelState, ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory {
public abstract class FCBasePart extends AEBasePart
implements IPowerChannelState, ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory {
protected static final int POWERED_FLAG = 4;
protected static final int CHANNEL_FLAG = 16;
@@ -56,172 +56,140 @@ public abstract class FCBasePart extends AEBasePart implements IPowerChannelStat
private int clientFlags = 0; // sent as byte.
private float opacity = -1;
private final IConfigManager cm = new ConfigManager( this );
private final AppEngInternalInventory viewCell = new AppEngInternalInventory( this, 5 );
private final IConfigManager cm = new ConfigManager(this);
private final AppEngInternalInventory viewCell = new AppEngInternalInventory(this, 5);
public FCBasePart( final ItemStack is )
{
this( is, false );
public FCBasePart(final ItemStack is) {
this(is, false);
}
protected FCBasePart( final ItemStack is, final boolean requireChannel )
{
super( is );
protected FCBasePart(final ItemStack is, final boolean requireChannel) {
super(is);
if( requireChannel )
{
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
this.getProxy().setIdlePowerUsage( 1.0 / 2.0 );
if (requireChannel) {
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
this.getProxy().setIdlePowerUsage(1.0 / 2.0);
} else {
this.getProxy().setIdlePowerUsage(1.0 / 16.0); // lights drain a little bit.
}
else
{
this.getProxy().setIdlePowerUsage( 1.0 / 16.0 ); // lights drain a little bit.
}
this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
this.cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
this.cm.registerSetting(Settings.SORT_BY, SortOrder.NAME);
this.cm.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
this.cm.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
}
@MENetworkEventSubscribe
public final void bootingRender( final MENetworkBootingStatusChange c )
{
if( !this.isLightSource() )
{
public final void bootingRender(final MENetworkBootingStatusChange c) {
if (!this.isLightSource()) {
this.getHost().markForUpdate();
}
}
@MENetworkEventSubscribe
public final void powerRender( final MENetworkPowerStatusChange c )
{
public final void powerRender(final MENetworkPowerStatusChange c) {
this.getHost().markForUpdate();
}
@Override
public final void getBoxes( final IPartCollisionHelper bch )
{
bch.addBox( 2, 2, 14, 14, 14, 16 );
bch.addBox( 4, 4, 13, 12, 12, 14 );
public final void getBoxes(final IPartCollisionHelper bch) {
bch.addBox(2, 2, 14, 14, 14, 16);
bch.addBox(4, 4, 13, 12, 12, 14);
}
@Override
public void onNeighborChanged()
{
public void onNeighborChanged() {
this.opacity = -1;
this.getHost().markForUpdate();
}
@Override
public void getDrops(final List<ItemStack> drops, final boolean wrenched )
{
super.getDrops( drops, wrenched );
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
super.getDrops(drops, wrenched);
for( final ItemStack is : this.viewCell )
{
if( is != null )
{
drops.add( is );
for (final ItemStack is : this.viewCell) {
if (is != null) {
drops.add(is);
}
}
}
@Override
public IConfigManager getConfigManager()
{
public IConfigManager getConfigManager() {
return this.cm;
}
@Override
public void readFromNBT( final NBTTagCompound data )
{
super.readFromNBT( data );
if( data.hasKey( "opacity" ) )
{
this.opacity = data.getFloat( "opacity" );
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
if (data.hasKey("opacity")) {
this.opacity = data.getFloat("opacity");
}
this.spin = data.getByte( "spin" );
this.cm.readFromNBT( data );
this.viewCell.readFromNBT( data, "viewCell" );
this.spin = data.getByte("spin");
this.cm.readFromNBT(data);
this.viewCell.readFromNBT(data, "viewCell");
}
@Override
public void writeToNBT( final NBTTagCompound data )
{
super.writeToNBT( data );
data.setFloat( "opacity", this.opacity );
data.setByte( "spin", this.getSpin() );
this.cm.writeToNBT( data );
this.viewCell.writeToNBT( data, "viewCell" );
public void writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
data.setFloat("opacity", this.opacity);
data.setByte("spin", this.getSpin());
this.cm.writeToNBT(data);
this.viewCell.writeToNBT(data, "viewCell");
}
public GuiBridge getGui(final EntityPlayer player )
{
public GuiBridge getGui(final EntityPlayer player) {
return GuiBridge.GUI_ME;
}
@Override
public void writeToStream( final ByteBuf data ) throws IOException
{
super.writeToStream( data );
public void writeToStream(final ByteBuf data) throws IOException {
super.writeToStream(data);
this.clientFlags = this.getSpin() & 3;
try
{
if( this.getProxy().getEnergy().isNetworkPowered() )
{
try {
if (this.getProxy().getEnergy().isNetworkPowered()) {
this.clientFlags = this.getClientFlags() | FCBasePart.POWERED_FLAG;
}
if( this.getProxy().getPath().isNetworkBooting() )
{
if (this.getProxy().getPath().isNetworkBooting()) {
this.clientFlags = this.getClientFlags() | FCBasePart.BOOTING_FLAG;
}
if( this.getProxy().getNode().meetsChannelRequirements() )
{
if (this.getProxy().getNode().meetsChannelRequirements()) {
this.clientFlags = this.getClientFlags() | FCBasePart.CHANNEL_FLAG;
}
}
catch( final GridAccessException e )
{
} catch (final GridAccessException e) {
// um.. nothing.
}
data.writeByte( (byte) this.getClientFlags() );
data.writeByte((byte) this.getClientFlags());
}
@Override
public boolean readFromStream( final ByteBuf data ) throws IOException
{
super.readFromStream( data );
public boolean readFromStream(final ByteBuf data) throws IOException {
super.readFromStream(data);
final int oldFlags = this.getClientFlags();
this.clientFlags = data.readByte();
this.spin = (byte) ( this.getClientFlags() & 3 );
this.spin = (byte) (this.getClientFlags() & 3);
return this.getClientFlags() != oldFlags;
}
@Override
public final int getLightLevel()
{
return this.blockLight( this.isPowered() ? ( this.isLightSource() ? 15 : 9 ) : 0 );
public final int getLightLevel() {
return this.blockLight(this.isPowered() ? (this.isLightSource() ? 15 : 9) : 0);
}
public boolean onPartActivate0(final EntityPlayer player, final Vec3 pos )
{
public boolean onPartActivate0(final EntityPlayer player, final Vec3 pos) {
final TileEntity te = this.getTile();
if( !player.isSneaking() && Platform.isWrench( player, player.inventory.getCurrentItem(), te.xCoord, te.yCoord, te.zCoord ) )
{
if( Platform.isServer() )
{
if( this.getSpin() > 3 )
{
if (!player.isSneaking()
&& Platform.isWrench(player, player.inventory.getCurrentItem(), te.xCoord, te.yCoord, te.zCoord)) {
if (Platform.isServer()) {
if (this.getSpin() > 3) {
this.spin = 0;
}
switch( this.getSpin() )
{
switch (this.getSpin()) {
case 0:
this.spin = 1;
break;
@@ -240,26 +208,20 @@ public abstract class FCBasePart extends AEBasePart implements IPowerChannelStat
this.saveChanges();
}
return true;
}
else
{
return super.onPartActivate( player, pos );
} else {
return super.onPartActivate(player, pos);
}
}
@Override
public boolean onPartActivate( final EntityPlayer player, final Vec3 pos )
{
if( !onPartActivate0( player, pos ) )
{
if( !player.isSneaking() )
{
if( Platform.isClient() )
{
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
if (!onPartActivate0(player, pos)) {
if (!player.isSneaking()) {
if (Platform.isClient()) {
return true;
}
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), this.getGui( player ) );
Platform.openGUI(player, this.getHost().getTile(), this.getSide(), this.getGui(player));
return true;
}
@@ -268,213 +230,206 @@ public abstract class FCBasePart extends AEBasePart implements IPowerChannelStat
}
@Override
public final void onPlacement( final EntityPlayer player, final ItemStack held, final ForgeDirection side )
{
super.onPlacement( player, held, side );
public final void onPlacement(final EntityPlayer player, final ItemStack held, final ForgeDirection side) {
super.onPlacement(player, held, side);
final byte rotation = (byte) ( MathHelper.floor_double( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 );
if( side == ForgeDirection.UP )
{
final byte rotation = (byte) (MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 2.5D) & 3);
if (side == ForgeDirection.UP) {
this.spin = rotation;
}
else if( side == ForgeDirection.DOWN )
{
} else if (side == ForgeDirection.DOWN) {
this.spin = rotation;
}
}
private int blockLight(final int emit )
{
if( this.opacity < 0 )
{
private int blockLight(final int emit) {
if (this.opacity < 0) {
final TileEntity te = this.getTile();
this.opacity = 255 - te.getWorldObj().getBlockLightOpacity( te.xCoord + this.getSide().offsetX, te.yCoord + this.getSide().offsetY, te.zCoord + this.getSide().offsetZ );
this.opacity = 255
- te.getWorldObj()
.getBlockLightOpacity(
te.xCoord + this.getSide().offsetX,
te.yCoord + this.getSide().offsetY,
te.zCoord + this.getSide().offsetZ);
}
return (int) ( emit * ( this.opacity / 255.0f ) );
return (int) (emit * (this.opacity / 255.0f));
}
@Override
public final boolean isPowered()
{
try
{
if( Platform.isServer() )
{
public final boolean isPowered() {
try {
if (Platform.isServer()) {
return this.getProxy().getEnergy().isNetworkPowered();
} else {
return ((this.getClientFlags() & FCBasePart.POWERED_FLAG) == FCBasePart.POWERED_FLAG);
}
else
{
return ( ( this.getClientFlags() & FCBasePart.POWERED_FLAG ) == FCBasePart.POWERED_FLAG );
}
}
catch( final GridAccessException e )
{
} catch (final GridAccessException e) {
return false;
}
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory()
{
try
{
public IMEMonitor<IAEItemStack> getItemInventory() {
try {
return this.getProxy().getStorage().getItemInventory();
}
catch( final GridAccessException e )
{
} catch (final GridAccessException e) {
// err nope?
}
return null;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory()
{
try
{
public IMEMonitor<IAEFluidStack> getFluidInventory() {
try {
return this.getProxy().getStorage().getFluidInventory();
}
catch( final GridAccessException e )
{
} catch (final GridAccessException e) {
// err nope?
}
return null;
}
@Override
public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue )
{
}
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {}
@Override
public IInventory getViewCellStorage()
{
public IInventory getViewCellStorage() {
return this.viewCell;
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
public void onChangeInventory(
final IInventory inv,
final int slot,
final InvOperation mc,
final ItemStack removedStack,
final ItemStack newStack) {
this.getHost().markForSave();
}
@Override
public final boolean isActive()
{
if( !this.isLightSource() )
{
return ( ( this.getClientFlags() & ( FCBasePart.CHANNEL_FLAG | FCBasePart.POWERED_FLAG ) ) == ( FCBasePart.CHANNEL_FLAG | FCBasePart.POWERED_FLAG ) );
}
else
{
public final boolean isActive() {
if (!this.isLightSource()) {
return ((this.getClientFlags() & (FCBasePart.CHANNEL_FLAG | FCBasePart.POWERED_FLAG))
== (FCBasePart.CHANNEL_FLAG | FCBasePart.POWERED_FLAG));
} else {
return this.isPowered();
}
}
public final int getClientFlags()
{
public final int getClientFlags() {
return this.clientFlags;
}
public final byte getSpin()
{
public final byte getSpin() {
return this.spin;
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer )
{
rh.setBounds( 2, 2, 14, 14, 14, 16 );
@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.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().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().mediumVariant);
rh.renderInventoryFace(this.getFrontDark().getIcon(), ForgeDirection.SOUTH, renderer);
rh.setInvColor( this.getColor().blackVariant );
rh.renderInventoryFace( this.getFrontColored().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 );
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() ) );
@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.setTexture(
sideTexture,
sideTexture,
backTexture,
FCPartsTexture.PartTerminalBroad.getIcon(),
sideTexture,
sideTexture);
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds(2, 2, 14, 14, 14, 16);
rh.renderBlock(x, y, z, renderer);
if( this.getLightLevel() > 0 )
{
if (this.getLightLevel() > 0) {
final int l = 13;
Tessellator.instance.setBrightness( l << 20 | l << 4 );
Tessellator.instance.setBrightness(l << 20 | l << 4);
}
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = this.getSpin();
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().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().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 );
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;
renderer.uvRotateBottom = renderer.uvRotateEast =
renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
final IIcon sideStatusTexture = CableBusTextures.PartMonitorSidesStatus.getIcon();
rh.setTexture( sideStatusTexture, sideStatusTexture, backTexture, this.getItemStack().getIconIndex(), sideStatusTexture, sideStatusTexture );
rh.setTexture(
sideStatusTexture,
sideStatusTexture,
backTexture,
this.getItemStack().getIconIndex(),
sideStatusTexture,
sideStatusTexture);
rh.setBounds( 4, 4, 13, 12, 12, 14 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds(4, 4, 13, 12, 12, 14);
rh.renderBlock(x, y, z, renderer);
final boolean hasChan = ( this.getClientFlags() & ( FCBasePart.POWERED_FLAG | FCBasePart.CHANNEL_FLAG ) ) == ( FCBasePart.POWERED_FLAG | FCBasePart.CHANNEL_FLAG );
final boolean hasPower = ( this.getClientFlags() & FCBasePart.POWERED_FLAG ) == FCBasePart.POWERED_FLAG;
final boolean hasChan = (this.getClientFlags() & (FCBasePart.POWERED_FLAG | FCBasePart.CHANNEL_FLAG))
== (FCBasePart.POWERED_FLAG | FCBasePart.CHANNEL_FLAG);
final boolean hasPower = (this.getClientFlags() & FCBasePart.POWERED_FLAG) == FCBasePart.POWERED_FLAG;
if( hasChan )
{
if (hasChan) {
final int l = 14;
Tessellator.instance.setBrightness( l << 20 | l << 4 );
Tessellator.instance.setColorOpaque_I( this.getColor().blackVariant );
}
else if( hasPower )
{
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 );
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 );
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);
}
/**
@@ -503,5 +458,4 @@ public abstract class FCBasePart extends AEBasePart implements IPowerChannelStat
* light source 9.
*/
public abstract boolean isLightSource();
}
@@ -26,7 +26,6 @@ import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import com.google.common.collect.ImmutableSet;
import cpw.mods.fml.relauncher.Side;
@@ -40,16 +39,15 @@ import net.minecraftforge.fluids.IFluidHandler;
public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingRequester {
private final BaseActionSource source;
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker( this, 9 );
private final MultiCraftingTracker craftingTracker = new MultiCraftingTracker(this, 9);
public PartFluidExportBus( ItemStack is )
{
super( is );
this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.getConfigManager().registerSetting( Settings.CRAFT_ONLY, YesNo.NO );
this.getConfigManager().registerSetting( Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
this.source = new MachineSource( this );
public PartFluidExportBus(ItemStack is) {
super(is);
this.getConfigManager().registerSetting(Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
this.getConfigManager().registerSetting(Settings.CRAFT_ONLY, YesNo.NO);
this.getConfigManager().registerSetting(Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT);
this.source = new MachineSource(this);
}
@Override
@@ -58,83 +56,87 @@ public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingR
}
@Override
public TickingRequest getTickingRequest( IGridNode node )
{
return new TickingRequest( 5, 40, this.isSleeping(), false );
public TickingRequest getTickingRequest(IGridNode node) {
return new TickingRequest(5, 40, this.isSleeping(), false);
}
@Override
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall )
{
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE;
}
@Override
protected boolean canDoBusWork()
{
protected boolean canDoBusWork() {
return this.getProxy().isActive();
}
@Override
protected TickRateModulation doBusWork()
{
if( !this.canDoBusWork() )
{
protected TickRateModulation doBusWork() {
if (!this.canDoBusWork()) {
return TickRateModulation.IDLE;
}
final TileEntity te = this.getConnectedTE();
if(te instanceof IFluidHandler)
{
try
{
if (te instanceof IFluidHandler) {
try {
final InventoryAdaptor destination = this.getHandler(te);
final ICraftingGrid cg = this.getProxy().getCrafting();
final IFluidHandler fh = (IFluidHandler) te;
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
final IMEMonitor<IAEFluidStack> inv =
this.getProxy().getStorage().getFluidInventory();
for( int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++ )
{
IAEFluidStack fluid = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
if( fluid != null )
{
for (int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++) {
IAEFluidStack fluid = AEFluidStack.create(ItemFluidPacket.getFluidStack(
this.getInventoryByName("config").getStackInSlot(i)));
if (fluid != null) {
boolean isAllowed = true;
final IAEFluidStack toExtract = fluid.copy();
toExtract.setStackSize( this.calculateAmountToSend() );
toExtract.setStackSize(this.calculateAmountToSend());
if( this.craftOnly() )
{
isAllowed = this.craftingTracker.handleCrafting( i, toExtract.getStackSize(), ItemFluidDrop.newAeStack(toExtract), destination, this.getTile().getWorldObj(), this.getProxy().getGrid(), cg, this.source );
if (this.craftOnly()) {
isAllowed = this.craftingTracker.handleCrafting(
i,
toExtract.getStackSize(),
ItemFluidDrop.newAeStack(toExtract),
destination,
this.getTile().getWorldObj(),
this.getProxy().getGrid(),
cg,
this.source);
}
final IAEFluidStack out = inv.extractItems( toExtract, Actionable.SIMULATE, this.source );
final IAEFluidStack out = inv.extractItems(toExtract, Actionable.SIMULATE, this.source);
if( out != null && isAllowed )
{
int wasInserted = fh.fill( this.getSide().getOpposite(), out.getFluidStack(), true );
if (out != null && isAllowed) {
int wasInserted = fh.fill(this.getSide().getOpposite(), out.getFluidStack(), true);
if( wasInserted > 0 )
{
toExtract.setStackSize( wasInserted );
inv.extractItems( toExtract, Actionable.MODULATE, this.source );
if (wasInserted > 0) {
toExtract.setStackSize(wasInserted);
inv.extractItems(toExtract, Actionable.MODULATE, this.source);
return TickRateModulation.FASTER;
}
}
if( this.isCraftingEnabled() ) {
this.craftingTracker.handleCrafting( i, toExtract.getStackSize(), ItemFluidDrop.newAeStack(toExtract), destination, this.getTile().getWorldObj(), this.getProxy().getGrid(), cg, this.source );
if (this.isCraftingEnabled()) {
this.craftingTracker.handleCrafting(
i,
toExtract.getStackSize(),
ItemFluidDrop.newAeStack(toExtract),
destination,
this.getTile().getWorldObj(),
this.getProxy().getGrid(),
cg,
this.source);
}
}
}
return TickRateModulation.SLOWER;
}
catch( GridAccessException e )
{
} catch (GridAccessException e) {
// Ignore
}
}
@@ -143,67 +145,81 @@ public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingR
}
@Override
public void getBoxes( final IPartCollisionHelper bch )
{
bch.addBox( 4, 4, 12, 12, 12, 14 );
bch.addBox( 5, 5, 14, 11, 11, 15 );
bch.addBox( 6, 6, 15, 10, 10, 16 );
bch.addBox( 6, 6, 11, 10, 10, 12 );
public void getBoxes(final IPartCollisionHelper bch) {
bch.addBox(4, 4, 12, 12, 12, 14);
bch.addBox(5, 5, 14, 11, 11, 15);
bch.addBox(6, 6, 15, 10, 10, 16);
bch.addBox(6, 6, 11, 10, 10, 12);
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer )
{
rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() );
@SideOnly(Side.CLIENT)
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
rh.setTexture(
CableBusTextures.PartExportSides.getIcon(),
CableBusTextures.PartExportSides.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(),
this.getFaceIcon(),
CableBusTextures.PartExportSides.getIcon(),
CableBusTextures.PartExportSides.getIcon());
rh.setBounds( 4, 4, 12, 12, 12, 14 );
rh.renderInventoryBox( renderer );
rh.setBounds(4, 4, 12, 12, 12, 14);
rh.renderInventoryBox(renderer);
rh.setBounds( 5, 5, 14, 11, 11, 15 );
rh.renderInventoryBox( renderer );
rh.setBounds(5, 5, 14, 11, 11, 15);
rh.renderInventoryBox(renderer);
rh.setBounds( 6, 6, 15, 10, 10, 16 );
rh.renderInventoryBox( renderer );
rh.setBounds(6, 6, 15, 10, 10, 16);
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() ) );
rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() );
@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()));
rh.setTexture(
CableBusTextures.PartExportSides.getIcon(),
CableBusTextures.PartExportSides.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(),
this.getFaceIcon(),
CableBusTextures.PartExportSides.getIcon(),
CableBusTextures.PartExportSides.getIcon());
rh.setBounds( 4, 4, 12, 12, 12, 14 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds(4, 4, 12, 12, 12, 14);
rh.renderBlock(x, y, z, renderer);
rh.setBounds( 5, 5, 14, 11, 11, 15 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds(5, 5, 14, 11, 11, 15);
rh.renderBlock(x, y, z, renderer);
rh.setBounds( 6, 6, 15, 10, 10, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds(6, 6, 15, 10, 10, 16);
rh.renderBlock(x, y, z, renderer);
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
rh.setTexture(
CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(),
this.getFaceIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon());
rh.setBounds( 6, 6, 11, 10, 10, 12 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds(6, 6, 11, 10, 10, 12);
rh.renderBlock(x, y, z, renderer);
this.renderLights( x, y, z, rh, renderer );
this.renderLights(x, y, z, rh, renderer);
}
@Override
public RedstoneMode getRSMode()
{
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
public RedstoneMode getRSMode() {
return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED);
}
private boolean craftOnly() {
return this.getConfigManager().getSetting(Settings.CRAFT_ONLY) == YesNo.YES;
}
private boolean isCraftingEnabled()
{
return this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0;
private boolean isCraftingEnabled() {
return this.getInstalledUpgrades(Upgrades.CRAFTING) > 0;
}
@Override
@@ -212,42 +228,37 @@ public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingR
}
protected InventoryAdaptor getHandler(TileEntity target) {
return target != null ? FluidConvertingInventoryAdaptor.wrap(target, Util.from(this.getSide().getOpposite())) : null;
return target != null
? FluidConvertingInventoryAdaptor.wrap(
target, Util.from(this.getSide().getOpposite()))
: null;
}
@Override
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) {
final InventoryAdaptor d = this.getHandler(getConnectedTE());
try
{
if( d != null && this.getProxy().isActive() )
{
try {
if (d != null && this.getProxy().isActive()) {
final IEnergyGrid energy = this.getProxy().getEnergy();
final double power = Math.ceil(items.getStackSize() / 1000D);
if( energy.extractAEPower( power, mode, PowerMultiplier.CONFIG ) > power - 0.01 )
{
if (energy.extractAEPower(power, mode, PowerMultiplier.CONFIG) > power - 0.01) {
ItemStack inputStack = items.getItemStack();
ItemStack remaining;
if( mode == Actionable.SIMULATE )
{
remaining = d.simulateAdd( inputStack );
}
else
{
remaining = d.addItems( inputStack );
if (mode == Actionable.SIMULATE) {
remaining = d.simulateAdd(inputStack);
} else {
remaining = d.addItems(inputStack);
}
return AEItemStack.create( remaining );
return AEItemStack.create(remaining);
}
}
}
catch( final GridAccessException e )
{
AELog.debug( e );
} catch (final GridAccessException e) {
AELog.debug(e);
}
return items;
@@ -255,6 +266,6 @@ public class PartFluidExportBus extends PartSharedFluidBus implements ICraftingR
@Override
public void jobStateChange(ICraftingLink link) {
this.craftingTracker.jobStateChange( link );
this.craftingTracker.jobStateChange(link);
}
}
@@ -29,14 +29,13 @@ public class PartFluidImportBus extends PartSharedFluidBus {
private final BaseActionSource source;
public PartFluidImportBus( ItemStack is )
{
super( is );
this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.getConfigManager().registerSetting( Settings.CRAFT_ONLY, YesNo.NO );
this.getConfigManager().registerSetting( Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
this.source = new MachineSource( this );
public PartFluidImportBus(ItemStack is) {
super(is);
this.getConfigManager().registerSetting(Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE);
this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
this.getConfigManager().registerSetting(Settings.CRAFT_ONLY, YesNo.NO);
this.getConfigManager().registerSetting(Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT);
this.source = new MachineSource(this);
}
@Override
@@ -45,33 +44,28 @@ public class PartFluidImportBus extends PartSharedFluidBus {
}
@Override
public TickingRequest getTickingRequest( IGridNode node )
{
return new TickingRequest( 5, 40, this.isSleeping(), false );
public TickingRequest getTickingRequest(IGridNode node) {
return new TickingRequest(5, 40, this.isSleeping(), false);
}
@Override
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall )
{
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE;
}
@Override
protected TickRateModulation doBusWork()
{
if( !this.canDoBusWork() )
{
protected TickRateModulation doBusWork() {
if (!this.canDoBusWork()) {
return TickRateModulation.IDLE;
}
final TileEntity te = this.getConnectedTE();
if(te instanceof IFluidHandler)
{
try
{
if (te instanceof IFluidHandler) {
try {
final IFluidHandler fh = (IFluidHandler) te;
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
final IMEMonitor<IAEFluidStack> inv =
this.getProxy().getStorage().getFluidInventory();
int maxDrain = this.calculateAmountToSend();
boolean drained = false;
@@ -89,7 +83,8 @@ public class PartFluidImportBus extends PartSharedFluidBus {
final AEFluidStack aeFluidStack = AEFluidStack.create(fluidStack);
if (aeFluidStack != null) {
final IAEFluidStack notInserted = inv.injectItems(aeFluidStack, Actionable.MODULATE, this.source);
final IAEFluidStack notInserted =
inv.injectItems(aeFluidStack, Actionable.MODULATE, this.source);
if (notInserted != null && notInserted.getStackSize() > 0) {
aeFluidStack.decStackSize(notInserted.getStackSize());
@@ -102,9 +97,7 @@ public class PartFluidImportBus extends PartSharedFluidBus {
}
return drained ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
}
catch(GridAccessException e )
{
} catch (GridAccessException e) {
e.printStackTrace();
}
}
@@ -113,31 +106,26 @@ public class PartFluidImportBus extends PartSharedFluidBus {
}
@Override
protected boolean canDoBusWork()
{
protected boolean canDoBusWork() {
return this.getProxy().isActive();
}
private boolean isInFilter( FluidStack fluid )
{
for( int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++ )
{
final IAEFluidStack stack = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
if( stack != null && stack.getFluidStack().equals( fluid ) )
{
private boolean isInFilter(FluidStack fluid) {
for (int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++) {
final IAEFluidStack stack = AEFluidStack.create(ItemFluidPacket.getFluidStack(
this.getInventoryByName("config").getStackInSlot(i)));
if (stack != null && stack.getFluidStack().equals(fluid)) {
return true;
}
}
return false;
}
private boolean filterEnabled()
{
for( int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++ )
{
final IAEFluidStack stack = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
if( stack != null )
{
private boolean filterEnabled() {
for (int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++) {
final IAEFluidStack stack = AEFluidStack.create(ItemFluidPacket.getFluidStack(
this.getInventoryByName("config").getStackInSlot(i)));
if (stack != null) {
return true;
}
}
@@ -145,56 +133,70 @@ public class PartFluidImportBus extends PartSharedFluidBus {
}
@Override
public RedstoneMode getRSMode()
{
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
public RedstoneMode getRSMode() {
return (RedstoneMode) this.getConfigManager().getSetting(Settings.REDSTONE_CONTROLLED);
}
@Override
public void getBoxes( final IPartCollisionHelper bch )
{
bch.addBox( 6, 6, 11, 10, 10, 13 );
bch.addBox( 5, 5, 13, 11, 11, 14 );
bch.addBox( 4, 4, 14, 12, 12, 16 );
public void getBoxes(final IPartCollisionHelper bch) {
bch.addBox(6, 6, 11, 10, 10, 13);
bch.addBox(5, 5, 13, 11, 11, 14);
bch.addBox(4, 4, 14, 12, 12, 16);
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer )
{
rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() );
@SideOnly(Side.CLIENT)
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
rh.setTexture(
CableBusTextures.PartImportSides.getIcon(),
CableBusTextures.PartImportSides.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(),
this.getFaceIcon(),
CableBusTextures.PartImportSides.getIcon(),
CableBusTextures.PartImportSides.getIcon());
rh.setBounds( 3, 3, 15, 13, 13, 16 );
rh.renderInventoryBox( renderer );
rh.setBounds(3, 3, 15, 13, 13, 16);
rh.renderInventoryBox(renderer);
rh.setBounds( 4, 4, 14, 12, 12, 15 );
rh.renderInventoryBox( renderer );
rh.setBounds(4, 4, 14, 12, 12, 15);
rh.renderInventoryBox(renderer);
rh.setBounds( 5, 5, 13, 11, 11, 14 );
rh.renderInventoryBox( renderer );
rh.setBounds(5, 5, 13, 11, 11, 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() ) );
rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() );
@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()));
rh.setTexture(
CableBusTextures.PartImportSides.getIcon(),
CableBusTextures.PartImportSides.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(),
this.getFaceIcon(),
CableBusTextures.PartImportSides.getIcon(),
CableBusTextures.PartImportSides.getIcon());
rh.setBounds( 4, 4, 14, 12, 12, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds(4, 4, 14, 12, 12, 16);
rh.renderBlock(x, y, z, renderer);
rh.setBounds( 5, 5, 13, 11, 11, 14 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds(5, 5, 13, 11, 11, 14);
rh.renderBlock(x, y, z, renderer);
rh.setBounds( 6, 6, 12, 10, 10, 13 );
rh.renderBlock( x, y, z, renderer );
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
rh.setBounds(6, 6, 12, 10, 10, 13);
rh.renderBlock(x, y, z, renderer);
rh.setTexture(
CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(),
this.getFaceIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon());
rh.setBounds( 6, 6, 11, 10, 10, 12 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds(6, 6, 11, 10, 10, 12);
rh.renderBlock(x, y, z, renderer);
this.renderLights( x, y, z, rh, renderer );
this.renderLights(x, y, z, rh, renderer);
}
}
@@ -35,6 +35,8 @@ import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import java.util.Objects;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -46,13 +48,10 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import java.io.IOException;
import java.util.Objects;
public class PartFluidInterface extends PartInterface implements IFluidHandler, IAEFluidInventory {
private final BaseActionSource ownActionSource = new MachineSource(this);
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 6 );
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this);
public PartFluidInterface(ItemStack is) {
@@ -60,42 +59,65 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
}
@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() ) );
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), FCPartsTexture.BlockInterface_Face.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
@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()));
rh.setTexture(
CableBusTextures.PartMonitorSides.getIcon(),
CableBusTextures.PartMonitorSides.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(),
FCPartsTexture.BlockInterface_Face.getIcon(),
CableBusTextures.PartMonitorSides.getIcon(),
CableBusTextures.PartMonitorSides.getIcon());
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds(2, 2, 14, 14, 14, 16);
rh.renderBlock(x, y, z, renderer);
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), FCPartsTexture.BlockInterface_Face.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
rh.setTexture(
CableBusTextures.PartMonitorSides.getIcon(),
CableBusTextures.PartMonitorSides.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(),
FCPartsTexture.BlockInterface_Face.getIcon(),
CableBusTextures.PartMonitorSides.getIcon(),
CableBusTextures.PartMonitorSides.getIcon());
rh.setBounds( 5, 5, 12, 11, 11, 13 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds(5, 5, 12, 11, 11, 13);
rh.renderBlock(x, y, z, renderer);
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), FCPartsTexture.BlockInterface_Face.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
rh.setTexture(
CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(),
FCPartsTexture.BlockInterface_Face.getIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon());
rh.setBounds( 5, 5, 13, 11, 11, 14 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds(5, 5, 13, 11, 11, 14);
rh.renderBlock(x, y, z, renderer);
this.renderLights( x, y, z, rh, renderer );
this.renderLights(x, y, z, rh, renderer);
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory( final IPartRenderHelper rh, final RenderBlocks renderer )
{
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), FCPartsTexture.BlockInterface_Face.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() );
@SideOnly(Side.CLIENT)
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
rh.setTexture(
CableBusTextures.PartMonitorSides.getIcon(),
CableBusTextures.PartMonitorSides.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(),
FCPartsTexture.BlockInterface_Face.getIcon(),
CableBusTextures.PartMonitorSides.getIcon(),
CableBusTextures.PartMonitorSides.getIcon());
rh.setBounds( 2, 2, 14, 14, 14, 16 );
rh.renderInventoryBox( renderer );
rh.setBounds(2, 2, 14, 14, 14, 16);
rh.renderInventoryBox(renderer);
rh.setBounds( 5, 5, 12, 11, 11, 13 );
rh.renderInventoryBox( renderer );
rh.setBounds(5, 5, 12, 11, 11, 13);
rh.renderInventoryBox(renderer);
rh.setBounds( 5, 5, 13, 11, 11, 14 );
rh.renderInventoryBox( renderer );
rh.setBounds(5, 5, 13, 11, 11, 14);
rh.renderInventoryBox(renderer);
}
@MENetworkEventSubscribe
@@ -123,12 +145,11 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
}
public AppEngInternalAEInventory getConfig() {
for (int i = 0; i < fluidDuality.getConfig().getSlots(); i ++) {
for (int i = 0; i < fluidDuality.getConfig().getSlots(); i++) {
IAEFluidStack fluid = fluidDuality.getConfig().getFluidInSlot(i);
if (fluid == null) {
config.setInventorySlotContents(i, null);
}
else {
} else {
config.setInventorySlotContents(i, ItemFluidPacket.newDisplayStack(fluid.getFluidStack()));
}
}
@@ -140,7 +161,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
super.writeToStream(data);
for (int i = 0; i < config.getSizeInventory(); i++) {
ByteBufUtils.writeItemStack(data, config.getStackInSlot(i));
for (int j = 0; j < config.getSizeInventory(); j ++) {
for (int j = 0; j < config.getSizeInventory(); j++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
}
@@ -170,7 +191,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
config.setInventorySlotContents(i, stack);
changed = true;
}
for (int j = 0; j < config.getSizeInventory(); j ++) {
for (int j = 0; j < config.getSizeInventory(); j++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
}
@@ -195,10 +216,10 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
}
@Override
public void readFromNBT( NBTTagCompound data ) {
super.readFromNBT( data );
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
config.readFromNBT(data, "ConfigInv");
for (int i = 0; i < config.getSizeInventory(); i ++) {
for (int i = 0; i < config.getSizeInventory(); i++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(i));
fluidDuality.getConfig().setFluidInSlot(i, fluidDuality.getStandardFluid(fluid));
}
@@ -206,21 +227,23 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
}
@Override
public void writeToNBT( NBTTagCompound data ) {
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
config.writeToNBT(data, "ConfigInv");
getInternalFluid().writeToNBT(data, "FluidInv");
}
@Override
public int getInstalledUpgrades( final Upgrades u )
{
return getInterfaceDuality().getInstalledUpgrades( u );
public int getInstalledUpgrades(final Upgrades u) {
return getInterfaceDuality().getInstalledUpgrades(u);
}
private IMEMonitor<IAEFluidStack> getFluidGrid() {
try {
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
return getProxy()
.getGrid()
.<IStorageGrid>getCache(IStorageGrid.class)
.getFluidInventory();
} catch (GridAccessException e) {
return null;
}
@@ -238,8 +261,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
IEnergyGrid energyGrid = getEnergyGrid();
if (energyGrid == null || fluidGrid == null || resource == null)
return 0;
if (energyGrid == null || fluidGrid == null || resource == null) return 0;
int ori = resource.amount;
IAEFluidStack remove;
if (doFill) {
@@ -276,15 +298,17 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos)
{
if( player.isSneaking() )
{
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
if (player.isSneaking()) {
return false;
}
if( Platform.isServer() )
{
InventoryHandler.openGui(player, this.getHost().getTile().getWorldObj(), new BlockPos(this.getHost().getTile()), Objects.requireNonNull(Util.from(this.getSide())), GuiType.DUAL_INTERFACE_PART);
if (Platform.isServer()) {
InventoryHandler.openGui(
player,
this.getHost().getTile().getWorldObj(),
new BlockPos(this.getHost().getTile()),
Objects.requireNonNull(Util.from(this.getSide())),
GuiType.DUAL_INTERFACE_PART);
}
return true;
}
@@ -298,7 +322,8 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
public void setConfig(int id, IAEFluidStack fluid) {
if (id >= 0 && id < 6) {
config.setInventorySlotContents(id, ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack()));
config.setInventorySlotContents(
id, ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack()));
fluidDuality.getConfig().setFluidInSlot(id, fluidDuality.getStandardFluid(fluid));
}
}
@@ -310,15 +335,14 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
}
@Override
public TickingRequest getTickingRequest( final IGridNode node )
{
public TickingRequest getTickingRequest(final IGridNode node) {
TickingRequest item = super.getTickingRequest(node);
TickingRequest fluid = fluidDuality.getTickingRequest(node);
return new TickingRequest(
Math.min(item.minTickRate, fluid.minTickRate),
Math.max(item.maxTickRate, fluid.maxTickRate),
item.isSleeping && fluid.isSleeping,
true);
Math.min(item.minTickRate, fluid.minTickRate),
Math.max(item.maxTickRate, fluid.maxTickRate),
item.isSleeping && fluid.isSleeping,
true);
}
@Override
@@ -331,5 +355,4 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
return fluid;
}
}
}
@@ -17,6 +17,8 @@ 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.List;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -25,18 +27,15 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.Vec3;
import java.util.List;
import java.util.Objects;
public class PartFluidPatternTerminal extends FCBasePart {
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidPatternTerminal_Bright;
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark;
private final AppEngInternalInventory crafting = new BiggerAppEngInventory( this, 9 );
private final AppEngInternalInventory output = new BiggerAppEngInventory( this, 3 );
private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
private final AppEngInternalInventory crafting = new BiggerAppEngInventory(this, 9);
private final AppEngInternalInventory output = new BiggerAppEngInventory(this, 3);
private final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
private boolean craftingMode = true;
private boolean substitute = false;
@@ -48,29 +47,31 @@ public class PartFluidPatternTerminal extends FCBasePart {
}
@Override
public void getDrops(final List<ItemStack> drops, final boolean wrenched )
{
for( final ItemStack is : this.pattern )
{
if( is != null )
{
drops.add( is );
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
for (final ItemStack is : this.pattern) {
if (is != null) {
drops.add(is);
}
}
}
@Override
public boolean onPartActivate( final EntityPlayer player, final Vec3 pos ) {
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
TileEntity te = this.getTile();
BlockPos tePos = new BlockPos(te);
if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) {
return super.onPartActivate(player, pos);
}
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())), GuiType.FLUID_PATTERN_TERMINAL);
}
else {
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())),
GuiType.FLUID_PATTERN_TERMINAL);
} else {
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
}
}
@@ -78,69 +79,69 @@ public class PartFluidPatternTerminal extends FCBasePart {
}
@Override
public void readFromNBT( final NBTTagCompound data )
{
super.readFromNBT( data );
this.setCraftingRecipe( data.getBoolean( "craftingMode" ) );
this.setSubstitution( data.getBoolean( "substitute" ) );
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
this.setCraftingRecipe(data.getBoolean("craftingMode"));
this.setSubstitution(data.getBoolean("substitute"));
this.setCombineMode(data.getBoolean("combine"));
this.setBeSubstitute(data.getBoolean("beSubstitute"));
this.pattern.readFromNBT(data, "pattern");
this.output.readFromNBT( data, "outputList" );
this.crafting.readFromNBT( data, "craftingGrid" );
this.output.readFromNBT(data, "outputList");
this.crafting.readFromNBT(data, "craftingGrid");
}
@Override
public void writeToNBT( final NBTTagCompound data )
{
super.writeToNBT( data );
data.setBoolean( "craftingMode", this.craftingMode );
data.setBoolean( "substitute", this.substitute );
public void writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
data.setBoolean("craftingMode", this.craftingMode);
data.setBoolean("substitute", this.substitute);
data.setBoolean("combine", this.combine);
data.setBoolean("beSubstitute", this.beSubstitute);
this.pattern.writeToNBT(data, "pattern");
this.output.writeToNBT( data, "outputList" );
this.crafting.writeToNBT( data, "craftingGrid" );
this.output.writeToNBT(data, "outputList");
this.crafting.writeToNBT(data, "craftingGrid");
}
@Override
public GuiBridge getGui(final EntityPlayer p )
{
public GuiBridge getGui(final EntityPlayer p) {
int x = (int) p.posX;
int y = (int) p.posY;
int z = (int) p.posZ;
if( this.getHost().getTile() != null )
{
if (this.getHost().getTile() != null) {
x = this.getTile().xCoord;
y = this.getTile().yCoord;
z = this.getTile().zCoord;
}
if( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.getSide(), p ) )
{
if (GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
return GuiBridge.GUI_PATTERN_TERMINAL;
}
return GuiBridge.GUI_ME;
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
public void onChangeInventory(
final IInventory inv,
final int slot,
final InvOperation mc,
final ItemStack removedStack,
final ItemStack newStack) {
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem(is, this.getHost().getTile().getWorldObj());
final ICraftingPatternDetails details =
pattern.getPatternForItem(is, this.getHost().getTile().getWorldObj());
if (details != null) {
final IAEItemStack[] inItems = details.getInputs();
final IAEItemStack[] outItems = details.getOutputs();
this.setCraftingRecipe(details.isCraftable());
this.setSubstitution(details.canSubstitute());
if(newStack != null){
if (newStack != null) {
NBTTagCompound data = newStack.getTagCompound();
this.setCombineMode(data.getInteger("combine") == 1);
// this.setBeSubstitute(data.getBoolean("beSubstitute"));
// this.setBeSubstitute(data.getBoolean("beSubstitute"));
}
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
this.crafting.setInventorySlotContents(i, null);
@@ -154,10 +155,10 @@ public class PartFluidPatternTerminal extends FCBasePart {
if (inItems[i] != null) {
final IAEItemStack item = inItems[i];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
ItemStack packet =
ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.crafting.setInventorySlotContents(i, packet);
} else
this.crafting.setInventorySlotContents(i, item == null ? null : item.getItemStack());
} else this.crafting.setInventorySlotContents(i, item == null ? null : item.getItemStack());
}
}
@@ -165,10 +166,10 @@ public class PartFluidPatternTerminal extends FCBasePart {
if (outItems[i] != null) {
final IAEItemStack item = outItems[i];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
ItemStack packet =
ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(i, packet);
} else
this.output.setInventorySlotContents(i, item == null ? null : item.getItemStack());
} else this.output.setInventorySlotContents(i, item == null ? null : item.getItemStack());
}
}
}
@@ -177,39 +178,31 @@ public class PartFluidPatternTerminal extends FCBasePart {
this.getHost().markForSave();
}
private void fixCraftingRecipes()
{
if( this.craftingMode )
{
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
final ItemStack is = this.crafting.getStackInSlot( x );
if( is != null )
{
private void fixCraftingRecipes() {
if (this.craftingMode) {
for (int x = 0; x < this.crafting.getSizeInventory(); x++) {
final ItemStack is = this.crafting.getStackInSlot(x);
if (is != null) {
is.stackSize = 1;
}
}
}
}
public boolean isCraftingRecipe()
{
public boolean isCraftingRecipe() {
return this.craftingMode;
}
public void setCraftingRecipe( final boolean craftingMode )
{
public void setCraftingRecipe(final boolean craftingMode) {
this.craftingMode = craftingMode;
this.fixCraftingRecipes();
}
public boolean isSubstitution()
{
public boolean isSubstitution() {
return this.substitute;
}
public boolean shouldCombine()
{
public boolean shouldCombine() {
return this.combine;
}
@@ -245,24 +238,20 @@ public class PartFluidPatternTerminal extends FCBasePart {
}
@Override
public IInventory getInventoryByName( final String name )
{
if( name.equals( "crafting" ) )
{
public IInventory getInventoryByName(final String name) {
if (name.equals("crafting")) {
return this.crafting;
}
if( name.equals( "output" ) )
{
if (name.equals("output")) {
return this.output;
}
if( name.equals( "pattern" ) )
{
if (name.equals("pattern")) {
return this.pattern;
}
return super.getInventoryByName( name );
return super.getInventoryByName(name);
}
@Override
@@ -17,6 +17,8 @@ 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.List;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -25,18 +27,15 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.Vec3;
import java.util.List;
import java.util.Objects;
public class PartFluidPatternTerminalEx extends FCBasePart {
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidPatternTerminal_Bright;
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark;
private final AppEngInternalInventory crafting = new BiggerAppEngInventory( this, 32 );
private final AppEngInternalInventory output = new BiggerAppEngInventory( this, 32 );
private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
private final AppEngInternalInventory crafting = new BiggerAppEngInventory(this, 32);
private final AppEngInternalInventory output = new BiggerAppEngInventory(this, 32);
private final AppEngInternalInventory pattern = new AppEngInternalInventory(this, 2);
private boolean substitute = false;
private boolean combine = false;
@@ -50,29 +49,31 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
}
@Override
public void getDrops(final List<ItemStack> drops, final boolean wrenched )
{
for( final ItemStack is : this.pattern )
{
if( is != null )
{
drops.add( is );
public void getDrops(final List<ItemStack> drops, final boolean wrenched) {
for (final ItemStack is : this.pattern) {
if (is != null) {
drops.add(is);
}
}
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos ) {
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
TileEntity te = this.getTile();
BlockPos tePos = new BlockPos(te);
if (Platform.isWrench(player, player.inventory.getCurrentItem(), tePos.getX(), tePos.getY(), tePos.getZ())) {
return super.onPartActivate(player, pos);
}
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())), GuiType.FLUID_PATTERN_TERMINAL_EX);
}
else {
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())),
GuiType.FLUID_PATTERN_TERMINAL_EX);
} else {
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
}
}
@@ -80,68 +81,68 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
}
@Override
public void readFromNBT( final NBTTagCompound data )
{
super.readFromNBT( data );
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
this.setSubstitution( data.getBoolean( "substitute" ) );
this.setCombineMode( data.getBoolean("combine") );
this.pattern.readFromNBT( data, "pattern" );
this.output.readFromNBT( data, "outputList" );
this.setSubstitution(data.getBoolean("substitute"));
this.setCombineMode(data.getBoolean("combine"));
this.pattern.readFromNBT(data, "pattern");
this.output.readFromNBT(data, "outputList");
this.crafting.readFromNBT(data, "craftingGrid");
this.setBeSubstitute(data.getBoolean("beSubstitute"));
this.setSubstitution(data.getBoolean("substitute"));
this.setPrioritization( data.getBoolean( "priorization") );
this.setInverted( data.getBoolean( "inverted" ) );
this.setActivePage( data.getInteger( "activePage" ) );
this.setPrioritization(data.getBoolean("priorization"));
this.setInverted(data.getBoolean("inverted"));
this.setActivePage(data.getInteger("activePage"));
}
@Override
public void writeToNBT( final NBTTagCompound data )
{
super.writeToNBT( data );
public void writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
data.setBoolean( "substitute", this.substitute );
data.setBoolean( "combine", this.combine );
this.pattern.writeToNBT( data, "pattern" );
this.output.writeToNBT( data, "outputList" );
data.setBoolean("substitute", this.substitute);
data.setBoolean("combine", this.combine);
this.pattern.writeToNBT(data, "pattern");
this.output.writeToNBT(data, "outputList");
this.crafting.writeToNBT(data, "craftingGrid");
data.setBoolean("beSubstitute", this.beSubstitute);
data.setBoolean("priorization", this.prioritize);
data.setBoolean( "substitute", this.substitute );
data.setBoolean( "inverted", this.inverted );
data.setInteger( "activePage", this.activePage );
data.setBoolean("substitute", this.substitute);
data.setBoolean("inverted", this.inverted);
data.setInteger("activePage", this.activePage);
}
@Override
public GuiBridge getGui(final EntityPlayer p )
{
public GuiBridge getGui(final EntityPlayer p) {
int x = (int) p.posX;
int y = (int) p.posY;
int z = (int) p.posZ;
if( this.getHost().getTile() != null )
{
if (this.getHost().getTile() != null) {
x = this.getTile().xCoord;
y = this.getTile().yCoord;
z = this.getTile().zCoord;
}
if( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.getSide(), p ) )
{
if (GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions(this.getHost().getTile(), x, y, z, this.getSide(), p)) {
return GuiBridge.GUI_PATTERN_TERMINAL;
}
return GuiBridge.GUI_ME;
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
public void onChangeInventory(
final IInventory inv,
final int slot,
final InvOperation mc,
final ItemStack removedStack,
final ItemStack newStack) {
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem(is, this.getHost().getTile().getWorldObj());
final ICraftingPatternDetails details =
pattern.getPatternForItem(is, this.getHost().getTile().getWorldObj());
if (details != null) {
final IAEItemStack[] inItems = details.getInputs();
@@ -162,10 +163,10 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
}
this.setSubstitution(details.canSubstitute());
if(newStack != null){
if (newStack != null) {
NBTTagCompound data = newStack.getTagCompound();
this.setCombineMode(data.getInteger("combine") == 1);
// this.setBeSubstitute(data.getBoolean("beSubstitute"));
// this.setBeSubstitute(data.getBoolean("beSubstitute"));
}
this.setInverted(inputsCount <= 8 && outputCount > 8);
this.setActivePage(0);
@@ -182,7 +183,8 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
final IAEItemStack item = inItems[i];
if (item != null) {
if (item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
ItemStack packet =
ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.crafting.setInventorySlotContents(i, packet);
} else this.crafting.setInventorySlotContents(i, item.getItemStack());
}
@@ -193,7 +195,8 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
final IAEItemStack item = outItems[i];
if (item != null) {
if (item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
ItemStack packet =
ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(i, packet);
} else this.output.setInventorySlotContents(i, item.getItemStack());
}
@@ -203,10 +206,10 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
final IAEItemStack item = outItems[i];
if (item != null) {
if (item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
ItemStack packet =
ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, packet);
} else
this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, item.getItemStack());
} else this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, item.getItemStack());
}
}
}
@@ -216,13 +219,11 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
this.getHost().markForSave();
}
public boolean shouldCombine()
{
public boolean shouldCombine() {
return this.combine;
}
public void setCombineMode(boolean shouldCombine)
{
public void setCombineMode(boolean shouldCombine) {
this.combine = shouldCombine;
}
@@ -256,7 +257,7 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
if (crafting instanceof AppEngInternalInventory && output instanceof AppEngInternalInventory) {
for (int x = 0; x < crafting.getSizeInventory() && x < newCrafting.length; x++) {
final IAEItemStack item = newCrafting[x];
crafting.setInventorySlotContents(x, item == null ? null: item.getItemStack());
crafting.setInventorySlotContents(x, item == null ? null : item.getItemStack());
}
for (int x = 0; x < output.getSizeInventory() && x < newOutput.length; x++) {
final IAEItemStack item = newOutput[x];
@@ -266,24 +267,20 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
}
@Override
public IInventory getInventoryByName( final String name )
{
if( name.equals( "crafting" ) )
{
public IInventory getInventoryByName(final String name) {
if (name.equals("crafting")) {
return this.crafting;
}
if( name.equals( "output" ) )
{
if (name.equals("output")) {
return this.output;
}
if( name.equals( "pattern" ) )
{
if (name.equals("pattern")) {
return this.pattern;
}
return super.getInventoryByName( name );
return super.getInventoryByName(name);
}
@Override
@@ -321,5 +318,4 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
public void setActivePage(int activePage) {
this.activePage = activePage;
}
}
@@ -9,14 +9,13 @@ 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.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.Vec3;
import java.util.Objects;
public class PartFluidTerminal extends FCBasePart {
private static final FCPartsTexture FRONT_BRIGHT_ICON = FCPartsTexture.PartFluidTerminal_Bright;
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidTerminal_Colored;
@@ -59,8 +58,14 @@ public class PartFluidTerminal extends FCBasePart {
return super.onPartActivate(player, pos);
}
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())), GuiType.FLUID_TERMINAL);
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())),
GuiType.FLUID_TERMINAL);
} else {
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
}
@@ -84,5 +89,4 @@ public class PartFluidTerminal extends FCBasePart {
}
return GuiBridge.GUI_ME;
}
}
@@ -16,6 +16,7 @@ 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;
import net.minecraft.item.ItemStack;
@@ -25,96 +26,79 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import java.util.Objects;
public abstract class PartSharedFluidBus extends PartUpgradeable implements IGridTickable {
public abstract class PartSharedFluidBus extends PartUpgradeable implements IGridTickable
{
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 );
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 9);
private boolean lastRedstone;
public PartSharedFluidBus( ItemStack is )
{
super( is );
public PartSharedFluidBus(ItemStack is) {
super(is);
}
public abstract IIcon getFaceIcon();
@Override
public void upgradesChanged()
{
public void upgradesChanged() {
this.updateState();
}
@Override
public void onNeighborChanged()
{
public void onNeighborChanged() {
this.updateState();
if( this.lastRedstone != this.getHost().hasRedstone( this.getSide() ) )
{
if (this.lastRedstone != this.getHost().hasRedstone(this.getSide())) {
this.lastRedstone = !this.lastRedstone;
if( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE )
{
if (this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE) {
this.doBusWork();
}
}
}
private void updateState()
{
try
{
if( !this.isSleeping() )
{
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
private void updateState() {
try {
if (!this.isSleeping()) {
this.getProxy().getTick().wakeDevice(this.getProxy().getNode());
} else {
this.getProxy().getTick().sleepDevice(this.getProxy().getNode());
}
else
{
this.getProxy().getTick().sleepDevice( this.getProxy().getNode() );
}
}
catch( final GridAccessException e )
{
} catch (final GridAccessException e) {
// :P
}
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos)
{
if( player.isSneaking() )
{
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
if (player.isSneaking()) {
return false;
}
if( Platform.isServer() )
{
InventoryHandler.openGui(player, this.getHost().getTile().getWorldObj(), new BlockPos(this.getHost().getTile()), Objects.requireNonNull(Util.from(this.getSide())), GuiType.FLUID_BUS_IO);
if (Platform.isServer()) {
InventoryHandler.openGui(
player,
this.getHost().getTile().getWorldObj(),
new BlockPos(this.getHost().getTile()),
Objects.requireNonNull(Util.from(this.getSide())),
GuiType.FLUID_BUS_IO);
}
return true;
}
@Override
public void getBoxes( IPartCollisionHelper bch )
{
bch.addBox( 6, 6, 11, 10, 10, 13 );
bch.addBox( 5, 5, 13, 11, 11, 14 );
bch.addBox( 4, 4, 14, 12, 12, 16 );
public void getBoxes(IPartCollisionHelper bch) {
bch.addBox(6, 6, 11, 10, 10, 13);
bch.addBox(5, 5, 13, 11, 11, 14);
bch.addBox(4, 4, 14, 12, 12, 16);
}
protected TileEntity getConnectedTE()
{
protected TileEntity getConnectedTE() {
TileEntity self = this.getHost().getTile();
return this.getTileEntity( self, (new BlockPos(self)).getOffSet( this.getSide() ) );
return this.getTileEntity(self, (new BlockPos(self)).getOffSet(this.getSide()));
}
private TileEntity getTileEntity( final TileEntity self, final BlockPos pos )
{
private TileEntity getTileEntity(final TileEntity self, final BlockPos pos) {
final World w = self.getWorldObj();
if( w.getChunkProvider().chunkExists( pos.getX() >> 4, pos.getZ() >> 4 ) )
{
return w.getTileEntity( pos.getX(), pos.getY(), pos.getZ() );
if (w.getChunkProvider().chunkExists(pos.getX() >> 4, pos.getZ() >> 4)) {
return w.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
}
return null;
@@ -133,22 +117,20 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
amount = amount * 8;
case 0:
default:
return (int) Math.floor( amount );
return (int) Math.floor(amount);
}
}
@Override
public void readFromNBT( NBTTagCompound extra )
{
super.readFromNBT( extra );
this.config.readFromNBT( extra, "config" );
public void readFromNBT(NBTTagCompound extra) {
super.readFromNBT(extra);
this.config.readFromNBT(extra, "config");
}
@Override
public void writeToNBT( NBTTagCompound extra )
{
super.writeToNBT( extra );
this.config.writeToNBT( extra, "config" );
public void writeToNBT(NBTTagCompound extra) {
super.writeToNBT(extra);
this.config.writeToNBT(extra, "config");
}
@Override
@@ -164,8 +146,7 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
this.config.setInventorySlotContents(id, tmp);
}
protected StorageChannel getChannel()
{
protected StorageChannel getChannel() {
return StorageChannel.FLUIDS;
}
@@ -174,9 +155,7 @@ public abstract class PartSharedFluidBus extends PartUpgradeable implements IGri
protected abstract boolean canDoBusWork();
@Override
public int cableConnectionRenderTo()
{
public int cableConnectionRenderTo() {
return 5;
}
}
@@ -1,59 +1,49 @@
package com.glodblock.github.common.storage;
import appeng.core.features.AEFeature;
import java.util.EnumSet;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import java.util.EnumSet;
public enum CellType {
Cell1kPart( 0, AEFeature.StorageCells ),
Cell4kPart( 1, AEFeature.StorageCells ),
Cell16kPart( 2, AEFeature.StorageCells ),
Cell64kPart( 3, AEFeature.StorageCells ),
Cell256kPart( 4, AEFeature.StorageCells ),
Cell1024kPart( 5, AEFeature.StorageCells ),
Cell4096kPart( 6, AEFeature.StorageCells );
Cell1kPart(0, AEFeature.StorageCells),
Cell4kPart(1, AEFeature.StorageCells),
Cell16kPart(2, AEFeature.StorageCells),
Cell64kPart(3, AEFeature.StorageCells),
Cell256kPart(4, AEFeature.StorageCells),
Cell1024kPart(5, AEFeature.StorageCells),
Cell4096kPart(6, AEFeature.StorageCells);
private final EnumSet<AEFeature> features;
private int damageValue;
private Item itemInstance;
CellType( final int metaValue, final AEFeature part )
{
this.setDamageValue( metaValue );
this.features = EnumSet.of( part );
CellType(final int metaValue, final AEFeature part) {
this.setDamageValue(metaValue);
this.features = EnumSet.of(part);
}
void setDamageValue( final int damageValue )
{
this.damageValue = damageValue;
}
public int getDamageValue()
{
public int getDamageValue() {
return this.damageValue;
}
EnumSet<AEFeature> getFeature()
{
void setDamageValue(final int damageValue) {
this.damageValue = damageValue;
}
EnumSet<AEFeature> getFeature() {
return this.features;
}
public ItemStack stack(final int size )
{
return new ItemStack( this.getItemInstance(), size, this.getDamageValue() );
public ItemStack stack(final int size) {
return new ItemStack(this.getItemInstance(), size, this.getDamageValue());
}
public Item getItemInstance()
{
public Item getItemInstance() {
return this.itemInstance;
}
public void setItemInstance( final Item itemInstance )
{
public void setItemInstance(final Item itemInstance) {
this.itemInstance = itemInstance;
}
}
@@ -12,64 +12,63 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
public class FluidCellHandler implements ICellHandler
{
public class FluidCellHandler implements ICellHandler {
@Override
public boolean isCell( final ItemStack is )
{
return FluidCellInventory.isCell( is );
public boolean isCell(final ItemStack is) {
return FluidCellInventory.isCell(is);
}
@Override
public IMEInventoryHandler getCellInventory(final ItemStack is, final ISaveProvider container, final StorageChannel channel )
{
if( channel == StorageChannel.FLUIDS )
{
return FluidCellInventory.getCell( is, container );
public IMEInventoryHandler getCellInventory(
final ItemStack is, final ISaveProvider container, final StorageChannel channel) {
if (channel == StorageChannel.FLUIDS) {
return FluidCellInventory.getCell(is, container);
}
return null;
}
@Override
public IIcon getTopTexture_Light()
{
public IIcon getTopTexture_Light() {
return ExtraBlockTextures.BlockMEChestItems_Light.getIcon();
}
@Override
public IIcon getTopTexture_Medium()
{
public IIcon getTopTexture_Medium() {
return ExtraBlockTextures.BlockMEChestItems_Medium.getIcon();
}
@Override
public IIcon getTopTexture_Dark()
{
public IIcon getTopTexture_Dark() {
return ExtraBlockTextures.BlockMEChestItems_Dark.getIcon();
}
@Override
public void openChestGui(final EntityPlayer player, final IChestOrDrive chest, final ICellHandler cellHandler, final IMEInventoryHandler inv, final ItemStack is, final StorageChannel chan )
{
public void openChestGui(
final EntityPlayer player,
final IChestOrDrive chest,
final ICellHandler cellHandler,
final IMEInventoryHandler inv,
final ItemStack is,
final StorageChannel chan) {
if (ModAndClassUtil.EC2) {
if (chan == StorageChannel.FLUIDS) {
IStorageMonitorable monitorable = null;
if (chest != null) {
monitorable = ((IMEChest)chest).getMonitorable(ForgeDirection.UNKNOWN, new PlayerSource(player, chest));
monitorable =
((IMEChest) chest).getMonitorable(ForgeDirection.UNKNOWN, new PlayerSource(player, chest));
}
if (monitorable != null) {
GuiHandler.launchGui(GuiHandler.getGuiId(0), player, new Object[]{monitorable.getFluidInventory()});
GuiHandler.launchGui(
GuiHandler.getGuiId(0), player, new Object[] {monitorable.getFluidInventory()});
}
}
}
}
@Override
public int getStatusForCell( final ItemStack is, final IMEInventory handler )
{
if( handler instanceof FluidCellInventoryHandler)
{
public int getStatusForCell(final ItemStack is, final IMEInventory handler) {
if (handler instanceof FluidCellInventoryHandler) {
final FluidCellInventoryHandler ci = (FluidCellInventoryHandler) handler;
return ci.getStatusForCell();
}
@@ -77,9 +76,8 @@ public class FluidCellHandler implements ICellHandler
}
@Override
public double cellIdleDrain( final ItemStack is, final IMEInventory handler )
{
final IFluidCellInventory inv = ( (IFluidCellInventoryHandler) handler ).getCellInv();
public double cellIdleDrain(final ItemStack is, final IMEInventory handler) {
final IFluidCellInventory inv = ((IFluidCellInventoryHandler) handler).getCellInv();
return inv.getIdleDrain();
}
}
@@ -29,30 +29,27 @@ public class FluidCellInventory implements IFluidCellInventory {
private static String[] fluidSlotCount;
private final ItemStack cellItem;
private final ISaveProvider container;
private final static int MAX_TYPE = 1;
private static final int MAX_TYPE = 1;
private long storedFluidCount;
private short storedFluids;
private IItemList<IAEFluidStack> cellItems;
private final NBTTagCompound tagCompound;
public static final int singleByteAmount = 256 * 8;
public FluidCellInventory( final ItemStack o, final ISaveProvider container ) throws AppEngException {
public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException {
if( fluidSlots == null )
{
if (fluidSlots == null) {
fluidSlots = new String[MAX_TYPE];
fluidSlotCount = new String[MAX_TYPE];
for( int x = 0; x < MAX_TYPE; x++ )
{
for (int x = 0; x < MAX_TYPE; x++) {
fluidSlots[x] = FLUID_SLOT + x;
fluidSlotCount[x] = FLUID_SLOT_COUNT + x;
}
}
if( o == null )
{
throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" );
if (o == null) {
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
}
this.cellType = null;
@@ -60,52 +57,42 @@ public class FluidCellInventory implements IFluidCellInventory {
final Item type = this.cellItem.getItem();
if( type instanceof IStorageFluidCell)
{
if (type instanceof IStorageFluidCell) {
this.cellType = (IStorageFluidCell) this.cellItem.getItem();
}
if( this.cellType == null )
{
throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" );
if (this.cellType == null) {
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
}
if( !this.cellType.isStorageCell( this.cellItem ) )
{
throw new AppEngException( "ItemStack was used as a cell, but was not a cell!" );
if (!this.cellType.isStorageCell(this.cellItem)) {
throw new AppEngException("ItemStack was used as a cell, but was not a cell!");
}
this.container = container;
this.tagCompound = Platform.openNbtData( o );
this.storedFluids = this.tagCompound.getShort( FLUID_TYPE_TAG );
this.storedFluidCount = this.tagCompound.getLong( FLUID_COUNT_TAG );
this.tagCompound = Platform.openNbtData(o);
this.storedFluids = this.tagCompound.getShort(FLUID_TYPE_TAG);
this.storedFluidCount = this.tagCompound.getLong(FLUID_COUNT_TAG);
this.cellItems = null;
}
public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, final ISaveProvider container2 )
{
try
{
return new FluidCellInventoryHandler( new FluidCellInventory( o, container2 ) );
}
catch( final AppEngException e )
{
public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, final ISaveProvider container2) {
try {
return new FluidCellInventoryHandler(new FluidCellInventory(o, container2));
} catch (final AppEngException e) {
return null;
}
}
public static boolean isCell( final ItemStack itemStack )
{
if( itemStack == null )
{
public static boolean isCell(final ItemStack itemStack) {
if (itemStack == null) {
return false;
}
final Item type = itemStack.getItem();
if( type instanceof IStorageFluidCell)
{
return ( (IStorageFluidCell) type ).isStorageCell( itemStack );
if (type instanceof IStorageFluidCell) {
return ((IStorageFluidCell) type).isStorageCell(itemStack);
}
return false;
@@ -123,12 +110,12 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public IInventory getConfigInventory() {
return this.cellType.getConfigInventory( this.cellItem );
return this.cellType.getConfigInventory(this.cellItem);
}
@Override
public int getBytesPerType() {
return this.cellType.getBytesPerType( this.cellItem );
return this.cellType.getBytesPerType(this.cellItem);
}
@Override
@@ -138,7 +125,7 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public long getTotalBytes() {
return this.cellType.getBytes( this.cellItem );
return this.cellType.getBytes(this.cellItem);
}
@Override
@@ -185,26 +172,21 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public int getUnusedFluidCount() {
return (int) (this.getStoredFluidCount() % singleByteAmount);
}
@Override
public int getStatusForCell() {
if( this.canHoldNewFluid() )
{
if (this.canHoldNewFluid()) {
return 1;
}
if( this.getRemainingFluidCount() > 0 )
{
if (this.getRemainingFluidCount() > 0) {
return 2;
}
return 3;
}
private void loadCellItems()
{
if( this.cellItems == null )
{
private void loadCellItems() {
if (this.cellItems == null) {
this.cellItems = AEApi.instance().storage().createFluidList();
}
@@ -212,67 +194,56 @@ public class FluidCellInventory implements IFluidCellInventory {
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 );
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 != null) {
aet.setStackSize(this.tagCompound.getLong(fluidSlotCount[x]));
if( aet.getStackSize() > 0 )
{
this.cellItems.add( aet );
if (aet.getStackSize() > 0) {
this.cellItems.add(aet);
}
}
}
}
private IItemList<IAEFluidStack> getCellItems()
{
if( this.cellItems == null )
{
private IItemList<IAEFluidStack> getCellItems() {
if (this.cellItems == null) {
this.loadCellItems();
}
return this.cellItems;
}
private void updateFluidCount( final long delta )
{
private void updateFluidCount(final long delta) {
this.storedFluidCount += delta;
this.tagCompound.setLong( FLUID_COUNT_TAG, this.storedFluidCount );
this.tagCompound.setLong(FLUID_COUNT_TAG, this.storedFluidCount);
}
private void saveChanges()
{
private void saveChanges() {
long itemCount = 0;
int x = 0;
for( final IAEFluidStack v : this.cellItems )
{
for (final IAEFluidStack v : this.cellItems) {
itemCount += v.getStackSize();
final NBTBase c = this.tagCompound.getTag( fluidSlots[x] );
final NBTBase c = this.tagCompound.getTag(fluidSlots[x]);
if( c instanceof NBTTagCompound )
{
v.writeToNBT( (NBTTagCompound) c );
}
else
{
if (c instanceof NBTTagCompound) {
v.writeToNBT((NBTTagCompound) c);
} else {
final NBTTagCompound g = new NBTTagCompound();
v.writeToNBT( g );
this.tagCompound.setTag( fluidSlots[x], g );
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() );
this.tagCompound.setLong(fluidSlotCount[x], v.getStackSize());
x++;
}
@@ -287,13 +258,10 @@ public class FluidCellInventory implements IFluidCellInventory {
*/
this.storedFluids = (short) this.cellItems.size();
if( this.cellItems.isEmpty() )
{
this.tagCompound.removeTag( FLUID_TYPE_TAG );
}
else
{
this.tagCompound.setShort( FLUID_TYPE_TAG, this.storedFluids );
if (this.cellItems.isEmpty()) {
this.tagCompound.removeTag(FLUID_TYPE_TAG);
} else {
this.tagCompound.setShort(FLUID_TYPE_TAG, this.storedFluids);
}
/*
@@ -301,75 +269,61 @@ public class FluidCellInventory implements IFluidCellInventory {
*/
this.storedFluidCount = itemCount;
if( itemCount == 0 )
{
this.tagCompound.removeTag( FLUID_COUNT_TAG );
}
else
{
this.tagCompound.setLong( FLUID_COUNT_TAG, itemCount );
if (itemCount == 0) {
this.tagCompound.removeTag(FLUID_COUNT_TAG);
} else {
this.tagCompound.setLong(FLUID_COUNT_TAG, itemCount);
}
// clean any old crusty stuff...
for( ; x < oldStoredItems && x < MAX_TYPE; x++ )
{
this.tagCompound.removeTag( fluidSlots[x] );
this.tagCompound.removeTag( fluidSlotCount[x] );
for (; x < oldStoredItems && x < MAX_TYPE; x++) {
this.tagCompound.removeTag(fluidSlots[x]);
this.tagCompound.removeTag(fluidSlotCount[x]);
}
if( this.container != null )
{
this.container.saveChanges( this );
if (this.container != null) {
this.container.saveChanges(this);
}
}
@Override
public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode, BaseActionSource src) {
if( input == null )
{
if (input == null) {
return null;
}
if( input.getStackSize() == 0 )
{
if (input.getStackSize() == 0) {
return null;
}
if(this.cellType.isBlackListed( this.cellItem, input ))
{
if (this.cellType.isBlackListed(this.cellItem, input)) {
return input;
}
final IAEFluidStack l = this.getCellItems().findPrecise( input );
final IAEFluidStack l = this.getCellItems().findPrecise(input);
if( l != null )
{
final long remainingItemSlots = this.getRemainingFluidCount() - (long) this.getBytesPerType() * singleByteAmount;
if (l != null) {
final long remainingItemSlots =
this.getRemainingFluidCount() - (long) this.getBytesPerType() * singleByteAmount;
if( remainingItemSlots < 0 )
{
if (remainingItemSlots < 0) {
return input;
}
if( input.getStackSize() > remainingItemSlots )
{
if (input.getStackSize() > remainingItemSlots) {
final IAEFluidStack r = input.copy();
r.setStackSize( r.getStackSize() - remainingItemSlots );
r.setStackSize(r.getStackSize() - remainingItemSlots);
if( mode == Actionable.MODULATE )
{
l.setStackSize( l.getStackSize() + remainingItemSlots );
this.updateFluidCount( remainingItemSlots );
if (mode == Actionable.MODULATE) {
l.setStackSize(l.getStackSize() + remainingItemSlots);
this.updateFluidCount(remainingItemSlots);
this.saveChanges();
}
return r;
}
else
{
if( mode == Actionable.MODULATE )
{
l.setStackSize( l.getStackSize() + input.getStackSize() );
this.updateFluidCount( input.getStackSize() );
} else {
if (mode == Actionable.MODULATE) {
l.setStackSize(l.getStackSize() + input.getStackSize());
this.updateFluidCount(input.getStackSize());
this.saveChanges();
}
@@ -377,14 +331,13 @@ public class FluidCellInventory implements IFluidCellInventory {
}
}
if( this.canHoldNewFluid() ) // room for new type, and for at least one item!
if (this.canHoldNewFluid()) // room for new type, and for at least one item!
{
final long remainingItemCount = this.getRemainingFluidCount() - ((long) this.getBytesPerType() * singleByteAmount);
final long remainingItemCount =
this.getRemainingFluidCount() - ((long) this.getBytesPerType() * singleByteAmount);
if( remainingItemCount > 0 )
{
if( input.getStackSize() > remainingItemCount )
{
if (remainingItemCount > 0) {
if (input.getStackSize() > remainingItemCount) {
final IAEFluidStack toReturn = input.copy();
toReturn.decStackSize(remainingItemCount);
@@ -401,10 +354,9 @@ public class FluidCellInventory implements IFluidCellInventory {
return toReturn;
}
if( mode == Actionable.MODULATE )
{
this.updateFluidCount( input.getStackSize() );
this.cellItems.add( input );
if (mode == Actionable.MODULATE) {
this.updateFluidCount(input.getStackSize());
this.cellItems.add(input);
this.saveChanges();
}
@@ -417,8 +369,7 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, BaseActionSource src) {
if( request == null )
{
if (request == null) {
return null;
}
@@ -426,31 +377,25 @@ public class FluidCellInventory implements IFluidCellInventory {
IAEFluidStack results = null;
final IAEFluidStack l = this.getCellItems().findPrecise( request );
final IAEFluidStack l = this.getCellItems().findPrecise(request);
if( l != null )
{
if (l != null) {
results = l.copy();
if( l.getStackSize() <= size )
{
results.setStackSize( l.getStackSize() );
if (l.getStackSize() <= size) {
results.setStackSize(l.getStackSize());
if( mode == Actionable.MODULATE )
{
this.updateFluidCount( -l.getStackSize() );
l.setStackSize( 0 );
if (mode == Actionable.MODULATE) {
this.updateFluidCount(-l.getStackSize());
l.setStackSize(0);
this.saveChanges();
}
}
else
{
results.setStackSize( size );
} else {
results.setStackSize(size);
if( mode == Actionable.MODULATE )
{
l.setStackSize( l.getStackSize() - size );
this.updateFluidCount( -size );
if (mode == Actionable.MODULATE) {
l.setStackSize(l.getStackSize() - size);
this.updateFluidCount(-size);
this.saveChanges();
}
}
@@ -461,9 +406,8 @@ public class FluidCellInventory implements IFluidCellInventory {
@Override
public IItemList<IAEFluidStack> getAvailableItems(IItemList<IAEFluidStack> out) {
for( final IAEFluidStack i : this.getCellItems() )
{
out.add( i );
for (final IAEFluidStack i : this.getCellItems()) {
out.add(i);
}
return out;
@@ -17,17 +17,16 @@ import net.minecraft.item.ItemStack;
public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack> implements IFluidCellInventoryHandler {
FluidCellInventoryHandler( final IMEInventory<IAEFluidStack> c )
{
super( c, StorageChannel.FLUIDS );
FluidCellInventoryHandler(final IMEInventory<IAEFluidStack> c) {
super(c, StorageChannel.FLUIDS);
final IFluidCellInventory ci = this.getCellInv();
if( ci != null )
{
if (ci != null) {
final IInventory config = ci.getConfigInventory();
final IItemList<IAEFluidStack> priorityList = AEApi.instance().storage().createFluidList();
final IItemList<IAEFluidStack> priorityList =
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) {
@@ -42,16 +41,14 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
}
@Override
public IFluidCellInventory getCellInv()
{
public IFluidCellInventory getCellInv() {
Object o = this.getInternal();
if( o instanceof MEPassThrough)
{
o = Ae2Reflect.getInternal( (MEPassThrough) o );
if (o instanceof MEPassThrough) {
o = Ae2Reflect.getInternal((MEPassThrough) o);
}
return (IFluidCellInventory) ( o instanceof IFluidCellInventory ? o : null );
return (IFluidCellInventory) (o instanceof IFluidCellInventory ? o : null);
}
@Override
@@ -60,23 +57,19 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
}
@Override
public boolean isPreformatted()
{
public boolean isPreformatted() {
return !Ae2Reflect.getPartitionList(this).isEmpty();
}
@Override
public IncludeExclude getIncludeExcludeMode()
{
public IncludeExclude getIncludeExcludeMode() {
return IncludeExclude.WHITELIST;
}
public int getStatusForCell()
{
public int getStatusForCell() {
int val = this.getCellInv().getStatusForCell();
if( val == 1 && this.isPreformatted() )
{
if (val == 1 && this.isPreformatted()) {
val = 2;
}
@@ -5,8 +5,7 @@ import appeng.api.storage.data.IAEFluidStack;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
public interface IFluidCellInventory extends IMEInventory<IAEFluidStack>
{
public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
/**
* @return the item stack of this storage cell.
@@ -12,5 +12,4 @@ public interface IFluidCellInventoryHandler {
boolean isPreformatted();
IncludeExclude getIncludeExcludeMode();
}
@@ -6,18 +6,17 @@ import net.minecraft.item.ItemStack;
public interface IStorageFluidCell extends ICellWorkbenchItem {
int getBytes( ItemStack cellItem );
int getBytes(ItemStack cellItem);
int getBytesPerType( ItemStack cellItem );
int getBytesPerType(ItemStack cellItem);
boolean isBlackListed( ItemStack cellItem, IAEFluidStack requestedAddition );
boolean isBlackListed(ItemStack cellItem, IAEFluidStack requestedAddition);
boolean storableInStorageCell();
boolean isStorageCell( ItemStack i );
boolean isStorageCell(ItemStack i);
double getIdleDrain();
int getTotalTypes( ItemStack cellItem );
int getTotalTypes(ItemStack cellItem);
}
@@ -9,7 +9,7 @@ public class FluidCraftingTabs extends CreativeTabs {
public static final FluidCraftingTabs INSTANCE = new FluidCraftingTabs(FluidCraft.MODID);
public FluidCraftingTabs(String name){
public FluidCraftingTabs(String name) {
super(name);
}
@@ -20,7 +20,6 @@ import appeng.me.cache.CraftingGridCache;
import appeng.me.storage.MEInventoryHandler;
import appeng.tile.grid.AENetworkTile;
import com.glodblock.github.common.item.ItemFluidDrop;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -41,7 +40,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
@Override
public boolean canBeRotated() {
return false;
//based
// based
}
@Override
@@ -64,12 +63,12 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
@Override
public void setPriority(int newValue) {
//do nothing
// do nothing
}
@Override
public void blinkCell(int slot) {
//do nothing
// do nothing
}
@Override
@@ -87,7 +86,10 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
private IMEMonitor<IAEFluidStack> getFluidGrid() {
try {
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
return getProxy()
.getGrid()
.<IStorageGrid>getCache(IStorageGrid.class)
.getFluidInventory();
} catch (GridAccessException e) {
return null;
}
@@ -128,7 +130,8 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
updateState();
}
private class FluidDiscretizingInventory implements IMEInventory<IAEItemStack>, IMEMonitorHandlerReceiver<IAEFluidStack> {
private class FluidDiscretizingInventory
implements IMEInventory<IAEItemStack>, IMEMonitorHandlerReceiver<IAEFluidStack> {
private final MEInventoryHandler<IAEItemStack> invHandler = new MEInventoryHandler<>(this, getChannel());
private List<IAEItemStack> itemCache = null;
@@ -153,8 +156,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
}
if (type == Actionable.SIMULATE) {
return ItemFluidDrop.newAeStack(fluidGrid.injectItems(fluidStack.copy(), Actionable.SIMULATE, src));
}
else {
} else {
return ItemFluidDrop.newAeStack(fluidGrid.injectItems(fluidStack.copy(), Actionable.MODULATE, src));
}
}
@@ -175,8 +177,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
}
if (mode == Actionable.SIMULATE) {
return ItemFluidDrop.newAeStack(fluidGrid.extractItems(fluidStack.copy(), Actionable.SIMULATE, src));
}
else {
} else {
return ItemFluidDrop.newAeStack(fluidGrid.extractItems(fluidStack.copy(), Actionable.MODULATE, src));
}
}
@@ -213,7 +214,8 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
}
@Override
public void postChange(IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change, BaseActionSource actionSource) {
public void postChange(
IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change, BaseActionSource actionSource) {
itemCache = null;
try {
List<IAEItemStack> mappedChanges = new ArrayList<>();
@@ -223,8 +225,10 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
mappedChanges.add(itemStack);
}
}
getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class)
.postAlterationOfStoredItems(getChannel(), mappedChanges, ownActionSource);
getProxy()
.getGrid()
.<IStorageGrid>getCache(IStorageGrid.class)
.postAlterationOfStoredItems(getChannel(), mappedChanges, ownActionSource);
} catch (GridAccessException e) {
// NO-OP
}
@@ -254,8 +258,8 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
return null;
}
if (craftingGrid instanceof CraftingGridCache) {
IAEStack remaining = ((CraftingGridCache)craftingGrid).injectItems(
ItemFluidDrop.newAeStack(input), type, ownActionSource);
IAEStack remaining = ((CraftingGridCache) craftingGrid)
.injectItems(ItemFluidDrop.newAeStack(input), type, ownActionSource);
if (remaining instanceof IAEItemStack) {
return ItemFluidDrop.getAeFluidStack((IAEItemStack) remaining);
}
@@ -277,7 +281,5 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
public StorageChannel getChannel() {
return StorageChannel.FLUIDS;
}
}
}
@@ -24,6 +24,8 @@ import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.DualityFluidInterface;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
@@ -32,19 +34,11 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import javax.annotation.Nullable;
import java.io.IOException;
public class TileFluidInterface extends TileInterface implements IFluidHandler, IAEFluidInventory
{
public TileFluidInterface() {
super.getInterfaceDuality().getConfigManager()
.registerSetting(Settings.SIDELESS_MODE, SidelessMode.SIDELESS);
}
public class TileFluidInterface extends TileInterface implements IFluidHandler, IAEFluidInventory {
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this) {
private final IConfigManager dualityConfigManager = getInterfaceDuality().getConfigManager();
private final IConfigManager dualityConfigManager =
getInterfaceDuality().getConfigManager();
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
@@ -56,6 +50,11 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
return this.getTanks().drain(from.ordinal(), maxDrain, doDrain);
}
};
public TileFluidInterface() {
super.getInterfaceDuality().getConfigManager().registerSetting(Settings.SIDELESS_MODE, SidelessMode.SIDELESS);
}
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
@MENetworkEventSubscribe
@@ -85,12 +84,11 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
}
public AppEngInternalAEInventory getConfig() {
for (int i = 0; i < fluidDuality.getConfig().getSlots(); i ++) {
for (int i = 0; i < fluidDuality.getConfig().getSlots(); i++) {
IAEFluidStack fluid = fluidDuality.getConfig().getFluidInSlot(i);
if (fluid == null) {
config.setInventorySlotContents(i, null);
}
else {
} else {
config.setInventorySlotContents(i, ItemFluidPacket.newDisplayStack(fluid.getFluidStack()));
}
}
@@ -102,10 +100,10 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
TickingRequest item = super.getTickingRequest(node);
TickingRequest fluid = fluidDuality.getTickingRequest(node);
return new TickingRequest(
Math.min(item.minTickRate, fluid.minTickRate),
Math.max(item.maxTickRate, fluid.maxTickRate),
item.isSleeping && fluid.isSleeping,
true);
Math.min(item.minTickRate, fluid.minTickRate),
Math.max(item.maxTickRate, fluid.maxTickRate),
item.isSleeping && fluid.isSleeping,
true);
}
@Override
@@ -119,11 +117,11 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
}
}
@TileEvent( TileEventType.NETWORK_WRITE )
@TileEvent(TileEventType.NETWORK_WRITE)
protected void writeToStream(ByteBuf data) throws IOException {
for (int i = 0; i < config.getSizeInventory(); i++) {
ByteBufUtils.writeItemStack(data, config.getStackInSlot(i));
for (int j = 0; j < config.getSizeInventory(); j ++) {
for (int j = 0; j < config.getSizeInventory(); j++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
}
@@ -143,7 +141,7 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
}
}
@TileEvent( TileEventType.NETWORK_READ )
@TileEvent(TileEventType.NETWORK_READ)
protected boolean readFromStream(ByteBuf data) throws IOException {
boolean changed = false;
for (int i = 0; i < config.getSizeInventory(); i++) {
@@ -152,7 +150,7 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
config.setInventorySlotContents(i, stack);
changed = true;
}
for (int j = 0; j < config.getSizeInventory(); j ++) {
for (int j = 0; j < config.getSizeInventory(); j++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
}
@@ -176,17 +174,17 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
return changed;
}
@TileEvent( TileEventType.WORLD_NBT_READ )
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBTEvent(NBTTagCompound data) {
config.readFromNBT(data, "ConfigInv");
for (int i = 0; i < config.getSizeInventory(); i ++) {
for (int i = 0; i < config.getSizeInventory(); i++) {
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(i));
fluidDuality.getConfig().setFluidInSlot(i, fluidDuality.getStandardFluid(fluid));
}
getInternalFluid().readFromNBT(data, "FluidInv");
}
@TileEvent( TileEventType.WORLD_NBT_WRITE )
@TileEvent(TileEventType.WORLD_NBT_WRITE)
public NBTTagCompound writeToNBTEvent(NBTTagCompound data) {
config.writeToNBT(data, "ConfigInv");
getInternalFluid().writeToNBT(data, "FluidInv");
@@ -194,8 +192,7 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
}
@Nullable
protected ItemStack getItemFromTile( final Object obj )
{
protected ItemStack getItemFromTile(final Object obj) {
if (obj instanceof TileFluidInterface) {
return ItemAndBlockHolder.INTERFACE.stack();
}
@@ -203,9 +200,8 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
}
@Override
public int getInstalledUpgrades( final Upgrades u )
{
return getInterfaceDuality().getInstalledUpgrades( u );
public int getInstalledUpgrades(final Upgrades u) {
return getInterfaceDuality().getInstalledUpgrades(u);
}
@Override
@@ -247,7 +243,8 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
public void setConfig(int id, IAEFluidStack fluid) {
if (id >= 0 && id < 6) {
config.setInventorySlotContents(id, ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack()));
config.setInventorySlotContents(
id, ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack()));
fluidDuality.getConfig().setFluidInSlot(id, fluidDuality.getStandardFluid(fluid));
}
}
@@ -257,5 +254,4 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
getInternalFluid().setFluidInSlot(id, fluid);
}
}
}
@@ -66,7 +66,8 @@ public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickab
}
IAEFluidStack aeFluid = AEFluidStack.create(fluid.copy());
IEnergyGrid energyGrid = node.getGrid().getCache(IEnergyGrid.class);
IMEMonitor<IAEFluidStack> fluidGrid = node.getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
IMEMonitor<IAEFluidStack> fluidGrid =
node.getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
IAEFluidStack remaining = Platform.poweredInsert(energyGrid, fluidGrid, aeFluid, ownActionSource);
if (remaining != null) {
if (remaining.getStackSize() == aeFluid.getStackSize()) {
@@ -82,7 +83,8 @@ public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickab
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
public void onChangeInventory(
IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
try {
getProxy().getTick().alertDevice(getProxy().getNode());
} catch (GridAccessException e) {
@@ -90,13 +92,13 @@ public class TileFluidPacketDecoder extends AENetworkTile implements IGridTickab
}
}
@TileEvent( TileEventType.WORLD_NBT_WRITE )
@TileEvent(TileEventType.WORLD_NBT_WRITE)
public NBTTagCompound writeToNBTEvent(NBTTagCompound data) {
inventory.writeToNBT(data, "Inventory");
return data;
}
@TileEvent( TileEventType.WORLD_NBT_READ )
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBTEvent(NBTTagCompound data) {
inventory.readFromNBT(data, "Inventory");
}
@@ -10,17 +10,17 @@ import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import com.glodblock.github.inventory.AeStackInventory;
import com.glodblock.github.inventory.AeStackInventoryImpl;
import java.util.List;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import java.util.List;
public class TileFluidPatternEncoder extends AEBaseTile implements IAEAppEngInventory {
private final AppEngInternalInventory patternInv = new AppEngInternalInventory(this, 2);
private final AeStackInventoryImpl<IAEItemStack> crafting = new AeStackInventoryImpl<>(StorageChannel.ITEMS, 9, this);
private final AeStackInventoryImpl<IAEItemStack> crafting =
new AeStackInventoryImpl<>(StorageChannel.ITEMS, 9, this);
private final AeStackInventoryImpl<IAEItemStack> output = new AeStackInventoryImpl<>(StorageChannel.ITEMS, 3, this);
public IInventory getInventory() {
@@ -41,7 +41,7 @@ public class TileFluidPatternEncoder extends AEBaseTile implements IAEAppEngInve
}
@Override
public void getDrops(final World w, final int x, final int y, final int z, final List<ItemStack> drops ) {
public void getDrops(final World w, final int x, final int y, final int z, final List<ItemStack> drops) {
for (ItemStack stack : patternInv) {
if (stack != null) {
drops.add(stack);
@@ -49,14 +49,14 @@ public class TileFluidPatternEncoder extends AEBaseTile implements IAEAppEngInve
}
}
@TileEvent( TileEventType.WORLD_NBT_READ )
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBTEvent(NBTTagCompound data) {
patternInv.readFromNBT(data, "Inventory");
crafting.readFromNbt(data, "CraftingSlots");
output.readFromNbt(data, "OutputSlots");
}
@TileEvent( TileEventType.WORLD_NBT_WRITE )
@TileEvent(TileEventType.WORLD_NBT_WRITE)
public NBTTagCompound writeToNBTEvent(NBTTagCompound data) {
patternInv.writeToNBT(data, "Inventory");
crafting.writeToNbt(data, "CraftingSlots");
@@ -65,8 +65,6 @@ public class TileFluidPatternEncoder extends AEBaseTile implements IAEAppEngInve
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
}
public void onChangeInventory(
IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {}
}
@@ -12,6 +12,8 @@ import com.glodblock.github.inventory.IAEFluidInventory;
import com.glodblock.github.inventory.IAEFluidTank;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import javax.annotation.Nonnull;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -21,9 +23,6 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import javax.annotation.Nonnull;
import java.io.IOException;
public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInventory, IFluidHandler {
private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 9);
@@ -51,7 +50,7 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven
@Override
public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) {
return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8};
return new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8};
}
@Override
@@ -85,7 +84,7 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven
}
}
@TileEvent( TileEventType.NETWORK_READ )
@TileEvent(TileEventType.NETWORK_READ)
protected boolean readFromStream(ByteBuf data) throws IOException {
boolean changed = false;
for (int i = 0; i < invItems.getSizeInventory(); i++) {
@@ -114,13 +113,13 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven
return changed;
}
@TileEvent( TileEventType.WORLD_NBT_READ )
@TileEvent(TileEventType.WORLD_NBT_READ)
public void readFromNBTEvent(NBTTagCompound data) {
invItems.readFromNBT(data, "ItemInv");
invFluids.readFromNBT(data, "FluidInv");
}
@TileEvent( TileEventType.WORLD_NBT_WRITE )
@TileEvent(TileEventType.WORLD_NBT_WRITE)
public NBTTagCompound writeToNBTEvent(NBTTagCompound data) {
invItems.writeToNBT(data, "ItemInv");
invFluids.writeToNBT(data, "FluidInv");
@@ -12,6 +12,8 @@ import com.glodblock.github.inventory.IAEFluidInventory;
import com.glodblock.github.inventory.IAEFluidTank;
import cpw.mods.fml.common.network.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import java.io.IOException;
import javax.annotation.Nonnull;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -21,9 +23,6 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import javax.annotation.Nonnull;
import java.io.IOException;
public class TileLargeIngredientBuffer extends AEBaseInvTile implements IAEFluidInventory, IFluidHandler {
private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 27);
@@ -51,7 +50,9 @@ public class TileLargeIngredientBuffer extends AEBaseInvTile implements IAEFluid
@Override
public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) {
return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
return new int[] {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26
};
}
@Override
@@ -40,13 +40,13 @@ import com.glodblock.github.inventory.AeStackInventory;
import com.glodblock.github.inventory.AeStackInventoryImpl;
import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import java.util.concurrent.Future;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import java.util.concurrent.Future;
public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInventory, IGridTickable, ICraftingRequester, IPowerChannelState {
public class TileLevelMaintainer extends AENetworkTile
implements IAEAppEngInventory, IGridTickable, ICraftingRequester, IPowerChannelState {
public static final int REQ_COUNT = 5;
public final InventoryRequest requests = new InventoryRequest(this);
@@ -74,10 +74,14 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven
try {
if (this.getProxy().isActive()) {
final IEnergyGrid energy = this.getProxy().getEnergy();
final double power = Math.ceil(ItemFluidDrop.isFluidStack(items) ? items.getStackSize() / 1000D : items.getStackSize());
final double power = Math.ceil(
ItemFluidDrop.isFluidStack(items) ? items.getStackSize() / 1000D : items.getStackSize());
if (energy.extractAEPower(power, mode, PowerMultiplier.CONFIG) > power - 0.01) {
if (ItemFluidDrop.isFluidStack(items)) {
IAEFluidStack notInserted = this.getProxy().getStorage().getFluidInventory().injectItems(ItemFluidDrop.getAeFluidStack(items), mode, this.source);
IAEFluidStack notInserted = this.getProxy()
.getStorage()
.getFluidInventory()
.injectItems(ItemFluidDrop.getAeFluidStack(items), mode, this.source);
items.setStackSize(notInserted.getStackSize());
return items;
} else {
@@ -90,6 +94,7 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven
}
return items;
}
@Override
public void jobStateChange(ICraftingLink link) {
if (this.requests.getLinks() != null) {
@@ -120,15 +125,17 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven
try {
ICraftingGrid cg = this.getProxy().getCrafting();
IGrid grid = this.getProxy().getGrid();
final IItemList<IAEItemStack> inv = this.getProxy().getStorage().getItemInventory().getStorageList();
final IItemList<IAEItemStack> inv =
this.getProxy().getStorage().getItemInventory().getStorageList();
for (int i = 0; i < REQ_COUNT; i++) {
IAEItemStack is = requests.getRequestQtyStack(i);
if (is != null && requests.getBatchSize(i) > 0) {
IAEItemStack craftItem = requests.getCraftItem(i);
if (cg.canEmitFor(craftItem) || cg.isRequesting(craftItem) ||
(inv.findPrecise(is) != null && inv.findPrecise(is).getStackSize() >= is.getStackSize()) || !this.requests.isDone(i)
)
continue;
if (cg.canEmitFor(craftItem)
|| cg.isRequesting(craftItem)
|| (inv.findPrecise(is) != null
&& inv.findPrecise(is).getStackSize() >= is.getStackSize())
|| !this.requests.isDone(i)) continue;
// do crafting
Future<ICraftingJob> jobTask = requests.getJobs()[i];
if (jobTask == null) {
@@ -162,7 +169,8 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
public void onChangeInventory(
IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
try {
getProxy().getTick().alertDevice(getProxy().getNode());
} catch (GridAccessException e) {
@@ -175,9 +183,7 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven
}
@Override
public void gridChanged() {
}
public void gridChanged() {}
@Override
public boolean isPowered() {
@@ -279,8 +285,8 @@ public class TileLevelMaintainer extends AENetworkTile implements IAEAppEngInven
try {
newState = this.getProxy().isActive()
&& this.getProxy().getEnergy().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG)
> 0.0001;
&& this.getProxy().getEnergy().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG)
> 0.0001;
} catch (final GridAccessException ignored) {
}
@@ -24,12 +24,11 @@ public class TileOCPatternEditor extends AEBaseInvTile {
@Override
public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) {
return new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
return new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
}
@Override
public boolean isItemValidForSlot( final int i, final ItemStack itemstack ) {
public boolean isItemValidForSlot(final int i, final ItemStack itemstack) {
return itemstack == null || itemstack.getItem() instanceof ItemEncodedPattern;
}
}