Compare commits

...

3 Commits

Author SHA1 Message Date
Salomão 362b001cb4 level emitter dying fix 2021-03-25 22:48:42 -03:00
Salomão b6fd4b3c0f changed priority of JEI items on the 2021-03-23 22:23:58 -03:00
Salomão e364603a5a Changed level emitters to update only once when they tick 2021-03-17 21:35:26 -03:00
3 changed files with 71 additions and 47 deletions
@@ -237,22 +237,6 @@ public class PacketJEIRecipe extends AppEngPacket
// Fall back using an existing item // Fall back using an existing item
out = storage.extractItems( request, Actionable.SIMULATE, cct.getActionSource() ); out = storage.extractItems( request, Actionable.SIMULATE, cct.getActionSource() );
} }
if( out == null )
{
IItemList<IAEItemStack> items = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
Iterator<IAEItemStack> iterator = inv.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).getAvailableItems( items ).iterator();
while ( iterator.hasNext() )
{
final IAEItemStack o = iterator.next();
if( o.getDefinition().isItemEqual( request.getDefinition() ) && o.isCraftable() )
{
out = o;
break;
}
iterator.remove();
}
}
} }
if( out != null ) if( out != null )
@@ -274,13 +258,13 @@ public class PacketJEIRecipe extends AppEngPacket
else else
{ {
currentItem = ad.simulateSimilarRemove(recipe[x][y].getCount(), this.recipe[x][y],FuzzyMode.IGNORE_ALL, null ); currentItem = ad.simulateSimilarRemove(recipe[x][y].getCount(), this.recipe[x][y],FuzzyMode.IGNORE_ALL, null );
if( currentItem.isEmpty() ) }
}
}
}
if( currentItem.isEmpty() && this.recipe[x] != null)
{ {
currentItem = this.recipe[x][y].copy(); currentItem = this.recipe[x][0].copy();
}
}
}
}
} }
} }
ItemHandlerUtil.setStackInSlot( craftMatrix, x, currentItem ); ItemHandlerUtil.setStackInSlot( craftMatrix, x, currentItem );
+20 -5
View File
@@ -19,9 +19,9 @@
package appeng.me.cache; package appeng.me.cache;
import java.util.HashMap; import java.util.*;
import java.util.PriorityQueue;
import appeng.parts.automation.PartLevelEmitter;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReport;
@@ -46,6 +46,7 @@ public class TickManagerCache implements ITickManager
private final HashMap<IGridNode, TickTracker> alertable = new HashMap<>(); private final HashMap<IGridNode, TickTracker> alertable = new HashMap<>();
private final HashMap<IGridNode, TickTracker> sleeping = new HashMap<>(); private final HashMap<IGridNode, TickTracker> sleeping = new HashMap<>();
private final HashMap<IGridNode, TickTracker> awake = new HashMap<>(); private final HashMap<IGridNode, TickTracker> awake = new HashMap<>();
private final HashMap<IGridNode, TickTracker> laterTicker = new HashMap<>();
private final PriorityQueue<TickTracker> upcomingTicks = new PriorityQueue<>(); private final PriorityQueue<TickTracker> upcomingTicks = new PriorityQueue<>();
private long currentTick = 0; private long currentTick = 0;
@@ -86,7 +87,7 @@ public class TickManagerCache implements ITickManager
{ {
this.currentTick++; this.currentTick++;
while( !this.upcomingTicks.isEmpty() ) while ( !this.upcomingTicks.isEmpty() )
{ {
tt = this.upcomingTicks.peek(); tt = this.upcomingTicks.peek();
@@ -99,9 +100,16 @@ public class TickManagerCache implements ITickManager
this.upcomingTicks.poll(); this.upcomingTicks.poll();
final int diff = (int) ( this.currentTick - tt.getLastTick() ); final int diff = (int) ( this.currentTick - tt.getLastTick() );
if( tt.getGridTickable() instanceof PartLevelEmitter )
{
laterTicker.put( tt.getNode(), tt );
} else
{
final TickRateModulation mod = tt.getGridTickable().tickingRequest( tt.getNode(), diff ); final TickRateModulation mod = tt.getGridTickable().tickingRequest( tt.getNode(), diff );
switch( mod ) switch ( mod )
{ {
case FASTER: case FASTER:
tt.setCurrentRate( tt.getCurrentRate() - 2 ); tt.setCurrentRate( tt.getCurrentRate() - 2 );
@@ -123,12 +131,19 @@ public class TickManagerCache implements ITickManager
default: default:
break; break;
} }
}
if( this.awake.containsKey( tt.getNode() ) ) if( this.awake.containsKey( tt.getNode() ) )
{ {
this.addToQueue( tt ); this.addToQueue( tt );
} }
} }
Iterator<Map.Entry<IGridNode, TickTracker>> ltIterator = laterTicker.entrySet().iterator();
while ( ltIterator.hasNext() )
{
Map.Entry<IGridNode, TickTracker> tickTracker = ltIterator.next();
tickTracker.getValue().getGridTickable().tickingRequest( tickTracker.getKey(), 1 );
ltIterator.remove();
}
} }
catch( final Throwable t ) catch( final Throwable t )
{ {
@@ -19,9 +19,15 @@
package appeng.parts.automation; package appeng.parts.automation;
import javax.annotation.Nonnull;
import java.util.Collection; import java.util.Collection;
import java.util.Random; import java.util.Random;
import appeng.api.networking.IGridNode;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -82,7 +88,7 @@ import appeng.util.Platform;
import appeng.util.inv.InvOperation; import appeng.util.inv.InvOperation;
public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEItemStack>, ICraftingProvider public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEItemStack>, ICraftingProvider, IGridTickable
{ {
@PartModels @PartModels
@@ -118,6 +124,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
private double centerX; private double centerX;
private double centerY; private double centerY;
private double centerZ; private double centerZ;
private IBaseMonitor<IAEItemStack> changedMonitor;
@Reflected @Reflected
public PartLevelEmitter( final ItemStack is ) public PartLevelEmitter( final ItemStack is )
@@ -400,7 +407,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
@Override @Override
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource actionSource ) public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource actionSource )
{ {
this.updateReportingValue( (IMEMonitor<IAEItemStack>) monitor ); this.changedMonitor = monitor;
} }
@Override @Override
@@ -576,4 +583,22 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
return this.isLevelEmitterOn() ? MODEL_ON_OFF : MODEL_OFF_OFF; return this.isLevelEmitterOn() ? MODEL_ON_OFF : MODEL_OFF_OFF;
} }
} }
@Nonnull
@Override
public TickingRequest getTickingRequest( @Nonnull IGridNode node )
{
return new TickingRequest( 1,1,false,false );
}
@Nonnull
@Override
public TickRateModulation tickingRequest( @Nonnull IGridNode node, int ticksSinceLastCall )
{
if (this.changedMonitor != null)
{
this.updateReportingValue((IMEMonitor<IAEItemStack>) changedMonitor);
}
return TickRateModulation.URGENT;
}
} }