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,14 +19,6 @@
package appeng.tile.spatial;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.YesNo;
@@ -50,168 +42,146 @@ import appeng.util.Platform;
import appeng.util.inv.InvOperation;
import appeng.util.inv.WrapperFilteredItemHandler;
import appeng.util.inv.filter.IAEItemFilter;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull;
public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallable<Void>
{
public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallable<Void> {
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 );
private final IItemHandler invExt = new WrapperFilteredItemHandler( this.inv, new SpatialIOFilter() );
private YesNo lastRedstoneState = YesNo.UNDECIDED;
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 2);
private final IItemHandler invExt = new WrapperFilteredItemHandler(this.inv, new SpatialIOFilter());
private YesNo lastRedstoneState = YesNo.UNDECIDED;
public TileSpatialIOPort()
{
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
}
public TileSpatialIOPort() {
this.getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
}
@Override
public NBTTagCompound writeToNBT( final NBTTagCompound data )
{
super.writeToNBT( data );
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
return data;
}
@Override
public NBTTagCompound writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
data.setInteger("lastRedstoneState", this.lastRedstoneState.ordinal());
return data;
}
@Override
public void readFromNBT( final NBTTagCompound data )
{
super.readFromNBT( data );
if( data.hasKey( "lastRedstoneState" ) )
{
this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
}
}
@Override
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
if (data.hasKey("lastRedstoneState")) {
this.lastRedstoneState = YesNo.values()[data.getInteger("lastRedstoneState")];
}
}
public boolean getRedstoneState()
{
if( this.lastRedstoneState == YesNo.UNDECIDED )
{
this.updateRedstoneState();
}
public boolean getRedstoneState() {
if (this.lastRedstoneState == YesNo.UNDECIDED) {
this.updateRedstoneState();
}
return this.lastRedstoneState == YesNo.YES;
}
return this.lastRedstoneState == YesNo.YES;
}
public void updateRedstoneState()
{
final YesNo currentState = this.world.isBlockIndirectlyGettingPowered( this.pos ) != 0 ? YesNo.YES : YesNo.NO;
if( this.lastRedstoneState != currentState )
{
this.lastRedstoneState = currentState;
if( this.lastRedstoneState == YesNo.YES )
{
this.triggerTransition();
}
}
}
public void updateRedstoneState() {
final YesNo currentState = this.world.isBlockIndirectlyGettingPowered(this.pos) != 0 ? YesNo.YES : YesNo.NO;
if (this.lastRedstoneState != currentState) {
this.lastRedstoneState = currentState;
if (this.lastRedstoneState == YesNo.YES) {
this.triggerTransition();
}
}
}
private void triggerTransition()
{
if( Platform.isServer() )
{
final ItemStack cell = this.inv.getStackInSlot( 0 );
if( this.isSpatialCell( cell ) )
{
TickHandler.INSTANCE.addCallable( null, this );// this needs to be cross world synced.
}
}
}
private void triggerTransition() {
if (Platform.isServer()) {
final ItemStack cell = this.inv.getStackInSlot(0);
if (this.isSpatialCell(cell)) {
TickHandler.INSTANCE.addCallable(null, this);// this needs to be cross world synced.
}
}
}
private boolean isSpatialCell( final ItemStack cell )
{
if( !cell.isEmpty() && cell.getItem() instanceof ISpatialStorageCell )
{
final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
return sc != null && sc.isSpatialStorage( cell );
}
return false;
}
private boolean isSpatialCell(final ItemStack cell) {
if (!cell.isEmpty() && cell.getItem() instanceof ISpatialStorageCell) {
final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
return sc != null && sc.isSpatialStorage(cell);
}
return false;
}
@Override
public Void call( final World world ) throws Exception
{
final ItemStack cell = this.inv.getStackInSlot( 0 );
if( this.isSpatialCell( cell ) && this.inv.getStackInSlot( 1 ).isEmpty() )
{
final IGrid gi = this.getProxy().getGrid();
final IEnergyGrid energy = this.getProxy().getEnergy();
@Override
public Void call(final World world) throws Exception {
final ItemStack cell = this.inv.getStackInSlot(0);
if (this.isSpatialCell(cell) && this.inv.getStackInSlot(1).isEmpty()) {
final IGrid gi = this.getProxy().getGrid();
final IEnergyGrid energy = this.getProxy().getEnergy();
final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
final ISpatialStorageCell sc = (ISpatialStorageCell) cell.getItem();
final SpatialPylonCache spc = gi.getCache( ISpatialCache.class );
if( spc.hasRegion() && spc.isValidRegion() )
{
final double req = spc.requiredPower();
final double pr = energy.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.CONFIG );
if( Math.abs( pr - req ) < req * 0.001 )
{
final MENetworkEvent res = gi.postEvent( new MENetworkSpatialEvent( this, req ) );
if( !res.isCanceled() )
{
int playerId = -1;
if( this.getProxy().getSecurity().isAvailable() )
{
playerId = this.getProxy().getSecurity().getOwner();
}
final SpatialPylonCache spc = gi.getCache(ISpatialCache.class);
if (spc.hasRegion() && spc.isValidRegion()) {
final double req = spc.requiredPower();
final double pr = energy.extractAEPower(req, Actionable.SIMULATE, PowerMultiplier.CONFIG);
if (Math.abs(pr - req) < req * 0.001) {
final MENetworkEvent res = gi.postEvent(new MENetworkSpatialEvent(this, req));
if (!res.isCanceled()) {
int playerId = -1;
if (this.getProxy().getSecurity().isAvailable()) {
playerId = this.getProxy().getSecurity().getOwner();
}
final TransitionResult tr = sc.doSpatialTransition( cell, this.world, spc.getMin(), spc.getMax(), playerId );
if( tr.success )
{
energy.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
this.inv.setStackInSlot( 0, ItemStack.EMPTY );
this.inv.setStackInSlot( 1, cell );
}
}
}
}
}
final TransitionResult tr = sc.doSpatialTransition(cell, this.world, spc.getMin(), spc.getMax(), playerId);
if (tr.success) {
energy.extractAEPower(req, Actionable.MODULATE, PowerMultiplier.CONFIG);
this.inv.setStackInSlot(0, ItemStack.EMPTY);
this.inv.setStackInSlot(1, cell);
}
}
}
}
}
return null;
}
return null;
}
@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
protected @Nonnull IItemHandler getItemHandlerForSide( @Nonnull EnumFacing side )
{
return this.invExt;
}
@Override
protected @Nonnull
IItemHandler getItemHandlerForSide(@Nonnull EnumFacing side) {
return this.invExt;
}
@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 )
{
@Override
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added) {
}
}
private class SpatialIOFilter implements IAEItemFilter
{
@Override
public boolean allowExtract( IItemHandler inv, int slot, int amount )
{
return slot == 1;
}
private class SpatialIOFilter implements IAEItemFilter {
@Override
public boolean allowExtract(IItemHandler inv, int slot, int amount) {
return slot == 1;
}
@Override
public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack )
{
return( slot == 0 && TileSpatialIOPort.this.isSpatialCell( stack ) );
}
@Override
public boolean allowInsert(IItemHandler inv, int slot, ItemStack stack) {
return (slot == 0 && TileSpatialIOPort.this.isSpatialCell(stack));
}
}
}
}