2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
package appeng.parts.automation;
|
|
|
|
|
2015-01-15 14:06:23 +01:00
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
import java.util.Collection;
|
2013-12-27 23:59:59 +01:00
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
2014-01-05 09:49:08 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.inventory.IInventory;
|
2014-08-11 07:08:31 +02:00
|
|
|
import net.minecraft.inventory.InventoryCrafting;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2014-01-05 09:49:08 +01:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraft.util.IIcon;
|
2014-01-05 09:49:08 +01:00
|
|
|
import net.minecraft.util.Vec3;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.world.World;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-12-29 21:59:05 +01:00
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.api.config.FuzzyMode;
|
2014-02-21 07:10:38 +01:00
|
|
|
import appeng.api.config.LevelType;
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.api.config.RedstoneMode;
|
|
|
|
import appeng.api.config.Settings;
|
|
|
|
import appeng.api.config.Upgrades;
|
2014-08-11 07:08:31 +02:00
|
|
|
import appeng.api.config.YesNo;
|
|
|
|
import appeng.api.networking.crafting.ICraftingGrid;
|
|
|
|
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
|
|
|
import appeng.api.networking.crafting.ICraftingProvider;
|
|
|
|
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
|
|
|
import appeng.api.networking.crafting.ICraftingWatcher;
|
|
|
|
import appeng.api.networking.crafting.ICraftingWatcherHost;
|
2014-02-21 07:10:38 +01:00
|
|
|
import appeng.api.networking.energy.IEnergyGrid;
|
|
|
|
import appeng.api.networking.energy.IEnergyWatcher;
|
|
|
|
import appeng.api.networking.energy.IEnergyWatcherHost;
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.api.networking.events.MENetworkChannelsChanged;
|
2014-08-13 07:33:13 +02:00
|
|
|
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.api.networking.events.MENetworkEventSubscribe;
|
|
|
|
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
|
|
|
import appeng.api.networking.security.BaseActionSource;
|
2014-06-27 07:44:56 +02:00
|
|
|
import appeng.api.networking.storage.IBaseMonitor;
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.api.networking.storage.IStackWatcher;
|
|
|
|
import appeng.api.networking.storage.IStackWatcherHost;
|
2014-09-20 22:20:53 +02:00
|
|
|
import appeng.api.parts.IPartCollisionHelper;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.parts.IPartRenderHelper;
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.api.storage.IMEMonitor;
|
2014-02-12 17:35:42 +01:00
|
|
|
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.api.storage.StorageChannel;
|
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
|
|
|
import appeng.api.storage.data.IAEStack;
|
|
|
|
import appeng.api.storage.data.IItemList;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.util.AECableType;
|
2014-02-17 01:50:25 +01:00
|
|
|
import appeng.api.util.IConfigManager;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.client.texture.CableBusTextures;
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.core.sync.GuiBridge;
|
2015-01-03 02:53:14 +01:00
|
|
|
import appeng.helpers.Reflected;
|
2014-01-05 09:49:08 +01:00
|
|
|
import appeng.me.GridAccessException;
|
|
|
|
import appeng.tile.inventory.AppEngInternalAEInventory;
|
|
|
|
import appeng.tile.inventory.InvOperation;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.util.Platform;
|
|
|
|
|
2015-01-15 14:06:23 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEItemStack>, ICraftingProvider
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
final int FLAG_ON = 4;
|
|
|
|
|
2014-09-29 09:54:34 +02:00
|
|
|
final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 1 );
|
2014-01-05 09:49:08 +01:00
|
|
|
|
|
|
|
boolean prevState = false;
|
|
|
|
|
|
|
|
long lastReportedValue = 0;
|
|
|
|
long reportingValue = 0;
|
|
|
|
|
|
|
|
IStackWatcher myWatcher;
|
2014-02-21 07:10:38 +01:00
|
|
|
IEnergyWatcher myEnergyWatcher;
|
2014-08-11 07:08:31 +02:00
|
|
|
ICraftingWatcher myCraftingWatcher;
|
2015-01-03 02:53:14 +01:00
|
|
|
double centerX;
|
|
|
|
double centerY;
|
|
|
|
double centerZ;
|
|
|
|
boolean status = false;
|
|
|
|
|
|
|
|
@Reflected
|
|
|
|
public PartLevelEmitter( ItemStack is )
|
|
|
|
{
|
|
|
|
super( is );
|
|
|
|
|
|
|
|
this.getConfigManager().registerSetting( Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL );
|
|
|
|
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
|
|
|
this.getConfigManager().registerSetting( Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL );
|
|
|
|
this.getConfigManager().registerSetting( Settings.CRAFT_VIA_REDSTONE, YesNo.NO );
|
|
|
|
}
|
2014-01-05 09:49:08 +01:00
|
|
|
|
|
|
|
public long getReportingValue()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.reportingValue;
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
2015-01-15 14:06:23 +01:00
|
|
|
public void setReportingValue( long v )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.reportingValue = v;
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.configureWatchers();
|
2014-02-21 07:10:38 +01:00
|
|
|
else
|
2014-12-29 15:13:47 +01:00
|
|
|
this.updateState();
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@MENetworkEventSubscribe
|
2015-01-15 14:06:23 +01:00
|
|
|
public void powerChanged( MENetworkPowerStatusChange c )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.updateState();
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void updateState()
|
|
|
|
{
|
2015-01-15 14:06:23 +01:00
|
|
|
boolean isOn = this.isLevelEmitterOn();
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.prevState != isOn )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2015-01-15 14:06:23 +01:00
|
|
|
this.host.markForUpdate();
|
|
|
|
TileEntity te = this.host.getTile();
|
|
|
|
this.prevState = isOn;
|
|
|
|
Platform.notifyBlocksOfNeighbors( te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord );
|
|
|
|
Platform.notifyBlocksOfNeighbors( te.getWorldObj(), te.xCoord + this.side.offsetX, te.yCoord + this.side.offsetY, te.zCoord + this.side.offsetZ );
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
private boolean isLevelEmitterOn()
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( Platform.isClient() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
return ( this.clientFlags & this.FLAG_ON ) == this.FLAG_ON;
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !this.proxy.isActive() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return this.proxy.getCrafting().isRequesting( this.config.getAEStackInSlot( 0 ) );
|
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
catch( GridAccessException e )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
// :P
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.prevState;
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean flipState = this.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) == RedstoneMode.LOW_SIGNAL;
|
|
|
|
return flipState ? this.reportingValue >= this.lastReportedValue + 1 : this.reportingValue < this.lastReportedValue + 1;
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
@MENetworkEventSubscribe
|
|
|
|
public void channelChanged( MENetworkChannelsChanged c )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.updateState();
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
2015-01-15 14:06:23 +01:00
|
|
|
protected int populateFlags( int cf )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-01-15 14:06:23 +01:00
|
|
|
return cf | ( this.prevState ? this.FLAG_ON : 0 );
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
2014-08-11 07:08:31 +02:00
|
|
|
@Override
|
2015-01-03 02:53:14 +01:00
|
|
|
public IIcon getBreakingTexture()
|
2014-08-11 07:08:31 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.is.getIconIndex();
|
2014-08-11 07:08:31 +02:00
|
|
|
}
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
@Override
|
2015-01-03 02:53:14 +01:00
|
|
|
public void updateWatcher( ICraftingWatcher newWatcher )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.myCraftingWatcher = newWatcher;
|
2014-12-29 15:13:47 +01:00
|
|
|
this.configureWatchers();
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
2014-02-21 07:10:38 +01:00
|
|
|
@Override
|
2015-01-03 02:53:14 +01:00
|
|
|
public void onRequestChange( ICraftingGrid craftingGrid, IAEItemStack what )
|
2014-02-21 07:10:38 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.updateState();
|
2014-02-21 07:10:38 +01:00
|
|
|
}
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
// update the system...
|
2014-09-21 01:50:11 +02:00
|
|
|
public void configureWatchers()
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
IAEItemStack myStack = this.config.getAEStackInSlot( 0 );
|
2014-01-05 09:49:08 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.myWatcher != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.myWatcher.clear();
|
2014-02-21 07:10:38 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.myEnergyWatcher != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.myEnergyWatcher.clear();
|
2014-02-21 07:10:38 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.myCraftingWatcher != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.myCraftingWatcher.clear();
|
2014-08-11 07:08:31 +02:00
|
|
|
|
2014-08-13 07:33:13 +02:00
|
|
|
try
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.proxy.getGrid().postEvent( new MENetworkCraftingPatternChange( this, this.proxy.getNode() ) );
|
2014-08-13 07:33:13 +02:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
catch( GridAccessException e1 )
|
2014-08-13 07:33:13 +02:00
|
|
|
{
|
|
|
|
// :/
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
2014-08-11 07:08:31 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.myCraftingWatcher != null && myStack != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.myCraftingWatcher.add( myStack );
|
2014-08-11 07:08:31 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
2014-02-21 07:10:38 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.myEnergyWatcher != null )
|
2015-01-03 02:53:14 +01:00
|
|
|
this.myEnergyWatcher.add( (double) this.reportingValue );
|
2014-02-21 07:10:38 +01:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// update to power...
|
2015-01-03 02:53:14 +01:00
|
|
|
this.lastReportedValue = (long) this.proxy.getEnergy().getStoredPower();
|
2014-12-29 15:13:47 +01:00
|
|
|
this.updateState();
|
2014-02-21 07:10:38 +01:00
|
|
|
|
2014-09-21 02:33:59 +02:00
|
|
|
// no more item stuff..
|
2014-12-29 15:13:47 +01:00
|
|
|
this.proxy.getStorage().getItemInventory().removeListener( this );
|
2014-02-21 07:10:38 +01:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
catch( GridAccessException e )
|
2014-02-21 07:10:38 +01:00
|
|
|
{
|
|
|
|
// :P
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
try
|
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 || myStack == null )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.proxy.getStorage().getItemInventory().addListener( this, this.proxy.getGrid() );
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.proxy.getStorage().getItemInventory().removeListener( this );
|
2014-01-05 09:49:08 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.myWatcher != null )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.myWatcher.add( myStack );
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
catch( GridAccessException e )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
|
|
|
// >.>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-15 14:06:23 +01:00
|
|
|
private void updateReportingValue( IMEMonitor<IAEItemStack> monitor )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
IAEItemStack myStack = this.config.getAEStackInSlot( 0 );
|
2014-01-05 09:49:08 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( myStack == null )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.lastReportedValue = 0;
|
2015-04-03 08:54:31 +02:00
|
|
|
for( IAEItemStack st : monitor.getStorageList() )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.lastReportedValue += st.getStackSize();
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
else if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.lastReportedValue = 0;
|
2015-01-03 02:53:14 +01:00
|
|
|
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
2014-01-05 09:49:08 +01:00
|
|
|
Collection<IAEItemStack> fuzzyList = monitor.getStorageList().findFuzzy( myStack, fzMode );
|
2015-04-03 08:54:31 +02:00
|
|
|
for( IAEItemStack st : fuzzyList )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.lastReportedValue += st.getStackSize();
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IAEItemStack r = monitor.getStorageList().findPrecise( myStack );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( r == null )
|
2014-12-29 15:13:47 +01:00
|
|
|
this.lastReportedValue = 0;
|
2014-01-05 09:49:08 +01:00
|
|
|
else
|
2014-12-29 15:13:47 +01:00
|
|
|
this.lastReportedValue = r.getStackSize();
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.updateState();
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
2014-08-11 07:08:31 +02:00
|
|
|
@Override
|
2015-01-03 02:53:14 +01:00
|
|
|
public void updateWatcher( IStackWatcher newWatcher )
|
2014-08-11 07:08:31 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.myWatcher = newWatcher;
|
|
|
|
this.configureWatchers();
|
2014-08-11 07:08:31 +02:00
|
|
|
}
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
@Override
|
2015-01-15 14:06:23 +01:00
|
|
|
public void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( chan == StorageChannel.ITEMS && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.lastReportedValue = fullStack.getStackSize();
|
|
|
|
this.updateState();
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-03 02:53:14 +01:00
|
|
|
public void updateWatcher( IEnergyWatcher newWatcher )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.myEnergyWatcher = newWatcher;
|
|
|
|
this.configureWatchers();
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
@Override
|
|
|
|
public void onThresholdPass( IEnergyGrid energyGrid )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.lastReportedValue = (long) energyGrid.getStoredPower();
|
|
|
|
this.updateState();
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
@Override
|
|
|
|
public boolean isValid( Object effectiveGrid )
|
|
|
|
{
|
|
|
|
try
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.proxy.getGrid() == effectiveGrid;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
catch( GridAccessException e )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return false;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
@Override
|
|
|
|
public void postChange( IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource actionSource )
|
|
|
|
{
|
|
|
|
this.updateReportingValue( (IMEMonitor<IAEItemStack>) monitor );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onListUpdate()
|
|
|
|
{
|
|
|
|
try
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
catch( GridAccessException e )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
// ;P
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
@Override
|
|
|
|
public AECableType getCableConnectionType( ForgeDirection dir )
|
|
|
|
{
|
|
|
|
return AECableType.SMART;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void getBoxes( IPartCollisionHelper bch )
|
|
|
|
{
|
|
|
|
bch.addBox( 7, 7, 11, 9, 9, 16 );
|
|
|
|
}
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
2015-01-03 02:53:14 +01:00
|
|
|
@SideOnly( Side.CLIENT )
|
|
|
|
public void renderInventory( IPartRenderHelper rh, RenderBlocks renderer )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
rh.setTexture( this.is.getIconIndex() );
|
|
|
|
Tessellator.instance.startDrawingQuads();
|
|
|
|
this.renderTorchAtAngle( 0, -0.5, 0 );
|
|
|
|
Tessellator.instance.draw();
|
|
|
|
// rh.setBounds( 7, 7, 10, 9, 9, 15 );
|
|
|
|
// rh.renderInventoryBox( renderer );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-01-15 14:06:23 +01:00
|
|
|
public void renderTorchAtAngle( double baseX, double baseY, double baseZ )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
boolean isOn = this.isLevelEmitterOn();
|
|
|
|
IIcon offTexture = this.is.getIconIndex();
|
2015-01-15 14:06:23 +01:00
|
|
|
IIcon IIcon = ( isOn ? CableBusTextures.LevelEmitterTorchOn.getIcon() : offTexture );
|
2013-12-27 23:59:59 +01:00
|
|
|
//
|
2014-12-29 15:13:47 +01:00
|
|
|
this.centerX = baseX + 0.5;
|
|
|
|
this.centerY = baseY + 0.5;
|
|
|
|
this.centerZ = baseZ + 0.5;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
baseY += 7.0 / 16.0;
|
2014-09-28 00:50:06 +02:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
double par10 = 0;
|
|
|
|
// double par11 = 0;
|
|
|
|
double Zero = 0;
|
|
|
|
|
|
|
|
/*
|
2014-02-09 02:34:52 +01:00
|
|
|
* double d5 = (double)IIcon.func_94209_e(); double d6 = (double)IIcon.func_94206_g(); double d7 =
|
|
|
|
* (double)IIcon.func_94212_f(); double d8 = (double)IIcon.func_94210_h(); double d9 =
|
|
|
|
* (double)IIcon.func_94214_a(7.0D); double d10 = (double)IIcon.func_94207_b(6.0D); double d11 =
|
|
|
|
* (double)IIcon.func_94214_a(9.0D); double d12 = (double)IIcon.func_94207_b(8.0D); double d13 =
|
|
|
|
* (double)IIcon.func_94214_a(7.0D); double d14 = (double)IIcon.func_94207_b(13.0D); double d15 =
|
|
|
|
* (double)IIcon.func_94214_a(9.0D); double d16 = (double)IIcon.func_94207_b(15.0D);
|
2013-12-27 23:59:59 +01:00
|
|
|
*/
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
float var16 = IIcon.getMinU();
|
|
|
|
float var17 = IIcon.getMaxU();
|
|
|
|
float var18 = IIcon.getMinV();
|
|
|
|
float var19 = IIcon.getMaxV();
|
2013-12-27 23:59:59 +01:00
|
|
|
/*
|
|
|
|
* float var16 = (float)var14 / 256.0F; float var17 = ((float)var14 + 15.99F) / 256.0F; float var18 =
|
|
|
|
* (float)var15 / 256.0F; float var19 = ((float)var15 + 15.99F) / 256.0F;
|
|
|
|
*/
|
2014-09-28 20:56:16 +02:00
|
|
|
double var20b = offTexture.getInterpolatedU( 7.0D );
|
|
|
|
double var24b = offTexture.getInterpolatedU( 9.0D );
|
2014-02-18 04:24:02 +01:00
|
|
|
|
2014-09-28 20:56:16 +02:00
|
|
|
double var20 = IIcon.getInterpolatedU( 7.0D );
|
|
|
|
double var24 = IIcon.getInterpolatedU( 9.0D );
|
2015-01-15 14:06:23 +01:00
|
|
|
double var22 = IIcon.getInterpolatedV( 6.0D + ( isOn ? 0 : 1.0D ) );
|
|
|
|
double var26 = IIcon.getInterpolatedV( 8.0D + ( isOn ? 0 : 1.0D ) );
|
2014-09-28 20:56:16 +02:00
|
|
|
double var28 = IIcon.getInterpolatedU( 7.0D );
|
|
|
|
double var30 = IIcon.getInterpolatedV( 13.0D );
|
|
|
|
double var32 = IIcon.getInterpolatedU( 9.0D );
|
|
|
|
double var34 = IIcon.getInterpolatedV( 15.0D );
|
2014-02-09 02:34:52 +01:00
|
|
|
|
2014-09-28 20:56:16 +02:00
|
|
|
double var22b = IIcon.getInterpolatedV( 9.0D );
|
|
|
|
double var26b = IIcon.getInterpolatedV( 11.0D );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
baseX += 0.5D;
|
|
|
|
baseZ += 0.5D;
|
|
|
|
double var36 = baseX - 0.5D;
|
|
|
|
double var38 = baseX + 0.5D;
|
|
|
|
double var40 = baseZ - 0.5D;
|
|
|
|
double var42 = baseZ + 0.5D;
|
|
|
|
double var44 = 0.0625D;
|
2014-02-18 04:24:02 +01:00
|
|
|
double var422 = 0.1915D + 1.0 / 16.0;
|
2013-12-27 23:59:59 +01:00
|
|
|
double TorchLen = 0.625D;
|
|
|
|
|
|
|
|
double toff = 0.0d;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !isOn )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
toff = 1.0d / 16.0d;
|
|
|
|
}
|
|
|
|
|
|
|
|
Tessellator var12 = Tessellator.instance;
|
2015-04-03 08:54:31 +02:00
|
|
|
if( isOn )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
var12.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
|
|
|
|
var12.setBrightness( 11 << 20 | 11 << 4 );
|
|
|
|
}
|
|
|
|
|
2015-01-15 14:06:23 +01:00
|
|
|
this.addVertexWithUV( baseX + Zero * ( 1.0D - TorchLen ) - var44, baseY + TorchLen - toff, baseZ + par10 * ( 1.0D - TorchLen ) - var44, var20, var22 );
|
|
|
|
this.addVertexWithUV( baseX + Zero * ( 1.0D - TorchLen ) - var44, baseY + TorchLen - toff, baseZ + par10 * ( 1.0D - TorchLen ) + var44, var20, var26 );
|
|
|
|
this.addVertexWithUV( baseX + Zero * ( 1.0D - TorchLen ) + var44, baseY + TorchLen - toff, baseZ + par10 * ( 1.0D - TorchLen ) + var44, var24, var26 );
|
|
|
|
this.addVertexWithUV( baseX + Zero * ( 1.0D - TorchLen ) + var44, baseY + TorchLen - toff, baseZ + par10 * ( 1.0D - TorchLen ) - var44, var24, var22 );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-01-15 14:06:23 +01:00
|
|
|
this.addVertexWithUV( baseX + Zero * ( 1.0D - TorchLen ) + var44, baseY + var422, baseZ + par10 * ( 1.0D - TorchLen ) - var44, var24b, var22b );
|
|
|
|
this.addVertexWithUV( baseX + Zero * ( 1.0D - TorchLen ) + var44, baseY + var422, baseZ + par10 * ( 1.0D - TorchLen ) + var44, var24b, var26b );
|
|
|
|
this.addVertexWithUV( baseX + Zero * ( 1.0D - TorchLen ) - var44, baseY + var422, baseZ + par10 * ( 1.0D - TorchLen ) + var44, var20b, var26b );
|
|
|
|
this.addVertexWithUV( baseX + Zero * ( 1.0D - TorchLen ) - var44, baseY + var422, baseZ + par10 * ( 1.0D - TorchLen ) - var44, var20b, var22b );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
this.addVertexWithUV( baseX + var44 + Zero, baseY, baseZ - var44 + par10, var32, var30 );
|
|
|
|
this.addVertexWithUV( baseX + var44 + Zero, baseY, baseZ + var44 + par10, var32, var34 );
|
|
|
|
this.addVertexWithUV( baseX - var44 + Zero, baseY, baseZ + var44 + par10, var28, var34 );
|
|
|
|
this.addVertexWithUV( baseX - var44 + Zero, baseY, baseZ - var44 + par10, var28, var30 );
|
|
|
|
|
2014-09-28 20:56:16 +02:00
|
|
|
this.addVertexWithUV( baseX - var44, baseY + 1.0D, var40, var16, var18 );
|
|
|
|
this.addVertexWithUV( baseX - var44 + Zero, baseY + 0.0D, var40 + par10, var16, var19 );
|
|
|
|
this.addVertexWithUV( baseX - var44 + Zero, baseY + 0.0D, var42 + par10, var17, var19 );
|
|
|
|
this.addVertexWithUV( baseX - var44, baseY + 1.0D, var42, var17, var18 );
|
|
|
|
|
|
|
|
this.addVertexWithUV( baseX + var44, baseY + 1.0D, var42, var16, var18 );
|
|
|
|
this.addVertexWithUV( baseX + Zero + var44, baseY + 0.0D, var42 + par10, var16, var19 );
|
|
|
|
this.addVertexWithUV( baseX + Zero + var44, baseY + 0.0D, var40 + par10, var17, var19 );
|
|
|
|
this.addVertexWithUV( baseX + var44, baseY + 1.0D, var40, var17, var18 );
|
|
|
|
|
|
|
|
this.addVertexWithUV( var36, baseY + 1.0D, baseZ + var44, var16, var18 );
|
|
|
|
this.addVertexWithUV( var36 + Zero, baseY + 0.0D, baseZ + var44 + par10, var16, var19 );
|
|
|
|
this.addVertexWithUV( var38 + Zero, baseY + 0.0D, baseZ + var44 + par10, var17, var19 );
|
|
|
|
this.addVertexWithUV( var38, baseY + 1.0D, baseZ + var44, var17, var18 );
|
|
|
|
|
|
|
|
this.addVertexWithUV( var38, baseY + 1.0D, baseZ - var44, var16, var18 );
|
|
|
|
this.addVertexWithUV( var38 + Zero, baseY + 0.0D, baseZ - var44 + par10, var16, var19 );
|
|
|
|
this.addVertexWithUV( var36 + Zero, baseY + 0.0D, baseZ - var44 + par10, var17, var19 );
|
|
|
|
this.addVertexWithUV( var36, baseY + 1.0D, baseZ - var44, var17, var18 );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
public void addVertexWithUV( double x, double y, double z, double u, double v )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
Tessellator var12 = Tessellator.instance;
|
|
|
|
|
|
|
|
x -= this.centerX;
|
|
|
|
y -= this.centerY;
|
|
|
|
z -= this.centerZ;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.side == ForgeDirection.DOWN )
|
2015-01-15 14:06:23 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
y = -y;
|
|
|
|
z = -z;
|
2015-01-15 14:06:23 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.side == ForgeDirection.EAST )
|
2015-01-15 14:06:23 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
double m = x;
|
|
|
|
x = y;
|
|
|
|
y = m;
|
|
|
|
y = -y;
|
2015-01-15 14:06:23 +01:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.side == ForgeDirection.WEST )
|
2014-08-11 07:08:31 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
double m = x;
|
|
|
|
x = -y;
|
|
|
|
y = m;
|
|
|
|
}
|
2014-08-11 07:08:31 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.side == ForgeDirection.SOUTH )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
double m = z;
|
|
|
|
z = y;
|
|
|
|
y = m;
|
|
|
|
y = -y;
|
2014-08-11 07:08:31 +02:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.side == ForgeDirection.NORTH )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
double m = z;
|
|
|
|
z = -y;
|
|
|
|
y = m;
|
|
|
|
}
|
|
|
|
|
|
|
|
x += this.centerX;// + orientation.offsetX * 0.4;
|
|
|
|
y += this.centerY;// + orientation.offsetY * 0.4;
|
|
|
|
z += this.centerZ;// + orientation.offsetZ * 0.4;
|
|
|
|
|
|
|
|
var12.addVertexWithUV( x, y, z, u, v );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-15 14:06:23 +01:00
|
|
|
@SideOnly( Side.CLIENT )
|
|
|
|
public void renderStatic( int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
rh.setTexture( this.is.getIconIndex() );
|
2013-12-27 23:59:59 +01:00
|
|
|
// rh.setTexture( CableBusTextures.ItemPartLevelEmitterOn.getIcon() );
|
|
|
|
|
|
|
|
// rh.setBounds( 2, 2, 14, 14, 14, 16 );
|
|
|
|
// rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
|
|
|
// rh.setBounds( 7, 7, 10, 9, 9, 15 );
|
|
|
|
// rh.renderBlock( x, y, z, renderer );
|
|
|
|
|
|
|
|
renderer.renderAllFaces = true;
|
|
|
|
|
|
|
|
Tessellator tess = Tessellator.instance;
|
2014-02-09 02:34:52 +01:00
|
|
|
tess.setBrightness( rh.getBlock().getMixedBrightnessForBlock( this.getHost().getTile().getWorldObj(), x, y, z ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
tess.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.renderTorchAtAngle( x, y, z );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
renderer.renderAllFaces = false;
|
|
|
|
|
|
|
|
rh.setBounds( 7, 7, 11, 9, 9, 12 );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.renderLights( x, y, z, rh, renderer );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
// super.renderWorldBlock( world, x, y, z, block, modelId, renderer );
|
|
|
|
}
|
|
|
|
|
2014-06-11 07:14:37 +02:00
|
|
|
@Override
|
2015-01-03 02:53:14 +01:00
|
|
|
public int isProvidingStrongPower()
|
2014-06-11 07:14:37 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.prevState ? 15 : 0;
|
2014-06-11 07:14:37 +02:00
|
|
|
}
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
@Override
|
|
|
|
public int isProvidingWeakPower()
|
|
|
|
{
|
|
|
|
return this.prevState ? 15 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void randomDisplayTick( World world, int x, int y, int z, Random r )
|
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.isLevelEmitterOn() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
ForgeDirection d = this.side;
|
|
|
|
|
|
|
|
double d0 = d.offsetX * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
|
|
|
|
double d1 = d.offsetY * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
|
|
|
|
double d2 = d.offsetZ * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
|
|
|
|
|
|
|
|
world.spawnParticle( "reddust", 0.5 + x + d0, 0.5 + y + d1, 0.5 + z + d2, 0.0D, 0.0D, 0.0D );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
|
|
|
public int cableConnectionRenderTo()
|
|
|
|
{
|
|
|
|
return 16;
|
|
|
|
}
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
@Override
|
|
|
|
public boolean onPartActivate( EntityPlayer player, Vec3 pos )
|
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !player.isSneaking() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( Platform.isClient() )
|
2015-01-03 02:53:14 +01:00
|
|
|
return true;
|
|
|
|
|
|
|
|
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_LEVEL_EMITTER );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-01-06 07:54:51 +01:00
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
2014-01-06 07:54:51 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
this.configureWatchers();
|
2014-01-06 07:54:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack )
|
2014-01-06 07:54:51 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( inv == this.config )
|
|
|
|
this.configureWatchers();
|
2014-01-06 07:54:51 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
|
|
|
}
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2014-01-06 07:54:51 +01:00
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public void upgradesChanged()
|
2014-01-06 07:54:51 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
this.configureWatchers();
|
2014-01-06 07:54:51 +01:00
|
|
|
}
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public boolean canConnectRedstone()
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
return true;
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
2014-02-21 07:10:38 +01:00
|
|
|
|
2014-03-28 05:31:06 +01:00
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public void readFromNBT( NBTTagCompound data )
|
2014-03-28 05:31:06 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
super.readFromNBT( data );
|
|
|
|
this.lastReportedValue = data.getLong( "lastReportedValue" );
|
|
|
|
this.reportingValue = data.getLong( "reportingValue" );
|
|
|
|
this.prevState = data.getBoolean( "prevState" );
|
|
|
|
this.config.readFromNBT( data, "config" );
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public void writeToNBT( NBTTagCompound data )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
super.writeToNBT( data );
|
|
|
|
data.setLong( "lastReportedValue", this.lastReportedValue );
|
|
|
|
data.setLong( "reportingValue", this.reportingValue );
|
|
|
|
data.setBoolean( "prevState", this.prevState );
|
|
|
|
this.config.writeToNBT( data, "config" );
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public IInventory getInventoryByName( String name )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( name.equals( "config" ) )
|
|
|
|
return this.config;
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
return super.getInventoryByName( name );
|
2014-03-28 05:31:06 +01:00
|
|
|
}
|
|
|
|
|
2014-08-11 07:08:31 +02:00
|
|
|
@Override
|
2015-01-15 14:06:23 +01:00
|
|
|
public boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table )
|
2014-08-11 07:08:31 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isBusy()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-15 14:06:23 +01:00
|
|
|
public void provideCrafting( ICraftingProviderHelper craftingTracker )
|
2014-08-11 07:08:31 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
|
2014-08-11 07:08:31 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.getConfigManager().getSetting( Settings.CRAFT_VIA_REDSTONE ) == YesNo.YES )
|
2014-08-11 07:08:31 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
IAEItemStack what = this.config.getAEStackInSlot( 0 );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( what != null )
|
2014-08-11 07:08:31 +02:00
|
|
|
craftingTracker.setEmitable( what );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|