More compile things

This commit is contained in:
covers1624
2020-06-01 22:17:34 +09:30
parent 086b9ab1e3
commit dffea9a167
42 changed files with 188 additions and 211 deletions
@@ -25,11 +25,8 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import javax.annotation.Nullable;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
@@ -37,6 +34,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
@@ -46,7 +44,6 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.YesNo;
import appeng.api.exceptions.FailedConnectionException;
import appeng.api.implementations.parts.IPartCable;
@@ -69,6 +66,7 @@ import appeng.client.render.cablebus.CableBusRenderState;
import appeng.client.render.cablebus.CableCoreType;
import appeng.client.render.cablebus.FacadeRenderState;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.facade.FacadeContainer;
import appeng.helpers.AEMultiTile;
import appeng.me.GridConnection;
@@ -550,7 +548,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
private void updateRedstone()
{
final TileEntity te = this.getTile();
this.hasRedstone = te.getWorld().isBlockIndirectlyGettingPowered( te.getPos() ) != 0 ? YesNo.YES : YesNo.NO;
this.hasRedstone = te.getWorld().getRedstonePowerFromNeighbors( te.getPos() ) != 0 ? YesNo.YES : YesNo.NO;
}
private void updateDynamicRender()
@@ -575,7 +573,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
{
final EnumSet<Direction> sides = EnumSet.allOf( Direction.class );
for( final Direction s : Direction.VALUES )
for( final Direction s : Direction.values() )
{
if( this.getPart( s ) != null || this.isBlocked( s ) )
{
@@ -930,7 +928,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
return light;
}
public void writeToStream( final ByteBuf data ) throws IOException
public void writeToStream( final PacketBuffer data ) throws IOException
{
int sides = 0;
for( int x = 0; x < 7; x++ )
@@ -951,8 +949,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
{
final ItemStack is = p.getItemStack( PartItemStack.NETWORK );
data.writeShort( Item.getIdFromItem( is.getItem() ) );
data.writeShort( is.getItemDamage() );
data.writeVarInt( Item.getIdFromItem( is.getItem() ) );
p.writeToStream( data );
}
@@ -961,7 +958,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
this.getFacadeContainer().writeToStream( data );
}
public boolean readFromStream( final ByteBuf data ) throws IOException
public boolean readFromStream( final PacketBuffer data ) throws IOException
{
final byte sides = data.readByte();
@@ -974,13 +971,12 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
{
IPart p = this.getPart( side );
final short itemID = data.readShort();
final short dmgValue = data.readShort();
final int itemID = data.readVarInt();
final Item myItem = Item.getItemById( itemID );
final ItemStack current = p != null ? p.getItemStack( PartItemStack.NETWORK ) : null;
if( current != null && current.getItem() == myItem && current.getItemDamage() == dmgValue )
if( current != null && current.getItem() == myItem )
{
if( p.readFromStream( data ) )
{
@@ -990,7 +986,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
else
{
this.removePart( side, false );
side = this.addPart( new ItemStack( myItem, 1, dmgValue ), side, null, null );
side = this.addPart( new ItemStack( myItem, 1 ), side, null, null );
if( side != null )
{
p = this.getPart( side );
@@ -1018,7 +1014,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
public void writeToNBT( final CompoundNBT data )
{
data.setInteger( "hasRedstone", this.hasRedstone.ordinal() );
data.putInt( "hasRedstone", this.hasRedstone.ordinal() );
final IFacadeContainer fc = this.getFacadeContainer();
for( final AEPartLocation s : AEPartLocation.values() )
@@ -1029,13 +1025,13 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
if( part != null )
{
final CompoundNBT def = new CompoundNBT();
part.getItemStack( PartItemStack.WORLD ).writeToNBT( def );
part.getItemStack( PartItemStack.WORLD ).write( def );
final CompoundNBT extra = new CompoundNBT();
part.writeToNBT( extra );
data.setTag( "def:" + this.getSide( part ).ordinal(), def );
data.setTag( "extra:" + this.getSide( part ).ordinal(), extra );
data.put( "def:" + this.getSide( part ).ordinal(), def );
data.put( "extra:" + this.getSide( part ).ordinal(), extra );
}
}
}
@@ -1062,21 +1058,21 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
public void readFromNBT( final CompoundNBT data )
{
if( data.hasKey( "hasRedstone" ) )
if( data.contains( "hasRedstone" ) )
{
this.hasRedstone = YesNo.values()[data.getInteger( "hasRedstone" )];
this.hasRedstone = YesNo.values()[data.getInt( "hasRedstone" )];
}
for( int x = 0; x < 7; x++ )
{
AEPartLocation side = AEPartLocation.fromOrdinal( x );
final CompoundNBT def = data.getCompoundTag( "def:" + side.ordinal() );
final CompoundNBT extra = data.getCompoundTag( "extra:" + side.ordinal() );
final CompoundNBT def = data.getCompound( "def:" + side.ordinal() );
final CompoundNBT extra = data.getCompound( "extra:" + side.ordinal() );
if( def != null && extra != null )
{
IPart p = this.getPart( side );
final ItemStack iss = new ItemStack( def );
final ItemStack iss = ItemStack.read( def );
if( iss.isEmpty() )
{
continue;
@@ -227,14 +227,14 @@ public abstract class PartAbstractFormationPlane<T extends IAEStack<T>> extends
public void readFromNBT( final CompoundNBT data )
{
super.readFromNBT( data );
this.priority = data.getInteger( "priority" );
this.priority = data.getInt( "priority" );
}
@Override
public void writeToNBT( final CompoundNBT data )
{
super.writeToNBT( data );
data.setInteger( "priority", this.getPriority() );
data.putInt( "priority", this.getPriority() );
}
@Override
@@ -24,12 +24,10 @@ import java.util.List;
import com.google.common.collect.Lists;
import net.minecraft.block.BlockState;
import net.minecraft.entity.item.I
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.block.Blocks;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;temEntity;
import net.minecraft.block.Blocks;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
@@ -37,9 +35,8 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.server.ServerWorld;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.networking.IGridNode;
@@ -60,6 +57,7 @@ import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.core.settings.TickRates;
import appeng.core.sync.packets.PacketTransitionEffect;
@@ -228,25 +226,24 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
@Override
public void onEntityCollision( final Entity entity )
{
if( this.isAccepting && entity instanceof EntityItem && !entity.isDead && Platform.isServer() && this.getProxy().isActive() )
if( this.isAccepting && entity instanceof ItemEntity && entity.isAlive() && Platform.isServer() && this.getProxy().isActive() )
{
boolean capture = false;
final BlockPos pos = this.getTile().getPos();
// This is the middle point of the entities BB, which is better suited for comparisons that don't rely on it
// "touching" the plane
double posYMiddle = ( entity.getEntityBoundingBox().minY + entity.getEntityBoundingBox().maxY ) / 2.0D;
double posYMiddle = ( entity.getBoundingBox().minY + entity.getBoundingBox().maxY ) / 2.0D;
switch( this.getSide() )
{
case DOWN:
case UP:
if( entity.posX > pos.getX() && entity.posX < pos.getX() + 1 )
if( entity.getPosX() > pos.getX() && entity.getPosX() < pos.getX() + 1 )
{
if( entity.posZ > pos.getZ() && entity.posZ < pos.getZ() + 1 )
if( entity.getPosZ() > pos.getZ() && entity.getPosZ() < pos.getZ() + 1 )
{
if( ( entity.posY > pos.getY() + 0.9 && this.getSide() == AEPartLocation.UP ) || ( entity.posY < pos.getY() + 0.1 && this
.getSide() == AEPartLocation.DOWN ) )
if( ( entity.getPosY() > pos.getY() + 0.9 && this.getSide() == AEPartLocation.UP ) || ( entity.getPosY() < pos.getY() + 0.1 && this.getSide() == AEPartLocation.DOWN ) )
{
capture = true;
}
@@ -255,12 +252,11 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
break;
case SOUTH:
case NORTH:
if( entity.posX > pos.getX() && entity.posX < pos.getX() + 1 )
if( entity.getPosX() > pos.getX() && entity.getPosX() < pos.getX() + 1 )
{
if( posYMiddle > pos.getY() && posYMiddle < pos.getY() + 1 )
{
if( ( entity.posZ > pos.getZ() + 0.9 && this.getSide() == AEPartLocation.SOUTH ) || ( entity.posZ < pos.getZ() + 0.1 && this
.getSide() == AEPartLocation.NORTH ) )
if( ( entity.getPosZ() > pos.getZ() + 0.9 && this.getSide() == AEPartLocation.SOUTH ) || ( entity.getPosZ() < pos.getZ() + 0.1 && this.getSide() == AEPartLocation.NORTH ) )
{
capture = true;
}
@@ -269,12 +265,11 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
break;
case EAST:
case WEST:
if( entity.posZ > pos.getZ() && entity.posZ < pos.getZ() + 1 )
if( entity.getPosZ() > pos.getZ() && entity.getPosZ() < pos.getZ() + 1 )
{
if( posYMiddle > pos.getY() && posYMiddle < pos.getY() + 1 )
{
if( ( entity.posX > pos.getX() + 0.9 && this.getSide() == AEPartLocation.EAST ) || ( entity.posX < pos.getX() + 0.1 && this
.getSide() == AEPartLocation.WEST ) )
if( ( entity.getPosX() > pos.getX() + 0.9 && this.getSide() == AEPartLocation.EAST ) || ( entity.getPosX() < pos.getX() + 0.1 && this.getSide() == AEPartLocation.WEST ) )
{
capture = true;
}
@@ -292,8 +287,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
if( changed )
{
AppEng.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, this.getTile().getWorld(),
new PacketTransitionEffect( entity.posX, entity.posY, entity.posZ, this.getSide(), false ) );
AppEng.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, this.getTile().getWorld(), new PacketTransitionEffect( entity.getPosX(), entity.getPosY(), entity.getPosZ(), this.getSide(), false ) );
}
}
}
@@ -306,13 +300,13 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
}
/**
* Stores an {@link EntityItem} inside the network and either marks it as dead or sets it to the leftover stackSize.
* Stores an {@link ItemEntity} inside the network and either marks it as dead or sets it to the leftover stackSize.
*
* @param entityItem {@link EntityItem} to store
* @param entityItem {@link ItemEntity} to store
*/
private boolean storeEntityItem( final ItemEntity entityItem )
{
if( !entityItem.isDead )
if( entityItem.isAlive() )
{
final IAEItemStack overflow = this.storeItemStack( entityItem.getItem() );
@@ -336,8 +330,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
{
final IStorageGrid storage = this.getProxy().getStorage();
final IEnergyGrid energy = this.getProxy().getEnergy();
final IAEItemStack overflow = Platform.poweredInsert( energy,
storage.getInventory( Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) ), itemToStore, this.mySrc );
final IAEItemStack overflow = Platform.poweredInsert( energy, storage.getInventory( Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) ), itemToStore, this.mySrc );
this.isAccepting = overflow == null;
@@ -361,11 +354,11 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
*
* @return true, if the entity was changed otherwise false.
*/
private boolean handleOverflow( final EntityItem entityItem, final IAEItemStack overflow )
private boolean handleOverflow( final ItemEntity entityItem, final IAEItemStack overflow )
{
if( overflow == null || overflow.getStackSize() == 0 )
{
entityItem.setDead();
entityItem.remove();
return true;
}
@@ -411,7 +404,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
try
{
final TileEntity te = this.getTile();
final WorldServer w = (WorldServer) te.getWorld();
final ServerWorld w = (ServerWorld) te.getWorld();
final BlockPos pos = te.getPos().offset( this.getSide().getFacing() );
final IEnergyGrid energy = this.getProxy().getEnergy();
@@ -430,8 +423,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
{
energy.extractAEPower( requiredPower, Actionable.MODULATE, PowerMultiplier.CONFIG );
this.breakBlockAndStoreItems( w, pos );
AppEng.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, w,
new PacketTransitionEffect( pos.getX(), pos.getY(), pos.getZ(), this.getSide(), true ) );
AppEng.proxy.sendToAllNearExcept( null, pos.getX(), pos.getY(), pos.getZ(), 64, w, new PacketTransitionEffect( pos.getX(), pos.getY(), pos.getZ(), this.getSide(), true ) );
}
else
{
@@ -473,21 +465,18 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
/**
* Checks if this plane can handle the block at the specific coordinates.
*/
private boolean canHandleBlock( final WorldServer w, final BlockPos pos )
private boolean canHandleBlock( final ServerWorld w, final BlockPos pos )
{
final BlockState state = w.getBlockState( pos );
final Material material = state.getMaterial();
final float hardness = state.getBlockHardness( w, pos );
final boolean ignoreMaterials = material == Material.AIR || material == Material.LAVA || material == Material.WATER || material.isLiquid();
final boolean ignoreBlocks = state.getBlock() == Blocks.BEDROCK || state.getBlock() == Blocks.END_PORTAL || state
.getBlock() == Blocks.END_PORTAL_FRAME || state.getBlock() == Blocks.COMMAND_BLOCK;
final boolean ignoreBlocks = state.getBlock() == Blocks.BEDROCK || state.getBlock() == Blocks.END_PORTAL || state.getBlock() == Blocks.END_PORTAL_FRAME || state.getBlock() == Blocks.COMMAND_BLOCK;
return !ignoreMaterials && !ignoreBlocks && hardness >= 0f && !w.isAirBlock( pos ) && w.isBlockLoaded( pos ) && w.canMineBlockBody(
Platform.getPlayer( w ),
pos );
return !ignoreMaterials && !ignoreBlocks && hardness >= 0f && !w.isAirBlock( pos ) && w.isBlockLoaded( pos ) && w.canMineBlockBody( Platform.getPlayer( w ), pos );
}
protected List<ItemStack> obtainBlockDrops( final WorldServer w, final BlockPos pos )
protected List<ItemStack> obtainBlockDrops( final ServerWorld w, final BlockPos pos )
{
final ItemStack[] out = Platform.getBlockDrops( w, pos );
return Lists.newArrayList( out );
@@ -496,7 +485,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
/**
* Checks if this plane can handle the block at the specific coordinates.
*/
protected float calculateEnergyUsage( final WorldServer w, final BlockPos pos, final List<ItemStack> items )
protected float calculateEnergyUsage( final ServerWorld w, final BlockPos pos, final List<ItemStack> items )
{
final BlockState state = w.getBlockState( pos );
final float hardness = state.getBlockHardness( w, pos );
@@ -530,8 +519,7 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
for( final ItemStack itemStack : itemStacks )
{
final IAEItemStack itemToTest = AEItemStack.fromItemStack( itemStack );
final IAEItemStack overflow = storage.getInventory( Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) )
.injectItems( itemToTest, Actionable.SIMULATE, this.mySrc );
final IAEItemStack overflow = storage.getInventory( Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) ).injectItems( itemToTest, Actionable.SIMULATE, this.mySrc );
if( overflow == null || itemToTest.getStackSize() > overflow.getStackSize() )
{
canStore = true;
@@ -547,16 +535,16 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
return canStore;
}
private void breakBlockAndStoreItems( final WorldServer w, final BlockPos pos )
private void breakBlockAndStoreItems( final ServerWorld w, final BlockPos pos )
{
w.destroyBlock( pos, true );
final AxisAlignedBB box = new AxisAlignedBB( pos ).grow( 0.2 );
for( final Object ei : w.getEntitiesWithinAABB( EntityItem.class, box ) )
for( final Object ei : w.getEntitiesWithinAABB( ItemEntity.class, box ) )
{
if( ei instanceof EntityItem )
if( ei instanceof ItemEntity )
{
final EntityItem entityItem = (EntityItem) ei;
final ItemEntity entityItem = (ItemEntity) ei;
this.storeEntityItem( entityItem );
}
}
@@ -581,5 +569,4 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
{
return MODELS.getModel( this.getConnections(), this.isPowered(), this.isActive() );
}
}
@@ -54,6 +54,7 @@ import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.core.settings.TickRates;
import appeng.core.sync.GuiBridge;
@@ -105,7 +106,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
{
super.readFromNBT( extra );
this.craftingTracker.readFromNBT( extra );
this.nextSlot = extra.getInteger( "nextSlot" );
this.nextSlot = extra.getInt( "nextSlot" );
}
@Override
@@ -113,7 +114,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
{
super.writeToNBT( extra );
this.craftingTracker.writeToNBT( extra );
extra.setInteger( "nextSlot", this.nextSlot );
extra.putInt( "nextSlot", this.nextSlot );
}
@Override
@@ -68,6 +68,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.AEPartLocation;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.sync.GuiBridge;
import appeng.items.parts.PartModels;
import appeng.me.GridAccessException;
@@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ServerWorld;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory;
@@ -44,6 +44,7 @@ import appeng.api.storage.IMEMonitor;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.core.settings.TickRates;
import appeng.core.sync.GuiBridge;
@@ -23,19 +23,18 @@ import java.util.Collection;
import java.util.Random;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.RedstoneParticleData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.config.LevelType;
import appeng.api.config.RedstoneMode;
@@ -71,6 +70,7 @@ import appeng.api.storage.data.IItemList;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.api.util.IConfigManager;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.core.sync.GuiBridge;
import appeng.helpers.Reflected;
@@ -290,11 +290,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
{
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 || myStack == null )
{
this.getProxy()
.getStorage()
.getInventory( Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) )
.addListener( this,
this.getProxy().getGrid() );
this.getProxy().getStorage().getInventory( Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) ).addListener( this, this.getProxy().getGrid() );
}
else
{
@@ -362,8 +358,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
@Override
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final IStorageChannel chan )
{
if( chan == Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this
.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
if( chan == Api.INSTANCE.storage().getStorageChannel( IItemStorageChannel.class ) && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
{
this.lastReportedValue = fullStack.getStackSize();
this.updateState();
@@ -451,8 +446,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
final double d1 = d.yOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
final double d2 = d.zOffset * 0.45F + ( r.nextFloat() - 0.5F ) * 0.2D;
world.spawnParticle( EnumParticleTypes.REDSTONE, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D,
new int[0] );
world.addParticle( RedstoneParticleData.REDSTONE_DUST, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1, 0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D );
}
}
@@ -517,7 +511,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
super.writeToNBT( data );
data.putLong( "lastReportedValue", this.lastReportedValue );
data.putLong( "reportingValue", this.reportingValue );
data.putBoolean("prevState", this.prevState);
data.putBoolean( "prevState", this.prevState );
this.config.writeToNBT( data, "config" );
}
@@ -533,7 +527,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
}
@Override
public boolean pushPattern( final ICraftingPatternDetails patternDetails, final InventoryCrafting table )
public boolean pushPattern( final ICraftingPatternDetails patternDetails, final CraftingInventory table )
{
return false;
}
@@ -22,6 +22,7 @@ package appeng.parts.automation;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
@@ -103,7 +104,7 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
{
final World w = self.getWorld();
if( w.getChunkProvider().getLoadedChunk( pos.getX() >> 4, pos.getZ() >> 4 ) != null )
if( w.getChunkProvider().isChunkLoaded( new ChunkPos( pos ) ) )
{
return w.getTileEntity( pos );
}
@@ -145,11 +146,9 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
{
final TileEntity self = this.getHost().getTile();
final BlockPos selfPos = self.getPos().offset( this.getSide().getFacing() );
final int xCoordinate = selfPos.getX();
final int zCoordinate = selfPos.getZ();
final World world = self.getWorld();
return world != null && world.getChunkProvider().getLoadedChunk( xCoordinate >> 4, zCoordinate >> 4 ) != null;
return world != null && world.getChunkProvider().isChunkLoaded( new ChunkPos( selfPos ) );
}
private void updateState()
@@ -40,6 +40,7 @@ import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.me.GridAccessException;
import appeng.me.helpers.IGridProxyable;
import appeng.me.storage.ITickingMonitor;
@@ -25,7 +25,7 @@ import java.util.List;
import com.google.common.collect.ImmutableSet;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
@@ -36,7 +36,6 @@ import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.Upgrades;
import appeng.api.networking.IGridNode;
@@ -58,6 +57,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.core.sync.GuiBridge;
import appeng.helpers.DualityInterface;
@@ -230,7 +230,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public boolean pushPattern( final ICraftingPatternDetails patternDetails, final InventoryCrafting table )
public boolean pushPattern( final ICraftingPatternDetails patternDetails, final CraftingInventory table )
{
return this.duality.pushPattern( patternDetails, table );
}
@@ -41,6 +41,7 @@ import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager;
import appeng.core.Api;
import appeng.helpers.IPriorityHost;
import appeng.me.GridAccessException;
import appeng.parts.automation.PartUpgradeable;
@@ -163,14 +164,14 @@ public abstract class PartSharedStorageBus extends PartUpgradeable implements IG
public void readFromNBT( final CompoundNBT data )
{
super.readFromNBT( data );
this.priority = data.getInteger( "priority" );
this.priority = data.getInt( "priority" );
}
@Override
public void writeToNBT( final CompoundNBT data )
{
super.writeToNBT( data );
data.setInteger( "priority", this.priority );
data.putInt( "priority", this.priority );
}
@Override
@@ -33,6 +33,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
@@ -72,6 +73,7 @@ import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.api.util.IConfigManager;
import appeng.capabilities.Capabilities;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.core.settings.TickRates;
import appeng.core.sync.GuiBridge;
@@ -194,7 +196,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{
super.readFromNBT( data );
this.Config.readFromNBT( data, "config" );
this.priority = data.getInteger( "priority" );
this.priority = data.getInt( "priority" );
}
@Override
@@ -202,7 +204,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{
super.writeToNBT( data );
this.Config.writeToNBT( data, "config" );
data.setInteger( "priority", this.priority );
data.putInt( "priority", this.priority );
}
@Override
@@ -378,10 +380,11 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
Direction targetSide = this.getSide().getFacing().getOpposite();
// Prioritize a handler to directly link to another ME network
IStorageMonitorableAccessor accessor = target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide );
final LazyOptional<IStorageMonitorableAccessor> accessorOpt = target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide );
if( accessor != null )
if( accessorOpt.isPresent() )
{
IStorageMonitorableAccessor accessor = accessorOpt.orElse( null );
IStorageMonitorable inventory = accessor.getInventory( this.mySrc );
if( inventory != null )
{
@@ -396,16 +399,17 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
}
// Check via cap for IItemHandler
IItemHandler handlerExt = target.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide );
if( handlerExt != null )
final LazyOptional<IItemHandler> handlerExtOpt = target.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide );
if( handlerExtOpt.isPresent() )
{
return new ItemHandlerAdapter( handlerExt, this );
return new ItemHandlerAdapter( handlerExtOpt.orElse( null ), this );
}
return null;
}
//TODO, LazyOptionals are cacheable this might need changing?
private int createHandlerHash( TileEntity target )
{
if( target == null )
@@ -415,15 +419,18 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
final Direction targetSide = this.getSide().getFacing().getOpposite();
if( target.hasCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ) )
final LazyOptional<IStorageMonitorableAccessor> accessorOpt = target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide );
if( accessorOpt.isPresent() )
{
return Objects.hash( target, target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ) );
return Objects.hash( target, accessorOpt.orElse( null ) );
}
final IItemHandler itemHandler = target.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide );
final LazyOptional<IItemHandler> itemHandlerOpt = target.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide );
if( itemHandler != null )
if( itemHandlerOpt.isPresent() )
{
IItemHandler itemHandler = itemHandlerOpt.orElse( null );
return Objects.hash( target, itemHandler, itemHandler.getSlots() );
}
@@ -40,6 +40,7 @@ import appeng.api.parts.IPartModel;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
@@ -47,6 +47,7 @@ import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
import appeng.api.util.IReadOnlyCollection;
import appeng.core.Api;
import appeng.items.parts.ItemPart;
import appeng.me.GridAccessException;
import appeng.parts.AEBasePart;
@@ -283,7 +284,7 @@ public class PartCable extends AEBasePart implements IPartCable
howMany = Math.max( gc.getUsedChannels(), howMany );
}
data.setByte( "usedChannels", (byte) howMany );
data.putByte( "usedChannels", (byte) howMany );
}
}
}
@@ -20,13 +20,13 @@ package appeng.parts.p2p;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.IEnergyStorage;
import appeng.api.config.PowerUnits;
@@ -68,17 +68,18 @@ public class PartP2PFEPower extends PartP2PTunnel<PartP2PFEPower>
private IEnergyStorage getAttachedEnergyStorage()
{
LazyOptional<IEnergyStorage> energyStorageOpt = LazyOptional.empty();
if( this.isActive() )
{
final TileEntity self = this.getTile();
final TileEntity te = self.getWorld().getTileEntity( self.getPos().offset( this.getSide().getFacing() ) );
if( te != null && te.hasCapability( Capabilities.FORGE_ENERGY, this.getSide().getOpposite().getFacing() ) )
if( te != null )
{
return te.getCapability( Capabilities.FORGE_ENERGY, this.getSide().getOpposite().getFacing() );
energyStorageOpt = te.getCapability( Capabilities.FORGE_ENERGY, this.getSide().getOpposite().getFacing() );
}
}
return NULL_ENERGY_STORAGE;
return energyStorageOpt.orElse( NULL_ENERGY_STORAGE );
}
@Override
@@ -206,6 +207,7 @@ public class PartP2PFEPower extends PartP2PTunnel<PartP2PFEPower>
}
}
private class OutputEnergyStorage implements IEnergyStorage
{
@Override
@@ -252,6 +254,7 @@ public class PartP2PFEPower extends PartP2PTunnel<PartP2PFEPower>
}
}
private static class NullEnergyStorage implements IEnergyStorage
{
@@ -290,6 +293,5 @@ public class PartP2PFEPower extends PartP2PTunnel<PartP2PFEPower>
{
return false;
}
}
}
@@ -25,12 +25,12 @@ import java.util.Deque;
import java.util.Iterator;
import java.util.List;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.FluidTankProperties;
@@ -194,10 +194,10 @@ public class PartP2PFluids extends PartP2PTunnel<PartP2PFluids> implements IFlui
throw new IllegalStateException( "Invalid Recursion detected." );
}
return Math.min( resource.amount, requestTotal );
return Math.min( resource.getAmount(), requestTotal );
}
int available = resource.amount;
int available = resource.getAmount();
i = list.iterator();
int used = 0;
@@ -207,10 +207,10 @@ public class PartP2PFluids extends PartP2PTunnel<PartP2PFluids> implements IFlui
final PartP2PFluids l = i.next();
final FluidStack insert = resource.copy();
insert.amount = (int) Math.ceil( insert.amount * ( (double) l.tmpUsed / (double) requestTotal ) );
if( insert.amount > available )
insert.setAmount( (int) Math.ceil( insert.getAmount() * ( (double) l.tmpUsed / (double) requestTotal ) ) );
if( insert.getAmount() > available )
{
insert.amount = available;
insert.setAmount( available );
}
final IFluidHandler tank = l.getTarget();
@@ -223,7 +223,7 @@ public class PartP2PFluids extends PartP2PTunnel<PartP2PFluids> implements IFlui
l.tmpUsed = 0;
}
available -= insert.amount;
available -= insert.getAmount();
used += l.tmpUsed;
}
@@ -306,4 +306,4 @@ public class PartP2PFluids extends PartP2PTunnel<PartP2PFluids> implements IFlui
return null;
}
}
}
@@ -48,6 +48,7 @@ import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
import appeng.api.util.AEPartLocation;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.me.GridAccessException;
import appeng.me.cache.P2PCache;
import appeng.me.cache.helpers.TunnelCollection;
@@ -42,6 +42,7 @@ import appeng.api.parts.IPartModel;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.settings.TickRates;
import appeng.hooks.TickHandler;
import appeng.items.parts.PartModels;