Changed AE Tile Event Stuff.
This commit is contained in:
parent
5a6cd05e20
commit
3a0f3ee792
|
@ -1,7 +1,5 @@
|
|||
package appeng.tile;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
|
@ -16,7 +14,7 @@ public abstract class AEBaseInvTile extends AEBaseTile implements ISidedInventor
|
|||
{
|
||||
|
||||
public AEBaseInvTile() {
|
||||
addNewHandler( new AETileEventHandler( EnumSet.of( TileEventType.WORLD_NBT ) ) {
|
||||
addNewHandler( new AETileEventHandler( TileEventType.WORLD_NBT ) {
|
||||
|
||||
@Override
|
||||
public void readFromNBT(net.minecraft.nbt.NBTTagCompound data)
|
||||
|
|
|
@ -14,8 +14,10 @@ public abstract class AETileEventHandler
|
|||
|
||||
final EnumSet<TileEventType> supportedEvents;
|
||||
|
||||
public AETileEventHandler(EnumSet<TileEventType> events) {
|
||||
supportedEvents = events;
|
||||
public AETileEventHandler(TileEventType... events) {
|
||||
supportedEvents = EnumSet.noneOf( TileEventType.class );
|
||||
for (TileEventType t : events)
|
||||
supportedEvents.add( t );
|
||||
}
|
||||
|
||||
public EnumSet<TileEventType> getSubscribedEvents()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package appeng.tile.grindstone;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -29,7 +28,7 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
|||
public int rotation = 0;
|
||||
|
||||
public TileCrank() {
|
||||
addNewHandler( new AETileEventHandler( EnumSet.of( TileEventType.NETWORK, TileEventType.TICK ) ) {
|
||||
addNewHandler( new AETileEventHandler( TileEventType.NETWORK, TileEventType.TICK ) {
|
||||
|
||||
@Override
|
||||
public void Tick()
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package appeng.tile.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -72,7 +70,7 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
|||
{
|
||||
|
||||
public TileCellWorkbenchHandler() {
|
||||
super( EnumSet.of( TileEventType.WORLD_NBT ) );
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,7 @@ import appeng.api.config.PowerMultiplier;
|
|||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.implementations.tiles.ICrankable;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.me.GridAccessException;
|
||||
|
@ -50,7 +51,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
|||
{
|
||||
|
||||
public TileChargerHandler() {
|
||||
super( EnumSet.of( TileEventType.TICK, TileEventType.NETWORK ) );
|
||||
super( TileEventType.TICK, TileEventType.NETWORK );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -141,6 +142,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
|||
|
||||
public TileCharger() {
|
||||
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
gridProxy.setFlags( GridFlags.CANNOT_CARRY );
|
||||
internalMaxPower = 1500;
|
||||
gridProxy.setIdlePowerUsage( 0 );
|
||||
addNewHandler( new TileChargerHandler() );
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package appeng.tile.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -40,7 +38,7 @@ public class TileCondenser extends AEBaseInvTile implements IAEAppEngInventory,
|
|||
{
|
||||
|
||||
public TileCondenserHandler() {
|
||||
super( EnumSet.of( TileEventType.WORLD_NBT ) );
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,7 @@ public class TileInscriber extends AENetworkPowerTile
|
|||
{
|
||||
|
||||
public TileInscriberHandler() {
|
||||
super( EnumSet.of( TileEventType.TICK, TileEventType.NETWORK ) );
|
||||
super( TileEventType.TICK, TileEventType.NETWORK );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package appeng.tile.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -45,7 +43,7 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IS
|
|||
{
|
||||
|
||||
public TileInterfaceHandler() {
|
||||
super( EnumSet.of( TileEventType.WORLD_NBT ) );
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,7 +3,6 @@ package appeng.tile.misc;
|
|||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -11,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
|
@ -50,7 +50,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
|||
{
|
||||
|
||||
public TileVibrationChamberHandler() {
|
||||
super( EnumSet.of( TileEventType.NETWORK, TileEventType.WORLD_NBT ) );
|
||||
super( TileEventType.NETWORK, TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,6 +87,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
|||
|
||||
public TileVibrationChamber() {
|
||||
gridProxy.setIdlePowerUsage( 0 );
|
||||
gridProxy.setFlags( GridFlags.CANNOT_CARRY );
|
||||
addNewHandler( new TileVibrationChamberHandler() );
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
|||
{
|
||||
|
||||
public CableBusHandler() {
|
||||
super( EnumSet.of( TileEventType.NETWORK, TileEventType.WORLD_NBT ) );
|
||||
super( TileEventType.NETWORK, TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package appeng.tile.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
@ -32,7 +30,7 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
|||
{
|
||||
|
||||
public TilePowerRelayHandler() {
|
||||
super( EnumSet.of( TileEventType.TICK ) );
|
||||
super( TileEventType.TICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,10 +42,11 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
|||
{
|
||||
IEnergyGrid eg = gridProxy.getEnergy();
|
||||
double powerRequested = internalCurrentPower - eg.injectPower( internalCurrentPower, Actionable.SIMULATE );
|
||||
|
||||
|
||||
if ( powerRequested > 0 )
|
||||
{
|
||||
internalCurrentPower += eg.injectPower( extractAEPower( powerRequested, Actionable.MODULATE, PowerMultiplier.ONE ), Actionable.MODULATE );
|
||||
internalCurrentPower += eg
|
||||
.injectPower( extractAEPower( powerRequested, Actionable.MODULATE, PowerMultiplier.ONE ), Actionable.MODULATE );
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package appeng.tile.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.api.networking.events.MENetworkPowerStorage;
|
||||
import appeng.api.networking.events.MENetworkPowerStorage.PowerEventType;
|
||||
|
@ -51,7 +50,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
|||
{
|
||||
|
||||
public TileEnergyCellHandler() {
|
||||
super( EnumSet.of( TileEventType.WORLD_NBT ) );
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,6 +69,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
|||
|
||||
public TileEnergyCell() {
|
||||
gridProxy.setIdlePowerUsage( 0 );
|
||||
gridProxy.setFlags( GridFlags.CANNOT_CARRY );
|
||||
addNewHandler( new TileEnergyCellHandler() );
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package appeng.tile.networking;
|
|||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -54,7 +53,7 @@ public class TileWireless extends AENetworkInvTile
|
|||
{
|
||||
|
||||
public TileWirelessHandler() {
|
||||
super( EnumSet.of( TileEventType.NETWORK ) );
|
||||
super( TileEventType.NETWORK );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,7 +44,7 @@ public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowe
|
|||
{
|
||||
|
||||
public AEPoweredRootHandler() {
|
||||
super( EnumSet.of( TileEventType.WORLD_NBT ) );
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package appeng.tile.powersink;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
@ -28,7 +26,7 @@ public abstract class BuildCraft extends AERootPoweredTile implements IPowerRece
|
|||
final protected PowerHandler bcPowerHandler;
|
||||
|
||||
public BCPerdition(IPowerReceptor te) {
|
||||
super( EnumSet.of( TileEventType.TICK, TileEventType.WORLD_NBT ) );
|
||||
super( TileEventType.TICK, TileEventType.WORLD_NBT );
|
||||
bcPowerHandler = new PowerHandler( te, Type.MACHINE );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package appeng.tile.powersink;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import Reika.RotaryCraft.API.ShaftPowerReceiver;
|
||||
import appeng.api.config.PowerUnits;
|
||||
|
@ -23,7 +21,7 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
|
|||
{
|
||||
|
||||
public RotaryCraftHandler() {
|
||||
super( EnumSet.of( TileEventType.TICK ) );
|
||||
super( TileEventType.TICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
|||
{
|
||||
|
||||
public QBridgeHandler() {
|
||||
super( EnumSet.of( TileEventType.NETWORK, TileEventType.TICK ) );
|
||||
super( TileEventType.NETWORK, TileEventType.TICK );
|
||||
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
gridProxy.setFlags( GridFlags.TIER_2_CAPACITY );
|
||||
gridProxy.setIdlePowerUsage( 22 );
|
||||
|
|
|
@ -57,7 +57,7 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
|||
{
|
||||
|
||||
public TileSpatialPylonHandler() {
|
||||
super( EnumSet.of( TileEventType.NETWORK ) );
|
||||
super( TileEventType.NETWORK );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.io.DataOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
@ -45,6 +44,7 @@ import appeng.api.storage.data.IAEFluidStack;
|
|||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.helpers.AENoHandler;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
|
@ -55,7 +55,7 @@ import appeng.tile.inventory.InvOperation;
|
|||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHandler, IStorageMonitorable
|
||||
public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHandler, IStorageMonitorable, IPriorityHost
|
||||
{
|
||||
|
||||
static final AENoHandler noHandler = new AENoHandler();
|
||||
|
@ -109,7 +109,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||
{
|
||||
|
||||
public invManger() {
|
||||
super( EnumSet.of( TileEventType.TICK, TileEventType.NETWORK, TileEventType.WORLD_NBT ) );
|
||||
super( TileEventType.TICK, TileEventType.NETWORK, TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -664,4 +664,23 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int newValue)
|
||||
{
|
||||
priority = newValue;
|
||||
|
||||
icell = null;
|
||||
fcell = null;
|
||||
isCached = false; // recalculate the storage cell.
|
||||
|
||||
try
|
||||
{
|
||||
gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package appeng.tile.storage;
|
|||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -27,6 +26,7 @@ import appeng.api.storage.StorageChannel;
|
|||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.DriveWatcher;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
|
@ -37,7 +37,7 @@ import appeng.tile.inventory.AppEngInternalInventory;
|
|||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class TileDrive extends AENetworkInvTile implements IChestOrDrive
|
||||
public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPriorityHost
|
||||
{
|
||||
|
||||
final int sides[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
@ -74,7 +74,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive
|
|||
{
|
||||
|
||||
public invManger() {
|
||||
super( EnumSet.of( TileEventType.WORLD_NBT, TileEventType.NETWORK ) );
|
||||
super( TileEventType.WORLD_NBT, TileEventType.NETWORK );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -316,4 +316,22 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive
|
|||
return gridProxy.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int newValue)
|
||||
{
|
||||
priority = newValue;
|
||||
onInventoryChanged();
|
||||
|
||||
isCached = false; // recalculate the storage cell.
|
||||
updateState();
|
||||
|
||||
try
|
||||
{
|
||||
gridProxy.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package appeng.tile.storage;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -64,7 +62,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
|||
{
|
||||
|
||||
public TileIOPortHandler() {
|
||||
super( EnumSet.of( TileEventType.WORLD_NBT ) );
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue