Applied-Energistics-2-tiler.../src/main/java/appeng/parts/automation/PartLevelEmitter.java

709 lines
20 KiB
Java
Raw Normal View History

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>.
*/
package appeng.parts.automation;
import java.util.Collection;
import java.util.Random;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
2014-08-11 07:08:31 +02:00
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
2014-02-09 02:34:52 +01:00
import net.minecraft.util.IIcon;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
2014-02-09 02:34:52 +01:00
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.FuzzyMode;
import appeng.api.config.LevelType;
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;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergyWatcher;
import appeng.api.networking.energy.IEnergyWatcherHost;
import appeng.api.networking.events.MENetworkChannelsChanged;
2014-08-13 07:33:13 +02:00
import appeng.api.networking.events.MENetworkCraftingPatternChange;
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;
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;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.AECableType;
2014-02-17 01:50:25 +01:00
import appeng.api.util.IConfigManager;
import appeng.client.texture.CableBusTextures;
import appeng.core.sync.GuiBridge;
import appeng.me.GridAccessException;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2014-08-11 07:08:31 +02:00
public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost,
IMEMonitorHandlerReceiver<IAEItemStack>, ICraftingProvider
{
final int FLAG_ON = 4;
final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 1 );
boolean prevState = false;
long lastReportedValue = 0;
long reportingValue = 0;
IStackWatcher myWatcher;
IEnergyWatcher myEnergyWatcher;
2014-08-11 07:08:31 +02:00
ICraftingWatcher myCraftingWatcher;
public long getReportingValue()
{
2014-12-29 15:13:47 +01:00
return this.reportingValue;
}
public void setReportingValue(long v)
{
2014-12-29 15:13:47 +01:00
this.reportingValue = v;
if ( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
this.configureWatchers();
else
2014-12-29 15:13:47 +01:00
this.updateState();
}
@MENetworkEventSubscribe
public void powerChanged(MENetworkPowerStatusChange c)
{
2014-12-29 15:13:47 +01:00
this.updateState();
}
@MENetworkEventSubscribe
public void channelChanged(MENetworkChannelsChanged c)
{
2014-12-29 15:13:47 +01:00
this.updateState();
}
@Override
public void upgradesChanged()
{
2014-12-29 15:13:47 +01:00
this.configureWatchers();
}
@Override
2014-02-17 01:50:25 +01:00
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
{
2014-12-29 15:13:47 +01:00
this.configureWatchers();
}
private void updateState()
{
2014-12-29 15:13:47 +01:00
if ( this.proxy.isActive() )
{
2014-12-29 15:13:47 +01:00
boolean isOn = this.isLevelEmitterOn();
if ( this.prevState != isOn )
2014-08-11 07:08:31 +02:00
{
2014-12-29 15:13:47 +01:00
this.host.markForUpdate();
TileEntity te = this.host.getTile();
this.prevState = isOn;
2014-08-11 07:08:31 +02:00
Platform.notifyBlocksOfNeighbors( te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord );
2014-12-29 15:13:47 +01:00
Platform.notifyBlocksOfNeighbors( te.getWorldObj(), te.xCoord + this.side.offsetX, te.yCoord + this.side.offsetY, te.zCoord + this.side.offsetZ );
2014-08-11 07:08:31 +02:00
}
}
}
@Override
public void writeToNBT(NBTTagCompound data)
{
super.writeToNBT( data );
2014-12-29 15:13:47 +01:00
data.setLong( "lastReportedValue", this.lastReportedValue );
data.setLong( "reportingValue", this.reportingValue );
data.setBoolean( "prevState", this.prevState );
this.config.writeToNBT( data, "config" );
}
@Override
public void readFromNBT(NBTTagCompound data)
{
super.readFromNBT( data );
2014-12-29 15:13:47 +01:00
this.lastReportedValue = data.getLong( "lastReportedValue" );
this.reportingValue = data.getLong( "reportingValue" );
this.prevState = data.getBoolean( "prevState" );
this.config.readFromNBT( data, "config" );
}
@Override
protected int populateFlags(int cf)
{
2014-12-29 15:13:47 +01:00
return cf | (this.prevState ? this.FLAG_ON : 0);
}
2014-08-11 07:08:31 +02:00
@Override
public void updateWatcher(ICraftingWatcher newWatcher)
{
2014-12-29 15:13:47 +01:00
this.myCraftingWatcher = newWatcher;
this.configureWatchers();
2014-08-11 07:08:31 +02:00
}
@Override
public void updateWatcher(IStackWatcher newWatcher)
{
2014-12-29 15:13:47 +01:00
this.myWatcher = newWatcher;
this.configureWatchers();
}
@Override
public void updateWatcher(IEnergyWatcher newWatcher)
{
2014-12-29 15:13:47 +01:00
this.myEnergyWatcher = newWatcher;
this.configureWatchers();
}
// update the system...
2014-09-21 01:50:11 +02:00
public void configureWatchers()
{
2014-12-29 15:13:47 +01:00
IAEItemStack myStack = this.config.getAEStackInSlot( 0 );
2014-12-29 15:13:47 +01:00
if ( this.myWatcher != null )
this.myWatcher.clear();
2014-12-29 15:13:47 +01:00
if ( this.myEnergyWatcher != null )
this.myEnergyWatcher.clear();
2014-12-29 15:13:47 +01:00
if ( this.myCraftingWatcher != null )
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
}
catch (GridAccessException e1)
{
// :/
}
2014-12-29 15:13:47 +01:00
if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
2014-08-11 07:08:31 +02:00
{
2014-12-29 15:13:47 +01:00
if ( this.myCraftingWatcher != null && myStack != null )
this.myCraftingWatcher.add( myStack );
2014-08-11 07:08:31 +02:00
return;
}
2014-12-29 15:13:47 +01:00
if ( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
{
2014-12-29 15:13:47 +01:00
if ( this.myEnergyWatcher != null )
this.myEnergyWatcher.add( (double) this.reportingValue );
try
{
// update to power...
2014-12-29 15:13:47 +01:00
this.lastReportedValue = (long) this.proxy.getEnergy().getStoredPower();
this.updateState();
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 );
}
catch (GridAccessException e)
{
// :P
}
return;
}
try
{
2014-12-29 15:13:47 +01:00
if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 || myStack == null )
{
2014-12-29 15:13:47 +01:00
this.proxy.getStorage().getItemInventory().addListener( this, this.proxy.getGrid() );
}
else
{
2014-12-29 15:13:47 +01:00
this.proxy.getStorage().getItemInventory().removeListener( this );
2014-12-29 15:13:47 +01:00
if ( this.myWatcher != null )
this.myWatcher.add( myStack );
}
2014-12-29 15:13:47 +01:00
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
}
catch (GridAccessException e)
{
// >.>
}
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
{
2014-12-29 15:13:47 +01:00
if ( inv == this.config )
this.configureWatchers();
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
}
@Override
public void postChange(IBaseMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change, BaseActionSource actionSource)
{
2014-12-29 15:13:47 +01:00
this.updateReportingValue( (IMEMonitor<IAEItemStack>) monitor );
}
@Override
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
{
if ( !player.isSneaking() )
{
if ( Platform.isClient() )
return true;
2014-12-29 15:13:47 +01:00
Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_LEVEL_EMITTER );
return true;
}
return false;
}
private void updateReportingValue(IMEMonitor<IAEItemStack> monitor)
{
2014-12-29 15:13:47 +01:00
IAEItemStack myStack = this.config.getAEStackInSlot( 0 );
if ( myStack == null )
{
2014-12-29 15:13:47 +01:00
this.lastReportedValue = 0;
for (IAEItemStack st : monitor.getStorageList())
2014-12-29 15:13:47 +01:00
this.lastReportedValue += st.getStackSize();
}
2014-12-29 15:13:47 +01:00
else if ( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
{
2014-12-29 15:13:47 +01:00
this.lastReportedValue = 0;
FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
Collection<IAEItemStack> fuzzyList = monitor.getStorageList().findFuzzy( myStack, fzMode );
for (IAEItemStack st : fuzzyList)
2014-12-29 15:13:47 +01:00
this.lastReportedValue += st.getStackSize();
}
else
{
IAEItemStack r = monitor.getStorageList().findPrecise( myStack );
if ( r == null )
2014-12-29 15:13:47 +01:00
this.lastReportedValue = 0;
else
2014-12-29 15:13:47 +01:00
this.lastReportedValue = r.getStackSize();
}
2014-12-29 15:13:47 +01:00
this.updateState();
}
@Override
public boolean isValid(Object effectiveGrid)
{
try
{
2014-12-29 15:13:47 +01:00
return this.proxy.getGrid() == effectiveGrid;
}
catch (GridAccessException e)
{
return false;
}
}
2014-08-11 07:08:31 +02:00
@Override
public void onRequestChange(ICraftingGrid craftingGrid, IAEItemStack what)
{
2014-12-29 15:13:47 +01:00
this.updateState();
2014-08-11 07:08:31 +02:00
}
@Override
2014-09-20 22:45:48 +02:00
public void onThresholdPass(IEnergyGrid energyGrid)
{
2014-12-29 15:13:47 +01:00
this.lastReportedValue = (long) energyGrid.getStoredPower();
this.updateState();
}
@Override
public void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan)
{
2014-12-29 15:13:47 +01:00
if ( chan == StorageChannel.ITEMS && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
{
2014-12-29 15:13:47 +01:00
this.lastReportedValue = fullStack.getStackSize();
this.updateState();
}
}
public PartLevelEmitter(ItemStack is) {
super( PartLevelEmitter.class, is );
2014-12-29 15:13:47 +01:00
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 );
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
{
2014-12-29 15:13:47 +01:00
rh.setTexture( this.is.getIconIndex() );
Tessellator.instance.startDrawingQuads();
2014-12-29 15:13:47 +01:00
this.renderTorchAtAngle( 0, -0.5, 0 );
Tessellator.instance.draw();
// rh.setBounds( 7, 7, 10, 9, 9, 15 );
// rh.renderInventoryBox( renderer );
}
double centerX;
double centerY;
double centerZ;
public void addVertexWithUV(double x, double y, double z, double u, double v)
{
Tessellator var12 = Tessellator.instance;
2014-12-29 15:13:47 +01:00
x -= this.centerX;
y -= this.centerY;
z -= this.centerZ;
2014-12-29 15:13:47 +01:00
if ( this.side == ForgeDirection.DOWN )
{
y = -y;
z = -z;
}
2014-12-29 15:13:47 +01:00
if ( this.side == ForgeDirection.EAST )
{
double m = x;
x = y;
y = m;
y = -y;
}
2014-12-29 15:13:47 +01:00
if ( this.side == ForgeDirection.WEST )
{
double m = x;
x = -y;
y = m;
}
2014-12-29 15:13:47 +01:00
if ( this.side == ForgeDirection.SOUTH )
{
double m = z;
z = y;
y = m;
y = -y;
}
2014-12-29 15:13:47 +01:00
if ( this.side == ForgeDirection.NORTH )
{
double m = z;
z = -y;
y = m;
}
2014-12-29 15:13:47 +01:00
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 );
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random r)
{
2014-12-29 15:13:47 +01:00
if ( this.isLevelEmitterOn() )
{
2014-12-29 15:13:47 +01:00
ForgeDirection d = this.side;
2014-09-28 20:56:16 +02:00
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 );
}
}
public void renderTorchAtAngle(double baseX, double baseY, double baseZ)
{
2014-12-29 15:13:47 +01:00
boolean isOn = this.isLevelEmitterOn();
IIcon offTexture = this.is.getIconIndex();
IIcon IIcon = (isOn ? CableBusTextures.LevelEmitterTorchOn.getIcon() : offTexture);
//
2014-12-29 15:13:47 +01:00
this.centerX = baseX + 0.5;
this.centerY = baseY + 0.5;
this.centerZ = baseZ + 0.5;
baseY += 7.0 / 16.0;
2014-09-28 00:50:06 +02: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);
*/
2014-02-09 02:34:52 +01:00
float var16 = IIcon.getMinU();
float var17 = IIcon.getMaxU();
float var18 = IIcon.getMinV();
float var19 = IIcon.getMaxV();
/*
* 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-09-28 20:56:16 +02:00
double var20 = IIcon.getInterpolatedU( 7.0D );
double var24 = IIcon.getInterpolatedU( 9.0D );
double var22 = IIcon.getInterpolatedV( 6.0D + (isOn ? 0 : 1.0D) );
double var26 = IIcon.getInterpolatedV( 8.0D + (isOn ? 0 : 1.0D) );
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 );
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;
double var422 = 0.1915D + 1.0 / 16.0;
double TorchLen = 0.625D;
double toff = 0.0d;
if ( !isOn )
{
toff = 1.0d / 16.0d;
}
Tessellator var12 = Tessellator.instance;
if ( isOn )
{
var12.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
var12.setBrightness( 11 << 20 | 11 << 4 );
}
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 );
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 );
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 );
}
2014-09-28 00:50:06 +02:00
boolean status = false;
private boolean isLevelEmitterOn()
{
if ( Platform.isClient() )
2014-12-29 15:13:47 +01:00
return (this.clientFlags & this.FLAG_ON) == this.FLAG_ON;
2014-12-29 15:13:47 +01:00
if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
2014-08-11 07:08:31 +02:00
{
try
{
2014-12-29 15:13:47 +01:00
return this.proxy.getCrafting().isRequesting( this.config.getAEStackInSlot( 0 ) );
2014-08-11 07:08:31 +02:00
}
catch (GridAccessException e)
{
// :P
}
2014-12-29 15:13:47 +01:00
return this.prevState;
2014-08-11 07:08:31 +02:00
}
2014-12-29 15:13:47 +01:00
boolean flipState = this.getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) == RedstoneMode.LOW_SIGNAL;
return flipState ? this.reportingValue >= this.lastReportedValue + 1 : this.reportingValue < this.lastReportedValue + 1;
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
{
2014-12-29 15:13:47 +01:00
rh.setTexture( this.is.getIconIndex() );
// 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 ) );
tess.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
2014-12-29 15:13:47 +01:00
this.renderTorchAtAngle( x, y, z );
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 );
// super.renderWorldBlock( world, x, y, z, block, modelId, renderer );
}
@Override
public IIcon getBreakingTexture()
{
2014-12-29 15:13:47 +01:00
return this.is.getIconIndex();
}
@Override
2014-09-20 22:20:53 +02:00
public void getBoxes(IPartCollisionHelper bch)
{
bch.addBox( 7, 7, 11, 9, 9, 16 );
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir)
{
return AECableType.SMART;
}
@Override
public int cableConnectionRenderTo()
{
return 16;
}
2014-01-06 07:54:51 +01:00
@Override
public boolean canConnectRedstone()
{
return true;
}
@Override
public int isProvidingStrongPower()
{
2014-12-29 15:13:47 +01:00
return this.prevState ? 15 : 0;
2014-01-06 07:54:51 +01:00
}
@Override
public int isProvidingWeakPower()
{
2014-12-29 15:13:47 +01:00
return this.prevState ? 15 : 0;
2014-01-06 07:54:51 +01:00
}
@Override
public IInventory getInventoryByName(String name)
{
if ( name.equals( "config" ) )
2014-12-29 15:13:47 +01:00
return this.config;
return super.getInventoryByName( name );
}
@Override
public void onListUpdate()
{
try
{
2014-12-29 15:13:47 +01:00
this.updateReportingValue( this.proxy.getStorage().getItemInventory() );
}
catch (GridAccessException e)
{
// ;P
}
}
2014-08-11 07:08:31 +02:00
@Override
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table)
{
return false;
}
@Override
public boolean isBusy()
{
return true;
}
@Override
public void provideCrafting(ICraftingProviderHelper craftingTracker)
{
2014-12-29 15:13:47 +01:00
if ( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 )
2014-08-11 07:08:31 +02:00
{
2014-12-29 15:13:47 +01:00
if ( this.settings.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 );
2014-08-11 07:08:31 +02:00
if ( what != null )
craftingTracker.setEmitable( what );
}
}
}
}