Fixes #2575: Removed ITickable from AEBaseTile
Removed TileEventType.TICK, use ITickable when really needed. The few tiles needing to tick and are not a grid tile now implement ITickable. Charger is no longer implementing ITickable.
This commit is contained in:
parent
fe1a67ffaa
commit
5328627d7a
|
@ -37,6 +37,8 @@ public enum TickRates
|
|||
|
||||
Inscriber( 1, 1 ),
|
||||
|
||||
Charger( 10, 120 ),
|
||||
|
||||
IOPort( 1, 5 ),
|
||||
|
||||
VibrationChamber( 10, 40 ),
|
||||
|
|
|
@ -34,8 +34,6 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
|||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
|
@ -45,8 +43,8 @@ public class TileChunkLoader extends AEBaseTile implements ITickable
|
|||
private boolean requestTicket = true;
|
||||
private Ticket ct = null;
|
||||
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void onTickEvent()
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if( this.requestTicket )
|
||||
{
|
||||
|
|
|
@ -30,8 +30,6 @@ import net.minecraft.util.text.TextComponentString;
|
|||
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
|
@ -43,8 +41,8 @@ public class TileCubeGenerator extends AEBaseTile implements ITickable
|
|||
private int countdown = 20 * 10;
|
||||
private EntityPlayer who = null;
|
||||
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void onTickEvent()
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if( this.is != null && Platform.isServer() )
|
||||
{
|
||||
|
|
|
@ -43,7 +43,6 @@ import net.minecraft.network.NetworkManager;
|
|||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -63,7 +62,7 @@ import appeng.util.Platform;
|
|||
import appeng.util.SettingsFrom;
|
||||
|
||||
|
||||
public class AEBaseTile extends TileEntity implements ITickable, IOrientable, ICommonTile, ICustomNameObject
|
||||
public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, ICustomNameObject
|
||||
{
|
||||
|
||||
private static final ThreadLocal<WeakReference<AEBaseTile>> DROP_NO_ITEMS = new ThreadLocal<WeakReference<AEBaseTile>>();
|
||||
|
@ -117,14 +116,15 @@ public class AEBaseTile extends TileEntity implements ITickable, IOrientable, IC
|
|||
}
|
||||
|
||||
@Nonnull
|
||||
public IBlockState getBlockState(){
|
||||
public IBlockState getBlockState()
|
||||
{
|
||||
if( state == null )
|
||||
{
|
||||
state = worldObj.getBlockState( getPos() );
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* for dormant chunk cache.
|
||||
*/
|
||||
|
@ -194,15 +194,6 @@ public class AEBaseTile extends TileEntity implements ITickable, IOrientable, IC
|
|||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void update()
|
||||
{
|
||||
for( final AETileEventHandler h : this.getHandlerListFor( TileEventType.TICK ) )
|
||||
{
|
||||
h.tick( this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SPacketUpdateTileEntity getUpdatePacket()
|
||||
{
|
||||
|
@ -271,7 +262,8 @@ public class AEBaseTile extends TileEntity implements ITickable, IOrientable, IC
|
|||
{
|
||||
final NBTTagCompound data = writeUpdateData();
|
||||
|
||||
if (data == null) {
|
||||
if( data == null )
|
||||
{
|
||||
return new NBTTagCompound();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,6 @@ package appeng.tile.events;
|
|||
|
||||
public enum TileEventType
|
||||
{
|
||||
/**
|
||||
* Requires ITickable, this makes the tile entity tick in 1.8
|
||||
*/
|
||||
TICK,
|
||||
|
||||
WORLD_NBT_READ, WORLD_NBT_WRITE,
|
||||
|
||||
/**
|
||||
|
|
|
@ -53,8 +53,8 @@ public class TileCrank extends AEBaseTile implements ICustomCollision, ITickable
|
|||
private int hits = 0;
|
||||
private int rotation = 0;
|
||||
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void Tick_TileCrank()
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if( this.rotation > 0 )
|
||||
{
|
||||
|
|
|
@ -30,7 +30,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
|
@ -40,10 +39,15 @@ import appeng.api.definitions.IItemDefinition;
|
|||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.implementations.tiles.ICrankable;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
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;
|
||||
|
@ -54,7 +58,7 @@ import appeng.util.Platform;
|
|||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class TileCharger extends AENetworkPowerTile implements ICrankable, ITickable
|
||||
public class TileCharger extends AENetworkPowerTile implements ICrankable, IGridTickable
|
||||
{
|
||||
|
||||
private final int[] sides = { 0 };
|
||||
|
@ -104,75 +108,6 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, ITick
|
|||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void Tick_TileCharger()
|
||||
{
|
||||
if( this.lastUpdate > 60 && this.requiresUpdate )
|
||||
{
|
||||
this.requiresUpdate = false;
|
||||
this.markForUpdate();
|
||||
this.lastUpdate = 0;
|
||||
}
|
||||
this.lastUpdate++;
|
||||
|
||||
this.tickTickTimer++;
|
||||
if( this.tickTickTimer < 20 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.tickTickTimer = 0;
|
||||
|
||||
final ItemStack myItem = this.getStackInSlot( 0 );
|
||||
|
||||
// charge from the network!
|
||||
if( this.getInternalCurrentPower() < 1499 )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.injectExternalPower( PowerUnits.AE, this.getProxy().getEnergy().extractAEPower( Math.min( 150.0, 1500.0 - this.getInternalCurrentPower() ), Actionable.MODULATE, PowerMultiplier.ONE ) );
|
||||
this.tickTickTimer = 20; // keep ticking...
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// continue!
|
||||
}
|
||||
}
|
||||
|
||||
if( myItem == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
if( this.getInternalCurrentPower() > 149 && Platform.isChargeable( myItem ) )
|
||||
{
|
||||
final IAEItemPowerStorage ps = (IAEItemPowerStorage) myItem.getItem();
|
||||
if( ps.getAEMaxPower( myItem ) > ps.getAECurrentPower( myItem ) )
|
||||
{
|
||||
final double oldPower = this.getInternalCurrentPower();
|
||||
|
||||
final double adjustment = ps.injectAEPower( myItem, this.extractAEPower( 150.0, Actionable.MODULATE, PowerMultiplier.CONFIG ) );
|
||||
this.setInternalCurrentPower( this.getInternalCurrentPower() + adjustment );
|
||||
if( oldPower > this.getInternalCurrentPower() )
|
||||
{
|
||||
this.requiresUpdate = true;
|
||||
}
|
||||
this.tickTickTimer = 20; // keep ticking...
|
||||
}
|
||||
}
|
||||
else if( this.getInternalCurrentPower() > 1499 && materials.certusQuartzCrystal().isSameAs( myItem ) )
|
||||
{
|
||||
if( Platform.getRandomFloat() > 0.8f ) // simulate wait
|
||||
{
|
||||
this.extractAEPower( this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
|
||||
|
||||
materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).ifPresent( charged ->
|
||||
this.setInventorySlotContents( 0, charged ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOrientation( final EnumFacing inForward, final EnumFacing inUp )
|
||||
{
|
||||
|
@ -207,8 +142,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, ITick
|
|||
{
|
||||
this.extractAEPower( this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
|
||||
|
||||
materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).ifPresent( charged ->
|
||||
this.setInventorySlotContents( 0, charged ) );
|
||||
materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).ifPresent( charged -> this.setInventorySlotContents( 0, charged ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -242,6 +176,15 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, ITick
|
|||
@Override
|
||||
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removed, final ItemStack added )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
|
@ -292,4 +235,71 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, ITick
|
|||
Platform.spawnDrops( this.worldObj, this.pos.offset( this.getForward() ), drops );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return new TickingRequest( TickRates.Charger.getMin(), TickRates.Charger.getMin(), false, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall )
|
||||
{
|
||||
return doWork() ? TickRateModulation.FASTER : TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
private boolean doWork()
|
||||
{
|
||||
final ItemStack myItem = this.getStackInSlot( 0 );
|
||||
|
||||
// charge from the network!
|
||||
if( this.getInternalCurrentPower() < 1499 )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.injectExternalPower( PowerUnits.AE, this.getProxy().getEnergy().extractAEPower( Math.min( 500.0, 1500.0 - this.getInternalCurrentPower() ), Actionable.MODULATE, PowerMultiplier.ONE ) );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// continue!
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if( myItem == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
|
||||
if( this.getInternalCurrentPower() > 149 && Platform.isChargeable( myItem ) )
|
||||
{
|
||||
final IAEItemPowerStorage ps = (IAEItemPowerStorage) myItem.getItem();
|
||||
if( ps.getAEMaxPower( myItem ) > ps.getAECurrentPower( myItem ) )
|
||||
{
|
||||
final double oldPower = this.getInternalCurrentPower();
|
||||
|
||||
final double adjustment = ps.injectAEPower( myItem, this.extractAEPower( 150.0, Actionable.MODULATE, PowerMultiplier.CONFIG ) );
|
||||
this.setInternalCurrentPower( this.getInternalCurrentPower() + adjustment );
|
||||
|
||||
if( oldPower > this.getInternalCurrentPower() )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( this.getInternalCurrentPower() > 1499 && materials.certusQuartzCrystal().isSameAs( myItem ) )
|
||||
{
|
||||
if( Platform.getRandomFloat() > 0.8f ) // simulate wait
|
||||
{
|
||||
this.extractAEPower( this.getInternalMaxPower(), Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
|
||||
|
||||
materials.certusQuartzCrystalCharged().maybeStack( myItem.stackSize ).ifPresent( charged -> this.setInventorySlotContents( 0, charged ) );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@ package appeng.tile.misc;
|
|||
import net.minecraft.util.ITickable;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
|
@ -38,8 +36,8 @@ public class TileLightDetector extends AEBaseTile implements ITickable
|
|||
return this.lastLight > 0;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void Tick_TileLightDetector()
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
this.lastCheck++;
|
||||
if( this.lastCheck > 30 )
|
||||
|
|
|
@ -75,8 +75,8 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
|||
this.internalInventory.setMaxStackSize( 1 );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void onTickEvent()
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if( this.updateStatus )
|
||||
{
|
||||
|
|
|
@ -367,8 +367,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||
return super.extractAEPower( amt - stash, mode ) + stash;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void Tick_TileChest()
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if( this.worldObj.isRemote )
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ import net.minecraft.init.SoundEvents;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
|
@ -35,10 +36,46 @@ import appeng.tile.inventory.AppEngInternalInventory;
|
|||
import appeng.tile.inventory.InvOperation;
|
||||
|
||||
|
||||
public class TileSkyChest extends AEBaseInvTile
|
||||
public class TileSkyChest extends AEBaseInvTile implements ITickable
|
||||
{
|
||||
|
||||
private final int[] sides = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 };
|
||||
private final int[] sides = {
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
31,
|
||||
32,
|
||||
33,
|
||||
34,
|
||||
35 };
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 * 4 );
|
||||
// server
|
||||
private int numPlayersUsing;
|
||||
|
@ -126,8 +163,8 @@ public class TileSkyChest extends AEBaseInvTile
|
|||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.TICK )
|
||||
public void tick()
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
int i = this.pos.getX();
|
||||
int j = this.pos.getY();
|
||||
|
|
Loading…
Reference in New Issue