reformatted all src files (#141)

This commit is contained in:
YoungOnion
2022-09-17 05:08:02 -06:00
committed by GitHub
parent 3328bfcda2
commit 9011273229
1056 changed files with 88127 additions and 110597 deletions
@@ -19,34 +19,28 @@
package appeng.tile.networking;
import appeng.api.parts.IPart;
import appeng.tile.AEBaseTile;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.EnumFacing;
import appeng.api.parts.IPart;
import appeng.tile.AEBaseTile;
public class CableBusTESR extends TileEntitySpecialRenderer<AEBaseTile> {
public class CableBusTESR extends TileEntitySpecialRenderer<AEBaseTile>
{
@Override
public void render(AEBaseTile te, double x, double y, double z, float partialTicks, int destroyStage, float p_render_10_) {
@Override
public void render( AEBaseTile te, double x, double y, double z, float partialTicks, int destroyStage, float p_render_10_ )
{
if (!(te instanceof TileCableBusTESR)) {
return;
}
if( !( te instanceof TileCableBusTESR ) )
{
return;
}
TileCableBusTESR realTe = (TileCableBusTESR) te;
TileCableBusTESR realTe = (TileCableBusTESR) te;
for( EnumFacing facing : EnumFacing.values() )
{
IPart part = realTe.getPart( facing );
if( part != null && part.requireDynamicRender() )
{
part.renderDynamic( x, y, z, partialTicks, destroyStage );
}
}
}
for (EnumFacing facing : EnumFacing.values()) {
IPart part = realTe.getPart(facing);
if (part != null && part.requireDynamicRender()) {
part.renderDynamic(x, y, z, partialTicks, destroyStage);
}
}
}
}
@@ -19,26 +19,6 @@
package appeng.tile.networking;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import appeng.api.networking.IGridNode;
import appeng.api.parts.IFacadeContainer;
import appeng.api.parts.IPart;
@@ -55,363 +35,320 @@ import appeng.hooks.TickHandler;
import appeng.parts.CableBusContainer;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.List;
import java.util.Set;
public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomCollision
{
public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomCollision {
private CableBusContainer cb = new CableBusContainer( this );
private CableBusContainer cb = new CableBusContainer(this);
private int oldLV = -1; // on re-calculate light when it changes
private int oldLV = -1; // on re-calculate light when it changes
@Override
public void readFromNBT( final NBTTagCompound data )
{
super.readFromNBT( data );
this.getCableBus().readFromNBT( data );
}
@Override
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
this.getCableBus().readFromNBT(data);
}
@Override
public NBTTagCompound writeToNBT( final NBTTagCompound data )
{
super.writeToNBT( data );
this.getCableBus().writeToNBT( data );
return data;
}
@Override
public NBTTagCompound writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
this.getCableBus().writeToNBT(data);
return data;
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
{
final boolean c = super.readFromStream( data );
boolean ret = this.getCableBus().readFromStream( data );
@Override
protected boolean readFromStream(final ByteBuf data) throws IOException {
final boolean c = super.readFromStream(data);
boolean ret = this.getCableBus().readFromStream(data);
final int newLV = this.getCableBus().getLightValue();
if( newLV != this.oldLV )
{
this.oldLV = newLV;
this.world.checkLight( this.pos );
ret = true;
}
final int newLV = this.getCableBus().getLightValue();
if (newLV != this.oldLV) {
this.oldLV = newLV;
this.world.checkLight(this.pos);
ret = true;
}
this.updateTileSetting();
return ret || c;
}
this.updateTileSetting();
return ret || c;
}
@Override
protected void writeToStream( final ByteBuf data ) throws IOException
{
super.writeToStream( data );
this.getCableBus().writeToStream( data );
}
@Override
protected void writeToStream(final ByteBuf data) throws IOException {
super.writeToStream(data);
this.getCableBus().writeToStream(data);
}
/**
* Changes this tile to the TESR version if any of the parts require dynamic rendering.
*/
protected void updateTileSetting()
{
if( this.getCableBus().isRequiresDynamicRender() )
{
try
{
final TileCableBus tcb = (TileCableBus) BlockCableBus.getTesrTile().newInstance();
tcb.copyFrom( this );
this.getWorld().setTileEntity( this.pos, tcb );
}
catch( final Throwable ignored )
{
/**
* Changes this tile to the TESR version if any of the parts require dynamic rendering.
*/
protected void updateTileSetting() {
if (this.getCableBus().isRequiresDynamicRender()) {
try {
final TileCableBus tcb = (TileCableBus) BlockCableBus.getTesrTile().newInstance();
tcb.copyFrom(this);
this.getWorld().setTileEntity(this.pos, tcb);
} catch (final Throwable ignored) {
}
}
}
}
}
}
protected void copyFrom( final TileCableBus oldTile )
{
final CableBusContainer tmpCB = this.getCableBus();
this.setCableBus( oldTile.getCableBus() );
this.oldLV = oldTile.oldLV;
oldTile.setCableBus( tmpCB );
}
protected void copyFrom(final TileCableBus oldTile) {
final CableBusContainer tmpCB = this.getCableBus();
this.setCableBus(oldTile.getCableBus());
this.oldLV = oldTile.oldLV;
oldTile.setCableBus(tmpCB);
}
@Override
public double getMaxRenderDistanceSquared()
{
return 900.0;
}
@Override
public double getMaxRenderDistanceSquared() {
return 900.0;
}
@Override
public void invalidate()
{
super.invalidate();
this.getCableBus().removeFromWorld();
}
@Override
public void invalidate() {
super.invalidate();
this.getCableBus().removeFromWorld();
}
@Override
public void validate()
{
super.validate();
TickHandler.INSTANCE.addInit( this );
}
@Override
public void validate() {
super.validate();
TickHandler.INSTANCE.addInit(this);
}
@Override
public IGridNode getGridNode( final AEPartLocation dir )
{
return this.getCableBus().getGridNode( dir );
}
@Override
public IGridNode getGridNode(final AEPartLocation dir) {
return this.getCableBus().getGridNode(dir);
}
@Override
public AECableType getCableConnectionType( final AEPartLocation side )
{
return this.getCableBus().getCableConnectionType( side );
}
@Override
public AECableType getCableConnectionType(final AEPartLocation side) {
return this.getCableBus().getCableConnectionType(side);
}
@Override
public float getCableConnectionLength( AECableType cable )
{
return this.getCableBus().getCableConnectionLength( cable );
}
@Override
public float getCableConnectionLength(AECableType cable) {
return this.getCableBus().getCableConnectionLength(cable);
}
@Override
public void onChunkUnload()
{
super.onChunkUnload();
this.getCableBus().removeFromWorld();
}
@Override
public void onChunkUnload() {
super.onChunkUnload();
this.getCableBus().removeFromWorld();
}
@Override
public void markForUpdate()
{
if( this.world == null )
{
return;
}
@Override
public void markForUpdate() {
if (this.world == null) {
return;
}
final int newLV = this.getCableBus().getLightValue();
if( newLV != this.oldLV )
{
this.oldLV = newLV;
this.world.checkLight( this.pos );
}
final int newLV = this.getCableBus().getLightValue();
if (newLV != this.oldLV) {
this.oldLV = newLV;
this.world.checkLight(this.pos);
}
super.markForUpdate();
}
super.markForUpdate();
}
@Override
public boolean canBeRotated()
{
return false;
}
@Override
public boolean canBeRotated() {
return false;
}
@Override
public void getDrops( final World w, final BlockPos pos, final List drops )
{
this.getCableBus().getDrops( drops );
}
@Override
public void getDrops(final World w, final BlockPos pos, final List drops) {
this.getCableBus().getDrops(drops);
}
@Override
public void getNoDrops( final World w, final BlockPos pos, final List<ItemStack> drops )
{
this.getCableBus().getNoDrops( drops );
}
@Override
public void getNoDrops(final World w, final BlockPos pos, final List<ItemStack> drops) {
this.getCableBus().getNoDrops(drops);
}
@Override
public void onReady()
{
super.onReady();
if( this.getCableBus().isEmpty() )
{
if( this.world.getTileEntity( this.pos ) == this )
{
this.world.destroyBlock( this.pos, true );
}
}
else
{
this.getCableBus().addToWorld();
}
}
@Override
public void onReady() {
super.onReady();
if (this.getCableBus().isEmpty()) {
if (this.world.getTileEntity(this.pos) == this) {
this.world.destroyBlock(this.pos, true);
}
} else {
this.getCableBus().addToWorld();
}
}
@Override
public boolean requiresTESR()
{
return this.getCableBus().isRequiresDynamicRender();
}
@Override
public boolean requiresTESR() {
return this.getCableBus().isRequiresDynamicRender();
}
@Override
public IFacadeContainer getFacadeContainer()
{
return this.getCableBus().getFacadeContainer();
}
@Override
public IFacadeContainer getFacadeContainer() {
return this.getCableBus().getFacadeContainer();
}
@Override
public boolean canAddPart( final ItemStack is, final AEPartLocation side )
{
return this.getCableBus().canAddPart( is, side );
}
@Override
public boolean canAddPart(final ItemStack is, final AEPartLocation side) {
return this.getCableBus().canAddPart(is, side);
}
@Override
public AEPartLocation addPart( final ItemStack is, final AEPartLocation side, final EntityPlayer player, final EnumHand hand )
{
return this.getCableBus().addPart( is, side, player, hand );
}
@Override
public AEPartLocation addPart(final ItemStack is, final AEPartLocation side, final EntityPlayer player, final EnumHand hand) {
return this.getCableBus().addPart(is, side, player, hand);
}
@Override
public IPart getPart( final AEPartLocation side )
{
return this.cb.getPart( side );
}
@Override
public IPart getPart(final AEPartLocation side) {
return this.cb.getPart(side);
}
@Override
public IPart getPart( final EnumFacing side )
{
return this.getCableBus().getPart( side );
}
@Override
public IPart getPart(final EnumFacing side) {
return this.getCableBus().getPart(side);
}
@Override
public void removePart( final AEPartLocation side, final boolean suppressUpdate )
{
this.getCableBus().removePart( side, suppressUpdate );
}
@Override
public void removePart(final AEPartLocation side, final boolean suppressUpdate) {
this.getCableBus().removePart(side, suppressUpdate);
}
@Override
public DimensionalCoord getLocation()
{
return new DimensionalCoord( this );
}
@Override
public DimensionalCoord getLocation() {
return new DimensionalCoord(this);
}
@Override
public AEColor getColor()
{
return this.getCableBus().getColor();
}
@Override
public AEColor getColor() {
return this.getCableBus().getColor();
}
@Override
public void clearContainer()
{
this.setCableBus( new CableBusContainer( this ) );
}
@Override
public void clearContainer() {
this.setCableBus(new CableBusContainer(this));
}
@Override
public boolean isBlocked( final EnumFacing side )
{
// TODO 1.10.2-R - Stuff.
return false;
}
@Override
public boolean isBlocked(final EnumFacing side) {
// TODO 1.10.2-R - Stuff.
return false;
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool( final World w, final BlockPos pos, final Entity e, final boolean visual )
{
return this.getCableBus().getSelectedBoundingBoxesFromPool( false, true, e, visual );
}
@Override
public Iterable<AxisAlignedBB> getSelectedBoundingBoxesFromPool(final World w, final BlockPos pos, final Entity e, final boolean visual) {
return this.getCableBus().getSelectedBoundingBoxesFromPool(false, true, e, visual);
}
@Override
public SelectedPart selectPart( final Vec3d pos )
{
return this.getCableBus().selectPart( pos );
}
@Override
public SelectedPart selectPart(final Vec3d pos) {
return this.getCableBus().selectPart(pos);
}
@Override
public void markForSave()
{
this.saveChanges();
}
@Override
public void markForSave() {
this.saveChanges();
}
@Override
public void partChanged()
{
this.notifyNeighbors();
}
@Override
public void partChanged() {
this.notifyNeighbors();
}
@Override
public boolean hasRedstone( final AEPartLocation side )
{
return this.getCableBus().hasRedstone( side );
}
@Override
public boolean hasRedstone(final AEPartLocation side) {
return this.getCableBus().hasRedstone(side);
}
@Override
public boolean isEmpty()
{
return this.getCableBus().isEmpty();
}
@Override
public boolean isEmpty() {
return this.getCableBus().isEmpty();
}
@Override
public Set<LayerFlags> getLayerFlags()
{
return this.getCableBus().getLayerFlags();
}
@Override
public Set<LayerFlags> getLayerFlags() {
return this.getCableBus().getLayerFlags();
}
@Override
public void cleanup()
{
this.getWorld().setBlockToAir( this.pos );
}
@Override
public void cleanup() {
this.getWorld().setBlockToAir(this.pos);
}
@Override
public void addCollidingBlockToList( final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e )
{
for( final AxisAlignedBB bx : this.getSelectedBoundingBoxesFromPool( w, pos, e, false ) )
{
out.add( new AxisAlignedBB( bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ ) );
}
}
@Override
public void addCollidingBlockToList(final World w, final BlockPos pos, final AxisAlignedBB bb, final List<AxisAlignedBB> out, final Entity e) {
for (final AxisAlignedBB bx : this.getSelectedBoundingBoxesFromPool(w, pos, e, false)) {
out.add(new AxisAlignedBB(bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ));
}
}
@Override
public void notifyNeighbors()
{
if( this.world != null && this.world.isBlockLoaded( this.pos ) && !CableBusContainer.isLoading() )
{
Platform.notifyBlocksOfNeighbors( this.world, this.pos );
}
}
@Override
public void notifyNeighbors() {
if (this.world != null && this.world.isBlockLoaded(this.pos) && !CableBusContainer.isLoading()) {
Platform.notifyBlocksOfNeighbors(this.world, this.pos);
}
}
@Override
public boolean isInWorld()
{
return this.getCableBus().isInWorld();
}
@Override
public boolean isInWorld() {
return this.getCableBus().isInWorld();
}
@Override
public boolean recolourBlock( final EnumFacing side, final AEColor colour, final EntityPlayer who )
{
return this.getCableBus().recolourBlock( side, colour, who );
}
@Override
public boolean recolourBlock(final EnumFacing side, final AEColor colour, final EntityPlayer who) {
return this.getCableBus().recolourBlock(side, colour, who);
}
public CableBusContainer getCableBus()
{
return this.cb;
}
public CableBusContainer getCableBus() {
return this.cb;
}
private void setCableBus( final CableBusContainer cb )
{
this.cb = cb;
}
private void setCableBus(final CableBusContainer cb) {
this.cb = cb;
}
@Override
public boolean hasCapability( Capability<?> capabilityClass, @Nullable EnumFacing fromSide )
{
// Note that null will be translated to INTERNAL here
AEPartLocation partLocation = AEPartLocation.fromFacing( fromSide );
@Override
public boolean hasCapability(Capability<?> capabilityClass, @Nullable EnumFacing fromSide) {
// Note that null will be translated to INTERNAL here
AEPartLocation partLocation = AEPartLocation.fromFacing(fromSide);
IPart part = this.getPart( partLocation );
boolean result = part != null && part.hasCapability( capabilityClass );
IPart part = this.getPart(partLocation);
boolean result = part != null && part.hasCapability(capabilityClass);
return result || super.hasCapability( capabilityClass, fromSide );
}
return result || super.hasCapability(capabilityClass, fromSide);
}
@Override
public <T> T getCapability( Capability<T> capabilityClass, @Nullable EnumFacing fromSide )
{
// Note that null will be translated to INTERNAL here
AEPartLocation partLocation = AEPartLocation.fromFacing( fromSide );
@Override
public <T> T getCapability(Capability<T> capabilityClass, @Nullable EnumFacing fromSide) {
// Note that null will be translated to INTERNAL here
AEPartLocation partLocation = AEPartLocation.fromFacing(fromSide);
IPart part = this.getPart( partLocation );
T result = part == null ? null : part.getCapability( capabilityClass );
IPart part = this.getPart(partLocation);
T result = part == null ? null : part.getCapability(capabilityClass);
if( result != null )
{
return result;
}
if (result != null) {
return result;
}
return super.getCapability( capabilityClass, fromSide );
}
return super.getCapability(capabilityClass, fromSide);
}
}
@@ -22,27 +22,21 @@ package appeng.tile.networking;
import appeng.block.networking.BlockCableBus;
public class TileCableBusTESR extends TileCableBus
{
public class TileCableBusTESR extends TileCableBus {
/**
* Changes this tile to the non-TESR version, if none of the parts require dynamic rendering.
*/
@Override
protected void updateTileSetting()
{
if( !this.getCableBus().isRequiresDynamicRender() )
{
try
{
final TileCableBus tcb = (TileCableBus) BlockCableBus.getNoTesrTile().newInstance();
tcb.copyFrom( this );
this.getWorld().setTileEntity( this.pos, tcb );
}
catch( final Throwable ignored )
{
/**
* Changes this tile to the non-TESR version, if none of the parts require dynamic rendering.
*/
@Override
protected void updateTileSetting() {
if (!this.getCableBus().isRequiresDynamicRender()) {
try {
final TileCableBus tcb = (TileCableBus) BlockCableBus.getNoTesrTile().newInstance();
tcb.copyFrom(this);
this.getWorld().setTileEntity(this.pos, tcb);
} catch (final Throwable ignored) {
}
}
}
}
}
}
}
@@ -19,14 +19,6 @@
package appeng.tile.networking;
import java.util.EnumSet;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.EmptyHandler;
import appeng.api.config.Actionable;
import appeng.api.networking.GridFlags;
import appeng.api.networking.energy.IEnergyGrid;
@@ -43,177 +35,149 @@ import appeng.block.networking.BlockController.ControllerBlockState;
import appeng.me.GridAccessException;
import appeng.tile.grid.AENetworkPowerTile;
import appeng.util.inv.InvOperation;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.EmptyHandler;
import java.util.EnumSet;
public class TileController extends AENetworkPowerTile
{
private boolean isValid = false;
public class TileController extends AENetworkPowerTile {
private boolean isValid = false;
public TileController()
{
this.setInternalMaxPower( 8000 );
this.setInternalPublicPowerStorage( true );
this.getProxy().setIdlePowerUsage( 3 );
this.getProxy().setFlags( GridFlags.CANNOT_CARRY, GridFlags.DENSE_CAPACITY );
}
public TileController() {
this.setInternalMaxPower(8000);
this.setInternalPublicPowerStorage(true);
this.getProxy().setIdlePowerUsage(3);
this.getProxy().setFlags(GridFlags.CANNOT_CARRY, GridFlags.DENSE_CAPACITY);
}
@Override
public AECableType getCableConnectionType( final AEPartLocation dir )
{
return AECableType.DENSE_SMART;
}
@Override
public AECableType getCableConnectionType(final AEPartLocation dir) {
return AECableType.DENSE_SMART;
}
@Override
public void onReady()
{
this.onNeighborChange( true );
super.onReady();
}
@Override
public void onReady() {
this.onNeighborChange(true);
super.onReady();
}
public void onNeighborChange( final boolean force )
{
final boolean xx = this.checkController( this.pos.offset( EnumFacing.EAST ) ) && this.checkController( this.pos.offset( EnumFacing.WEST ) );
final boolean yy = this.checkController( this.pos.offset( EnumFacing.UP ) ) && this.checkController( this.pos.offset( EnumFacing.DOWN ) );
final boolean zz = this.checkController( this.pos.offset( EnumFacing.NORTH ) ) && this.checkController( this.pos.offset( EnumFacing.SOUTH ) );
public void onNeighborChange(final boolean force) {
final boolean xx = this.checkController(this.pos.offset(EnumFacing.EAST)) && this.checkController(this.pos.offset(EnumFacing.WEST));
final boolean yy = this.checkController(this.pos.offset(EnumFacing.UP)) && this.checkController(this.pos.offset(EnumFacing.DOWN));
final boolean zz = this.checkController(this.pos.offset(EnumFacing.NORTH)) && this.checkController(this.pos.offset(EnumFacing.SOUTH));
// int meta = world.getBlockMetadata( xCoord, yCoord, zCoord );
// boolean hasPower = meta > 0;
// boolean isConflict = meta == 2;
// int meta = world.getBlockMetadata( xCoord, yCoord, zCoord );
// boolean hasPower = meta > 0;
// boolean isConflict = meta == 2;
final boolean oldValid = this.isValid;
final boolean oldValid = this.isValid;
this.isValid = ( xx && !yy && !zz ) || ( !xx && yy && !zz ) || ( !xx && !yy && zz ) || ( ( xx ? 1 : 0 ) + ( yy ? 1 : 0 ) + ( zz ? 1 : 0 ) <= 1 );
this.isValid = (xx && !yy && !zz) || (!xx && yy && !zz) || (!xx && !yy && zz) || ((xx ? 1 : 0) + (yy ? 1 : 0) + (zz ? 1 : 0) <= 1);
if( oldValid != this.isValid || force )
{
if( this.isValid )
{
this.getProxy().setValidSides( EnumSet.allOf( EnumFacing.class ) );
}
else
{
this.getProxy().setValidSides( EnumSet.noneOf( EnumFacing.class ) );
}
if (oldValid != this.isValid || force) {
if (this.isValid) {
this.getProxy().setValidSides(EnumSet.allOf(EnumFacing.class));
} else {
this.getProxy().setValidSides(EnumSet.noneOf(EnumFacing.class));
}
this.updateMeta();
}
this.updateMeta();
}
}
}
private void updateMeta()
{
if( !this.getProxy().isReady() )
{
return;
}
private void updateMeta() {
if (!this.getProxy().isReady()) {
return;
}
ControllerBlockState metaState = ControllerBlockState.offline;
ControllerBlockState metaState = ControllerBlockState.offline;
try
{
if( this.getProxy().getEnergy().isNetworkPowered() )
{
metaState = ControllerBlockState.online;
try {
if (this.getProxy().getEnergy().isNetworkPowered()) {
metaState = ControllerBlockState.online;
if( this.getProxy().getPath().getControllerState() == ControllerState.CONTROLLER_CONFLICT )
{
metaState = ControllerBlockState.conflicted;
}
}
}
catch( final GridAccessException e )
{
metaState = ControllerBlockState.offline;
}
if (this.getProxy().getPath().getControllerState() == ControllerState.CONTROLLER_CONFLICT) {
metaState = ControllerBlockState.conflicted;
}
}
} catch (final GridAccessException e) {
metaState = ControllerBlockState.offline;
}
if( this.checkController( this.pos ) && this.world.getBlockState( this.pos ).getValue( BlockController.CONTROLLER_STATE ) != metaState )
{
this.world.setBlockState( this.pos, this.world.getBlockState( this.pos ).withProperty( BlockController.CONTROLLER_STATE, metaState ) );
}
if (this.checkController(this.pos) && this.world.getBlockState(this.pos).getValue(BlockController.CONTROLLER_STATE) != metaState) {
this.world.setBlockState(this.pos, this.world.getBlockState(this.pos).withProperty(BlockController.CONTROLLER_STATE, metaState));
}
}
}
@Override
protected double getFunnelPowerDemand( final double maxReceived )
{
try
{
final IEnergyGrid grid = this.getProxy().getEnergy();
@Override
protected double getFunnelPowerDemand(final double maxReceived) {
try {
final IEnergyGrid grid = this.getProxy().getEnergy();
return grid.getEnergyDemand( maxReceived );
}
catch( final GridAccessException e )
{
// no grid? use local...
return super.getFunnelPowerDemand( maxReceived );
}
}
return grid.getEnergyDemand(maxReceived);
} catch (final GridAccessException e) {
// no grid? use local...
return super.getFunnelPowerDemand(maxReceived);
}
}
@Override
protected double funnelPowerIntoStorage( final double power, final Actionable mode )
{
try
{
final IEnergyGrid grid = this.getProxy().getEnergy();
final double leftOver = grid.injectPower( power, mode );
@Override
protected double funnelPowerIntoStorage(final double power, final Actionable mode) {
try {
final IEnergyGrid grid = this.getProxy().getEnergy();
final double leftOver = grid.injectPower(power, mode);
return leftOver;
}
catch( final GridAccessException e )
{
// no grid? use local...
return super.funnelPowerIntoStorage( power, mode );
}
}
return leftOver;
} catch (final GridAccessException e) {
// no grid? use local...
return super.funnelPowerIntoStorage(power, mode);
}
}
@Override
protected void PowerEvent( final PowerEventType x )
{
try
{
this.getProxy().getGrid().postEvent( new MENetworkPowerStorage( this, x ) );
}
catch( final GridAccessException e )
{
// not ready!
}
}
@Override
protected void PowerEvent(final PowerEventType x) {
try {
this.getProxy().getGrid().postEvent(new MENetworkPowerStorage(this, x));
} catch (final GridAccessException e) {
// not ready!
}
}
@MENetworkEventSubscribe
public void onControllerChange( final MENetworkControllerChange status )
{
this.updateMeta();
}
@MENetworkEventSubscribe
public void onControllerChange(final MENetworkControllerChange status) {
this.updateMeta();
}
@MENetworkEventSubscribe
public void onPowerChange( final MENetworkPowerStatusChange status )
{
this.updateMeta();
}
@MENetworkEventSubscribe
public void onPowerChange(final MENetworkPowerStatusChange status) {
this.updateMeta();
}
@Override
public IItemHandler getInternalInventory()
{
return EmptyHandler.INSTANCE;
}
@Override
public IItemHandler getInternalInventory() {
return EmptyHandler.INSTANCE;
}
@Override
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
{
}
@Override
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added) {
}
/**
* Check for a controller at this coordinates as well as is it loaded.
*
* @return true if there is a loaded controller
*/
private boolean checkController( final BlockPos pos )
{
if( this.world.getChunkProvider().getLoadedChunk( pos.getX() >> 4, pos.getZ() >> 4 ) != null )
{
return this.world.getTileEntity( pos ) instanceof TileController;
}
/**
* Check for a controller at this coordinates as well as is it loaded.
*
* @return true if there is a loaded controller
*/
private boolean checkController(final BlockPos pos) {
if (this.world.getChunkProvider().getLoadedChunk(pos.getX() >> 4, pos.getZ() >> 4) != null) {
return this.world.getTileEntity(pos) instanceof TileController;
}
return false;
}
return false;
}
}
@@ -28,53 +28,44 @@ import appeng.api.util.AEPartLocation;
import appeng.tile.grid.AENetworkTile;
public class TileCreativeEnergyCell extends AENetworkTile implements IAEPowerStorage
{
public class TileCreativeEnergyCell extends AENetworkTile implements IAEPowerStorage {
public TileCreativeEnergyCell()
{
this.getProxy().setIdlePowerUsage( 0 );
}
public TileCreativeEnergyCell() {
this.getProxy().setIdlePowerUsage(0);
}
@Override
public AECableType getCableConnectionType( final AEPartLocation dir )
{
return AECableType.COVERED;
}
@Override
public AECableType getCableConnectionType(final AEPartLocation dir) {
return AECableType.COVERED;
}
@Override
public double injectAEPower( final double amt, final Actionable mode )
{
return 0;
}
@Override
public double injectAEPower(final double amt, final Actionable mode) {
return 0;
}
@Override
public double getAEMaxPower()
{
return Long.MAX_VALUE / 10000;
}
@Override
public double getAEMaxPower() {
return Long.MAX_VALUE / 10000;
}
@Override
public double getAECurrentPower()
{
return Long.MAX_VALUE / 10000;
}
@Override
public double getAECurrentPower() {
return Long.MAX_VALUE / 10000;
}
@Override
public boolean isAEPublicPowerStorage()
{
return true;
}
@Override
public boolean isAEPublicPowerStorage() {
return true;
}
@Override
public AccessRestriction getPowerFlow()
{
return AccessRestriction.READ_WRITE;
}
@Override
public AccessRestriction getPowerFlow() {
return AccessRestriction.READ_WRITE;
}
@Override
public double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier pm )
{
return amt;
}
@Override
public double extractAEPower(final double amt, final Actionable mode, final PowerMultiplier pm) {
return amt;
}
}
@@ -19,11 +19,9 @@
package appeng.tile.networking;
public class TileDenseEnergyCell extends TileEnergyCell
{
public class TileDenseEnergyCell extends TileEnergyCell {
public TileDenseEnergyCell()
{
this.setInternalMaxPower( 200000 * 8 );
}
public TileDenseEnergyCell() {
this.setInternalMaxPower(200000 * 8);
}
}
@@ -19,10 +19,6 @@
package appeng.tile.networking;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.EmptyHandler;
import appeng.api.config.Actionable;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.util.AECableType;
@@ -30,68 +26,57 @@ import appeng.api.util.AEPartLocation;
import appeng.me.GridAccessException;
import appeng.tile.grid.AENetworkPowerTile;
import appeng.util.inv.InvOperation;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.EmptyHandler;
public class TileEnergyAcceptor extends AENetworkPowerTile
{
public TileEnergyAcceptor()
{
this.getProxy().setIdlePowerUsage( 0.0 );
this.setInternalMaxPower( 0 );
}
public class TileEnergyAcceptor extends AENetworkPowerTile {
public TileEnergyAcceptor() {
this.getProxy().setIdlePowerUsage(0.0);
this.setInternalMaxPower(0);
}
@Override
public AECableType getCableConnectionType( final AEPartLocation dir )
{
return AECableType.COVERED;
}
@Override
public AECableType getCableConnectionType(final AEPartLocation dir) {
return AECableType.COVERED;
}
@Override
protected double getFunnelPowerDemand( final double maxRequired )
{
try
{
final IEnergyGrid grid = this.getProxy().getEnergy();
@Override
protected double getFunnelPowerDemand(final double maxRequired) {
try {
final IEnergyGrid grid = this.getProxy().getEnergy();
return grid.getEnergyDemand( maxRequired );
}
catch( final GridAccessException e )
{
return 0;
}
}
return grid.getEnergyDemand(maxRequired);
} catch (final GridAccessException e) {
return 0;
}
}
@Override
public double getInternalMaxPower()
{
return getFunnelPowerDemand( Long.MAX_VALUE );
}
@Override
public double getInternalMaxPower() {
return getFunnelPowerDemand(Long.MAX_VALUE);
}
@Override
protected double funnelPowerIntoStorage( final double power, final Actionable mode )
{
try
{
final IEnergyGrid grid = this.getProxy().getEnergy();
final double leftOver = grid.injectPower( power, mode );
@Override
protected double funnelPowerIntoStorage(final double power, final Actionable mode) {
try {
final IEnergyGrid grid = this.getProxy().getEnergy();
final double leftOver = grid.injectPower(power, mode);
return leftOver;
}
catch( final GridAccessException e )
{
return super.funnelPowerIntoStorage( power, mode );
}
}
return leftOver;
} catch (final GridAccessException e) {
return super.funnelPowerIntoStorage(power, mode);
}
}
@Override
public IItemHandler getInternalInventory()
{
return EmptyHandler.INSTANCE;
}
@Override
public IItemHandler getInternalInventory() {
return EmptyHandler.INSTANCE;
}
@Override
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
{
@Override
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added) {
}
}
}
@@ -19,8 +19,6 @@
package appeng.tile.networking;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
@@ -33,224 +31,188 @@ import appeng.block.networking.BlockEnergyCell;
import appeng.me.GridAccessException;
import appeng.tile.grid.AENetworkTile;
import appeng.util.SettingsFrom;
import net.minecraft.nbt.NBTTagCompound;
public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
{
public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage {
private double internalCurrentPower = 0.0;
private double internalMaxPower = 200000.0;
private double internalCurrentPower = 0.0;
private double internalMaxPower = 200000.0;
private byte currentMeta = -1;
private byte currentMeta = -1;
public TileEnergyCell()
{
this.getProxy().setIdlePowerUsage( 0 );
}
public TileEnergyCell() {
this.getProxy().setIdlePowerUsage(0);
}
@Override
public AECableType getCableConnectionType( final AEPartLocation dir )
{
return AECableType.COVERED;
}
@Override
public AECableType getCableConnectionType(final AEPartLocation dir) {
return AECableType.COVERED;
}
@Override
public void onReady()
{
super.onReady();
final int value = this.world.getBlockState( this.pos ).getValue( BlockEnergyCell.ENERGY_STORAGE );
this.currentMeta = (byte) value;
this.changePowerLevel();
}
@Override
public void onReady() {
super.onReady();
final int value = this.world.getBlockState(this.pos).getValue(BlockEnergyCell.ENERGY_STORAGE);
this.currentMeta = (byte) value;
this.changePowerLevel();
}
/**
* Given a fill factor, return the storage level (0-7) used for the state of the block.
* This is also used for determining the item model.
*/
public static int getStorageLevelFromFillFactor( double fillFactor )
{
byte boundMetadata = (byte) ( 8.0 * ( fillFactor ) );
/**
* Given a fill factor, return the storage level (0-7) used for the state of the block.
* This is also used for determining the item model.
*/
public static int getStorageLevelFromFillFactor(double fillFactor) {
byte boundMetadata = (byte) (8.0 * (fillFactor));
if( boundMetadata > 7 )
{
boundMetadata = 7;
}
if( boundMetadata < 0 )
{
boundMetadata = 0;
}
return boundMetadata;
}
if (boundMetadata > 7) {
boundMetadata = 7;
}
if (boundMetadata < 0) {
boundMetadata = 0;
}
return boundMetadata;
}
private void changePowerLevel()
{
if( this.notLoaded() || this.isInvalid() )
{
return;
}
private void changePowerLevel() {
if (this.notLoaded() || this.isInvalid()) {
return;
}
int storageLevel = getStorageLevelFromFillFactor( this.internalCurrentPower / this.getInternalMaxPower() );
int storageLevel = getStorageLevelFromFillFactor(this.internalCurrentPower / this.getInternalMaxPower());
if( this.currentMeta != storageLevel )
{
this.currentMeta = (byte) storageLevel;
this.world.setBlockState( this.pos, this.world.getBlockState( this.pos ).withProperty( BlockEnergyCell.ENERGY_STORAGE, storageLevel ) );
}
}
if (this.currentMeta != storageLevel) {
this.currentMeta = (byte) storageLevel;
this.world.setBlockState(this.pos, this.world.getBlockState(this.pos).withProperty(BlockEnergyCell.ENERGY_STORAGE, storageLevel));
}
}
@Override
public NBTTagCompound writeToNBT( final NBTTagCompound data )
{
super.writeToNBT( data );
data.setDouble( "internalCurrentPower", this.internalCurrentPower );
return data;
}
@Override
public NBTTagCompound writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
data.setDouble("internalCurrentPower", this.internalCurrentPower);
return data;
}
@Override
public void readFromNBT( final NBTTagCompound data )
{
super.readFromNBT( data );
this.internalCurrentPower = data.getDouble( "internalCurrentPower" );
}
@Override
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
this.internalCurrentPower = data.getDouble("internalCurrentPower");
}
@Override
public boolean canBeRotated()
{
return false;
}
@Override
public boolean canBeRotated() {
return false;
}
@Override
public void uploadSettings( final SettingsFrom from, final NBTTagCompound compound )
{
if( from == SettingsFrom.DISMANTLE_ITEM )
{
this.internalCurrentPower = compound.getDouble( "internalCurrentPower" );
}
}
@Override
public void uploadSettings(final SettingsFrom from, final NBTTagCompound compound) {
if (from == SettingsFrom.DISMANTLE_ITEM) {
this.internalCurrentPower = compound.getDouble("internalCurrentPower");
}
}
@Override
public NBTTagCompound downloadSettings( final SettingsFrom from )
{
if( from == SettingsFrom.DISMANTLE_ITEM )
{
final NBTTagCompound tag = new NBTTagCompound();
tag.setDouble( "internalCurrentPower", this.internalCurrentPower );
tag.setDouble( "internalMaxPower", this.getInternalMaxPower() ); // used for tool tip.
return tag;
}
return null;
}
@Override
public NBTTagCompound downloadSettings(final SettingsFrom from) {
if (from == SettingsFrom.DISMANTLE_ITEM) {
final NBTTagCompound tag = new NBTTagCompound();
tag.setDouble("internalCurrentPower", this.internalCurrentPower);
tag.setDouble("internalMaxPower", this.getInternalMaxPower()); // used for tool tip.
return tag;
}
return null;
}
@Override
public final double injectAEPower( double amt, final Actionable mode )
{
if( mode == Actionable.SIMULATE )
{
final double fakeBattery = this.internalCurrentPower + amt;
if( fakeBattery > this.getInternalMaxPower() )
{
return fakeBattery - this.getInternalMaxPower();
}
@Override
public final double injectAEPower(double amt, final Actionable mode) {
if (mode == Actionable.SIMULATE) {
final double fakeBattery = this.internalCurrentPower + amt;
if (fakeBattery > this.getInternalMaxPower()) {
return fakeBattery - this.getInternalMaxPower();
}
return 0;
}
return 0;
}
if( this.internalCurrentPower < 0.01 && amt > 0 )
{
this.getProxy().getNode().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.PROVIDE_POWER ) );
}
if (this.internalCurrentPower < 0.01 && amt > 0) {
this.getProxy().getNode().getGrid().postEvent(new MENetworkPowerStorage(this, PowerEventType.PROVIDE_POWER));
}
this.internalCurrentPower += amt;
if( this.internalCurrentPower > this.getInternalMaxPower() )
{
amt = this.internalCurrentPower - this.getInternalMaxPower();
this.internalCurrentPower = this.getInternalMaxPower();
this.internalCurrentPower += amt;
if (this.internalCurrentPower > this.getInternalMaxPower()) {
amt = this.internalCurrentPower - this.getInternalMaxPower();
this.internalCurrentPower = this.getInternalMaxPower();
this.changePowerLevel();
return amt;
}
this.changePowerLevel();
return amt;
}
this.changePowerLevel();
return 0;
}
this.changePowerLevel();
return 0;
}
@Override
public double getAEMaxPower()
{
return this.getInternalMaxPower();
}
@Override
public double getAEMaxPower() {
return this.getInternalMaxPower();
}
@Override
public double getAECurrentPower()
{
return this.internalCurrentPower;
}
@Override
public double getAECurrentPower() {
return this.internalCurrentPower;
}
@Override
public boolean isAEPublicPowerStorage()
{
return true;
}
@Override
public boolean isAEPublicPowerStorage() {
return true;
}
@Override
public AccessRestriction getPowerFlow()
{
return AccessRestriction.READ_WRITE;
}
@Override
public AccessRestriction getPowerFlow() {
return AccessRestriction.READ_WRITE;
}
@Override
public final double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier pm )
{
return pm.divide( this.extractAEPower( pm.multiply( amt ), mode ) );
}
@Override
public final double extractAEPower(final double amt, final Actionable mode, final PowerMultiplier pm) {
return pm.divide(this.extractAEPower(pm.multiply(amt), mode));
}
private double extractAEPower( double amt, final Actionable mode )
{
if( mode == Actionable.SIMULATE )
{
if( this.internalCurrentPower > amt )
{
return amt;
}
return this.internalCurrentPower;
}
private double extractAEPower(double amt, final Actionable mode) {
if (mode == Actionable.SIMULATE) {
if (this.internalCurrentPower > amt) {
return amt;
}
return this.internalCurrentPower;
}
final boolean wasFull = this.internalCurrentPower >= this.getInternalMaxPower() - 0.001;
final boolean wasFull = this.internalCurrentPower >= this.getInternalMaxPower() - 0.001;
if( wasFull && amt > 0 )
{
try
{
this.getProxy().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) );
}
catch( final GridAccessException ignored )
{
if (wasFull && amt > 0) {
try {
this.getProxy().getGrid().postEvent(new MENetworkPowerStorage(this, PowerEventType.REQUEST_POWER));
} catch (final GridAccessException ignored) {
}
}
}
}
if( this.internalCurrentPower > amt )
{
this.internalCurrentPower -= amt;
if (this.internalCurrentPower > amt) {
this.internalCurrentPower -= amt;
this.changePowerLevel();
return amt;
}
this.changePowerLevel();
return amt;
}
amt = this.internalCurrentPower;
this.internalCurrentPower = 0;
amt = this.internalCurrentPower;
this.internalCurrentPower = 0;
this.changePowerLevel();
return amt;
}
this.changePowerLevel();
return amt;
}
private double getInternalMaxPower()
{
return this.internalMaxPower;
}
private double getInternalMaxPower() {
return this.internalMaxPower;
}
void setInternalMaxPower( final double internalMaxPower )
{
this.internalMaxPower = internalMaxPower;
}
void setInternalMaxPower(final double internalMaxPower) {
this.internalMaxPower = internalMaxPower;
}
}
@@ -19,15 +19,6 @@
package appeng.tile.networking;
import java.io.IOException;
import java.util.EnumSet;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.implementations.tiles.IWirelessAccessPoint;
@@ -46,172 +37,149 @@ import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
import appeng.util.inv.InvOperation;
import appeng.util.inv.filter.AEItemDefinitionFilter;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.IItemHandler;
import java.io.IOException;
import java.util.EnumSet;
public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoint, IPowerChannelState
{
public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoint, IPowerChannelState {
public static final int POWERED_FLAG = 1;
public static final int CHANNEL_FLAG = 2;
public static final int POWERED_FLAG = 1;
public static final int CHANNEL_FLAG = 2;
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1 );
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 1);
private int clientFlags = 0;
private int clientFlags = 0;
public TileWireless()
{
this.inv.setFilter( new AEItemDefinitionFilter( AEApi.instance().definitions().materials().wirelessBooster() ) );
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
this.getProxy().setValidSides( EnumSet.noneOf( EnumFacing.class ) );
}
public TileWireless() {
this.inv.setFilter(new AEItemDefinitionFilter(AEApi.instance().definitions().materials().wirelessBooster()));
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
this.getProxy().setValidSides(EnumSet.noneOf(EnumFacing.class));
}
@Override
public void setOrientation( final EnumFacing inForward, final EnumFacing inUp )
{
super.setOrientation( inForward, inUp );
this.getProxy().setValidSides( EnumSet.of( this.getForward().getOpposite() ) );
}
@Override
public void setOrientation(final EnumFacing inForward, final EnumFacing inUp) {
super.setOrientation(inForward, inUp);
this.getProxy().setValidSides(EnumSet.of(this.getForward().getOpposite()));
}
@MENetworkEventSubscribe
public void chanRender( final MENetworkChannelsChanged c )
{
this.markForUpdate();
}
@MENetworkEventSubscribe
public void chanRender(final MENetworkChannelsChanged c) {
this.markForUpdate();
}
@MENetworkEventSubscribe
public void powerRender( final MENetworkPowerStatusChange c )
{
this.markForUpdate();
}
@MENetworkEventSubscribe
public void powerRender(final MENetworkPowerStatusChange c) {
this.markForUpdate();
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
{
final boolean c = super.readFromStream( data );
final int old = this.getClientFlags();
this.setClientFlags( data.readByte() );
@Override
protected boolean readFromStream(final ByteBuf data) throws IOException {
final boolean c = super.readFromStream(data);
final int old = this.getClientFlags();
this.setClientFlags(data.readByte());
return old != this.getClientFlags() || c;
}
return old != this.getClientFlags() || c;
}
@Override
protected void writeToStream( final ByteBuf data ) throws IOException
{
super.writeToStream( data );
this.setClientFlags( 0 );
@Override
protected void writeToStream(final ByteBuf data) throws IOException {
super.writeToStream(data);
this.setClientFlags(0);
try
{
if( this.getProxy().getEnergy().isNetworkPowered() )
{
this.setClientFlags( this.getClientFlags() | POWERED_FLAG );
}
try {
if (this.getProxy().getEnergy().isNetworkPowered()) {
this.setClientFlags(this.getClientFlags() | POWERED_FLAG);
}
if( this.getProxy().getNode().meetsChannelRequirements() )
{
this.setClientFlags( this.getClientFlags() | CHANNEL_FLAG );
}
}
catch( final GridAccessException e )
{
// meh
}
if (this.getProxy().getNode().meetsChannelRequirements()) {
this.setClientFlags(this.getClientFlags() | CHANNEL_FLAG);
}
} catch (final GridAccessException e) {
// meh
}
data.writeByte( (byte) this.getClientFlags() );
}
data.writeByte((byte) this.getClientFlags());
}
@Override
public AECableType getCableConnectionType( final AEPartLocation dir )
{
return AECableType.SMART;
}
@Override
public AECableType getCableConnectionType(final AEPartLocation dir) {
return AECableType.SMART;
}
@Override
public DimensionalCoord getLocation()
{
return new DimensionalCoord( this );
}
@Override
public DimensionalCoord getLocation() {
return new DimensionalCoord(this);
}
@Override
public IItemHandler getInternalInventory()
{
return this.inv;
}
@Override
public IItemHandler getInternalInventory() {
return this.inv;
}
@Override
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
{
// :P
}
@Override
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added) {
// :P
}
@Override
public void onReady()
{
this.updatePower();
super.onReady();
}
@Override
public void onReady() {
this.updatePower();
super.onReady();
}
private void updatePower()
{
this.getProxy().setIdlePowerUsage( AEConfig.instance().wireless_getPowerDrain( this.getBoosters() ) );
}
private void updatePower() {
this.getProxy().setIdlePowerUsage(AEConfig.instance().wireless_getPowerDrain(this.getBoosters()));
}
private int getBoosters()
{
final ItemStack boosters = this.inv.getStackInSlot( 0 );
return boosters == null ? 0 : boosters.getCount();
}
private int getBoosters() {
final ItemStack boosters = this.inv.getStackInSlot(0);
return boosters == null ? 0 : boosters.getCount();
}
@Override
public void saveChanges()
{
this.updatePower();
super.saveChanges();
}
@Override
public void saveChanges() {
this.updatePower();
super.saveChanges();
}
@Override
public double getRange()
{
return AEConfig.instance().wireless_getMaxRange( this.getBoosters() );
}
@Override
public double getRange() {
return AEConfig.instance().wireless_getMaxRange(this.getBoosters());
}
@Override
public boolean isActive()
{
if( Platform.isClient() )
{
return this.isPowered() && ( CHANNEL_FLAG == ( this.getClientFlags() & CHANNEL_FLAG ) );
}
@Override
public boolean isActive() {
if (Platform.isClient()) {
return this.isPowered() && (CHANNEL_FLAG == (this.getClientFlags() & CHANNEL_FLAG));
}
return this.getProxy().isActive();
}
return this.getProxy().isActive();
}
@Override
public IGrid getGrid()
{
try
{
return this.getProxy().getGrid();
}
catch( final GridAccessException e )
{
return null;
}
}
@Override
public IGrid getGrid() {
try {
return this.getProxy().getGrid();
} catch (final GridAccessException e) {
return null;
}
}
@Override
public boolean isPowered()
{
return POWERED_FLAG == ( this.getClientFlags() & POWERED_FLAG );
}
@Override
public boolean isPowered() {
return POWERED_FLAG == (this.getClientFlags() & POWERED_FLAG);
}
public int getClientFlags()
{
return this.clientFlags;
}
public int getClientFlags() {
return this.clientFlags;
}
private void setClientFlags( final int clientFlags )
{
this.clientFlags = clientFlags;
}
private void setClientFlags(final int clientFlags) {
this.clientFlags = clientFlags;
}
}