2013-12-27 23:59:59 +01:00
|
|
|
package appeng.parts.automation;
|
|
|
|
|
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;
|
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-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-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;
|
|
|
|
import appeng.api.networking.events.MENetworkEventSubscribe;
|
|
|
|
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
|
|
|
import appeng.api.networking.security.BaseActionSource;
|
|
|
|
import appeng.api.networking.storage.IStackWatcher;
|
|
|
|
import appeng.api.networking.storage.IStackWatcherHost;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.parts.IPartCollsionHelper;
|
|
|
|
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;
|
|
|
|
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;
|
2014-02-07 06:51:19 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-21 07:10:38 +01:00
|
|
|
public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, IMEMonitorHandlerReceiver<IAEItemStack>
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
final int FLAG_ON = 4;
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 1 );
|
|
|
|
|
|
|
|
boolean prevState = false;
|
|
|
|
|
|
|
|
long lastReportedValue = 0;
|
|
|
|
long reportingValue = 0;
|
|
|
|
|
|
|
|
IStackWatcher myWatcher;
|
2014-02-21 07:10:38 +01:00
|
|
|
IEnergyWatcher myEnergyWatcher;
|
2014-01-05 09:49:08 +01:00
|
|
|
|
|
|
|
public long getReportingValue()
|
|
|
|
{
|
|
|
|
return reportingValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setReportingValue(long v)
|
|
|
|
{
|
|
|
|
reportingValue = v;
|
2014-02-21 07:10:38 +01:00
|
|
|
if ( getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
|
|
|
confgiureWatchers();
|
|
|
|
else
|
|
|
|
updateState();
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@MENetworkEventSubscribe
|
|
|
|
public void powerChanged(MENetworkPowerStatusChange c)
|
|
|
|
{
|
|
|
|
updateState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@MENetworkEventSubscribe
|
|
|
|
public void channelChanged(MENetworkChannelsChanged c)
|
|
|
|
{
|
|
|
|
updateState();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void upgradesChanged()
|
|
|
|
{
|
|
|
|
confgiureWatchers();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-17 01:50:25 +01:00
|
|
|
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
|
|
|
confgiureWatchers();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateState()
|
|
|
|
{
|
|
|
|
if ( prevState != isLevelEmitterOn() && proxy.isActive() )
|
|
|
|
{
|
|
|
|
host.markForUpdate();
|
|
|
|
TileEntity te = host.getTile();
|
|
|
|
prevState = isLevelEmitterOn();
|
2014-02-09 02:34:52 +01:00
|
|
|
te.getWorldObj().notifyBlocksOfNeighborChange( te.xCoord, te.yCoord, te.zCoord, Platform.air );
|
|
|
|
te.getWorldObj().notifyBlocksOfNeighborChange( te.xCoord + side.offsetX, te.yCoord + side.offsetY, te.zCoord + side.offsetZ, Platform.air );
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void writeToNBT(NBTTagCompound data)
|
|
|
|
{
|
|
|
|
super.writeToNBT( data );
|
|
|
|
data.setLong( "lastReportedValue", lastReportedValue );
|
|
|
|
data.setLong( "reportingValue", reportingValue );
|
|
|
|
data.setBoolean( "prevState", prevState );
|
|
|
|
config.writeToNBT( data, "config" );
|
|
|
|
}
|
|
|
|
|
|
|
|
public void readFromNBT(NBTTagCompound data)
|
|
|
|
{
|
|
|
|
super.readFromNBT( data );
|
|
|
|
lastReportedValue = data.getLong( "lastReportedValue" );
|
|
|
|
reportingValue = data.getLong( "reportingValue" );
|
|
|
|
prevState = data.getBoolean( "prevState" );
|
|
|
|
config.readFromNBT( data, "config" );
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
|
|
|
protected int populateFlags(int cf)
|
|
|
|
{
|
2014-01-05 09:49:08 +01:00
|
|
|
return cf | (prevState ? FLAG_ON : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateWatcher(IStackWatcher newWatcher)
|
|
|
|
{
|
|
|
|
myWatcher = newWatcher;
|
|
|
|
confgiureWatchers();
|
|
|
|
}
|
|
|
|
|
2014-02-21 07:10:38 +01:00
|
|
|
@Override
|
|
|
|
public void updateWatcher(IEnergyWatcher newWatcher)
|
|
|
|
{
|
|
|
|
myEnergyWatcher = newWatcher;
|
|
|
|
confgiureWatchers();
|
|
|
|
}
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
// update the system...
|
|
|
|
public void confgiureWatchers()
|
|
|
|
{
|
|
|
|
IAEItemStack myStack = config.getAEStackInSlot( 0 );
|
|
|
|
|
|
|
|
if ( myWatcher != null )
|
|
|
|
myWatcher.clear();
|
2014-02-21 07:10:38 +01:00
|
|
|
|
|
|
|
if ( myEnergyWatcher != null )
|
|
|
|
myEnergyWatcher.clear();
|
|
|
|
|
|
|
|
if ( getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL )
|
|
|
|
{
|
|
|
|
if ( myEnergyWatcher != null )
|
|
|
|
myEnergyWatcher.add( (double) reportingValue );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// update to power...
|
|
|
|
lastReportedValue = (long) proxy.getEnergy().getStoredPower();
|
|
|
|
updateState();
|
|
|
|
|
|
|
|
// no more item stuf..
|
|
|
|
proxy.getStorage().getItemInventory().removeListener( this );
|
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
// :P
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if ( getInstalledUpgrades( Upgrades.FUZZY ) > 0 || myStack == null )
|
|
|
|
{
|
|
|
|
proxy.getStorage().getItemInventory().addListener( this, proxy.getGrid() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
proxy.getStorage().getItemInventory().removeListener( this );
|
|
|
|
|
|
|
|
if ( myWatcher != null )
|
|
|
|
myWatcher.add( myStack );
|
|
|
|
}
|
|
|
|
|
|
|
|
updateReportingValue( proxy.getStorage().getItemInventory() );
|
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
// >.>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack)
|
|
|
|
{
|
|
|
|
if ( inv == config )
|
|
|
|
confgiureWatchers();
|
|
|
|
|
|
|
|
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void postChange(IMEMonitor<IAEItemStack> monitor, IAEItemStack change, BaseActionSource actionSource)
|
|
|
|
{
|
|
|
|
updateReportingValue( monitor );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-20 06:18:49 +01:00
|
|
|
public boolean onPartActivate(EntityPlayer player, Vec3 pos)
|
2014-01-05 09:49:08 +01:00
|
|
|
{
|
|
|
|
if ( !player.isSneaking() )
|
|
|
|
{
|
|
|
|
if ( Platform.isClient() )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
Platform.openGUI( player, getHost().getTile(), side, GuiBridge.GUI_LEVELEMITTER );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateReportingValue(IMEMonitor<IAEItemStack> monitor)
|
|
|
|
{
|
|
|
|
IAEItemStack myStack = config.getAEStackInSlot( 0 );
|
|
|
|
|
|
|
|
if ( myStack == null )
|
|
|
|
{
|
|
|
|
lastReportedValue = 0;
|
|
|
|
for (IAEItemStack st : monitor.getStorageList())
|
|
|
|
lastReportedValue += st.getStackSize();
|
|
|
|
}
|
|
|
|
else if ( getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
|
|
|
{
|
|
|
|
lastReportedValue = 0;
|
|
|
|
FuzzyMode fzMode = (FuzzyMode) getConfigManager().getSetting( Settings.FUZZY_MODE );
|
|
|
|
Collection<IAEItemStack> fuzzyList = monitor.getStorageList().findFuzzy( myStack, fzMode );
|
|
|
|
for (IAEItemStack st : fuzzyList)
|
|
|
|
lastReportedValue += st.getStackSize();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IAEItemStack r = monitor.getStorageList().findPrecise( myStack );
|
|
|
|
if ( r == null )
|
|
|
|
lastReportedValue = 0;
|
|
|
|
else
|
|
|
|
lastReportedValue = r.getStackSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
updateState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isValid(Object effectiveGrid)
|
|
|
|
{
|
2014-02-06 05:36:10 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
return proxy.getGrid() == effectiveGrid;
|
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2014-01-05 09:49:08 +01:00
|
|
|
}
|
|
|
|
|
2014-02-21 07:10:38 +01:00
|
|
|
@Override
|
|
|
|
public void onThreshholdPass(IEnergyGrid energyGrid)
|
|
|
|
{
|
|
|
|
lastReportedValue = (long) energyGrid.getStoredPower();
|
|
|
|
updateState();
|
|
|
|
}
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
@Override
|
|
|
|
public void onStackChange(IItemList o, IAEStack fullStack, IAEStack diffStack, BaseActionSource src, StorageChannel chan)
|
|
|
|
{
|
|
|
|
if ( chan == StorageChannel.ITEMS && fullStack.equals( config.getAEStackInSlot( 0 ) ) && getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
|
|
|
|
{
|
|
|
|
lastReportedValue = fullStack.getStackSize();
|
|
|
|
updateState();
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public PartLevelEmitter(ItemStack is) {
|
|
|
|
super( PartLevelEmitter.class, is );
|
2014-01-05 09:49:08 +01:00
|
|
|
getConfigManager().registerSetting( Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL );
|
|
|
|
getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
2014-02-21 07:10:38 +01:00
|
|
|
getConfigManager().registerSetting( Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-27 23:59:59 +01:00
|
|
|
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
rh.setTexture( is.getIconIndex() );
|
|
|
|
Tessellator.instance.startDrawingQuads();
|
|
|
|
renderTorchAtAngle( 0, -0.5, 0 );
|
|
|
|
Tessellator.instance.draw();
|
|
|
|
// rh.setBounds( 7, 7, 10, 9, 9, 15 );
|
|
|
|
// rh.renderInventoryBox( renderer );
|
|
|
|
}
|
|
|
|
|
|
|
|
double cenx;
|
|
|
|
double ceny;
|
|
|
|
double cenz;
|
|
|
|
|
|
|
|
public void addVertexWithUV(double x, double y, double z, double u, double v)
|
|
|
|
{
|
|
|
|
Tessellator var12 = Tessellator.instance;
|
|
|
|
|
|
|
|
x -= cenx;
|
|
|
|
y -= ceny;
|
|
|
|
z -= cenz;
|
|
|
|
|
|
|
|
if ( side == ForgeDirection.DOWN )
|
|
|
|
{
|
|
|
|
y = -y;
|
|
|
|
z = -z;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( side == ForgeDirection.EAST )
|
|
|
|
{
|
|
|
|
double m = x;
|
|
|
|
x = y;
|
|
|
|
y = m;
|
|
|
|
y = -y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( side == ForgeDirection.WEST )
|
|
|
|
{
|
|
|
|
double m = x;
|
|
|
|
x = -y;
|
|
|
|
y = m;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( side == ForgeDirection.SOUTH )
|
|
|
|
{
|
|
|
|
double m = z;
|
|
|
|
z = y;
|
|
|
|
y = m;
|
|
|
|
y = -y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( side == ForgeDirection.NORTH )
|
|
|
|
{
|
|
|
|
double m = z;
|
|
|
|
z = -y;
|
|
|
|
y = m;
|
|
|
|
}
|
|
|
|
|
|
|
|
x += cenx;// + orientation.offsetX * 0.4;
|
|
|
|
y += ceny;// + orientation.offsetY * 0.4;
|
|
|
|
z += cenz;// + 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)
|
|
|
|
{
|
|
|
|
if ( isLevelEmitterOn() )
|
|
|
|
{
|
|
|
|
ForgeDirection d = side;
|
|
|
|
|
|
|
|
double d0 = (double) ((float) d.offsetX * 0.45F) + (double) (r.nextFloat() - 0.5F) * 0.2D;
|
|
|
|
double d1 = (double) ((float) d.offsetY * 0.45F) + (double) (r.nextFloat() - 0.5F) * 0.2D;
|
|
|
|
double d2 = (double) ((float) d.offsetZ * 0.45F) + (double) (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)
|
|
|
|
{
|
|
|
|
boolean isOn = isLevelEmitterOn();
|
2014-02-18 04:24:02 +01:00
|
|
|
IIcon offTexture = is.getIconIndex();
|
|
|
|
IIcon IIcon = (isOn ? CableBusTextures.LevelEmitterTorchOn.getIcon() : offTexture);
|
2013-12-27 23:59:59 +01:00
|
|
|
//
|
|
|
|
cenx = baseX + 0.5;
|
|
|
|
ceny = baseY + 0.5;
|
|
|
|
cenz = baseZ + 0.5;
|
|
|
|
|
|
|
|
baseY += 7.0 / 16.0;
|
|
|
|
;
|
|
|
|
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-02-18 04:24:02 +01:00
|
|
|
double var20b = (double) offTexture.getInterpolatedU( 7.0D );
|
|
|
|
double var24b = (double) offTexture.getInterpolatedU( 9.0D );
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
double var20 = (double) IIcon.getInterpolatedU( 7.0D );
|
|
|
|
double var24 = (double) IIcon.getInterpolatedU( 9.0D );
|
|
|
|
double var22 = (double) IIcon.getInterpolatedV( 6.0D + (isOn ? 0 : 1.0D) );
|
|
|
|
double var26 = (double) IIcon.getInterpolatedV( 8.0D + (isOn ? 0 : 1.0D) );
|
|
|
|
double var28 = (double) IIcon.getInterpolatedU( 7.0D );
|
|
|
|
double var30 = (double) IIcon.getInterpolatedV( 13.0D );
|
|
|
|
double var32 = (double) IIcon.getInterpolatedU( 9.0D );
|
|
|
|
double var34 = (double) IIcon.getInterpolatedV( 15.0D );
|
|
|
|
|
|
|
|
double var22b = (double) IIcon.getInterpolatedV( 9.0D );
|
|
|
|
double var26b = (double) 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;
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2014-02-18 04:24:02 +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 );
|
|
|
|
|
|
|
|
this.addVertexWithUV( baseX - var44, baseY + 1.0D, var40, (double) var16, (double) var18 );
|
|
|
|
this.addVertexWithUV( baseX - var44 + Zero, baseY + 0.0D, var40 + par10, (double) var16, (double) var19 );
|
|
|
|
this.addVertexWithUV( baseX - var44 + Zero, baseY + 0.0D, var42 + par10, (double) var17, (double) var19 );
|
|
|
|
this.addVertexWithUV( baseX - var44, baseY + 1.0D, var42, (double) var17, (double) var18 );
|
|
|
|
|
|
|
|
this.addVertexWithUV( baseX + var44, baseY + 1.0D, var42, (double) var16, (double) var18 );
|
|
|
|
this.addVertexWithUV( baseX + Zero + var44, baseY + 0.0D, var42 + par10, (double) var16, (double) var19 );
|
|
|
|
this.addVertexWithUV( baseX + Zero + var44, baseY + 0.0D, var40 + par10, (double) var17, (double) var19 );
|
|
|
|
this.addVertexWithUV( baseX + var44, baseY + 1.0D, var40, (double) var17, (double) var18 );
|
|
|
|
|
|
|
|
this.addVertexWithUV( var36, baseY + 1.0D, baseZ + var44, (double) var16, (double) var18 );
|
|
|
|
this.addVertexWithUV( var36 + Zero, baseY + 0.0D, baseZ + var44 + par10, (double) var16, (double) var19 );
|
|
|
|
this.addVertexWithUV( var38 + Zero, baseY + 0.0D, baseZ + var44 + par10, (double) var17, (double) var19 );
|
|
|
|
this.addVertexWithUV( var38, baseY + 1.0D, baseZ + var44, (double) var17, (double) var18 );
|
|
|
|
|
|
|
|
this.addVertexWithUV( var38, baseY + 1.0D, baseZ - var44, (double) var16, (double) var18 );
|
|
|
|
this.addVertexWithUV( var38 + Zero, baseY + 0.0D, baseZ - var44 + par10, (double) var16, (double) var19 );
|
|
|
|
this.addVertexWithUV( var36 + Zero, baseY + 0.0D, baseZ - var44 + par10, (double) var17, (double) var19 );
|
|
|
|
this.addVertexWithUV( var36, baseY + 1.0D, baseZ - var44, (double) var17, (double) var18 );
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean status = false;;
|
|
|
|
|
|
|
|
private boolean isLevelEmitterOn()
|
|
|
|
{
|
|
|
|
if ( Platform.isClient() )
|
|
|
|
return (clientFlags & FLAG_ON) == FLAG_ON;
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
boolean flipState = getConfigManager().getSetting( Settings.REDSTONE_EMITTER ) == RedstoneMode.LOW_SIGNAL;
|
|
|
|
return flipState ? reportingValue >= lastReportedValue + 1 : reportingValue < lastReportedValue + 1;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-27 23:59:59 +01:00
|
|
|
public void renderStatic(int x, int y, int z, IPartRenderHelper rh, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
rh.setTexture( 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 ) );
|
2013-12-27 23:59:59 +01:00
|
|
|
tess.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
|
|
|
|
|
|
|
|
renderTorchAtAngle( x, y, z );
|
|
|
|
|
|
|
|
renderer.renderAllFaces = false;
|
|
|
|
|
|
|
|
rh.setBounds( 7, 7, 11, 9, 9, 12 );
|
|
|
|
renderLights( x, y, z, rh, renderer );
|
|
|
|
|
|
|
|
// super.renderWorldBlock( world, x, y, z, block, modelId, renderer );
|
|
|
|
}
|
|
|
|
|
2014-06-11 07:14:37 +02:00
|
|
|
@Override
|
|
|
|
public IIcon getBreakingTexture()
|
|
|
|
{
|
|
|
|
return is.getIconIndex();
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
@Override
|
|
|
|
public void getBoxes(IPartCollsionHelper bch)
|
|
|
|
{
|
2014-02-18 04:24:02 +01:00
|
|
|
bch.addBox( 7, 7, 11, 9, 9, 16 );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@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()
|
|
|
|
{
|
|
|
|
return prevState ? 15 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int isProvidingWeakPower()
|
|
|
|
{
|
|
|
|
return prevState ? 15 : 0;
|
|
|
|
}
|
|
|
|
|
2014-01-05 09:49:08 +01:00
|
|
|
@Override
|
|
|
|
public IInventory getInventoryByName(String name)
|
|
|
|
{
|
|
|
|
if ( name.equals( "config" ) )
|
|
|
|
return config;
|
|
|
|
|
|
|
|
return super.getInventoryByName( name );
|
|
|
|
}
|
2014-02-21 07:10:38 +01:00
|
|
|
|
2014-03-28 05:31:06 +01:00
|
|
|
@Override
|
|
|
|
public void onListUpdate()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
updateReportingValue( proxy.getStorage().getItemInventory() );
|
|
|
|
}
|
|
|
|
catch (GridAccessException e)
|
|
|
|
{
|
|
|
|
// ;P
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|