Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 548af3c6cc | |||
| 98b9380494 | |||
| bbf4d4a9ce | |||
| 1513ba3f6a | |||
| f03f8ec432 | |||
| e1dcd588b7 | |||
| 8338a7d13e | |||
| b8e685b1b6 | |||
| d84500c5b7 | |||
| a1679c944b | |||
| a3a39201d1 | |||
| d788da687e |
@@ -22,7 +22,6 @@ hwyla_version=1.8.19-B33_1.12
|
||||
jei_version=4.7.1.69
|
||||
tesla_version=1.0.61
|
||||
ic2_version=2.8.9-ex112
|
||||
rf_version=2.0.0.1
|
||||
top_version=1.12-1.4.8-2
|
||||
|
||||
#########################################################
|
||||
|
||||
@@ -78,8 +78,7 @@ dependencies {
|
||||
compileOnly "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
|
||||
compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${top_version}:api"
|
||||
|
||||
// deobfCompile "mcp.mobius.waila:Hwyla:${hwyla_version}"
|
||||
deobfCompile "cofh:RedstoneFlux:${minecraft_version}-${rf_version}:universal"
|
||||
// deobfCompile "mcp.mobius.waila:Hwyla:${hwyla_version}"
|
||||
|
||||
// at runtime, use the full JEI jar
|
||||
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.implementations.TransitionResult;
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
import appeng.api.util.WorldCoord;
|
||||
|
||||
|
||||
@@ -57,7 +58,7 @@ public interface ISpatialStorageCell
|
||||
*
|
||||
* @return the world for this cell
|
||||
*/
|
||||
World getWorld( ItemStack is );
|
||||
ISpatialDimension getSpatialDimension();
|
||||
|
||||
/**
|
||||
* get the currently stored size.
|
||||
@@ -69,22 +70,13 @@ public interface ISpatialStorageCell
|
||||
WorldCoord getStoredSize( ItemStack is );
|
||||
|
||||
/**
|
||||
* Minimum coordinates in its world for the storage cell.
|
||||
* get the currently stored Dimension id.
|
||||
*
|
||||
* @param is spatial storage cell
|
||||
*
|
||||
* @return minimum coordinate of dimension
|
||||
* @return dimension id or -1
|
||||
*/
|
||||
WorldCoord getMin( ItemStack is );
|
||||
|
||||
/**
|
||||
* Maximum coordinates in its world for the storage cell.
|
||||
*
|
||||
* @param is spatial storage cell
|
||||
*
|
||||
* @return maximum coordinate of dimension
|
||||
*/
|
||||
WorldCoord getMax( ItemStack is );
|
||||
int getStoredDimensionID( ItemStack is );
|
||||
|
||||
/**
|
||||
* Perform a spatial swap with the contents of the cell, and the world.
|
||||
@@ -93,9 +85,9 @@ public interface ISpatialStorageCell
|
||||
* @param w world of spatial
|
||||
* @param min min coord
|
||||
* @param max max coord
|
||||
* @param doTransition transition
|
||||
* @param playerId owner of current grid or -1
|
||||
*
|
||||
* @return result of transition
|
||||
*/
|
||||
TransitionResult doSpatialTransition( ItemStack is, World w, WorldCoord min, WorldCoord max, boolean doTransition );
|
||||
TransitionResult doSpatialTransition( ItemStack is, World w, WorldCoord min, WorldCoord max, int playerId );
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
package appeng.api.networking.energy;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -37,15 +38,30 @@ public interface IEnergyGridProvider
|
||||
/**
|
||||
* internal use only
|
||||
*/
|
||||
double extractAEPower( double amt, Actionable mode, Set<IEnergyGrid> seen );
|
||||
Collection<IEnergyGridProvider> providers();
|
||||
|
||||
/**
|
||||
* internal use only
|
||||
*/
|
||||
double injectAEPower( double amt, Actionable mode, Set<IEnergyGrid> seen );
|
||||
double extractProviderPower( double amt, Actionable mode, Set<IEnergyGridProvider> seen );
|
||||
|
||||
/**
|
||||
* internal use only
|
||||
*/
|
||||
double getEnergyDemand( double d, Set<IEnergyGrid> seen );
|
||||
double injectProviderPower( double amt, Actionable mode, Set<IEnergyGridProvider> seen );
|
||||
|
||||
/**
|
||||
* internal use only
|
||||
*/
|
||||
double getProviderEnergyDemand( double d, Set<IEnergyGridProvider> seen );
|
||||
|
||||
/**
|
||||
* internal use only
|
||||
*/
|
||||
double getProviderStoredEnergy();
|
||||
|
||||
/**
|
||||
* internal use only
|
||||
*/
|
||||
double getProviderMaxEnergy();
|
||||
}
|
||||
|
||||
+17
-9
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -16,18 +16,26 @@
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.tile;
|
||||
package appeng.api.storage;
|
||||
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import appeng.tile.events.TileEventType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@Retention( RetentionPolicy.RUNTIME )
|
||||
public @interface TileEvent
|
||||
public interface ISpatialDimension
|
||||
{
|
||||
World getWorld();
|
||||
|
||||
TileEventType value();
|
||||
int createNewCellDimension( BlockPos contentSize, int playerId );
|
||||
|
||||
void deleteCellDimension( int cellDimId );
|
||||
|
||||
boolean isCellDimension( int cellDimID );
|
||||
|
||||
int getCellDimensionOwner( int cellDimId );
|
||||
|
||||
BlockPos getCellDimensionOrigin( int cellDimId );
|
||||
|
||||
BlockPos getCellContentSize( int cellDimId );
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
import appeng.api.storage.IStorageMonitorableAccessor;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
@@ -45,6 +46,8 @@ public final class Capabilities
|
||||
|
||||
public static Capability<IStorageMonitorableAccessor> STORAGE_MONITORABLE_ACCESSOR;
|
||||
|
||||
public static Capability<ISpatialDimension> SPATIAL_DIMENSION;
|
||||
|
||||
public static Capability<ITeslaConsumer> TESLA_CONSUMER;
|
||||
|
||||
public static Capability<ITeslaHolder> TESLA_HOLDER;
|
||||
@@ -57,6 +60,7 @@ public final class Capabilities
|
||||
public static void register()
|
||||
{
|
||||
CapabilityManager.INSTANCE.register( IStorageMonitorableAccessor.class, createNullStorage(), NullMENetworkAccessor::new );
|
||||
CapabilityManager.INSTANCE.register( ISpatialDimension.class, createNullStorage(), NullSpatialDimension::new );
|
||||
}
|
||||
|
||||
@CapabilityInject( IStorageMonitorableAccessor.class )
|
||||
@@ -65,6 +69,12 @@ public final class Capabilities
|
||||
STORAGE_MONITORABLE_ACCESSOR = cap;
|
||||
}
|
||||
|
||||
@CapabilityInject( ISpatialDimension.class )
|
||||
private static void capISpatialDimensionRegistered( Capability<ISpatialDimension> cap )
|
||||
{
|
||||
SPATIAL_DIMENSION = cap;
|
||||
}
|
||||
|
||||
@CapabilityInject( ITeslaConsumer.class )
|
||||
private static void capITeslaConsumerRegistered( Capability<ITeslaConsumer> cap )
|
||||
{
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.capabilities;
|
||||
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
|
||||
|
||||
class NullSpatialDimension implements ISpatialDimension
|
||||
{
|
||||
@Override
|
||||
public int createNewCellDimension( BlockPos size, int owner )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCellDimension( int cellStorageId )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellDimensionOwner( int cellStorageId )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCellDimensionOrigin( int cellStorageId )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellDimension( int cellDimID )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCellContentSize( int cellDimId )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -78,12 +78,23 @@ public class GuiSpatialIOPort extends AEBaseGui
|
||||
this.fontRenderer.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getCurrentPower(), false ), 13, 21,
|
||||
4210752 );
|
||||
this.fontRenderer.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getMaxPower(), false ), 13, 31, 4210752 );
|
||||
this.fontRenderer.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getRequiredPower(), false ), 13, 78,
|
||||
this.fontRenderer.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( this.container.getRequiredPower(), false ), 13, 73,
|
||||
4210752 );
|
||||
this.fontRenderer.drawString( GuiText.Efficiency.getLocal() + ": " + ( ( (float) this.container.getEfficency() ) / 100 ) + '%', 13, 88, 4210752 );
|
||||
this.fontRenderer.drawString( GuiText.Efficiency.getLocal() + ": " + ( ( (float) this.container.getEfficency() ) / 100 ) + '%', 13, 83, 4210752 );
|
||||
|
||||
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 );
|
||||
this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96, 4210752 );
|
||||
|
||||
if( this.container.xSize != 0 && this.container.ySize != 0 && this.container.zSize != 0 )
|
||||
{
|
||||
final String text = GuiText.SCSSize.getLocal() + ": " + this.container.xSize + "x" + this.container.ySize + "x" + this.container.zSize;
|
||||
this.fontRenderer.drawString( text, 13, 93, 4210752 );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fontRenderer.drawString( GuiText.SCSSize.getLocal() + ": " + GuiText.SCSSInvalid.getLocal(), 13, 93, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
|
||||
|
||||
@@ -46,6 +47,7 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
|
||||
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 1 );
|
||||
private final SlotCraftingMatrix[] craftingSlots = new SlotCraftingMatrix[9];
|
||||
private final SlotCraftingTerm outputSlot;
|
||||
private IRecipe currentRecipe;
|
||||
|
||||
public ContainerCraftingTerm( final InventoryPlayer ip, final ITerminalHost monitorable )
|
||||
{
|
||||
@@ -85,7 +87,21 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
|
||||
ic.setInventorySlotContents( x, this.craftingSlots[x].getStack() );
|
||||
}
|
||||
|
||||
this.outputSlot.putStack( CraftingManager.findMatchingResult( ic, this.getPlayerInv().player.world ) );
|
||||
if( this.currentRecipe == null || !this.currentRecipe.matches( ic, this.getPlayerInv().player.world ) )
|
||||
{
|
||||
this.currentRecipe = CraftingManager.findMatchingRecipe( ic, this.getPlayerInv().player.world );
|
||||
}
|
||||
|
||||
if( this.currentRecipe == null )
|
||||
{
|
||||
this.outputSlot.putStack( ItemStack.EMPTY );
|
||||
}
|
||||
else
|
||||
{
|
||||
final ItemStack craftingResult = this.currentRecipe.getCraftingResult( ic );
|
||||
|
||||
this.outputSlot.putStack( craftingResult );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,4 +131,9 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public IRecipe getCurrentRecipe()
|
||||
{
|
||||
return this.currentRecipe;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? ItemStack.EMPTY : packetPatternSlot.pattern[x].getItemStack() );
|
||||
}
|
||||
|
||||
final IRecipe r = Platform.findMatchingRecipe( ic, p.world );
|
||||
final IRecipe r = CraftingManager.findMatchingRecipe( ic, p.world );
|
||||
|
||||
if( r == null )
|
||||
{
|
||||
@@ -413,7 +413,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
||||
}
|
||||
}
|
||||
|
||||
final IRecipe rr = Platform.findMatchingRecipe( real, p.world );
|
||||
final IRecipe rr = CraftingManager.findMatchingRecipe( real, p.world );
|
||||
|
||||
if( rr == r && Platform.itemComparisons().isSameItem( rr.getCraftingResult( real ), is ) )
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.spatial.ISpatialCache;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
@@ -48,6 +49,13 @@ public class ContainerSpatialIOPort extends AEBaseContainer
|
||||
private IGrid network;
|
||||
private int delay = 40;
|
||||
|
||||
@GuiSync( 31 )
|
||||
public int xSize;
|
||||
@GuiSync( 32 )
|
||||
public int ySize;
|
||||
@GuiSync( 33 )
|
||||
public int zSize;
|
||||
|
||||
public ContainerSpatialIOPort( final InventoryPlayer ip, final TileSpatialIOPort spatialIOPort )
|
||||
{
|
||||
super( ip, spatialIOPort, null );
|
||||
@@ -85,6 +93,22 @@ public class ContainerSpatialIOPort extends AEBaseContainer
|
||||
this.setMaxPower( (long) ( 100.0 * eg.getMaxStoredPower() ) );
|
||||
this.setRequiredPower( (long) ( 100.0 * sc.requiredPower() ) );
|
||||
this.setEfficency( (long) ( 100.0f * sc.currentEfficiency() ) );
|
||||
|
||||
final DimensionalCoord min = sc.getMin();
|
||||
final DimensionalCoord max = sc.getMax();
|
||||
|
||||
if( min != null && max != null && sc.isValidRegion() )
|
||||
{
|
||||
this.xSize = sc.getMax().x - sc.getMin().x - 1;
|
||||
this.ySize = sc.getMax().y - sc.getMin().y - 1;
|
||||
this.zSize = sc.getMax().z - sc.getMin().z - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.xSize = 0;
|
||||
this.ySize = 0;
|
||||
this.zSize = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
@@ -149,7 +150,7 @@ public class AppEngCraftingSlot extends AppEngSlot
|
||||
ic.setInventorySlotContents( x, this.craftMatrix.getStackInSlot( x ) );
|
||||
}
|
||||
|
||||
final NonNullList<ItemStack> aitemstack = CraftingManager.getRemainingItems( ic, playerIn.world );
|
||||
final NonNullList<ItemStack> aitemstack = this.getRemainingItems( ic, playerIn.world );
|
||||
|
||||
ItemHandlerUtil.copy( ic, this.craftMatrix, false );
|
||||
|
||||
@@ -195,4 +196,10 @@ public class AppEngCraftingSlot extends AppEngSlot
|
||||
|
||||
return super.decrStackSize( par1 );
|
||||
}
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
protected NonNullList<ItemStack> getRemainingItems( InventoryCrafting ic, World world )
|
||||
{
|
||||
return CraftingManager.getRemainingItems( ic, world );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,11 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -39,6 +42,7 @@ import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
@@ -153,6 +157,41 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
protected IRecipe findRecipe( InventoryCrafting ic, World world )
|
||||
{
|
||||
if( this.container instanceof ContainerCraftingTerm )
|
||||
{
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
final IRecipe recipe = containerTerminal.getCurrentRecipe();
|
||||
|
||||
if( recipe != null && recipe.matches( ic, world ) )
|
||||
{
|
||||
return containerTerminal.getCurrentRecipe();
|
||||
}
|
||||
}
|
||||
|
||||
return CraftingManager.findMatchingRecipe( ic, world );
|
||||
}
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
@Override
|
||||
protected NonNullList<ItemStack> getRemainingItems( InventoryCrafting ic, World world )
|
||||
{
|
||||
if( this.container instanceof ContainerCraftingTerm )
|
||||
{
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
final IRecipe recipe = containerTerminal.getCurrentRecipe();
|
||||
|
||||
if( recipe != null && recipe.matches( ic, world ) )
|
||||
{
|
||||
return containerTerminal.getCurrentRecipe().getRemainingItems( ic );
|
||||
}
|
||||
}
|
||||
|
||||
return CraftingManager.getRemainingItems( ic, world );
|
||||
}
|
||||
|
||||
private int capCraftingAttempts( final int maxTimesToCraft )
|
||||
{
|
||||
return maxTimesToCraft;
|
||||
@@ -178,7 +217,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
|
||||
ic.setInventorySlotContents( x, this.getPattern().getStackInSlot( x ) );
|
||||
}
|
||||
|
||||
final IRecipe r = Platform.findMatchingRecipe( ic, p.world );
|
||||
final IRecipe r = this.findRecipe( ic, p.world );
|
||||
|
||||
if( r == null )
|
||||
{
|
||||
|
||||
@@ -95,8 +95,8 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
private final int[] levelByStacks = { 1, 10, 100, 1000 };
|
||||
|
||||
// Spatial IO/Dimension
|
||||
private int storageBiomeID = -1;
|
||||
private int storageProviderID = -1;
|
||||
private int storageDimensionID = -1;
|
||||
private double spatialPowerExponent = 1.35;
|
||||
private double spatialPowerMultiplier = 1250.0;
|
||||
|
||||
@@ -251,8 +251,8 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
|
||||
if( this.isFeatureEnabled( AEFeature.SPATIAL_IO ) )
|
||||
{
|
||||
this.storageBiomeID = this.get( "spatialio", "storageBiomeID", this.storageBiomeID ).getInt( this.storageBiomeID );
|
||||
this.storageProviderID = this.get( "spatialio", "storageProviderID", this.storageProviderID ).getInt( this.storageProviderID );
|
||||
this.storageDimensionID = this.get( "spatialio", "storageDimensionID", this.storageDimensionID ).getInt( this.storageDimensionID );
|
||||
this.spatialPowerMultiplier = this.get( "spatialio", "spatialPowerMultiplier", this.spatialPowerMultiplier ).getDouble(
|
||||
this.spatialPowerMultiplier );
|
||||
this.spatialPowerExponent = this.get( "spatialio", "spatialPowerExponent", this.spatialPowerExponent ).getDouble( this.spatialPowerExponent );
|
||||
@@ -397,8 +397,8 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
{
|
||||
if( this.isFeatureEnabled( AEFeature.SPATIAL_IO ) )
|
||||
{
|
||||
this.get( "spatialio", "storageBiomeID", this.storageBiomeID ).set( this.storageBiomeID );
|
||||
this.get( "spatialio", "storageProviderID", this.storageProviderID ).set( this.storageProviderID );
|
||||
this.get( "spatialio", "storageDimensionID", this.storageDimensionID ).set( this.storageDimensionID );
|
||||
}
|
||||
|
||||
this.get( "Client", "PowerUnit", this.selectedPowerUnit.name(), this.getListComment( this.selectedPowerUnit ) ).set( this.selectedPowerUnit.name() );
|
||||
@@ -619,16 +619,16 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
return this.levelByStacks;
|
||||
}
|
||||
|
||||
public int getStorageBiomeID()
|
||||
{
|
||||
return this.storageBiomeID;
|
||||
}
|
||||
|
||||
public int getStorageProviderID()
|
||||
{
|
||||
return this.storageProviderID;
|
||||
}
|
||||
|
||||
public int getStorageDimensionID()
|
||||
{
|
||||
return this.storageDimensionID;
|
||||
}
|
||||
|
||||
public double getSpatialPowerExponent()
|
||||
{
|
||||
return this.spatialPowerExponent;
|
||||
@@ -766,13 +766,13 @@ public final class AEConfig extends Configuration implements IConfigurableObject
|
||||
|
||||
// Setters keep visibility as low as possible.
|
||||
|
||||
void setStorageBiomeID( int id )
|
||||
{
|
||||
this.storageBiomeID = id;
|
||||
}
|
||||
|
||||
void setStorageProviderID( int id )
|
||||
{
|
||||
this.storageProviderID = id;
|
||||
}
|
||||
|
||||
void setStorageDimensionID( int id )
|
||||
{
|
||||
this.storageDimensionID = id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +136,11 @@ public final class AppEng
|
||||
return this.registration.storageDimensionType;
|
||||
}
|
||||
|
||||
public int getStorageDimensionID()
|
||||
{
|
||||
return this.registration.storageDimensionID;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void preInit( final FMLPreInitializationEvent event )
|
||||
{
|
||||
@@ -170,7 +175,7 @@ public final class AppEng
|
||||
{
|
||||
IntegrationRegistry.INSTANCE.add( type );
|
||||
}
|
||||
|
||||
|
||||
this.registration.preInitialize( event );
|
||||
|
||||
if( Platform.isClient() )
|
||||
|
||||
@@ -35,10 +35,13 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
@@ -86,10 +89,8 @@ import appeng.core.features.registries.cell.CreativeCellHandler;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.stats.PlayerStatsRegistration;
|
||||
import appeng.core.worlddata.SpatialDimensionManager;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.Integrations;
|
||||
import appeng.items.materials.ItemMaterial;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
import appeng.loot.ChestLoot;
|
||||
@@ -128,6 +129,7 @@ import appeng.worldgen.QuartzWorldGen;
|
||||
final class Registration
|
||||
{
|
||||
DimensionType storageDimensionType;
|
||||
int storageDimensionID;
|
||||
Biome storageBiome;
|
||||
|
||||
private File recipeDirectory;
|
||||
@@ -159,28 +161,29 @@ final class Registration
|
||||
definitions.getRegistry().getBootstrapComponents( IPreInitComponent.class ).forEachRemaining( b -> b.preInitialize( event.getSide() ) );
|
||||
}
|
||||
|
||||
private void registerSpatial( final boolean force, IForgeRegistry<Biome> registry )
|
||||
private void registerSpatialBiome( IForgeRegistry<Biome> registry )
|
||||
{
|
||||
if( !AEConfig.instance().isFeatureEnabled( AEFeature.SPATIAL_IO ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final AEConfig config = AEConfig.instance();
|
||||
|
||||
if( this.storageBiome == null )
|
||||
{
|
||||
this.storageBiome = new BiomeGenStorage();
|
||||
}
|
||||
|
||||
registry.register( this.storageBiome.setRegistryName( "appliedenergistics2:storage_biome" ) );
|
||||
}
|
||||
|
||||
if( config.getStorageProviderID() != -1 )
|
||||
private void registerSpatialDimension()
|
||||
{
|
||||
final AEConfig config = AEConfig.instance();
|
||||
if( !config.isFeatureEnabled( AEFeature.SPATIAL_IO ) )
|
||||
{
|
||||
this.storageDimensionType = DimensionType.register( "Storage Cell", "_cell", config.getStorageProviderID(), StorageWorldProvider.class, false );
|
||||
return;
|
||||
}
|
||||
|
||||
if( config.getStorageProviderID() == -1 && force )
|
||||
if( config.getStorageProviderID() == -1 )
|
||||
{
|
||||
final Set<Integer> ids = new HashSet<>();
|
||||
for( DimensionType type : DimensionType.values() )
|
||||
@@ -188,17 +191,25 @@ final class Registration
|
||||
ids.add( type.getId() );
|
||||
}
|
||||
|
||||
config.setStorageProviderID( -11 );
|
||||
|
||||
while( ids.contains( config.getStorageProviderID() ) )
|
||||
int newId = -11;
|
||||
while( ids.contains( newId ) )
|
||||
{
|
||||
config.setStorageProviderID( config.getStorageProviderID() - 1 );
|
||||
--newId;
|
||||
}
|
||||
|
||||
this.storageDimensionType = DimensionType.register( "Storage Cell", "_cell", config.getStorageProviderID(), StorageWorldProvider.class, false );
|
||||
|
||||
config.setStorageProviderID( newId );
|
||||
config.save();
|
||||
}
|
||||
|
||||
this.storageDimensionType = DimensionType.register( "Storage Cell", "_cell", config.getStorageProviderID(), StorageWorldProvider.class, true );
|
||||
|
||||
if( config.getStorageDimensionID() == -1 )
|
||||
{
|
||||
config.setStorageDimensionID( DimensionManager.getNextFreeDimId() );
|
||||
config.save();
|
||||
}
|
||||
this.storageDimensionID = config.getStorageDimensionID();
|
||||
|
||||
DimensionManager.registerDimension( this.storageDimensionID, this.storageDimensionType );
|
||||
}
|
||||
|
||||
private void registerCraftHandlers( final IRecipeHandlerRegistry registry )
|
||||
@@ -284,7 +295,7 @@ final class Registration
|
||||
public void registerBiomes( RegistryEvent.Register<Biome> event )
|
||||
{
|
||||
final IForgeRegistry<Biome> registry = event.getRegistry();
|
||||
this.registerSpatial( false, registry );
|
||||
this.registerSpatialBiome( registry );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -355,6 +366,16 @@ final class Registration
|
||||
recipeHandler.injectRecipes();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void attachSpatialDimensionManager( AttachCapabilitiesEvent<World> event )
|
||||
{
|
||||
if( AEConfig.instance()
|
||||
.isFeatureEnabled( AEFeature.SPATIAL_IO ) && event.getObject() == DimensionManager.getWorld( AEConfig.instance().getStorageDimensionID() ) )
|
||||
{
|
||||
event.addCapability( new ResourceLocation( "appliedenergistics2:spatial_dimension_manager" ), new SpatialDimensionManager( event.getObject() ) );
|
||||
}
|
||||
}
|
||||
|
||||
void postInit( final FMLPostInitializationEvent event )
|
||||
{
|
||||
final IRegistryContainer registries = Api.INSTANCE.registries();
|
||||
@@ -363,6 +384,8 @@ final class Registration
|
||||
final IBlocks blocks = definitions.blocks();
|
||||
final IItems items = definitions.items();
|
||||
|
||||
registerSpatialDimension();
|
||||
|
||||
// default settings..
|
||||
( (P2PTunnelRegistry) registries.p2pTunnel() ).configure();
|
||||
|
||||
@@ -469,6 +492,7 @@ final class Registration
|
||||
/*
|
||||
* White List Vanilla...
|
||||
*/
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityBanner.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityBeacon.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityBrewingStand.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityChest.class );
|
||||
@@ -480,15 +504,15 @@ final class Registration
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityEnchantmentTable.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityEnderChest.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityEndPortal.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntitySkull.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityFurnace.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityMobSpawner.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntitySign.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityPiston.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityFlowerPot.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityNote.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityFurnace.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityHopper.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityMobSpawner.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityNote.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityPiston.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntityShulkerBox.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntitySign.class );
|
||||
mr.whiteListTileEntity( net.minecraft.tileentity.TileEntitySkull.class );
|
||||
|
||||
/*
|
||||
* Whitelist AE2
|
||||
|
||||
@@ -92,7 +92,10 @@ public enum GuiText
|
||||
FETunnel,
|
||||
PressureTunnel,
|
||||
|
||||
// spatial
|
||||
StoredSize,
|
||||
CellId,
|
||||
|
||||
CopyMode,
|
||||
CopyModeDesc,
|
||||
PatternTerminal,
|
||||
@@ -114,6 +117,8 @@ public enum GuiText
|
||||
MaxPower,
|
||||
RequiredPower,
|
||||
Efficiency,
|
||||
SCSSize,
|
||||
SCSSInvalid,
|
||||
InWorldCrafting,
|
||||
|
||||
inWorldFluix,
|
||||
|
||||
@@ -39,7 +39,6 @@ import appeng.core.sync.packets.PacketLightning;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketMatterCannon;
|
||||
import appeng.core.sync.packets.PacketMockExplosion;
|
||||
import appeng.core.sync.packets.PacketNewStorageDimension;
|
||||
import appeng.core.sync.packets.PacketPaintedEntity;
|
||||
import appeng.core.sync.packets.PacketPartPlacement;
|
||||
import appeng.core.sync.packets.PacketPartialItem;
|
||||
@@ -83,8 +82,6 @@ public class AppEngPacketHandlerBase
|
||||
|
||||
PACKET_CLICK( PacketClick.class ),
|
||||
|
||||
PACKET_NEW_STORAGE_DIMENSION( PacketNewStorageDimension.class ),
|
||||
|
||||
PACKET_SWITCH_GUIS( PacketSwitchGuis.class ),
|
||||
|
||||
PACKET_SWAP_SLOTS( PacketSwapSlots.class ),
|
||||
|
||||
@@ -24,15 +24,12 @@ import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.network.ThreadQuickExitException;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
|
||||
import net.minecraftforge.fml.common.network.FMLEventChannel;
|
||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent;
|
||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerConnectionFromClientEvent;
|
||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
|
||||
|
||||
public class NetworkHandler
|
||||
@@ -89,21 +86,6 @@ public class NetworkHandler
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void newConnection( final ServerConnectionFromClientEvent ev )
|
||||
{
|
||||
WorldData.instance().dimensionData().sendToPlayer( ev.getManager() );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void newConnection( final PlayerLoggedInEvent loginEvent )
|
||||
{
|
||||
if( loginEvent.player instanceof EntityPlayerMP )
|
||||
{
|
||||
WorldData.instance().dimensionData().sendToPlayer( null );
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverPacket( final ServerCustomPacketEvent ev )
|
||||
{
|
||||
|
||||
@@ -30,17 +30,13 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -49,15 +45,13 @@ import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.AdaptorItemHandler;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.prioritylist.IPartitionList;
|
||||
@@ -114,165 +108,132 @@ public class PacketJEIRecipe extends AppEngPacket
|
||||
final EntityPlayerMP pmp = (EntityPlayerMP) player;
|
||||
final Container con = pmp.openContainer;
|
||||
|
||||
if( con instanceof IContainerCraftingPacket )
|
||||
if( !( con instanceof IContainerCraftingPacket ) )
|
||||
{
|
||||
final IContainerCraftingPacket cct = (IContainerCraftingPacket) con;
|
||||
final IGridNode node = cct.getNetworkNode();
|
||||
if( node != null )
|
||||
return;
|
||||
}
|
||||
|
||||
final IContainerCraftingPacket cct = (IContainerCraftingPacket) con;
|
||||
final IGridNode node = cct.getNetworkNode();
|
||||
|
||||
if( node == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final IGrid grid = node.getGrid();
|
||||
if( grid == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final IStorageGrid inv = grid.getCache( IStorageGrid.class );
|
||||
final IEnergyGrid energy = grid.getCache( IEnergyGrid.class );
|
||||
final ISecurityGrid security = grid.getCache( ISecurityGrid.class );
|
||||
final IItemHandler craftMatrix = cct.getInventoryByName( "crafting" );
|
||||
final IItemHandler playerInventory = cct.getInventoryByName( "player" );
|
||||
|
||||
if( inv != null && this.recipe != null && security != null )
|
||||
{
|
||||
final IMEMonitor<IAEItemStack> storage = inv.getItemInventory();
|
||||
final IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
|
||||
|
||||
for( int x = 0; x < craftMatrix.getSlots(); x++ )
|
||||
{
|
||||
final IGrid grid = node.getGrid();
|
||||
if( grid == null )
|
||||
ItemStack currentItem = craftMatrix.getStackInSlot( x );
|
||||
|
||||
// prepare slots
|
||||
if( !currentItem.isEmpty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
// already the correct item?
|
||||
ItemStack newItem = canUseInSlot( x, currentItem );
|
||||
|
||||
final IStorageGrid inv = grid.getCache( IStorageGrid.class );
|
||||
final IEnergyGrid energy = grid.getCache( IEnergyGrid.class );
|
||||
final ISecurityGrid security = grid.getCache( ISecurityGrid.class );
|
||||
final IItemHandler craftMatrix = cct.getInventoryByName( "crafting" );
|
||||
final IItemHandler playerInventory = cct.getInventoryByName( "player" );
|
||||
|
||||
final Actionable realForFake = cct.useRealItems() ? Actionable.MODULATE : Actionable.SIMULATE;
|
||||
|
||||
if( inv != null && this.recipe != null && security != null )
|
||||
{
|
||||
final InventoryCrafting testInv = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||
for( int x = 0; x < 9; x++ )
|
||||
// put away old item
|
||||
if( newItem != currentItem && security.hasPermission( player, SecurityPermissions.INJECT ) )
|
||||
{
|
||||
if( this.recipe[x] != null && this.recipe[x].length > 0 )
|
||||
final IAEItemStack in = AEItemStack.create( currentItem );
|
||||
final IAEItemStack out = cct.useRealItems() ? Platform.poweredInsert( energy, storage, in, cct.getActionSource() ) : null;
|
||||
if( out != null )
|
||||
{
|
||||
testInv.setInventorySlotContents( x, this.recipe[x][0] );
|
||||
currentItem = out.getItemStack();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentItem = ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final IRecipe r = Platform.findMatchingRecipe( testInv, pmp.world );
|
||||
|
||||
if( r != null && security.hasPermission( player, SecurityPermissions.EXTRACT ) )
|
||||
if( currentItem.isEmpty() && this.recipe[x] != null )
|
||||
{
|
||||
// for each variant
|
||||
for( int y = 0; y < this.recipe[x].length && currentItem.isEmpty(); y++ )
|
||||
{
|
||||
final ItemStack is = r.getCraftingResult( testInv );
|
||||
|
||||
if( !is.isEmpty() )
|
||||
final IAEItemStack request = AEItemStack.create( this.recipe[x][y] );
|
||||
if( request != null )
|
||||
{
|
||||
final IMEMonitor<IAEItemStack> storage = inv.getItemInventory();
|
||||
final IItemList all = storage.getStorageList();
|
||||
final IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
|
||||
|
||||
for( int x = 0; x < craftMatrix.getSlots(); x++ )
|
||||
// try ae
|
||||
if( ( filter == null || filter.isListed( request ) ) && security.hasPermission( player, SecurityPermissions.EXTRACT ) )
|
||||
{
|
||||
final ItemStack patternItem = testInv.getStackInSlot( x );
|
||||
|
||||
ItemStack currentItem = craftMatrix.getStackInSlot( x );
|
||||
if( !currentItem.isEmpty() )
|
||||
request.setStackSize( 1 );
|
||||
IAEItemStack out;
|
||||
if( cct.useRealItems() )
|
||||
{
|
||||
testInv.setInventorySlotContents( x, currentItem );
|
||||
final ItemStack newItemStack = r.matches( testInv, pmp.world ) ? r.getCraftingResult( testInv ) : ItemStack.EMPTY;
|
||||
testInv.setInventorySlotContents( x, patternItem );
|
||||
|
||||
if( newItemStack.isEmpty() || !Platform.itemComparisons().isSameItem( newItemStack, is ) )
|
||||
{
|
||||
final IAEItemStack in = AEItemStack.create( currentItem );
|
||||
if( in != null )
|
||||
{
|
||||
final IAEItemStack out = realForFake == Actionable.SIMULATE ? null : Platform.poweredInsert( energy, storage, in,
|
||||
cct.getActionSource() );
|
||||
if( out != null )
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( craftMatrix, x, out.getItemStack() );
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemHandlerUtil.setStackInSlot( craftMatrix, x, ItemStack.EMPTY );
|
||||
}
|
||||
|
||||
currentItem = craftMatrix.getStackInSlot( x );
|
||||
}
|
||||
}
|
||||
out = Platform.poweredExtraction( energy, storage, request, cct.getActionSource() );
|
||||
}
|
||||
else
|
||||
{
|
||||
out = storage.extractItems( request, Actionable.SIMULATE, cct.getActionSource() );
|
||||
}
|
||||
|
||||
// True if we need to fetch an item for the recipe
|
||||
if( !patternItem.isEmpty() && currentItem.isEmpty() )
|
||||
if( out != null )
|
||||
{
|
||||
// Grab from network by recipe
|
||||
ItemStack whichItem = Platform.extractItemsByRecipe( energy, cct.getActionSource(), storage, player.world, r, is, testInv,
|
||||
patternItem, x, all, realForFake, filter );
|
||||
|
||||
// If that doesn't get it, grab exact items from network (?)
|
||||
// TODO see if this code is necessary
|
||||
if( whichItem.isEmpty() )
|
||||
{
|
||||
for( int y = 0; y < this.recipe[x].length; y++ )
|
||||
{
|
||||
final IAEItemStack request = AEItemStack.create( this.recipe[x][y] );
|
||||
if( request != null )
|
||||
{
|
||||
if( filter == null || filter.isListed( request ) )
|
||||
{
|
||||
request.setStackSize( 1 );
|
||||
final IAEItemStack out = Platform.poweredExtraction( energy, storage, request, cct.getActionSource() );
|
||||
if( out != null )
|
||||
{
|
||||
whichItem = out.getItemStack();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If that doesn't work, grab from the player's inventory
|
||||
if( whichItem.isEmpty() && playerInventory != null )
|
||||
{
|
||||
whichItem = this.extractItemFromPlayerInventory( player, realForFake, patternItem );
|
||||
}
|
||||
|
||||
ItemHandlerUtil.setStackInSlot( craftMatrix, x, whichItem );
|
||||
currentItem = out.getItemStack();
|
||||
}
|
||||
}
|
||||
|
||||
// try inventory
|
||||
if( currentItem.isEmpty() )
|
||||
{
|
||||
AdaptorItemHandler ad = new AdaptorItemHandler( playerInventory );
|
||||
|
||||
if( cct.useRealItems() )
|
||||
{
|
||||
currentItem = ad.removeItems( 1, this.recipe[x][y], null );
|
||||
}
|
||||
else
|
||||
{
|
||||
currentItem = ad.simulateRemove( 1, this.recipe[x][y], null );
|
||||
}
|
||||
}
|
||||
con.onCraftMatrixChanged( new WrapperInvItemHandler( craftMatrix ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
ItemHandlerUtil.setStackInSlot( craftMatrix, x, currentItem );
|
||||
}
|
||||
con.onCraftMatrixChanged( new WrapperInvItemHandler( craftMatrix ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to extract an item from the player inventory. Does account for fuzzy items.
|
||||
*
|
||||
* @param player the {@link EntityPlayer} to extract from
|
||||
* @param mode the {@link Actionable} to simulate or modulate the operation
|
||||
* @param patternItem which {@link ItemStack} to extract
|
||||
* @return null or a found {@link ItemStack}
|
||||
*
|
||||
* @param slot
|
||||
* @param is itemstack
|
||||
* @return is if it can be used, else EMPTY
|
||||
*/
|
||||
private ItemStack extractItemFromPlayerInventory( final EntityPlayer player, final Actionable mode, final ItemStack patternItem )
|
||||
private ItemStack canUseInSlot( int slot, ItemStack is )
|
||||
{
|
||||
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player );
|
||||
final AEItemStack request = AEItemStack.create( patternItem );
|
||||
final boolean isSimulated = mode == Actionable.SIMULATE;
|
||||
final boolean checkFuzzy = request.isOre() || patternItem.getItemDamage() == OreDictionary.WILDCARD_VALUE || patternItem.hasTagCompound() || patternItem
|
||||
.isItemStackDamageable();
|
||||
|
||||
if( !checkFuzzy )
|
||||
if( this.recipe[slot] != null )
|
||||
{
|
||||
if( isSimulated )
|
||||
for( ItemStack option : this.recipe[slot] )
|
||||
{
|
||||
return ia.simulateRemove( 1, patternItem, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ia.removeItems( 1, patternItem, null );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( isSimulated )
|
||||
{
|
||||
return ia.simulateSimilarRemove( 1, patternItem, FuzzyMode.IGNORE_ALL, null );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ia.removeSimilarItems( 1, patternItem, FuzzyMode.IGNORE_ALL, null );
|
||||
if( is.isItemEqual( option ) )
|
||||
{
|
||||
return is;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
|
||||
public class PacketNewStorageDimension extends AppEngPacket
|
||||
{
|
||||
|
||||
private final int newDim;
|
||||
|
||||
// automatic.
|
||||
public PacketNewStorageDimension( final ByteBuf stream )
|
||||
{
|
||||
this.newDim = stream.readInt();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketNewStorageDimension( final int newDim )
|
||||
{
|
||||
this.newDim = newDim;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( newDim );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final EntityPlayer player )
|
||||
{
|
||||
try
|
||||
{
|
||||
DimensionManager.registerDimension( this.newDim, AppEng.instance().getStorageDimensionType() );
|
||||
}
|
||||
catch( final IllegalArgumentException iae )
|
||||
{
|
||||
// ok!
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.worlddata;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketNewStorageDimension;
|
||||
import appeng.hooks.TickHandler;
|
||||
|
||||
|
||||
/**
|
||||
* @author thatsIch
|
||||
* @version rv3 - 30.05.2015
|
||||
* @since rv3 30.05.2015
|
||||
*/
|
||||
final class DimensionData implements IWorldDimensionData, IOnWorldStartable, IOnWorldStoppable
|
||||
{
|
||||
private static final String CONFIG_CATEGORY = "DimensionManager";
|
||||
private static final String CONFIG_KEY = "StorageCells";
|
||||
private static final int[] STORAGE_CELLS_DEFAULT = new int[0];
|
||||
|
||||
private static final String STORAGE_CELL_CATEGORY = "StorageCell";
|
||||
|
||||
private static final String STORAGE_CELL_SCALE_X_KEY = "scaleX";
|
||||
private static final String STORAGE_CELL_SCALE_Y_KEY = "scaleY";
|
||||
private static final String STORAGE_CELL_SCALE_Z_KEY = "scaleZ";
|
||||
|
||||
private static final String PACKAGE_DEST_CATEGORY = "DimensionManager";
|
||||
private static final String PACKAGE_KEY_CATEGORY = "StorageCells";
|
||||
private static final int[] PACKAGE_DEF_CATEGORY = new int[0];
|
||||
|
||||
private final Configuration config;
|
||||
private final List<Integer> storageCellDimensionIDs;
|
||||
|
||||
DimensionData( @Nonnull final Configuration parentFile )
|
||||
{
|
||||
Preconditions.checkNotNull( parentFile );
|
||||
|
||||
this.config = parentFile;
|
||||
|
||||
final int[] storageCellIDs = this.storageCellIDsProperty().getIntList();
|
||||
|
||||
this.storageCellDimensionIDs = Lists.newArrayList();
|
||||
for( final int storageCellID : storageCellIDs )
|
||||
{
|
||||
this.storageCellDimensionIDs.add( storageCellID );
|
||||
}
|
||||
}
|
||||
|
||||
private Property storageCellIDsProperty()
|
||||
{
|
||||
return this.config.get( CONFIG_CATEGORY, CONFIG_KEY, STORAGE_CELLS_DEFAULT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldStart()
|
||||
{
|
||||
for( final Integer storageCellDimID : this.storageCellDimensionIDs )
|
||||
{
|
||||
DimensionManager.registerDimension( storageCellDimID, AppEng.instance().getStorageDimensionType() );
|
||||
}
|
||||
|
||||
this.config.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWorldStop()
|
||||
{
|
||||
this.config.save();
|
||||
|
||||
for( final Integer storageCellDimID : this.storageCellDimensionIDs )
|
||||
{
|
||||
DimensionManager.unregisterDimension( storageCellDimID );
|
||||
}
|
||||
|
||||
this.storageCellDimensionIDs.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStorageCell( final int newStorageCellID )
|
||||
{
|
||||
this.storageCellDimensionIDs.add( newStorageCellID );
|
||||
DimensionManager.registerDimension( newStorageCellID, AppEng.instance().getStorageDimensionType() );
|
||||
|
||||
NetworkHandler.instance().sendToAll( new PacketNewStorageDimension( newStorageCellID ) );
|
||||
|
||||
final String[] values = new String[this.storageCellDimensionIDs.size()];
|
||||
|
||||
for( int x = 0; x < values.length; x++ )
|
||||
{
|
||||
values[x] = String.valueOf( this.storageCellDimensionIDs.get( x ) );
|
||||
}
|
||||
|
||||
this.storageCellIDsProperty().set( values );
|
||||
this.config.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldCoord getStoredSize( final int dim )
|
||||
{
|
||||
final String category = STORAGE_CELL_CATEGORY + dim;
|
||||
|
||||
final int x = this.config.get( category, STORAGE_CELL_SCALE_X_KEY, 0 ).getInt();
|
||||
final int y = this.config.get( category, STORAGE_CELL_SCALE_Y_KEY, 0 ).getInt();
|
||||
final int z = this.config.get( category, STORAGE_CELL_SCALE_Z_KEY, 0 ).getInt();
|
||||
|
||||
return new WorldCoord( x, y, z );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredSize( final int dim, final int targetX, final int targetY, final int targetZ )
|
||||
{
|
||||
final String category = STORAGE_CELL_CATEGORY + dim;
|
||||
|
||||
this.config.get( category, STORAGE_CELL_SCALE_X_KEY, 0 ).set( targetX );
|
||||
this.config.get( category, STORAGE_CELL_SCALE_Y_KEY, 0 ).set( targetY );
|
||||
this.config.get( category, STORAGE_CELL_SCALE_Z_KEY, 0 ).set( targetZ );
|
||||
|
||||
this.config.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendToPlayer( @Nullable final NetworkManager manager )
|
||||
{
|
||||
if( manager != null )
|
||||
{
|
||||
for( final int newDim : this.config.get( PACKAGE_DEST_CATEGORY, PACKAGE_KEY_CATEGORY, PACKAGE_DEF_CATEGORY ).getIntList() )
|
||||
{
|
||||
manager.sendPacket( ( new PacketNewStorageDimension( newDim ) ).getProxy() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( final TickHandler.PlayerColor pc : TickHandler.INSTANCE.getPlayerColors().values() )
|
||||
{
|
||||
NetworkHandler.instance().sendToAll( pc.getPacket() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,9 +39,6 @@ public interface IWorldData
|
||||
@Nonnull
|
||||
IWorldPlayerData playerData();
|
||||
|
||||
@Nonnull
|
||||
IWorldDimensionData dimensionData();
|
||||
|
||||
@Nonnull
|
||||
IWorldCompassData compassData();
|
||||
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.core.worlddata;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
import appeng.capabilities.Capabilities;
|
||||
|
||||
|
||||
public class SpatialDimensionManager implements ISpatialDimension, ICapabilitySerializable<NBTTagCompound>
|
||||
{
|
||||
private static final String NBT_SPATIAL_DATA_KEY = "spatial_data";
|
||||
private static final String NBT_SPATIAL_ID_KEY = "id";
|
||||
|
||||
private World world;
|
||||
private Map<Integer, StorageCellData> spatialData = new HashMap<>();
|
||||
|
||||
private static final int MAX_CELL_DIMENSION = 512;
|
||||
|
||||
public SpatialDimensionManager( World world )
|
||||
{
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int createNewCellDimension( BlockPos contentSize, int owner )
|
||||
{
|
||||
int newId = this.getNextId();
|
||||
|
||||
StorageCellData data = new StorageCellData();
|
||||
data.contentDimension = contentSize;
|
||||
data.owner = owner;
|
||||
|
||||
this.spatialData.put( newId, data );
|
||||
|
||||
return newId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCellDimension( int cellStorageId )
|
||||
{
|
||||
StorageCellData removed = spatialData.remove( cellStorageId );
|
||||
if( removed != null )
|
||||
{
|
||||
this.clearCellArea( cellStorageId, removed );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellDimension( int cellStorageId )
|
||||
{
|
||||
return this.spatialData.containsKey( cellStorageId );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellDimensionOwner( int cellStorageId )
|
||||
{
|
||||
StorageCellData cell = this.spatialData.get( cellStorageId );
|
||||
if( cell != null )
|
||||
{
|
||||
return cell.owner;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCellDimensionOrigin( int cellStorageId )
|
||||
{
|
||||
if( this.isCellDimension( cellStorageId ) )
|
||||
{
|
||||
return getBlockPosFromId( cellStorageId );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCellContentSize( int cellStorageId )
|
||||
{
|
||||
StorageCellData cell = this.spatialData.get( cellStorageId );
|
||||
if( cell != null )
|
||||
{
|
||||
return cell.contentDimension;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capability, EnumFacing facing )
|
||||
{
|
||||
return capability == Capabilities.SPATIAL_DIMENSION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capability, EnumFacing facing )
|
||||
{
|
||||
if( capability == Capabilities.SPATIAL_DIMENSION )
|
||||
{
|
||||
return (T) this;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serializeNBT()
|
||||
{
|
||||
final NBTTagCompound ret = new NBTTagCompound();
|
||||
final NBTTagList list = new NBTTagList();
|
||||
|
||||
for( Map.Entry<Integer, StorageCellData> entry : this.spatialData.entrySet() )
|
||||
{
|
||||
final NBTTagCompound nbt = entry.getValue().serializeNBT();
|
||||
nbt.setInteger( NBT_SPATIAL_ID_KEY, entry.getKey() );
|
||||
list.appendTag( nbt );
|
||||
}
|
||||
ret.setTag( NBT_SPATIAL_DATA_KEY, list );
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT( NBTTagCompound nbt )
|
||||
{
|
||||
if( nbt.hasKey( NBT_SPATIAL_DATA_KEY ) )
|
||||
{
|
||||
final NBTTagList list = (NBTTagList) nbt.getTag( NBT_SPATIAL_DATA_KEY );
|
||||
|
||||
this.spatialData.clear();
|
||||
for( int i = 0; i < list.tagCount(); ++i )
|
||||
{
|
||||
final NBTTagCompound entry = list.getCompoundTagAt( i );
|
||||
final StorageCellData data = new StorageCellData();
|
||||
final int id = entry.getInteger( NBT_SPATIAL_ID_KEY );
|
||||
data.deserializeNBT( entry );
|
||||
this.spatialData.put( id, data );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getNextId()
|
||||
{
|
||||
return this.spatialData.keySet().stream().max( Integer::compare ).orElse( -1 ) + 1;
|
||||
}
|
||||
|
||||
private BlockPos getBlockPosFromId( int id )
|
||||
{
|
||||
int signBits = id & 0b11;
|
||||
int offsetBits = id >> 2;
|
||||
int offsetScale = 1;
|
||||
int posx = MAX_CELL_DIMENSION / 2;
|
||||
int posz = MAX_CELL_DIMENSION / 2;
|
||||
|
||||
// find quadrant
|
||||
while( offsetBits != 0 )
|
||||
{
|
||||
posx += MAX_CELL_DIMENSION * offsetScale * ( offsetBits & 0b01 );
|
||||
posz += MAX_CELL_DIMENSION * offsetScale * ( offsetBits >> 1 & 0b01 );
|
||||
|
||||
offsetBits >>= 2;
|
||||
offsetScale <<= 1;
|
||||
}
|
||||
|
||||
// mirror in one of 4 directions
|
||||
if( ( signBits & 0b01 ) == 0 )
|
||||
{
|
||||
posx *= -1;
|
||||
}
|
||||
if( ( signBits & 0b10 ) == 0 )
|
||||
{
|
||||
posz *= -1;
|
||||
}
|
||||
|
||||
// offset from cell center
|
||||
posx -= 64;
|
||||
posz -= 64;
|
||||
|
||||
return new BlockPos( posx, 64, posz );
|
||||
}
|
||||
|
||||
private void clearCellArea( int cellId, StorageCellData cell )
|
||||
{
|
||||
// TODO reset chunks?
|
||||
}
|
||||
|
||||
private static class StorageCellData implements INBTSerializable<NBTTagCompound>
|
||||
{
|
||||
private static final String NBT_OWNER_KEY = "owner";
|
||||
private static final String NBT_DIM_X_KEY = "dim_x";
|
||||
private static final String NBT_DIM_Y_KEY = "dim_y";
|
||||
private static final String NBT_DIM_Z_KEY = "dim_z";
|
||||
|
||||
public BlockPos contentDimension;
|
||||
public int owner;
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serializeNBT()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger( NBT_DIM_X_KEY, contentDimension.getX() );
|
||||
nbt.setInteger( NBT_DIM_Y_KEY, contentDimension.getY() );
|
||||
nbt.setInteger( NBT_DIM_Z_KEY, contentDimension.getZ() );
|
||||
nbt.setInteger( NBT_OWNER_KEY, owner );
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT( NBTTagCompound nbt )
|
||||
{
|
||||
contentDimension = new BlockPos( nbt.getInteger( NBT_DIM_X_KEY ), nbt.getInteger( NBT_DIM_Y_KEY ), nbt.getInteger( NBT_DIM_Z_KEY ) );
|
||||
owner = nbt.getInteger( NBT_OWNER_KEY );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,6 @@ public final class WorldData implements IWorldData
|
||||
private static IWorldData instance;
|
||||
|
||||
private final IWorldPlayerData playerData;
|
||||
private final IWorldDimensionData dimensionData;
|
||||
private final IWorldGridStorageData storageData;
|
||||
private final IWorldCompassData compassData;
|
||||
private final IWorldSpawnData spawnData;
|
||||
@@ -87,7 +86,6 @@ public final class WorldData implements IWorldData
|
||||
this.sharedConfig = new Configuration( settingsFile, AEConfig.VERSION );
|
||||
|
||||
final PlayerData playerData = new PlayerData( this.sharedConfig );
|
||||
final DimensionData dimensionData = new DimensionData( this.sharedConfig );
|
||||
final StorageData storageData = new StorageData( this.sharedConfig );
|
||||
|
||||
final ThreadFactory compassThreadFactory = new CompassThreadFactory();
|
||||
@@ -97,13 +95,12 @@ public final class WorldData implements IWorldData
|
||||
final IWorldSpawnData spawnData = new SpawnData( this.spawnDirectory );
|
||||
|
||||
this.playerData = playerData;
|
||||
this.dimensionData = dimensionData;
|
||||
this.storageData = storageData;
|
||||
this.compassData = compassData;
|
||||
this.spawnData = spawnData;
|
||||
|
||||
this.startables = Lists.<IOnWorldStartable>newArrayList( playerData, dimensionData, storageData );
|
||||
this.stoppables = Lists.<IOnWorldStoppable>newArrayList( playerData, dimensionData, storageData, compassData );
|
||||
this.startables = Lists.<IOnWorldStartable>newArrayList( playerData, storageData );
|
||||
this.stoppables = Lists.<IOnWorldStoppable>newArrayList( playerData, storageData, compassData );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,13 +195,6 @@ public final class WorldData implements IWorldData
|
||||
return this.playerData;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IWorldDimensionData dimensionData()
|
||||
{
|
||||
return this.dimensionData;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IWorldCompassData compassData()
|
||||
|
||||
@@ -106,7 +106,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
||||
|
||||
if( this.isCrafting )
|
||||
{
|
||||
this.standardRecipe = Platform.findMatchingRecipe( this.crafting, w );
|
||||
this.standardRecipe = CraftingManager.findMatchingRecipe( this.crafting, w );
|
||||
|
||||
if( this.standardRecipe != null )
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.google.common.collect.LinkedListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
@@ -166,18 +165,6 @@ public class TickHandler
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkLoad( final ChunkEvent.Load load )
|
||||
{
|
||||
for( final Object te : load.getChunk().getTileEntityMap().values() )
|
||||
{
|
||||
if( te instanceof AEBaseTile )
|
||||
{
|
||||
( (AEBaseTile) te ).onChunkLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick( final TickEvent ev )
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.minecraft.util.EnumFacing;
|
||||
import ic2.api.energy.prefab.BasicSink;
|
||||
import ic2.api.energy.tile.IEnergyEmitter;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.integration.abstraction.IC2PowerSink;
|
||||
import appeng.tile.powersink.IExternalPowerSink;
|
||||
@@ -76,7 +77,7 @@ public class IC2PowerSinkAdapter extends BasicSink implements IC2PowerSink
|
||||
@Override
|
||||
public double injectEnergy( EnumFacing directionFrom, double amount, double voltage )
|
||||
{
|
||||
return PowerUnits.EU.convertTo( PowerUnits.AE, this.powerSink.injectExternalPower( PowerUnits.EU, amount ) );
|
||||
return PowerUnits.EU.convertTo( PowerUnits.AE, this.powerSink.injectExternalPower( PowerUnits.EU, amount, Actionable.MODULATE ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -93,6 +93,13 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
|
||||
{
|
||||
final NBTTagList tags = new NBTTagList();
|
||||
final List<ItemStack> list = new LinkedList<>();
|
||||
final ItemStack displayed = ingredient.getDisplayedIngredient();
|
||||
|
||||
// prefer currently displayed item
|
||||
if( displayed != null && !displayed.isEmpty() )
|
||||
{
|
||||
list.add( displayed );
|
||||
}
|
||||
|
||||
// prefer pure crystals.
|
||||
for( ItemStack stack : ingredient.getAllIngredients() )
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.List;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -31,17 +32,23 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.implementations.TransitionResult;
|
||||
import appeng.api.implementations.items.ISpatialStorageCell;
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.spatial.StorageHelper;
|
||||
import appeng.spatial.StorageWorldProvider;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorageCell
|
||||
{
|
||||
private static final String NBT_CELL_ID_KEY = "StorageCellID";
|
||||
private static final String NBT_SIZE_X_KEY = "sizeX";
|
||||
private static final String NBT_SIZE_Y_KEY = "sizeY";
|
||||
private static final String NBT_SIZE_Z_KEY = "sizeZ";
|
||||
|
||||
private final int maxRegion;
|
||||
|
||||
public ItemSpatialStorageCell( final int spatialScale )
|
||||
@@ -54,6 +61,12 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
||||
@Override
|
||||
public void addCheckedInformation( final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips )
|
||||
{
|
||||
final int id = this.getStoredDimensionID( stack );
|
||||
if( id >= 0 )
|
||||
{
|
||||
lines.add( GuiText.CellId.getLocal() + ": " + id );
|
||||
}
|
||||
|
||||
final WorldCoord wc = this.getStoredSize( stack );
|
||||
if( wc.x > 0 )
|
||||
{
|
||||
@@ -74,26 +87,19 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld( final ItemStack is )
|
||||
public ISpatialDimension getSpatialDimension()
|
||||
{
|
||||
if( is.hasTagCompound() )
|
||||
final int id = AppEng.instance().getStorageDimensionID();
|
||||
World w = DimensionManager.getWorld( id );
|
||||
if( w == null )
|
||||
{
|
||||
final NBTTagCompound c = is.getTagCompound();
|
||||
final int dim = c.getInteger( "StorageDim" );
|
||||
World w = DimensionManager.getWorld( dim );
|
||||
if( w == null )
|
||||
{
|
||||
DimensionManager.initDimension( dim );
|
||||
w = DimensionManager.getWorld( dim );
|
||||
}
|
||||
DimensionManager.initDimension( id );
|
||||
w = DimensionManager.getWorld( id );
|
||||
}
|
||||
|
||||
if( w != null )
|
||||
{
|
||||
if( w.provider instanceof StorageWorldProvider )
|
||||
{
|
||||
return w;
|
||||
}
|
||||
}
|
||||
if( w != null && w.hasCapability( Capabilities.SPATIAL_DIMENSION, null ) )
|
||||
{
|
||||
return w.getCapability( Capabilities.SPATIAL_DIMENSION, null );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -104,102 +110,80 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
|
||||
if( is.hasTagCompound() )
|
||||
{
|
||||
final NBTTagCompound c = is.getTagCompound();
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
final int dim = c.getInteger( "StorageDim" );
|
||||
return WorldData.instance().dimensionData().getStoredSize( dim );
|
||||
}
|
||||
else
|
||||
{
|
||||
return new WorldCoord( c.getInteger( "sizeX" ), c.getInteger( "sizeY" ), c.getInteger( "sizeZ" ) );
|
||||
}
|
||||
return new WorldCoord( c.getInteger( NBT_SIZE_X_KEY ), c.getInteger( NBT_SIZE_Y_KEY ), c.getInteger( NBT_SIZE_Z_KEY ) );
|
||||
}
|
||||
return new WorldCoord( 0, 0, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldCoord getMin( final ItemStack is )
|
||||
public int getStoredDimensionID( final ItemStack is )
|
||||
{
|
||||
final World w = this.getWorld( is );
|
||||
if( w != null )
|
||||
if( is.hasTagCompound() )
|
||||
{
|
||||
final NBTTagCompound info = (NBTTagCompound) w.getWorldInfo().getAdditionalProperty( "storageCell" );
|
||||
if( info != null )
|
||||
{
|
||||
return new WorldCoord( info.getInteger( "minX" ), info.getInteger( "minY" ), info.getInteger( "minZ" ) );
|
||||
}
|
||||
final NBTTagCompound c = is.getTagCompound();
|
||||
return c.getInteger( NBT_CELL_ID_KEY );
|
||||
}
|
||||
return new WorldCoord( 0, 0, 0 );
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldCoord getMax( final ItemStack is )
|
||||
public TransitionResult doSpatialTransition( final ItemStack is, final World w, final WorldCoord min, final WorldCoord max, int playerId )
|
||||
{
|
||||
final World w = this.getWorld( is );
|
||||
if( w != null )
|
||||
{
|
||||
final NBTTagCompound info = (NBTTagCompound) w.getWorldInfo().getAdditionalProperty( "storageCell" );
|
||||
if( info != null )
|
||||
{
|
||||
return new WorldCoord( info.getInteger( "maxX" ), info.getInteger( "maxY" ), info.getInteger( "maxZ" ) );
|
||||
}
|
||||
}
|
||||
return new WorldCoord( 0, 0, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransitionResult doSpatialTransition( final ItemStack is, final World w, final WorldCoord min, final WorldCoord max, final boolean doTransition )
|
||||
{
|
||||
final WorldCoord scale = this.getStoredSize( is );
|
||||
|
||||
final int targetX = max.x - min.x - 1;
|
||||
final int targetY = max.y - min.y - 1;
|
||||
final int targetZ = max.z - min.z - 1;
|
||||
final int maxSize = this.getMaxStoredDim( is );
|
||||
|
||||
World destination = this.getWorld( is );
|
||||
final BlockPos targetSize = new BlockPos( targetX, targetY, targetZ );
|
||||
|
||||
if( ( scale.x == 0 && scale.y == 0 && scale.z == 0 ) || ( scale.x == targetX && scale.y == targetY && scale.z == targetZ ) )
|
||||
ISpatialDimension manager = this.getSpatialDimension();
|
||||
|
||||
int cellid = this.getStoredDimensionID( is );
|
||||
if( cellid < 0 )
|
||||
{
|
||||
if( targetX <= maxSize && targetY <= maxSize && targetZ <= maxSize )
|
||||
cellid = manager.createNewCellDimension( targetSize, playerId );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if( manager.isCellDimension( cellid ) )
|
||||
{
|
||||
if( destination == null )
|
||||
BlockPos scale = manager.getCellContentSize( cellid );
|
||||
|
||||
if( scale.equals( targetSize ) )
|
||||
{
|
||||
destination = this.createNewWorld( is );
|
||||
if( targetX <= maxSize && targetY <= maxSize && targetZ <= maxSize )
|
||||
{
|
||||
BlockPos offset = manager.getCellDimensionOrigin( cellid );
|
||||
|
||||
this.setStorageCell( is, cellid, targetSize );
|
||||
StorageHelper.getInstance().swapRegions( w, min.x + 1, min.y + 1, min.z + 1, manager.getWorld(), offset.getX(), offset.getY(),
|
||||
offset.getZ(), targetX - 1, targetY - 1,
|
||||
targetZ - 1 );
|
||||
|
||||
return new TransitionResult( true, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
final int floorBuffer = 64;
|
||||
StorageHelper.getInstance().swapRegions( w, min.x + 1, min.y + 1, min.z + 1, destination, 0, floorBuffer, 0, targetX - 1, targetY - 1,
|
||||
targetZ - 1 );
|
||||
this.setStoredSize( is, targetX, targetY, targetZ );
|
||||
|
||||
return new TransitionResult( true, 0 );
|
||||
}
|
||||
return new TransitionResult( false, 0 );
|
||||
}
|
||||
finally
|
||||
{
|
||||
// clean up newly created dimensions that failed transfer
|
||||
if( manager.isCellDimension( cellid ) && this.getStoredDimensionID( is ) < 0 )
|
||||
{
|
||||
manager.deleteCellDimension( cellid );
|
||||
}
|
||||
}
|
||||
|
||||
return new TransitionResult( false, 0 );
|
||||
}
|
||||
|
||||
private World createNewWorld( final ItemStack is )
|
||||
private void setStorageCell( final ItemStack is, int id, BlockPos size )
|
||||
{
|
||||
final NBTTagCompound c = Platform.openNbtData( is );
|
||||
final int newDim = DimensionManager.getNextFreeDimId();
|
||||
c.setInteger( "StorageDim", newDim );
|
||||
WorldData.instance().dimensionData().addStorageCell( newDim );
|
||||
DimensionManager.initDimension( newDim );
|
||||
return DimensionManager.getWorld( newDim );
|
||||
}
|
||||
|
||||
private void setStoredSize( final ItemStack is, final int targetX, final int targetY, final int targetZ )
|
||||
{
|
||||
if( is.hasTagCompound() )
|
||||
{
|
||||
final NBTTagCompound c = is.getTagCompound();
|
||||
final int dim = c.getInteger( "StorageDim" );
|
||||
c.setInteger( "sizeX", targetX );
|
||||
c.setInteger( "sizeY", targetY );
|
||||
c.setInteger( "sizeZ", targetZ );
|
||||
WorldData.instance().dimensionData().setStoredSize( dim, targetX, targetY, targetZ );
|
||||
}
|
||||
c.setInteger( NBT_CELL_ID_KEY, id );
|
||||
c.setInteger( NBT_SIZE_X_KEY, size.getX() );
|
||||
c.setInteger( NBT_SIZE_Y_KEY, size.getY() );
|
||||
c.setInteger( NBT_SIZE_Z_KEY, size.getZ() );
|
||||
}
|
||||
}
|
||||
|
||||
+213
-103
@@ -19,11 +19,15 @@
|
||||
package appeng.me.cache;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
@@ -48,8 +52,8 @@ import appeng.api.networking.events.MENetworkPostCacheConstruction;
|
||||
import appeng.api.networking.events.MENetworkPowerIdleChange;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.events.MENetworkPowerStorage;
|
||||
import appeng.api.networking.events.MENetworkPowerStorage.PowerEventType;
|
||||
import appeng.api.networking.pathing.IPathingGrid;
|
||||
import appeng.api.networking.storage.IStackWatcherHost;
|
||||
import appeng.me.Grid;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.me.energy.EnergyThreshold;
|
||||
@@ -59,6 +63,18 @@ import appeng.me.energy.EnergyWatcher;
|
||||
public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
|
||||
private static final double MAX_BUFFER_STORAGE = 200;
|
||||
private static final Comparator<IEnergyGridProvider> COMPARATOR_HIGHEST_AMOUNT_STORED_FIRST = ( o1, o2 ) -> Double.compare( o2.getProviderStoredEnergy(),
|
||||
o1.getProviderStoredEnergy() );
|
||||
|
||||
private static final Comparator<IEnergyGridProvider> COMPARATOR_LOWEST_PERCENTAGE_FIRST = ( o1, o2 ) ->
|
||||
{
|
||||
final double percent1 = ( o1.getProviderStoredEnergy() + 1 ) / ( o1.getProviderMaxEnergy() + 1 );
|
||||
final double percent2 = ( o2.getProviderStoredEnergy() + 1 ) / ( o2.getProviderMaxEnergy() + 1 );
|
||||
|
||||
return Double.compare( percent1, percent2 );
|
||||
};
|
||||
|
||||
private final NavigableSet<EnergyThreshold> interests = Sets.newTreeSet();
|
||||
private final double averageLength = 40.0;
|
||||
private final Set<IAEPowerStorage> providers = new LinkedHashSet<>();
|
||||
@@ -66,13 +82,14 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
private final Multiset<IEnergyGridProvider> energyGridProviders = HashMultiset.create();
|
||||
private final IGrid myGrid;
|
||||
private final HashMap<IGridNode, IEnergyWatcher> watchers = new HashMap<>();
|
||||
private final Set<IEnergyGrid> localSeen = new HashSet<>();
|
||||
|
||||
/**
|
||||
* estimated power available.
|
||||
*/
|
||||
private int availableTicksSinceUpdate = 0;
|
||||
private double globalAvailablePower = 0;
|
||||
private double globalMaxPower = 0;
|
||||
private double globalMaxPower = MAX_BUFFER_STORAGE;
|
||||
|
||||
/**
|
||||
* idle draw.
|
||||
*/
|
||||
@@ -81,24 +98,26 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
private double avgInjectionPerTick = 0;
|
||||
private double tickDrainPerTick = 0;
|
||||
private double tickInjectionPerTick = 0;
|
||||
|
||||
/**
|
||||
* power status
|
||||
*/
|
||||
private boolean publicHasPower = false;
|
||||
private boolean hasPower = true;
|
||||
private long ticksSinceHasPowerChange = 900;
|
||||
/**
|
||||
* excess power in the system.
|
||||
*/
|
||||
private double extra = 0;
|
||||
|
||||
private IAEPowerStorage lastProvider;
|
||||
private IAEPowerStorage lastRequester;
|
||||
private PathGridCache pgc;
|
||||
private double lastStoredPower = -1;
|
||||
|
||||
private final GridPowerStorage localStorage = new GridPowerStorage();
|
||||
|
||||
public EnergyGridCache( final IGrid g )
|
||||
{
|
||||
this.myGrid = g;
|
||||
this.requesters.add( this.localStorage );
|
||||
this.providers.add( this.localStorage );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
@@ -216,8 +235,30 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public double extractAEPower( final double amt, final Actionable mode, final PowerMultiplier pm )
|
||||
{
|
||||
this.localSeen.clear();
|
||||
return pm.divide( this.extractAEPower( pm.multiply( amt ), mode, this.localSeen ) );
|
||||
final double toExtract = pm.multiply( amt );
|
||||
final Queue<IEnergyGridProvider> toVisit = new PriorityQueue<>( COMPARATOR_HIGHEST_AMOUNT_STORED_FIRST );
|
||||
final Set<IEnergyGridProvider> visited = new HashSet<>();
|
||||
|
||||
double extracted = 0;
|
||||
toVisit.add( this );
|
||||
|
||||
while( !toVisit.isEmpty() && extracted < toExtract )
|
||||
{
|
||||
final IEnergyGridProvider next = toVisit.poll();
|
||||
visited.add( next );
|
||||
|
||||
extracted += next.extractProviderPower( toExtract - extracted, mode, visited );
|
||||
|
||||
for( IEnergyGridProvider iEnergyGridProvider : next.providers() )
|
||||
{
|
||||
if( !visited.contains( iEnergyGridProvider ) )
|
||||
{
|
||||
toVisit.add( iEnergyGridProvider );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pm.divide( extracted );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -252,55 +293,37 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower( final double amt, final Actionable mode, final Set<IEnergyGrid> seen )
|
||||
public Collection<IEnergyGridProvider> providers()
|
||||
{
|
||||
if( !seen.add( this ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return this.energyGridProviders;
|
||||
}
|
||||
|
||||
double extractedPower = this.extra;
|
||||
@Override
|
||||
public double extractProviderPower( final double amt, final Actionable mode, final Set<IEnergyGridProvider> seen )
|
||||
{
|
||||
double extractedPower = 0;
|
||||
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
extractedPower += this.simulateExtract( extractedPower, amt );
|
||||
|
||||
if( extractedPower < amt )
|
||||
{
|
||||
final Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while( extractedPower < amt && i.hasNext() )
|
||||
{
|
||||
extractedPower += i.next().extractAEPower( amt - extractedPower, mode, seen );
|
||||
}
|
||||
}
|
||||
|
||||
return extractedPower;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.extra = 0;
|
||||
extractedPower = this.doExtract( extractedPower, amt );
|
||||
}
|
||||
|
||||
// got more then we wanted?
|
||||
if( extractedPower > amt )
|
||||
{
|
||||
this.extra = extractedPower - amt;
|
||||
this.localStorage.addAECurrentPower( extractedPower - amt );
|
||||
this.globalAvailablePower -= amt;
|
||||
|
||||
this.tickDrainPerTick += amt;
|
||||
return amt;
|
||||
}
|
||||
|
||||
if( extractedPower < amt )
|
||||
{
|
||||
final Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while( extractedPower < amt && i.hasNext() )
|
||||
{
|
||||
extractedPower += i.next().extractAEPower( amt - extractedPower, mode, seen );
|
||||
}
|
||||
}
|
||||
|
||||
// go less or the correct amount?
|
||||
this.globalAvailablePower -= extractedPower;
|
||||
this.tickDrainPerTick += extractedPower;
|
||||
@@ -308,16 +331,8 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectAEPower( double amt, final Actionable mode, final Set<IEnergyGrid> seen )
|
||||
public double injectProviderPower( double amt, final Actionable mode, final Set<IEnergyGridProvider> seen )
|
||||
{
|
||||
if( !seen.add( this ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
final double ignore = this.extra;
|
||||
amt += this.extra;
|
||||
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||
@@ -327,16 +342,10 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
amt = node.injectAEPower( amt, Actionable.SIMULATE );
|
||||
}
|
||||
|
||||
final Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while( amt > 0 && i.hasNext() )
|
||||
{
|
||||
amt = i.next().injectAEPower( amt, mode, seen );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tickInjectionPerTick += amt - ignore;
|
||||
// totalInjectionPastTicks[0] += i;
|
||||
this.tickInjectionPerTick += amt;
|
||||
|
||||
while( amt > 0 && !this.requesters.isEmpty() )
|
||||
{
|
||||
@@ -349,35 +358,15 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
this.lastRequester = null;
|
||||
}
|
||||
}
|
||||
|
||||
final Iterator<IEnergyGridProvider> i = this.energyGridProviders.iterator();
|
||||
while( amt > 0 && i.hasNext() )
|
||||
{
|
||||
final IEnergyGridProvider what = i.next();
|
||||
final Set<IEnergyGrid> listCopy = new HashSet<>();
|
||||
listCopy.addAll( seen );
|
||||
|
||||
final double cannotHold = what.injectAEPower( amt, Actionable.SIMULATE, listCopy );
|
||||
what.injectAEPower( amt - cannotHold, mode, seen );
|
||||
|
||||
amt = cannotHold;
|
||||
}
|
||||
|
||||
this.extra = amt;
|
||||
}
|
||||
|
||||
return Math.max( 0.0, amt - this.buffer() );
|
||||
return Math.max( 0.0, amt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergyDemand( final double maxRequired, final Set<IEnergyGrid> seen )
|
||||
public double getProviderEnergyDemand( final double maxRequired, final Set<IEnergyGridProvider> seen )
|
||||
{
|
||||
if( !seen.add( this ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double required = this.buffer() - this.extra;
|
||||
double required = 0;
|
||||
|
||||
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||
while( required < maxRequired && it.hasNext() )
|
||||
@@ -389,13 +378,6 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
}
|
||||
|
||||
final Iterator<IEnergyGridProvider> ix = this.energyGridProviders.iterator();
|
||||
while( required < maxRequired && ix.hasNext() )
|
||||
{
|
||||
final IEnergyGridProvider node = ix.next();
|
||||
required += node.getEnergyDemand( maxRequired - required, seen );
|
||||
}
|
||||
|
||||
return required;
|
||||
}
|
||||
|
||||
@@ -432,7 +414,6 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
}
|
||||
|
||||
// totalDrainPastTicks[0] += extractedPower;
|
||||
return extractedPower;
|
||||
}
|
||||
|
||||
@@ -468,8 +449,32 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public double injectPower( final double amt, final Actionable mode )
|
||||
{
|
||||
this.localSeen.clear();
|
||||
return this.injectAEPower( amt, mode, this.localSeen );
|
||||
final Queue<IEnergyGridProvider> toVisit = new PriorityQueue<>( COMPARATOR_LOWEST_PERCENTAGE_FIRST );
|
||||
final Set<IEnergyGridProvider> visited = new HashSet<>();
|
||||
toVisit.add( this );
|
||||
|
||||
double leftover = amt;
|
||||
|
||||
while( !toVisit.isEmpty() && leftover > 0 )
|
||||
{
|
||||
final IEnergyGridProvider next = toVisit.poll();
|
||||
visited.add( next );
|
||||
|
||||
final double cannotHold = next.injectProviderPower( amt, Actionable.SIMULATE, visited );
|
||||
next.injectProviderPower( leftover - cannotHold, mode, visited );
|
||||
|
||||
leftover = cannotHold;
|
||||
|
||||
for( IEnergyGridProvider iEnergyGridProvider : next.providers() )
|
||||
{
|
||||
if( !visited.contains( iEnergyGridProvider ) )
|
||||
{
|
||||
toVisit.add( iEnergyGridProvider );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return leftover;
|
||||
}
|
||||
|
||||
private IAEPowerStorage getFirstRequester()
|
||||
@@ -483,11 +488,6 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
return this.lastRequester;
|
||||
}
|
||||
|
||||
private double buffer()
|
||||
{
|
||||
return this.providers.isEmpty() ? 1000.0 : 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getStoredPower()
|
||||
{
|
||||
@@ -508,8 +508,41 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public double getEnergyDemand( final double maxRequired )
|
||||
{
|
||||
this.localSeen.clear();
|
||||
return this.getEnergyDemand( maxRequired, this.localSeen );
|
||||
final Queue<IEnergyGridProvider> toVisit = new PriorityQueue<>( COMPARATOR_LOWEST_PERCENTAGE_FIRST );
|
||||
final Set<IEnergyGridProvider> visited = new HashSet<>();
|
||||
toVisit.add( this );
|
||||
|
||||
double required = 0;
|
||||
|
||||
while( !toVisit.isEmpty() && required < maxRequired )
|
||||
{
|
||||
final IEnergyGridProvider next = toVisit.poll();
|
||||
visited.add( next );
|
||||
|
||||
required += next.getProviderEnergyDemand( maxRequired - required, visited );
|
||||
|
||||
for( IEnergyGridProvider iEnergyGridProvider : next.providers() )
|
||||
{
|
||||
if( !visited.contains( iEnergyGridProvider ) )
|
||||
{
|
||||
toVisit.add( iEnergyGridProvider );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return required;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getProviderStoredEnergy()
|
||||
{
|
||||
return this.getStoredPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getProviderMaxEnergy()
|
||||
{
|
||||
return this.getMaxStoredPower();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -517,7 +550,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
if( machine instanceof IEnergyGridProvider )
|
||||
{
|
||||
this.energyGridProviders.remove( machine );
|
||||
this.energyGridProviders.remove( (IEnergyGridProvider) machine );
|
||||
}
|
||||
|
||||
// idle draw.
|
||||
@@ -546,18 +579,19 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
this.lastRequester = null;
|
||||
}
|
||||
|
||||
this.providers.remove( machine );
|
||||
this.requesters.remove( machine );
|
||||
this.providers.remove( ps );
|
||||
this.requesters.remove( ps );
|
||||
}
|
||||
}
|
||||
|
||||
if( machine instanceof IStackWatcherHost )
|
||||
if( machine instanceof IEnergyWatcherHost )
|
||||
{
|
||||
final IEnergyWatcher myWatcher = this.watchers.get( machine );
|
||||
if( myWatcher != null )
|
||||
final IEnergyWatcher watcher = this.watchers.get( node );
|
||||
|
||||
if( watcher != null )
|
||||
{
|
||||
myWatcher.reset();
|
||||
this.watchers.remove( machine );
|
||||
watcher.reset();
|
||||
this.watchers.remove( node );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -607,6 +641,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
final IEnergyWatcherHost swh = (IEnergyWatcherHost) machine;
|
||||
final EnergyWatcher iw = new EnergyWatcher( this, swh );
|
||||
|
||||
this.watchers.put( node, iw );
|
||||
swh.updateWatcher( iw );
|
||||
}
|
||||
@@ -617,20 +652,21 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public void onSplit( final IGridStorage storageB )
|
||||
{
|
||||
this.extra /= 2;
|
||||
storageB.dataObject().setDouble( "extraEnergy", this.extra );
|
||||
final double newBuffer = this.localStorage.getAECurrentPower() / 2;
|
||||
this.localStorage.setAECurrentPower( newBuffer );
|
||||
storageB.dataObject().setDouble( "buffer", newBuffer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin( final IGridStorage storageB )
|
||||
{
|
||||
this.extra += storageB.dataObject().getDouble( "extraEnergy" );
|
||||
this.localStorage.addAECurrentPower( storageB.dataObject().getDouble( "buffer" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateGridStorage( final IGridStorage storage )
|
||||
{
|
||||
storage.dataObject().setDouble( "extraEnergy", this.extra );
|
||||
storage.dataObject().setDouble( "buffer", this.localStorage.getAECurrentPower() );
|
||||
}
|
||||
|
||||
public boolean registerEnergyInterest( final EnergyThreshold threshold )
|
||||
@@ -643,4 +679,78 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
return this.interests.remove( threshold );
|
||||
}
|
||||
|
||||
private class GridPowerStorage implements IAEPowerStorage
|
||||
{
|
||||
double stored = 0;
|
||||
|
||||
@Override
|
||||
public double extractAEPower( double amt, Actionable mode, PowerMultiplier usePowerMultiplier )
|
||||
{
|
||||
double extracted = Math.min( amt, this.stored );
|
||||
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
this.stored -= extracted;
|
||||
|
||||
if( this.stored < MAX_BUFFER_STORAGE - 0.001 )
|
||||
{
|
||||
EnergyGridCache.this.myGrid.postEvent( new MENetworkPowerStorage( this, PowerEventType.REQUEST_POWER ) );
|
||||
}
|
||||
}
|
||||
|
||||
return extracted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAEPublicPowerStorage()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectAEPower( double amt, Actionable mode )
|
||||
{
|
||||
double toStore = Math.min( amt, MAX_BUFFER_STORAGE - this.stored );
|
||||
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
this.stored += toStore;
|
||||
|
||||
if( this.stored > 0.01 )
|
||||
{
|
||||
EnergyGridCache.this.myGrid.postEvent( new MENetworkPowerStorage( this, PowerEventType.PROVIDE_POWER ) );
|
||||
}
|
||||
}
|
||||
|
||||
return amt - toStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessRestriction getPowerFlow()
|
||||
{
|
||||
return AccessRestriction.READ_WRITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAEMaxPower()
|
||||
{
|
||||
return MAX_BUFFER_STORAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAECurrentPower()
|
||||
{
|
||||
return this.stored;
|
||||
}
|
||||
|
||||
public void setAECurrentPower( double amount )
|
||||
{
|
||||
this.stored = amount;
|
||||
}
|
||||
|
||||
public void addAECurrentPower( double amount )
|
||||
{
|
||||
this.stored += amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
package appeng.parts.networking;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -131,14 +133,14 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractAEPower( final double amt, final Actionable mode, final Set<IEnergyGrid> seen )
|
||||
public Collection<IEnergyGridProvider> providers()
|
||||
{
|
||||
double acquiredPower = 0;
|
||||
Collection<IEnergyGridProvider> stuff = new LinkedList<>();
|
||||
|
||||
try
|
||||
{
|
||||
final IEnergyGrid eg = this.getProxy().getEnergy();
|
||||
acquiredPower += eg.extractAEPower( amt - acquiredPower, mode, seen );
|
||||
stuff.add( eg );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
@@ -148,7 +150,43 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
try
|
||||
{
|
||||
final IEnergyGrid eg = this.outerProxy.getEnergy();
|
||||
acquiredPower += eg.extractAEPower( amt - acquiredPower, mode, seen );
|
||||
stuff.add( eg );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
return stuff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double extractProviderPower( final double amt, final Actionable mode, final Set<IEnergyGridProvider> seen )
|
||||
{
|
||||
double acquiredPower = 0;
|
||||
|
||||
try
|
||||
{
|
||||
final IEnergyGrid eg = this.getProxy().getEnergy();
|
||||
|
||||
if( !seen.contains( eg ) )
|
||||
{
|
||||
acquiredPower += eg.extractProviderPower( amt - acquiredPower, mode, seen );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final IEnergyGrid eg = this.outerProxy.getEnergy();
|
||||
|
||||
if( !seen.contains( eg ) )
|
||||
{
|
||||
acquiredPower += eg.extractProviderPower( amt - acquiredPower, mode, seen );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
@@ -159,15 +197,17 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectAEPower( final double amt, final Actionable mode, final Set<IEnergyGrid> seen )
|
||||
public double injectProviderPower( final double amt, final Actionable mode, final Set<IEnergyGridProvider> seen )
|
||||
{
|
||||
|
||||
double amount = amt;
|
||||
|
||||
try
|
||||
{
|
||||
final IEnergyGrid eg = this.getProxy().getEnergy();
|
||||
if( !seen.contains( eg ) )
|
||||
{
|
||||
return eg.injectAEPower( amt, mode, seen );
|
||||
amount = eg.injectProviderPower( amount, mode, seen );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
@@ -180,7 +220,7 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
final IEnergyGrid eg = this.outerProxy.getEnergy();
|
||||
if( !seen.contains( eg ) )
|
||||
{
|
||||
return eg.injectAEPower( amt, mode, seen );
|
||||
amount = eg.injectProviderPower( amount, mode, seen );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
@@ -188,18 +228,21 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
// :P
|
||||
}
|
||||
|
||||
return amt;
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergyDemand( final double amt, final Set<IEnergyGrid> seen )
|
||||
public double getProviderEnergyDemand( final double amt, final Set<IEnergyGridProvider> seen )
|
||||
{
|
||||
double demand = 0;
|
||||
|
||||
try
|
||||
{
|
||||
final IEnergyGrid eg = this.getProxy().getEnergy();
|
||||
demand += eg.getEnergyDemand( amt - demand, seen );
|
||||
if( !seen.contains( eg ) )
|
||||
{
|
||||
demand += eg.getProviderEnergyDemand( amt - demand, seen );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
@@ -209,7 +252,10 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
try
|
||||
{
|
||||
final IEnergyGrid eg = this.outerProxy.getEnergy();
|
||||
demand += eg.getEnergyDemand( amt - demand, seen );
|
||||
if( !seen.contains( eg ) )
|
||||
{
|
||||
demand += eg.getProviderEnergyDemand( amt - demand, seen );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
@@ -219,6 +265,18 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
return demand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getProviderStoredEnergy()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getProviderMaxEnergy()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
|
||||
@@ -141,7 +141,10 @@ public class PartP2PFEPower extends PartP2PTunnel<PartP2PFEPower>
|
||||
total += received;
|
||||
}
|
||||
|
||||
PartP2PFEPower.this.queueTunnelDrain( PowerUnits.RF, total );
|
||||
if( !simulate )
|
||||
{
|
||||
PartP2PFEPower.this.queueTunnelDrain( PowerUnits.RF, total );
|
||||
}
|
||||
}
|
||||
catch( GridAccessException ignored )
|
||||
{
|
||||
@@ -208,7 +211,14 @@ public class PartP2PFEPower extends PartP2PTunnel<PartP2PFEPower>
|
||||
@Override
|
||||
public int extractEnergy( int maxExtract, boolean simulate )
|
||||
{
|
||||
return PartP2PFEPower.this.getAttachedEnergyStorage().extractEnergy( maxExtract, simulate );
|
||||
final int total = PartP2PFEPower.this.getAttachedEnergyStorage().extractEnergy( maxExtract, simulate );
|
||||
|
||||
if( !simulate )
|
||||
{
|
||||
PartP2PFEPower.this.queueTunnelDrain( PowerUnits.RF, total );
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -147,13 +147,12 @@ public class CachedPlane
|
||||
else
|
||||
{
|
||||
final Object[] details = this.myColumns[tePOS.getX() - minX][tePOS.getZ() - minZ].getDetails( tePOS.getY() );
|
||||
final Block blk = (Block) details[0];
|
||||
final IBlockState blkState = (IBlockState) details[0];
|
||||
|
||||
// don't skip air, just let the code replace it...
|
||||
if( blk != null && blk.isAir( c.getWorld().getBlockState( tePOS ), c.getWorld(), tePOS ) && blk.isReplaceable( c.getWorld(),
|
||||
tePOS ) )
|
||||
if( blkState != null && blkState.getBlock() == Platform.AIR_BLOCK && blkState.getMaterial().isReplaceable() )
|
||||
{
|
||||
c.getWorld().setBlockToAir( tePOS );
|
||||
w.setBlockToAir( tePOS );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -241,8 +241,9 @@ public class StorageHelper
|
||||
@Override
|
||||
public void visit( final BlockPos pos )
|
||||
{
|
||||
final Block blk = this.dst.getBlockState( pos ).getBlock();
|
||||
blk.neighborChanged( Platform.AIR_BLOCK.getDefaultState(), this.dst, pos, Platform.AIR_BLOCK, pos );
|
||||
final IBlockState state = this.dst.getBlockState( pos );
|
||||
final Block blk = state.getBlock();
|
||||
blk.neighborChanged( state, this.dst, pos, blk, pos );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
@@ -46,9 +45,10 @@ import appeng.util.inv.InvOperation;
|
||||
public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInventory
|
||||
{
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AEBaseInvTile( final net.minecraft.nbt.NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
final IItemHandler inv = this.getInternalInventory();
|
||||
if( inv != EmptyHandler.INSTANCE )
|
||||
{
|
||||
@@ -63,9 +63,10 @@ public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInven
|
||||
|
||||
public abstract @Nonnull IItemHandler getInternalInventory();
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AEBaseInvTile( final net.minecraft.nbt.NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
final IItemHandler inv = this.getInternalInventory();
|
||||
if( inv != EmptyHandler.INSTANCE )
|
||||
{
|
||||
@@ -82,6 +83,7 @@ public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInven
|
||||
}
|
||||
data.setTag( "inv", opt );
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,12 +19,9 @@
|
||||
package appeng.tile;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -55,8 +52,6 @@ import appeng.core.AELog;
|
||||
import appeng.core.features.IStackSrc;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
@@ -66,14 +61,12 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
{
|
||||
|
||||
private static final ThreadLocal<WeakReference<AEBaseTile>> DROP_NO_ITEMS = new ThreadLocal<>();
|
||||
private static final Map<Class<? extends AEBaseTile>, Map<TileEventType, List<AETileEventHandler>>> HANDLERS = new HashMap<>();
|
||||
private static final Map<Class<? extends TileEntity>, IStackSrc> ITEM_STACKS = new HashMap<>();
|
||||
private int renderFragment = 0;
|
||||
@Nullable
|
||||
private String customName;
|
||||
private EnumFacing forward = null;
|
||||
private EnumFacing up = null;
|
||||
|
||||
private IBlockState state;
|
||||
|
||||
@Override
|
||||
@@ -125,20 +118,8 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* for dormant chunk cache.
|
||||
*/
|
||||
public void onChunkLoad()
|
||||
{
|
||||
if( this.isInvalid() )
|
||||
{
|
||||
this.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// NOTE: WAS FINAL, changed for Immibis
|
||||
public final void readFromNBT( final NBTTagCompound data )
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
|
||||
@@ -162,16 +143,10 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
catch( final IllegalArgumentException ignored )
|
||||
{
|
||||
}
|
||||
|
||||
for( final AETileEventHandler h : this.getHandlerListFor( TileEventType.WORLD_NBT_READ ) )
|
||||
{
|
||||
h.readFromNBT( this, data );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// NOTE: WAS FINAL, changed for Immibis
|
||||
public final NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
|
||||
@@ -186,11 +161,6 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
data.setString( "customName", this.customName );
|
||||
}
|
||||
|
||||
for( final AETileEventHandler h : this.getHandlerListFor( TileEventType.WORLD_NBT_WRITE ) )
|
||||
{
|
||||
h.writeToNBT( this, data );
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -200,13 +170,6 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return new SPacketUpdateTileEntity( this.pos, 64, this.getUpdateTag() );
|
||||
}
|
||||
|
||||
private boolean hasHandlerFor( final TileEventType type )
|
||||
{
|
||||
final List<AETileEventHandler> list = this.getHandlerListFor( type );
|
||||
|
||||
return !list.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket( final NetworkManager net, final SPacketUpdateTileEntity pkt )
|
||||
{
|
||||
@@ -217,13 +180,8 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
public void onReady()
|
||||
{
|
||||
if( !this.isInvalid() )
|
||||
{
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,6 +212,30 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return data;
|
||||
}
|
||||
|
||||
private boolean readUpdateData( ByteBuf stream )
|
||||
{
|
||||
boolean output = false;
|
||||
|
||||
try
|
||||
{
|
||||
this.renderFragment = 100;
|
||||
|
||||
output = readFromStream( stream );
|
||||
|
||||
if( ( this.renderFragment & 1 ) == 1 )
|
||||
{
|
||||
output = true;
|
||||
}
|
||||
this.renderFragment = 0;
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.debug( t );
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles tile entites that are being sent to the client as part of a full chunk.
|
||||
*/
|
||||
@@ -280,52 +262,36 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
public void handleUpdateTag( NBTTagCompound tag )
|
||||
{
|
||||
final ByteBuf stream = Unpooled.copiedBuffer( tag.getByteArray( "X" ) );
|
||||
if( this.readFromStream( stream ) )
|
||||
|
||||
if( this.readUpdateData( stream ) )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean readFromStream( final ByteBuf data )
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
boolean output = false;
|
||||
|
||||
try
|
||||
if( this.canBeRotated() )
|
||||
{
|
||||
final EnumFacing old_Forward = this.forward;
|
||||
final EnumFacing old_Up = this.up;
|
||||
|
||||
if( this.canBeRotated() )
|
||||
{
|
||||
final EnumFacing old_Forward = this.forward;
|
||||
final EnumFacing old_Up = this.up;
|
||||
final byte orientation = data.readByte();
|
||||
this.forward = EnumFacing.VALUES[orientation & 0x7];
|
||||
this.up = EnumFacing.VALUES[orientation >> 3];
|
||||
|
||||
final byte orientation = data.readByte();
|
||||
this.forward = EnumFacing.VALUES[orientation & 0x7];
|
||||
this.up = EnumFacing.VALUES[orientation >> 3];
|
||||
|
||||
output = this.forward != old_Forward || this.up != old_Up;
|
||||
}
|
||||
|
||||
this.renderFragment = 100;
|
||||
for( final AETileEventHandler h : this.getHandlerListFor( TileEventType.NETWORK_READ ) )
|
||||
{
|
||||
if( h.readFromStream( this, data ) )
|
||||
{
|
||||
output = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( ( this.renderFragment & 1 ) == 1 )
|
||||
{
|
||||
output = true;
|
||||
}
|
||||
this.renderFragment = 0;
|
||||
return this.forward != old_Forward || this.up != old_Up;
|
||||
}
|
||||
catch( final Throwable t )
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
if( this.canBeRotated() )
|
||||
{
|
||||
AELog.debug( t );
|
||||
final byte orientation = (byte) ( ( this.up.ordinal() << 3 ) | this.forward.ordinal() );
|
||||
data.writeByte( orientation );
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public void markForUpdate()
|
||||
@@ -345,27 +311,6 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
}
|
||||
}
|
||||
|
||||
private final void writeToStream( final ByteBuf data )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( this.canBeRotated() )
|
||||
{
|
||||
final byte orientation = (byte) ( ( this.up.ordinal() << 3 ) | this.forward.ordinal() );
|
||||
data.writeByte( orientation );
|
||||
}
|
||||
|
||||
for( final AETileEventHandler h : this.getHandlerListFor( TileEventType.NETWORK_WRITE ) )
|
||||
{
|
||||
h.writeToStream( this, data );
|
||||
}
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.debug( t );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* By default all blocks can have orientation, this handles saving, and loading, as well as synchronization.
|
||||
*
|
||||
@@ -377,75 +322,6 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private List<AETileEventHandler> getHandlerListFor( final TileEventType type )
|
||||
{
|
||||
final Map<TileEventType, List<AETileEventHandler>> eventToHandlers = this.getEventToHandlers();
|
||||
final List<AETileEventHandler> handlers = this.getHandlers( eventToHandlers, type );
|
||||
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private Map<TileEventType, List<AETileEventHandler>> getEventToHandlers()
|
||||
{
|
||||
final Class<? extends AEBaseTile> clazz = this.getClass();
|
||||
final Map<TileEventType, List<AETileEventHandler>> storedHandlers = HANDLERS.get( clazz );
|
||||
|
||||
if( storedHandlers == null )
|
||||
{
|
||||
final Map<TileEventType, List<AETileEventHandler>> newStoredHandlers = new EnumMap<>( TileEventType.class );
|
||||
|
||||
HANDLERS.put( clazz, newStoredHandlers );
|
||||
|
||||
for( final Method method : clazz.getMethods() )
|
||||
{
|
||||
final TileEvent event = method.getAnnotation( TileEvent.class );
|
||||
if( event != null )
|
||||
{
|
||||
this.addHandler( newStoredHandlers, event.value(), method );
|
||||
}
|
||||
}
|
||||
|
||||
return newStoredHandlers;
|
||||
}
|
||||
else
|
||||
{
|
||||
return storedHandlers;
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private List<AETileEventHandler> getHandlers( final Map<TileEventType, List<AETileEventHandler>> eventToHandlers, final TileEventType event )
|
||||
{
|
||||
final List<AETileEventHandler> oldHandlers = eventToHandlers.get( event );
|
||||
|
||||
if( oldHandlers == null )
|
||||
{
|
||||
final List<AETileEventHandler> newHandlers = new LinkedList<>();
|
||||
eventToHandlers.put( event, newHandlers );
|
||||
|
||||
return newHandlers;
|
||||
}
|
||||
else
|
||||
{
|
||||
return oldHandlers;
|
||||
}
|
||||
}
|
||||
|
||||
private void addHandler( final Map<TileEventType, List<AETileEventHandler>> handlerSet, final TileEventType value, final Method m )
|
||||
{
|
||||
List<AETileEventHandler> list = handlerSet.get( value );
|
||||
|
||||
if( list == null )
|
||||
{
|
||||
list = new ArrayList<>();
|
||||
handlerSet.put( value, list );
|
||||
}
|
||||
|
||||
list.add( new AETileEventHandler( m ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getForward()
|
||||
{
|
||||
@@ -542,11 +418,6 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
|
||||
}
|
||||
|
||||
public void onReady()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* null means nothing to store...
|
||||
*
|
||||
|
||||
@@ -32,8 +32,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
@@ -49,9 +47,10 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
private IAEItemStack dspPlay;
|
||||
private AEColor paintedColor = AEColor.TRANSPARENT;
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCraftingMonitorTile( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final AEColor oldPaintedColor = this.paintedColor;
|
||||
this.paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
@@ -67,12 +66,13 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
}
|
||||
|
||||
this.setUpdateList( true );
|
||||
return oldPaintedColor != this.paintedColor; // tesr!
|
||||
return oldPaintedColor != this.paintedColor || c; // tesr!
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCraftingMonitorTile( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeByte( this.paintedColor.ordinal() );
|
||||
|
||||
if( this.dspPlay == null )
|
||||
@@ -86,19 +86,22 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCraftingMonitorTile( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
{
|
||||
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCraftingMonitorTile( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,8 +51,6 @@ import appeng.me.cluster.implementations.CraftingCPUCalculator;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.AENetworkProxyMultiblock;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -194,19 +192,22 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
return this.cluster != null;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCraftingTile( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setBoolean( "core", this.isCoreBlock() );
|
||||
if( this.isCoreBlock() && this.cluster != null )
|
||||
{
|
||||
this.cluster.writeToNBT( data );
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCraftingTile( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.setCoreBlock( data.getBoolean( "core" ) );
|
||||
if( this.isCoreBlock() )
|
||||
{
|
||||
|
||||
@@ -65,8 +65,6 @@ import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.DefinitionUpgradeInventory;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -198,23 +196,26 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
return this.upgrades.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileMolecularAssembler( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean oldPower = this.isPowered;
|
||||
this.isPowered = data.readBoolean();
|
||||
return this.isPowered != oldPower;
|
||||
return this.isPowered != oldPower || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileMolecularAssembler( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.isPowered );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileMolecularAssembler( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
if( this.forcePlan && this.myPlan != null )
|
||||
{
|
||||
final ItemStack pattern = this.myPlan.getPattern();
|
||||
@@ -228,14 +229,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
}
|
||||
|
||||
this.upgrades.writeToNBT( data, "upgrades" );
|
||||
this.gridInv.writeToNBT( data, "inv" );
|
||||
this.patternInv.writeToNBT( data, "pattern" );
|
||||
this.settings.writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileMolecularAssembler( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
if( data.hasKey( "myPlan" ) )
|
||||
{
|
||||
final ItemStack myPat = new ItemStack( data.getCompoundTag( "myPlan" ) );
|
||||
@@ -255,8 +256,6 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
}
|
||||
|
||||
this.upgrades.readFromNBT( data, "upgrades" );
|
||||
this.gridInv.readFromNBT( data, "inv" );
|
||||
this.patternInv.readFromNBT( data, "pattern" );
|
||||
this.settings.readFromNBT( data );
|
||||
this.recalculatePlan();
|
||||
}
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.tile.events;
|
||||
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
|
||||
public final class AETileEventHandler
|
||||
{
|
||||
|
||||
private final Method method;
|
||||
|
||||
public AETileEventHandler( final Method method )
|
||||
{
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
// TICK
|
||||
public void tick( final AEBaseTile tile )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.method.invoke( tile );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// WORLD_NBT
|
||||
public void writeToNBT( final AEBaseTile tile, final NBTTagCompound data )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.method.invoke( tile, data );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// WORLD NBT
|
||||
public void readFromNBT( final AEBaseTile tile, final NBTTagCompound data )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.method.invoke( tile, data );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// NETWORK
|
||||
public void writeToStream( final AEBaseTile tile, final ByteBuf data )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.method.invoke( tile, data );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// NETWORK
|
||||
|
||||
/**
|
||||
* returning true from this method, will update the block's render
|
||||
*
|
||||
* @param data data of stream
|
||||
*
|
||||
* @return true of method could be invoked
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
public boolean readFromStream( final AEBaseTile tile, final ByteBuf data )
|
||||
{
|
||||
try
|
||||
{
|
||||
return (Boolean) this.method.invoke( tile, data );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.tile.events;
|
||||
|
||||
|
||||
public enum TileEventType
|
||||
{
|
||||
WORLD_NBT_READ,
|
||||
WORLD_NBT_WRITE,
|
||||
|
||||
/**
|
||||
* Methods annotated with this need to return a boolean
|
||||
*/
|
||||
NETWORK_READ,
|
||||
|
||||
NETWORK_WRITE
|
||||
}
|
||||
@@ -27,8 +27,6 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionHost, IGridProxyable
|
||||
@@ -36,16 +34,19 @@ public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionH
|
||||
|
||||
private final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AENetwork( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.getProxy().readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AENetwork( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.getProxy().writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,8 +28,6 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.powersink.AEBasePoweredTile;
|
||||
|
||||
|
||||
@@ -38,16 +36,19 @@ public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IA
|
||||
|
||||
private final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AENetwork( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.getProxy().readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AENetwork( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.getProxy().writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,8 +29,6 @@ import appeng.api.util.DimensionalCoord;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxyable
|
||||
@@ -38,16 +36,19 @@ public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxy
|
||||
|
||||
private final AENetworkProxy gridProxy = this.createProxy();
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AENetwork( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.getProxy().readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AENetwork( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.getProxy().writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
protected AENetworkProxy createProxy()
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.grindstone;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,8 +37,6 @@ import net.minecraft.world.World;
|
||||
import appeng.api.implementations.tiles.ICrankable;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@@ -90,16 +89,18 @@ public class TileCrank extends AEBaseTile implements ICustomCollision, ITickable
|
||||
return null;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCrank( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
this.rotation = data.readInt();
|
||||
return false;
|
||||
return c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCrank( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeInt( this.rotation );
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@ import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -104,17 +102,20 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
return null;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCellWorkbench( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.cell.writeToNBT( data, "cell" );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
this.manager.writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCellWorkbench( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.cell.readFromNBT( data, "cell" );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
this.manager.readFromNBT( data );
|
||||
|
||||
@@ -49,8 +49,6 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
@@ -81,9 +79,10 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCharger( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
try
|
||||
{
|
||||
final IAEItemStack item = AEItemStack.loadItemStackFromPacket( data );
|
||||
@@ -94,12 +93,13 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
|
||||
{
|
||||
this.inv.setStackInSlot( 0, ItemStack.EMPTY );
|
||||
}
|
||||
return false; // TESR doesn't need updates!
|
||||
return c; // TESR doesn't need updates!
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCharger( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
final AEItemStack is = AEItemStack.create( this.inv.getStackInSlot( 0 ) );
|
||||
if( is != null )
|
||||
{
|
||||
@@ -130,7 +130,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
|
||||
@Override
|
||||
public void applyTurn()
|
||||
{
|
||||
this.injectExternalPower( PowerUnits.AE, 150 );
|
||||
this.injectExternalPower( PowerUnits.AE, 150, Actionable.MODULATE );
|
||||
|
||||
final ItemStack myItem = this.inv.getStackInSlot( 0 );
|
||||
if( this.getInternalCurrentPower() > 1499 )
|
||||
@@ -222,7 +222,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
|
||||
try
|
||||
{
|
||||
this.injectExternalPower( PowerUnits.AE, this.getProxy().getEnergy().extractAEPower( Math.min( 500.0, 1500.0 - this.getInternalCurrentPower() ),
|
||||
Actionable.MODULATE, PowerMultiplier.ONE ) );
|
||||
Actionable.MODULATE, PowerMultiplier.ONE ), Actionable.MODULATE );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
@@ -246,7 +246,8 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
|
||||
{
|
||||
final double oldPower = this.getInternalCurrentPower();
|
||||
|
||||
final double adjustment = ps.injectAEPower( myItem, this.extractAEPower( 150.0, Actionable.MODULATE, PowerMultiplier.CONFIG ), Actionable.MODULATE );
|
||||
final double adjustment = ps.injectAEPower( myItem, this.extractAEPower( 150.0, Actionable.MODULATE, PowerMultiplier.CONFIG ),
|
||||
Actionable.MODULATE );
|
||||
this.setInternalCurrentPower( this.getInternalCurrentPower() + adjustment );
|
||||
|
||||
if( oldPower > this.getInternalCurrentPower() )
|
||||
|
||||
@@ -48,8 +48,6 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
@@ -78,16 +76,19 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
|
||||
this.cm.registerSetting( Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCondenser( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.cm.writeToNBT( data );
|
||||
data.setDouble( "storedPower", this.getStoredPower() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCondenser( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.cm.readFromNBT( data );
|
||||
this.setStoredPower( data.getDouble( "storedPower" ) );
|
||||
}
|
||||
|
||||
@@ -58,12 +58,9 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.DefinitionUpgradeInventory;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -103,7 +100,6 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
|
||||
private final IItemHandlerModifiable inv = new WrapperChainedItemHandler( this.topItemHandler, this.bottomItemHandler, this.sideItemHandler );
|
||||
|
||||
@Reflected
|
||||
public TileInscriber()
|
||||
{
|
||||
this.getProxy().setValidSides( EnumSet.noneOf( EnumFacing.class ) );
|
||||
@@ -133,29 +129,27 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileInscriber( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
this.topItemHandler.writeToNBT( data, "inscriberInvTop" );
|
||||
this.bottomItemHandler.writeToNBT( data, "inscriberInvBottom" );
|
||||
this.sideItemHandler.writeToNBT( data, "inscriberInvSided" );
|
||||
super.writeToNBT( data );
|
||||
this.upgrades.writeToNBT( data, "upgrades" );
|
||||
this.settings.writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileInscriber( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
this.topItemHandler.readFromNBT( data, "inscriberInvTop" );
|
||||
this.bottomItemHandler.readFromNBT( data, "inscriberInvBottom" );
|
||||
this.sideItemHandler.readFromNBT( data, "inscriberInvSided" );
|
||||
super.readFromNBT( data );
|
||||
this.upgrades.readFromNBT( data, "upgrades" );
|
||||
this.settings.readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileInscriber( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int slot = data.readByte();
|
||||
|
||||
final boolean oldSmash = this.isSmash();
|
||||
@@ -179,12 +173,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileInscriber( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
int slot = this.isSmash() ? 64 : 0;
|
||||
|
||||
for( int num = 0; num < this.inv.getSlots(); num++ )
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -58,8 +59,6 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
@@ -171,32 +170,37 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, II
|
||||
this.duality.initialize();
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileInterface( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setBoolean( "omniDirectional", this.omniDirectional );
|
||||
this.duality.writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileInterface( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.omniDirectional = data.getBoolean( "omniDirectional" );
|
||||
|
||||
this.duality.readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileInterface( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
boolean oldOmniDirectional = this.omniDirectional;
|
||||
this.omniDirectional = data.readBoolean();
|
||||
return oldOmniDirectional != this.omniDirectional;
|
||||
return oldOmniDirectional != this.omniDirectional || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileInterface( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.omniDirectional );
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -40,8 +41,6 @@ import appeng.api.util.AEColor;
|
||||
import appeng.helpers.Splotch;
|
||||
import appeng.items.misc.ItemPaintBall;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public class TilePaint extends AEBaseTile
|
||||
@@ -58,15 +57,17 @@ public class TilePaint extends AEBaseTile
|
||||
return false;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TilePaint( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
final ByteBuf myDat = Unpooled.buffer();
|
||||
this.writeBuffer( myDat );
|
||||
if( myDat.hasArray() )
|
||||
{
|
||||
data.setByteArray( "dots", myDat.array() );
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private void writeBuffer( final ByteBuf out )
|
||||
@@ -85,9 +86,10 @@ public class TilePaint extends AEBaseTile
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TilePaint( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
if( data.hasKey( "dots" ) )
|
||||
{
|
||||
this.readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
|
||||
@@ -136,15 +138,17 @@ public class TilePaint extends AEBaseTile
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TilePaint( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
this.writeBuffer( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TilePaint( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.readFromStream( data );
|
||||
this.readBuffer( data );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -32,8 +33,6 @@ import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -62,17 +61,19 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileQuartzGrowthAccelerator( final ByteBuf data )
|
||||
@Override
|
||||
public boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean hadPower = this.isPowered();
|
||||
this.setPowered( data.readBoolean() );
|
||||
return this.isPowered() != hadPower;
|
||||
return this.isPowered() != hadPower || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileQuartzGrowthAccelerator( final ByteBuf data )
|
||||
@Override
|
||||
public void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
try
|
||||
{
|
||||
data.writeBoolean( this.getProxy().getEnergy().isNetworkPowered() );
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -68,8 +69,6 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.helpers.PlayerSecurityWrapper;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.SecurityStationInventory;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -135,28 +134,31 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileSecurity( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean wasActive = this.isActive;
|
||||
this.isActive = data.readBoolean();
|
||||
|
||||
final AEColor oldPaintedColor = this.paintedColor;
|
||||
this.paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
return oldPaintedColor != this.paintedColor || wasActive != this.isActive;
|
||||
return oldPaintedColor != this.paintedColor || wasActive != this.isActive || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileSecurity( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.getProxy().isActive() );
|
||||
data.writeByte( this.paintedColor.ordinal() );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileSecurity( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.cm.writeToNBT( data );
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
|
||||
@@ -175,11 +177,13 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
|
||||
}
|
||||
|
||||
data.setTag( "storedItems", storedItems );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileSecurity( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.cm.readFromNBT( data );
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
{
|
||||
|
||||
@@ -19,12 +19,17 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -37,14 +42,12 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
|
||||
@@ -55,6 +58,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
private static final double DILATION_SCALING = 100.0;
|
||||
private static final int MIN_BURN_SPEED = 20;
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 1 );
|
||||
private final IItemHandler invExt = new WrapperFilteredItemHandler( inv, new FuelSlotFilter() );
|
||||
|
||||
private int burnSpeed = 100;
|
||||
private double burnTime = 0;
|
||||
@@ -65,7 +69,6 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
|
||||
public TileVibrationChamber()
|
||||
{
|
||||
this.inv.setFilter( new FuelSlotFilter() );
|
||||
this.getProxy().setIdlePowerUsage( 0 );
|
||||
this.getProxy().setFlags();
|
||||
}
|
||||
@@ -76,40 +79,49 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@Reflected
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean hasUpdate( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean wasOn = this.isOn;
|
||||
|
||||
this.isOn = data.readBoolean();
|
||||
|
||||
return wasOn != this.isOn; // TESR doesn't need updates!
|
||||
return wasOn != this.isOn || c; // TESR doesn't need updates!
|
||||
}
|
||||
|
||||
@Reflected
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToNetwork( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.getBurnTime() > 0 );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileVibrationChamber( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setDouble( "burnTime", this.getBurnTime() );
|
||||
data.setDouble( "maxBurnTime", this.getMaxBurnTime() );
|
||||
data.setInteger( "burnSpeed", this.getBurnSpeed() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileVibrationChamber( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.setBurnTime( data.getDouble( "burnTime" ) );
|
||||
this.setMaxBurnTime( data.getDouble( "maxBurnTime" ) );
|
||||
this.setBurnSpeed( data.getInteger( "burnSpeed" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IItemHandler getItemHandlerForSide( @Nonnull EnumFacing facing )
|
||||
{
|
||||
return this.invExt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory()
|
||||
{
|
||||
|
||||
@@ -54,8 +54,6 @@ import appeng.helpers.ICustomCollision;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@@ -66,21 +64,25 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
|
||||
private int oldLV = -1; // on re-calculate light when it changes
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCableBus( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.getCableBus().readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCableBus( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.getCableBus().writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCableBus( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean ret = this.getCableBus().readFromStream( data );
|
||||
|
||||
final int newLV = this.getCableBus().getLightValue();
|
||||
@@ -91,7 +93,14 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
}
|
||||
|
||||
this.updateTileSetting();
|
||||
return ret;
|
||||
return ret || c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
this.getCableBus().writeToStream( data );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,12 +131,6 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
oldTile.setCableBus( tmpCB );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCableBus( final ByteBuf data ) throws IOException
|
||||
{
|
||||
this.getCableBus().writeToStream( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxRenderDistanceSquared()
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkControllerChange;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
@@ -137,7 +138,9 @@ public class TileController extends AENetworkPowerTile
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.getProxy().getEnergy().getEnergyDemand( 8000 );
|
||||
final IEnergyGrid grid = this.getProxy().getEnergy();
|
||||
|
||||
return grid.getEnergyDemand( maxReceived );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
@@ -151,12 +154,10 @@ public class TileController extends AENetworkPowerTile
|
||||
{
|
||||
try
|
||||
{
|
||||
final double ret = this.getProxy().getEnergy().injectPower( power, mode );
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
final IEnergyGrid grid = this.getProxy().getEnergy();
|
||||
final double leftOver = grid.injectPower( power, mode );
|
||||
|
||||
return leftOver;
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ package appeng.tile.networking;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
@@ -41,22 +40,6 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
this.setInternalMaxPower( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT_AENetwork( final NBTTagCompound data )
|
||||
{
|
||||
/**
|
||||
* Does nothing here since the NBT tag in the parent is not needed anymore
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT_AENetwork( final NBTTagCompound data )
|
||||
{
|
||||
/**
|
||||
* Does nothing here since the NBT tag in the parent is not needed anymore
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
@@ -69,6 +52,7 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
try
|
||||
{
|
||||
final IEnergyGrid grid = this.getProxy().getEnergy();
|
||||
|
||||
return grid.getEnergyDemand( maxRequired );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
@@ -84,11 +68,8 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
{
|
||||
final IEnergyGrid grid = this.getProxy().getEnergy();
|
||||
final double leftOver = grid.injectPower( power, mode );
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return leftOver;
|
||||
}
|
||||
return 0.0;
|
||||
|
||||
return leftOver;
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
|
||||
@@ -31,8 +31,6 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.networking.BlockEnergyCell;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.SettingsFrom;
|
||||
|
||||
@@ -100,18 +98,18 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileEnergyCell( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
if( !this.world.isRemote )
|
||||
{
|
||||
data.setDouble( "internalCurrentPower", this.internalCurrentPower );
|
||||
}
|
||||
super.writeToNBT( data );
|
||||
data.setDouble( "internalCurrentPower", this.internalCurrentPower );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileEnergyCell( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.internalCurrentPower = data.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -40,8 +41,6 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
@@ -85,18 +84,20 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileWireless( final ByteBuf data )
|
||||
@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();
|
||||
return old != this.getClientFlags() || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileWireless( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
this.setClientFlags( 0 );
|
||||
|
||||
try
|
||||
|
||||
@@ -38,8 +38,6 @@ import appeng.capabilities.Capabilities;
|
||||
import appeng.integration.Integrations;
|
||||
import appeng.integration.abstraction.IC2PowerSink;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowerStorage, IExternalPowerSink
|
||||
@@ -81,15 +79,18 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
// trigger re-calc!
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AERootPoweredTile( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setDouble( "internalCurrentPower", this.getInternalCurrentPower() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AERootPoweredTile( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.setInternalCurrentPower( data.getDouble( "internalCurrentPower" ) );
|
||||
}
|
||||
|
||||
@@ -105,9 +106,9 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
}
|
||||
|
||||
@Override
|
||||
public final double injectExternalPower( final PowerUnits input, final double amt )
|
||||
public final double injectExternalPower( final PowerUnits input, final double amt, Actionable mode )
|
||||
{
|
||||
return PowerUnits.AE.convertTo( input, this.funnelPowerIntoStorage( input.convertTo( PowerUnits.AE, amt ), Actionable.MODULATE ) );
|
||||
return PowerUnits.AE.convertTo( input, this.funnelPowerIntoStorage( input.convertTo( PowerUnits.AE, amt ), mode ) );
|
||||
}
|
||||
|
||||
protected double funnelPowerIntoStorage( final double power, final Actionable mode )
|
||||
@@ -123,34 +124,20 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
final double fakeBattery = this.getInternalCurrentPower() + amt;
|
||||
final double required = this.getAEMaxPower() - this.getAECurrentPower();
|
||||
final double insertable = Math.min( required, amt );
|
||||
|
||||
if( fakeBattery > this.getInternalMaxPower() )
|
||||
{
|
||||
return fakeBattery - this.getInternalMaxPower();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
if( mode == Actionable.MODULATE )
|
||||
{
|
||||
if( this.getInternalCurrentPower() < 0.01 && amt > 0.01 )
|
||||
if( this.getInternalCurrentPower() < 0.01 && insertable > 0.01 )
|
||||
{
|
||||
this.PowerEvent( PowerEventType.PROVIDE_POWER );
|
||||
}
|
||||
|
||||
this.setInternalCurrentPower( this.getInternalCurrentPower() + amt );
|
||||
if( this.getInternalCurrentPower() > this.getInternalMaxPower() )
|
||||
{
|
||||
amt = this.getInternalCurrentPower() - this.getInternalMaxPower();
|
||||
this.setInternalCurrentPower( this.getInternalMaxPower() );
|
||||
return amt;
|
||||
}
|
||||
|
||||
return 0;
|
||||
this.setInternalCurrentPower( this.getInternalCurrentPower() + insertable );
|
||||
}
|
||||
|
||||
return amt - insertable;
|
||||
}
|
||||
|
||||
protected void PowerEvent( final PowerEventType x )
|
||||
|
||||
@@ -4,6 +4,7 @@ package appeng.tile.powersink;
|
||||
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
|
||||
|
||||
@@ -23,15 +24,10 @@ class ForgeEnergyAdapter implements IEnergyStorage
|
||||
@Override
|
||||
public final int receiveEnergy( int maxReceive, boolean simulate )
|
||||
{
|
||||
final int networkDemand = (int) Math.floor( this.sink.getExternalPowerDemand( PowerUnits.RF, maxReceive ) );
|
||||
final int used = Math.min( maxReceive, networkDemand );
|
||||
final double offered = (double) maxReceive;
|
||||
final double overflow = this.sink.injectExternalPower( PowerUnits.RF, offered, simulate ? Actionable.SIMULATE : Actionable.MODULATE );
|
||||
|
||||
if( !simulate )
|
||||
{
|
||||
this.sink.injectExternalPower( PowerUnits.RF, used );
|
||||
}
|
||||
|
||||
return used;
|
||||
return (int) ( maxReceive - overflow );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.powersink;
|
||||
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.networking.energy.IAEPowerStorage;
|
||||
|
||||
@@ -26,8 +27,22 @@ import appeng.api.networking.energy.IAEPowerStorage;
|
||||
public interface IExternalPowerSink extends IAEPowerStorage
|
||||
{
|
||||
|
||||
double injectExternalPower( PowerUnits input, double amt );
|
||||
/**
|
||||
* Inject power into the network
|
||||
*
|
||||
* @param externalUnit The {@link PowerUnits} used by the input
|
||||
* @param amount The amount offered to the sink.
|
||||
* @param mode Modulate or simulate the operation.
|
||||
* @return The unused amount, which could not be inserted into the sink.
|
||||
*/
|
||||
double injectExternalPower( PowerUnits externalUnit, double amount, Actionable mode );
|
||||
|
||||
/**
|
||||
*
|
||||
* @param externalUnit The {@link PowerUnits} used by the input
|
||||
* @param maxPowerRequired Limit the demand to this upper bound.
|
||||
* @return The amount of power demanded by the sink.
|
||||
*/
|
||||
double getExternalPowerDemand( PowerUnits externalUnit, double maxPowerRequired );
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.tile.powersink;
|
||||
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
|
||||
|
||||
@@ -41,17 +42,10 @@ class TeslaEnergyAdapter implements ITeslaConsumer
|
||||
public long givePower( long power, boolean simulated )
|
||||
{
|
||||
// Cut it down to what we can represent in a double
|
||||
double powerDbl = (double) power;
|
||||
double offeredPower = (double) power;
|
||||
|
||||
double networkDemand = this.sink.getExternalPowerDemand( PowerUnits.RF, powerDbl );
|
||||
long used = (long) Math.min( powerDbl, networkDemand );
|
||||
final double overflow = this.sink.injectExternalPower( PowerUnits.RF, offeredPower, simulated ? Actionable.SIMULATE : Actionable.MODULATE );
|
||||
|
||||
if( !simulated )
|
||||
{
|
||||
this.sink.injectExternalPower( PowerUnits.RF, used );
|
||||
}
|
||||
|
||||
return used;
|
||||
return (long) ( power - overflow );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.qnb;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -46,8 +47,6 @@ import appeng.me.cluster.IAECluster;
|
||||
import appeng.me.cluster.IAEMultiBlock;
|
||||
import appeng.me.cluster.implementations.QuantumCalculator;
|
||||
import appeng.me.cluster.implementations.QuantumCluster;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
@@ -87,9 +86,10 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void onNetworkWriteEvent( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
int out = this.constructed;
|
||||
|
||||
if( !this.internalInventory.getStackInSlot( 0 ).isEmpty() && this.constructed != -1 )
|
||||
@@ -105,12 +105,13 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
data.writeByte( (byte) out );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean onNetworkReadEvent( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int oldValue = this.constructed;
|
||||
this.constructed = data.readByte();
|
||||
return this.constructed != oldValue;
|
||||
return this.constructed != oldValue || c;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,8 +19,11 @@
|
||||
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;
|
||||
|
||||
@@ -40,13 +43,12 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.me.cache.SpatialPylonCache;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.IWorldCallable;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
|
||||
@@ -54,23 +56,26 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
|
||||
{
|
||||
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 );
|
||||
private final IItemHandler invExt = new WrapperFilteredItemHandler( inv, new SpatialIOFilter() );
|
||||
private YesNo lastRedstoneState = YesNo.UNDECIDED;
|
||||
|
||||
public TileSpatialIOPort()
|
||||
{
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
this.inv.setFilter( new SpatialIOFilter() );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileSpatialIOPort( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileSpatialIOPort( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
if( data.hasKey( "lastRedstoneState" ) )
|
||||
{
|
||||
this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
|
||||
@@ -143,7 +148,13 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
|
||||
final MENetworkEvent res = gi.postEvent( new MENetworkSpatialEvent( this, req ) );
|
||||
if( !res.isCanceled() )
|
||||
{
|
||||
final TransitionResult tr = sc.doSpatialTransition( cell, this.world, spc.getMin(), spc.getMax(), true );
|
||||
int playerId = -1;
|
||||
if( getProxy().getSecurity().isAvailable() )
|
||||
{
|
||||
playerId = 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 );
|
||||
@@ -170,6 +181,12 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
|
||||
return new DimensionalCoord( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nonnull IItemHandler getItemHandlerForSide( @Nonnull EnumFacing side )
|
||||
{
|
||||
return this.invExt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInternalInventory()
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.spatial;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -35,8 +36,6 @@ import appeng.me.cluster.implementations.SpatialPylonCalculator;
|
||||
import appeng.me.cluster.implementations.SpatialPylonCluster;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.AENetworkProxyMultiblock;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
|
||||
|
||||
@@ -217,17 +216,19 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
return 0;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileSpatialPylon( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int old = this.displayBits;
|
||||
this.displayBits = data.readByte();
|
||||
return old != this.displayBits;
|
||||
return old != this.displayBits || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileSpatialPylon( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeByte( this.displayBits );
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -89,8 +90,6 @@ import appeng.capabilities.Capabilities;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -433,9 +432,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileChest( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
|
||||
if( this.world.getTotalWorldTime() - this.lastStateChange > 8 )
|
||||
{
|
||||
this.state = 0;
|
||||
@@ -474,9 +475,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileChest( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
|
||||
final int oldState = this.state;
|
||||
final ItemStack oldType = this.storageType;
|
||||
|
||||
@@ -498,12 +501,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
this.lastStateChange = this.world.getTotalWorldTime();
|
||||
|
||||
return oldPaintedColor != this.paintedColor || ( this.state & 0xDB6DB6DB ) != ( oldState & 0xDB6DB6DB ) || !Platform.itemComparisons()
|
||||
.isSameItem( oldType, this.storageType );
|
||||
.isSameItem( oldType, this.storageType ) || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileChest( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.config.readFromNBT( data );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
@@ -512,12 +516,14 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileChest( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.config.writeToNBT( data );
|
||||
data.setInteger( "priority", this.priority );
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -51,8 +52,6 @@ import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.DriveWatcher;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
@@ -99,9 +98,10 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
this.inv.setFilter( new CellValidInventoryFilter() );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileDrive( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
int newState = 0;
|
||||
|
||||
if( this.getProxy().isActive() )
|
||||
@@ -117,6 +117,15 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
data.writeInt( newState );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int oldState = this.state;
|
||||
this.state = data.readInt();
|
||||
return ( this.state & BIT_STATE_MASK ) != ( oldState & BIT_STATE_MASK ) || c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellCount()
|
||||
{
|
||||
@@ -176,25 +185,20 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
return ( ( this.state >> ( slot * 3 + 2 ) ) & 0x01 ) == 0x01;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileDrive( final ByteBuf data )
|
||||
{
|
||||
final int oldState = this.state;
|
||||
this.state = data.readInt();
|
||||
return ( this.state & BIT_STATE_MASK ) != ( oldState & BIT_STATE_MASK );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileDrive( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.isCached = false;
|
||||
this.priority = data.getInteger( "priority" );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileDrive( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setInteger( "priority", this.priority );
|
||||
return data;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
|
||||
@@ -58,12 +58,9 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.BlockUpgradeInventory;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -96,7 +93,6 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
private IMEInventory<IAEFluidStack> cachedFluid;
|
||||
private IMEInventory<IAEItemStack> cachedItem;
|
||||
|
||||
@Reflected
|
||||
public TileIOPort()
|
||||
{
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
@@ -111,22 +107,21 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
this.upgrades = new BlockUpgradeInventory( ioPortBlock, this, 3 );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileIOPort( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.manager.writeToNBT( data );
|
||||
this.inputCells.writeToNBT( data, "cellsInput" );
|
||||
this.outputCells.writeToNBT( data, "cellsOutput" );
|
||||
this.upgrades.writeToNBT( data, "upgrades" );
|
||||
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileIOPort( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.manager.readFromNBT( data );
|
||||
this.inputCells.readFromNBT( data, "cellsInput" );
|
||||
this.outputCells.readFromNBT( data, "cellsOutput" );
|
||||
this.upgrades.readFromNBT( data, "upgrades" );
|
||||
if( data.hasKey( "lastRedstoneState" ) )
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -29,8 +31,6 @@ import net.minecraft.util.SoundCategory;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
@@ -46,15 +46,17 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
|
||||
private float lidAngle;
|
||||
private float prevLidAngle;
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileSkyChest( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.getPlayerOpen() > 0 );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileSkyChest( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int wasOpen = this.getPlayerOpen();
|
||||
this.setPlayerOpen( data.readBoolean() ? 1 : 0 );
|
||||
|
||||
@@ -63,7 +65,7 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
|
||||
this.setLastEvent( System.currentTimeMillis() );
|
||||
}
|
||||
|
||||
return false; // TESR yo!
|
||||
return c; // TESR yo!
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -432,25 +432,6 @@ public class Platform
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The usual version of this returns an ItemStack, this version returns the recipe.
|
||||
*/
|
||||
public static IRecipe findMatchingRecipe( final InventoryCrafting inventoryCrafting, final World par2World )
|
||||
{
|
||||
IForgeRegistry<IRecipe> recipes = ForgeRegistries.RECIPES;
|
||||
final List<IRecipe> rl = recipes.getValues();
|
||||
|
||||
for( final IRecipe r : rl )
|
||||
{
|
||||
if( r.matches( inventoryCrafting, par2World ) )
|
||||
{
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack[] getBlockDrops( final World w, final BlockPos pos )
|
||||
{
|
||||
List<ItemStack> out = new ArrayList<>();
|
||||
|
||||
@@ -117,6 +117,8 @@ gui.appliedenergistics2.security.build.tip=User can modify the physical structur
|
||||
gui.appliedenergistics2.security.security.tip=User can access and modify the security terminal of the network.
|
||||
|
||||
gui.appliedenergistics2.Efficiency=Efficiency
|
||||
gui.appliedenergistics2.SCSSize=SCS Size
|
||||
gui.appliedenergistics2.SCSInvalid=Invalid
|
||||
gui.appliedenergistics2.RequiredPower=Required Power
|
||||
gui.appliedenergistics2.StoredPower=Stored Power
|
||||
gui.appliedenergistics2.MaxPower=Max Power
|
||||
@@ -168,6 +170,7 @@ gui.appliedenergistics2.Blank=Blank
|
||||
gui.appliedenergistics2.Unlinked=Unlinked
|
||||
gui.appliedenergistics2.Linked=Linked
|
||||
gui.appliedenergistics2.StoredSize=Stored Size
|
||||
gui.appliedenergistics2.CellId=Cell ID
|
||||
gui.appliedenergistics2.SkyChest=Sky Stone Chest
|
||||
gui.appliedenergistics2.PatternTerminal=Pattern Terminal
|
||||
gui.appliedenergistics2.CraftingPattern=Crafting Pattern
|
||||
|
||||
@@ -43,10 +43,10 @@ tile.appliedenergistics2.sky_stone_chest.name=Baule di roccia del cielo
|
||||
tile.appliedenergistics2.smooth_sky_stone_chest.name=Baule di blocchi del cielo
|
||||
tile.appliedenergistics2.sky_compass.name=Bussola per Meteoriti
|
||||
tile.appliedenergistics2.crafting_monitor.name=Monitor per fabbricazione
|
||||
tile.appliedenergistics2.crafting_storage_1k.name=Deposito per fabbricazione da 1k
|
||||
tile.appliedenergistics2.crafting_storage_4k.name=Deposito per fabbricazione da 4k
|
||||
tile.appliedenergistics2.crafting_storage_16k.name=Deposito per fabbricazione da 16k
|
||||
tile.appliedenergistics2.crafting_storage_64k.name=Deposito per fabbricazione da 64k
|
||||
tile.appliedenergistics2.crafting_storage_1k.name=Memoria di fabbricazione da 1k
|
||||
tile.appliedenergistics2.crafting_storage_4k.name=Memoria di fabbricazione da 4k
|
||||
tile.appliedenergistics2.crafting_storage_16k.name=Memoria di fabbricazione da 16k
|
||||
tile.appliedenergistics2.crafting_storage_64k.name=Memoria di fabbricazione da 64k
|
||||
tile.appliedenergistics2.crafting_accelerator.name=Unità co-processore per fabbricazione
|
||||
tile.appliedenergistics2.crafting_unit.name=Unità di fabbricazione
|
||||
tile.appliedenergistics2.molecular_assembler.name=Assemblatore moleculare
|
||||
@@ -123,7 +123,7 @@ gui.appliedenergistics2.NetworkTool=Attrezzo per sistema
|
||||
gui.appliedenergistics2.PowerUsageRate=Uso di energia
|
||||
gui.appliedenergistics2.PowerInputRate=Generazione di energia
|
||||
gui.appliedenergistics2.PortableCell=Cella portabile
|
||||
gui.appliedenergistics2.Security=Term sicurezza
|
||||
gui.appliedenergistics2.Security=Terminale di sicurezza
|
||||
gui.appliedenergistics2.CellWorkbench=Banco da lavoro per celle
|
||||
gui.appliedenergistics2.QuantumLinkChamber=Camera di collegamento quantistico
|
||||
gui.appliedenergistics2.IOPort=Porta IO ME
|
||||
@@ -132,7 +132,7 @@ gui.appliedenergistics2.Condenser=Condesatore di materia
|
||||
gui.appliedenergistics2.Config=Configurazioni
|
||||
gui.appliedenergistics2.Drive=Drive ME
|
||||
gui.appliedenergistics2.ExportBus=Bus esportatore ME
|
||||
gui.appliedenergistics2.GrindStone=Macina di quarzo
|
||||
gui.appliedenergistics2.GrindStone=Macina
|
||||
gui.appliedenergistics2.ImportBus=Bus importatore ME
|
||||
gui.appliedenergistics2.Interface=Interfacia ME
|
||||
gui.appliedenergistics2.LevelEmitter=Emettitore di pietrarossa ME
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"parent": "block/block",
|
||||
"textures": {
|
||||
"block": "blocks/stone",
|
||||
"quartz": "appliedenergistics2:blocks/charged_quartz_ore_light"
|
||||
"quartz": "appliedenergistics2:blocks/charged_quartz_ore_light",
|
||||
"particle": "appliedenergistics2:blocks/charged_quartz_ore"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package appeng.core.worlddata;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class SpatialDimensionManagerTest
|
||||
{
|
||||
private static final BlockPos CONTENT = new BlockPos(1, 1, 1);
|
||||
|
||||
private static final int ID_1 = 0;
|
||||
private static final int ID_2 = 1;
|
||||
private static final int ID_3 = 2;
|
||||
private static final int ID_4 = 3;
|
||||
private static final int ID_5 = 4;
|
||||
private static final int ID_6 = 5;
|
||||
private static final int ID_7 = 6;
|
||||
private static final int ID_8 = 7;
|
||||
private static final int ID_9 = 8;
|
||||
private static final int ID_A = 9;
|
||||
private static final int ID_B = 10;
|
||||
private static final int ID_C = 11;
|
||||
|
||||
|
||||
private static final BlockPos POS_1 = new BlockPos( -320, 64, -320);
|
||||
private static final BlockPos POS_2 = new BlockPos( 192, 64, -320);
|
||||
private static final BlockPos POS_3 = new BlockPos( -320, 64, 192);
|
||||
private static final BlockPos POS_4 = new BlockPos( 192, 64, 192);
|
||||
|
||||
private static final BlockPos POS_5 = new BlockPos( -832, 64, -320);
|
||||
private static final BlockPos POS_6 = new BlockPos( 704, 64, -320);
|
||||
private static final BlockPos POS_7 = new BlockPos( -832, 64, 192);
|
||||
private static final BlockPos POS_8 = new BlockPos( 704, 64, 192);
|
||||
|
||||
private static final BlockPos POS_9 = new BlockPos( -320, 64, -832);
|
||||
private static final BlockPos POS_A = new BlockPos( 192, 64, -832);
|
||||
private static final BlockPos POS_B = new BlockPos( -320, 64, 704);
|
||||
private static final BlockPos POS_C = new BlockPos( 192, 64, 704);
|
||||
|
||||
|
||||
@Test
|
||||
public void testBlockPosGeneration()
|
||||
{
|
||||
SpatialDimensionManager manager = new SpatialDimensionManager( null );
|
||||
|
||||
Assert.assertEquals( ID_1, manager.createNewCellDimension( CONTENT, -1 ));
|
||||
Assert.assertEquals( ID_2, manager.createNewCellDimension( CONTENT, -1 ));
|
||||
Assert.assertEquals( ID_3, manager.createNewCellDimension( CONTENT, -1 ));
|
||||
Assert.assertEquals( ID_4, manager.createNewCellDimension( CONTENT, -1 ));
|
||||
Assert.assertEquals( ID_5, manager.createNewCellDimension( CONTENT, -1 ));
|
||||
Assert.assertEquals( ID_6, manager.createNewCellDimension( CONTENT, -1 ));
|
||||
Assert.assertEquals( ID_7, manager.createNewCellDimension( CONTENT, -1 ));
|
||||
Assert.assertEquals( ID_8, manager.createNewCellDimension( CONTENT, -1 ));
|
||||
Assert.assertEquals( ID_9, manager.createNewCellDimension( CONTENT, -1 ));
|
||||
Assert.assertEquals( ID_A, manager.createNewCellDimension( CONTENT, -1 ));
|
||||
Assert.assertEquals( ID_B, manager.createNewCellDimension( CONTENT, -1 ));
|
||||
Assert.assertEquals( ID_C, manager.createNewCellDimension( CONTENT, -1 ));
|
||||
|
||||
Assert.assertEquals( POS_1, manager.getCellDimensionOrigin( ID_1 ) );
|
||||
Assert.assertEquals( POS_2, manager.getCellDimensionOrigin( ID_2 ) );
|
||||
Assert.assertEquals( POS_3, manager.getCellDimensionOrigin( ID_3 ) );
|
||||
Assert.assertEquals( POS_4, manager.getCellDimensionOrigin( ID_4 ) );
|
||||
Assert.assertEquals( POS_5, manager.getCellDimensionOrigin( ID_5 ) );
|
||||
Assert.assertEquals( POS_6, manager.getCellDimensionOrigin( ID_6 ) );
|
||||
Assert.assertEquals( POS_7, manager.getCellDimensionOrigin( ID_7 ) );
|
||||
Assert.assertEquals( POS_8, manager.getCellDimensionOrigin( ID_8 ) );
|
||||
Assert.assertEquals( POS_9, manager.getCellDimensionOrigin( ID_9 ) );
|
||||
Assert.assertEquals( POS_A, manager.getCellDimensionOrigin( ID_A ) );
|
||||
Assert.assertEquals( POS_B, manager.getCellDimensionOrigin( ID_B ) );
|
||||
Assert.assertEquals( POS_C, manager.getCellDimensionOrigin( ID_C ) );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user