reformatted all src files (#141)
This commit is contained in:
@@ -19,8 +19,10 @@
|
||||
package appeng.parts.p2p;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRedstoneWire;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -31,200 +33,154 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.Platform;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
{
|
||||
public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone> {
|
||||
|
||||
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_redstone" );
|
||||
private static final P2PModels MODELS = new P2PModels("part/p2p/p2p_tunnel_redstone");
|
||||
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels()
|
||||
{
|
||||
return MODELS.getModels();
|
||||
}
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels() {
|
||||
return MODELS.getModels();
|
||||
}
|
||||
|
||||
private int power;
|
||||
private boolean recursive = false;
|
||||
private int power;
|
||||
private boolean recursive = false;
|
||||
|
||||
public PartP2PRedstone( final ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
}
|
||||
public PartP2PRedstone(final ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
private void setNetworkReady()
|
||||
{
|
||||
if( this.isOutput() )
|
||||
{
|
||||
try
|
||||
{
|
||||
int power = 0;
|
||||
for( PartP2PRedstone in : this.getInputs() )
|
||||
{
|
||||
if( in != null )
|
||||
{
|
||||
power = Math.max( power, in.power );
|
||||
}
|
||||
}
|
||||
this.putInput( power );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void setNetworkReady() {
|
||||
if (this.isOutput()) {
|
||||
try {
|
||||
int power = 0;
|
||||
for (PartP2PRedstone in : this.getInputs()) {
|
||||
if (in != null) {
|
||||
power = Math.max(power, in.power);
|
||||
}
|
||||
}
|
||||
this.putInput(power);
|
||||
} catch (GridAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void putInput( final Object o )
|
||||
{
|
||||
if( this.recursive )
|
||||
{
|
||||
return;
|
||||
}
|
||||
private void putInput(final Object o) {
|
||||
if (this.recursive) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.recursive = true;
|
||||
if( this.isOutput() )
|
||||
{
|
||||
if( this.getProxy().isActive() )
|
||||
{
|
||||
final int newPower = (Integer) o;
|
||||
if( this.power != newPower )
|
||||
{
|
||||
this.power = newPower;
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.power = 0;
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
}
|
||||
this.recursive = false;
|
||||
}
|
||||
this.recursive = true;
|
||||
if (this.isOutput()) {
|
||||
if (this.getProxy().isActive()) {
|
||||
final int newPower = (Integer) o;
|
||||
if (this.power != newPower) {
|
||||
this.power = newPower;
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
} else {
|
||||
this.power = 0;
|
||||
this.notifyNeighbors();
|
||||
}
|
||||
}
|
||||
this.recursive = false;
|
||||
}
|
||||
|
||||
private void notifyNeighbors()
|
||||
{
|
||||
final World world = this.getTile().getWorld();
|
||||
private void notifyNeighbors() {
|
||||
final World world = this.getTile().getWorld();
|
||||
|
||||
Platform.notifyBlocksOfNeighbors( world, this.getTile().getPos() );
|
||||
Platform.notifyBlocksOfNeighbors(world, this.getTile().getPos());
|
||||
|
||||
// and this cause sometimes it can go thought walls.
|
||||
for( final EnumFacing face : EnumFacing.VALUES )
|
||||
{
|
||||
Platform.notifyBlocksOfNeighbors( world, this.getTile().getPos().offset( face ) );
|
||||
}
|
||||
}
|
||||
// and this cause sometimes it can go thought walls.
|
||||
for (final EnumFacing face : EnumFacing.VALUES) {
|
||||
Platform.notifyBlocksOfNeighbors(world, this.getTile().getPos().offset(face));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound tag )
|
||||
{
|
||||
super.readFromNBT( tag );
|
||||
this.power = tag.getInteger( "power" );
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(final NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
this.power = tag.getInteger("power");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( final NBTTagCompound tag )
|
||||
{
|
||||
super.writeToNBT( tag );
|
||||
tag.setInteger( "power", this.power );
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT(final NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
tag.setInteger("power", this.power);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
this.setNetworkReady();
|
||||
}
|
||||
@Override
|
||||
public void onTunnelNetworkChange() {
|
||||
this.setNetworkReady();
|
||||
}
|
||||
|
||||
public float getPowerDrainPerTick()
|
||||
{
|
||||
return 0.5f;
|
||||
}
|
||||
public float getPowerDrainPerTick() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
||||
{
|
||||
if( !this.isOutput() )
|
||||
{
|
||||
final BlockPos target = this.getTile().getPos().offset( this.getSide().getFacing() );
|
||||
@Override
|
||||
public void onNeighborChanged(IBlockAccess w, BlockPos pos, BlockPos neighbor) {
|
||||
if (!this.isOutput()) {
|
||||
final BlockPos target = this.getTile().getPos().offset(this.getSide().getFacing());
|
||||
|
||||
final IBlockState state = this.getTile().getWorld().getBlockState( target );
|
||||
final Block b = state.getBlock();
|
||||
if( b != null && !this.isOutput() )
|
||||
{
|
||||
EnumFacing srcSide = this.getSide().getFacing();
|
||||
if( b instanceof BlockRedstoneWire )
|
||||
{
|
||||
srcSide = EnumFacing.UP;
|
||||
}
|
||||
final IBlockState state = this.getTile().getWorld().getBlockState(target);
|
||||
final Block b = state.getBlock();
|
||||
if (b != null && !this.isOutput()) {
|
||||
EnumFacing srcSide = this.getSide().getFacing();
|
||||
if (b instanceof BlockRedstoneWire) {
|
||||
srcSide = EnumFacing.UP;
|
||||
}
|
||||
|
||||
this.power = b.getWeakPower( state, this.getTile().getWorld(), target, srcSide );
|
||||
this.power = Math.max( this.power, b.getWeakPower( state, this.getTile().getWorld(), target, srcSide ) );
|
||||
int powerOut = this.power;
|
||||
try
|
||||
{
|
||||
for( PartP2PRedstone in : this.getInputs() )
|
||||
{
|
||||
if( in != null )
|
||||
{
|
||||
powerOut = Math.max( in.power, powerOut );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.sendToOutput( powerOut );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.sendToOutput( 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
this.power = b.getWeakPower(state, this.getTile().getWorld(), target, srcSide);
|
||||
this.power = Math.max(this.power, b.getWeakPower(state, this.getTile().getWorld(), target, srcSide));
|
||||
int powerOut = this.power;
|
||||
try {
|
||||
for (PartP2PRedstone in : this.getInputs()) {
|
||||
if (in != null) {
|
||||
powerOut = Math.max(in.power, powerOut);
|
||||
}
|
||||
}
|
||||
} catch (GridAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.sendToOutput(powerOut);
|
||||
} else {
|
||||
this.sendToOutput(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canConnectRedstone() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower()
|
||||
{
|
||||
return this.isOutput() ? this.power : 0;
|
||||
}
|
||||
@Override
|
||||
public int isProvidingStrongPower() {
|
||||
return this.isOutput() ? this.power : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower()
|
||||
{
|
||||
return this.isOutput() ? this.power : 0;
|
||||
}
|
||||
@Override
|
||||
public int isProvidingWeakPower() {
|
||||
return this.isOutput() ? this.power : 0;
|
||||
}
|
||||
|
||||
private void sendToOutput( final int power )
|
||||
{
|
||||
try
|
||||
{
|
||||
for( final PartP2PRedstone rs : this.getOutputs() )
|
||||
{
|
||||
rs.putInput( power );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
private void sendToOutput(final int power) {
|
||||
try {
|
||||
for (final PartP2PRedstone rs : this.getOutputs()) {
|
||||
rs.putInput(power);
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
return MODELS.getModel( this.isPowered(), this.isActive() );
|
||||
}
|
||||
@Override
|
||||
public IPartModel getStaticModels() {
|
||||
return MODELS.getModel(this.isPowered(), this.isActive());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user