Compare commits

...

20 Commits

Author SHA1 Message Date
PrototypeTrousers 2e0250de37 Merge pull request #1 from talchas/rv6-1.12
merge talchas fixes
2020-10-20 14:32:48 -03:00
yueh d730503378 Fixes #4388: Ensure correct ticking priority order (#4393) 2020-05-27 16:13:20 +02:00
yueh f3349b0a2d Fixes #4372: Limit validated itemstack to a size of 1 (#4373) 2020-05-07 11:49:00 +02:00
yueh f667e9a5f0 Reduce lock time 2020-04-25 18:28:33 +02:00
Hinara 2c0a2975de Fix #4114 (#4357) 2020-04-25 18:05:14 +02:00
yueh 2e3d6b721a Run daily after the initial cleanup is done 2020-03-30 11:00:43 +02:00
yueh 94e294f4e9 Remove redundant option 2020-03-27 21:28:55 +01:00
yueh 91620a0042 Handle issues and prs 2020-03-27 21:23:29 +01:00
yueh ffc79b5494 Run workflow hourly 2020-03-27 19:43:09 +01:00
yueh ce7c29d0ac Create lock.yml 2020-03-27 18:06:46 +01:00
yueh 6ece190ac4 Fixes #4127: Increase JEI box for grindstone recipes (#4270) 2020-01-30 10:06:14 +01:00
yueh 00a596ea8f Fixes #4268: Disabled JEI facade recipe when disabled. (#4269) 2020-01-30 09:35:45 +01:00
yueh 1fc1d5517d Fixes #4213: Prevent NPE when inserting via conversion monitor (#4265) 2020-01-26 13:36:06 +01:00
yueh d5fc7a5b21 Fixes #4256: Cache AESharedItemStack#hashCode() (#4257) 2020-01-16 13:22:42 +01:00
Rik Pronk 1f85d0f607 Fix CraftTweaker Grindstone second optional output (#4250)
Fixes an issue where the CraftTweaker Grindstone integration registered the second optional output as first optional output
2020-01-16 10:57:18 +01:00
talchas 34c490f92b Safer implementation of CraftingGridCache updatePatterns coalescing 2019-12-20 19:54:14 -08:00
ruifung 5efa6d6251 Update API JavaDocs for clarification (#4180)
* Fix javadoc for IGridBlock.getMachineRepresentation()

Javadoc should state proper semantics for that method, and telling people to return null there is a sure crash. #4178

* Update IPart interface javadoc.

Update the javadoc to state that functional parts should not be allowed to be placed on dense cables.
2019-12-19 10:18:27 +01:00
Andrew Motz 4269a66a4b Fix Typos in README.md (#4183)
"Summery" to "Summary"
2019-12-19 10:16:59 +01:00
talchas 401f1ebb3e Avoid quadratic behavior from rebuilding the entire crafting cache for
each interface visited. Instead rebuild it at most once per tick, like
cpu clusters.

This is particularly important when channels are disabled, since in
that case even adding a cable visits every grid node.
2019-12-09 22:43:55 -08:00
Chan, Danny df2a7c1858 Add "cullface" into charged_quartz_ore.json (#4108) 2019-08-07 10:08:05 +02:00
17 changed files with 162 additions and 86 deletions
+15
View File
@@ -0,0 +1,15 @@
name: 'Lock threads'
on:
schedule:
- cron: '0 0 * * *'
jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
with:
github-token: ${{ github.token }}
issue-lock-inactive-days: '180'
pr-lock-inactive-days: '180'
+1 -1
View File
@@ -128,7 +128,7 @@ Here are a few things to keep in mind that will help get your PR approved.
* HTTPS `git clone https://github.com/<your username>/Applied-Energistics-2.git`
3. Change code base
4. Add changes to git `git add -A`
5. Commit changes to your clone `git commit -m "<summery of made changes>"`
5. Commit changes to your clone `git commit -m "<summary of made changes>"`
6. Push to your fork `git push`
7. Create a Pull-Request on GitHub
8. Wait for review
@@ -123,7 +123,7 @@ public interface IGridBlock
/**
* Determines what item stack is used to render this node in the GUI.
*
* @return the render item stack to use to render this node, null is valid, and will not show this node.
* @return the render item stack to use to render this node. Returning an empty ItemStack will not show this node.
*/
@Nonnull
ItemStack getMachineRepresentation();
+4 -1
View File
@@ -291,6 +291,9 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
/**
* Used to determine which parts can be placed on what cables.
*
* Dense cables are not allowed for functional (getGridNode returns a node) parts.
* Doing so will result in crashes.
*
* @param what placed part
*
@@ -365,4 +368,4 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
return null;
}
}
}
@@ -147,7 +147,7 @@ public class CraftingTreeNode
for( IAEItemStack fuzz : itemList )
{
if( this.parent.details.isValidItemForSlot( this.getSlot(), fuzz.createItemStack(), this.world ) )
if( this.parent.details.isValidItemForSlot( this.getSlot(), fuzz.copy().setStackSize( 1 ).createItemStack(), this.world ) )
{
fuzz = fuzz.copy();
fuzz.setStackSize( l );
@@ -105,7 +105,7 @@ public class BlockQuartzGlass extends AEBaseBlock
}
}
return w.getBlockState( pos ).shouldSideBeRendered( w, adjacentPos, side );
return super.shouldSideBeRendered( state, w, pos, side );
}
@Override
@@ -62,7 +62,7 @@ public class GrinderRecipes
final ItemStack s2 = CTModule.toStack( secondary2Output );
if( !s2.isEmpty() )
{
builder.withFirstOptional( s2, secondary2Chance == null ? 1.0f : secondary2Chance );
builder.withSecondOptional( s2, secondary2Chance == null ? 1.0f : secondary2Chance );
}
CTModule.MODIFICATIONS.add( new Add( builder.build() ) );
}
@@ -48,7 +48,7 @@ class GrinderRecipeCategory implements IRecipeCategory<GrinderRecipeWrapper>, IR
this.localizedName = I18n.format( "tile.appliedenergistics2.grindstone.name" );
ResourceLocation location = new ResourceLocation( AppEng.MOD_ID, "textures/guis/grinder.png" );
this.background = guiHelper.createDrawable( location, 11, 16, 154, 64 );
this.background = guiHelper.createDrawable( location, 11, 16, 154, 70 );
}
@Override
@@ -203,7 +203,7 @@ public class JEIPlugin implements IModPlugin
{
Optional<Item> itemFacade = definitions.items().facade().maybeItem();
Optional<ItemStack> cableAnchor = definitions.parts().cableAnchor().maybeStack( 1 );
if( itemFacade.isPresent() && cableAnchor.isPresent() )
if( itemFacade.isPresent() && cableAnchor.isPresent() && AEConfig.instance().isFeatureEnabled( AEFeature.ENABLE_FACADE_CRAFTING ) )
{
registry.addRecipeRegistryPlugin( new FacadeRegistryPlugin( (ItemFacade) itemFacade.get(), cableAnchor.get() ) );
}
+5 -1
View File
@@ -39,6 +39,7 @@ import appeng.api.util.IReadOnlyCollection;
import appeng.core.worlddata.WorldData;
import appeng.hooks.TickHandler;
import appeng.util.ReadOnlyCollection;
import appeng.me.cache.CraftingGridCache;
public class Grid implements IGrid
@@ -219,7 +220,10 @@ public class Grid implements IGrid
@Override
public MENetworkEvent postEvent( final MENetworkEvent ev )
{
return this.eventBus.postEvent( this, ev );
CraftingGridCache.pauseRebuilds();
final MENetworkEvent ret = this.eventBus.postEvent( this, ev );
CraftingGridCache.unpauseRebuilds();
return ret;
}
@Override
+4
View File
@@ -55,6 +55,7 @@ import appeng.api.util.IReadOnlyCollection;
import appeng.core.AELog;
import appeng.core.worlddata.WorldData;
import appeng.hooks.TickHandler;
import appeng.me.cache.CraftingGridCache;
import appeng.me.pathfinding.IPathItem;
import appeng.util.IWorldCallable;
import appeng.util.ReadOnlyCollection;
@@ -164,6 +165,8 @@ public class GridNode implements IGridNode, IPathItem
{
final Object tracker = new Object();
CraftingGridCache.pauseRebuilds();
Deque<GridNode> nextRun = new ArrayDeque<>();
nextRun.add( this );
@@ -203,6 +206,7 @@ public class GridNode implements IGridNode, IPathItem
}
}
}
CraftingGridCache.unpauseRebuilds();
}
@Override
+28
View File
@@ -114,6 +114,8 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
private IStorageGrid storageGrid;
private IEnergyGrid energyGrid;
private boolean updateList = false;
private static int pauseRebuilds = 0;
private static Set<CraftingGridCache> rebuildNeeded = new HashSet<>();
public CraftingGridCache( final IGrid grid )
{
@@ -240,8 +242,34 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
// nothing!
}
public static void pauseRebuilds()
{
pauseRebuilds++;
}
public static void unpauseRebuilds()
{
pauseRebuilds--;
if (pauseRebuilds == 0 && rebuildNeeded.size() > 0)
{
ImmutableSet<CraftingGridCache> needed = ImmutableSet.copyOf(rebuildNeeded);
rebuildNeeded.clear();
for ( CraftingGridCache cache: needed )
{
cache.updatePatterns();
}
}
}
private void updatePatterns()
{
// coalesce change events during a grid traversal to a single rebuild
if (pauseRebuilds != 0)
{
rebuildNeeded.add(this);
return;
}
final Map<IAEItemStack, ImmutableList<ICraftingPatternDetails>> oldItems = this.craftableItems;
// erase list.
+39 -35
View File
@@ -47,6 +47,7 @@ public class TickManagerCache implements ITickManager
private final HashMap<IGridNode, TickTracker> sleeping = new HashMap<>();
private final HashMap<IGridNode, TickTracker> awake = new HashMap<>();
private final PriorityQueue<TickTracker> upcomingTicks = new PriorityQueue<>();
private long currentTick = 0;
public TickManagerCache( final IGrid g )
@@ -80,50 +81,52 @@ public class TickManagerCache implements ITickManager
public void onUpdateTick()
{
TickTracker tt = null;
try
{
this.currentTick++;
while( !this.upcomingTicks.isEmpty() )
{
tt = this.upcomingTicks.peek();
final int diff = (int) ( this.currentTick - tt.getLastTick() );
if( diff >= tt.getCurrentRate() )
// Stop once it reaches a TickTracker running at a later tick
if( tt.getNextTick() > this.currentTick )
{
// remove tt..
this.upcomingTicks.poll();
final TickRateModulation mod = tt.getGridTickable().tickingRequest( tt.getNode(), diff );
switch( mod )
{
case FASTER:
tt.setRate( tt.getCurrentRate() - 2 );
break;
case IDLE:
tt.setRate( tt.getRequest().maxTickRate );
break;
case SAME:
break;
case SLEEP:
this.sleepDevice( tt.getNode() );
break;
case SLOWER:
tt.setRate( tt.getCurrentRate() + 1 );
break;
case URGENT:
tt.setRate( 0 );
break;
default:
break;
}
if( this.awake.containsKey( tt.getNode() ) )
{
this.addToQueue( tt );
}
break;
}
else
this.upcomingTicks.poll();
final int diff = (int) ( this.currentTick - tt.getLastTick() );
final TickRateModulation mod = tt.getGridTickable().tickingRequest( tt.getNode(), diff );
switch( mod )
{
return; // done!
case FASTER:
tt.setCurrentRate( tt.getCurrentRate() - 2 );
break;
case IDLE:
tt.setCurrentRate( tt.getRequest().maxTickRate );
break;
case SAME:
break;
case SLEEP:
this.sleepDevice( tt.getNode() );
break;
case SLOWER:
tt.setCurrentRate( tt.getCurrentRate() + 1 );
break;
case URGENT:
tt.setCurrentRate( 0 );
break;
default:
break;
}
if( this.awake.containsKey( tt.getNode() ) )
{
this.addToQueue( tt );
}
}
}
@@ -255,6 +258,7 @@ public class TickManagerCache implements ITickManager
final TickTracker gt = this.sleeping.get( node );
this.sleeping.remove( node );
this.awake.put( node, gt );
this.upcomingTicks.remove( gt );
this.addToQueue( gt );
return true;
+22 -21
View File
@@ -37,7 +37,6 @@ public class TickTracker implements Comparable<TickTracker>
private final TickingRequest request;
private final IGridTickable gt;
private final IGridNode node;
private final TickManagerCache host;
private final long LastFiveTicksTime = 0;
@@ -51,7 +50,6 @@ public class TickTracker implements Comparable<TickTracker>
this.node = node;
this.setCurrentRate( ( req.minTickRate + req.maxTickRate ) / 2 );
this.setLastTick( currentTick );
this.host = tickManagerCache;
}
public long getAvgNanos()
@@ -59,27 +57,25 @@ public class TickTracker implements Comparable<TickTracker>
return( this.LastFiveTicksTime / 5 );
}
public void setRate( final int rate )
{
this.setCurrentRate( rate );
if( this.getCurrentRate() < this.getRequest().minTickRate )
{
this.setCurrentRate( this.getRequest().minTickRate );
}
if( this.getCurrentRate() > this.getRequest().maxTickRate )
{
this.setCurrentRate( this.getRequest().maxTickRate );
}
}
@Override
public int compareTo( @Nonnull final TickTracker t )
{
final int nextTick = (int) ( ( this.getLastTick() - this.host.getCurrentTick() ) + this.getCurrentRate() );
final int ts_nextTick = (int) ( ( t.getLastTick() - this.host.getCurrentTick() ) + t.getCurrentRate() );
return nextTick - ts_nextTick;
int next = Long.compare( this.getNextTick(), t.getNextTick() );
if( next != 0 )
{
return next;
}
int last = Long.compare( this.getLastTick(), t.getLastTick() );
if( last != 0 )
{
return last;
}
return Integer.compare( this.getCurrentRate(), t.getCurrentRate() );
}
public void addEntityCrashInfo( final CrashReportCategory crashreportcategory )
@@ -111,7 +107,12 @@ public class TickTracker implements Comparable<TickTracker>
public void setCurrentRate( final int currentRate )
{
this.currentRate = currentRate;
this.currentRate = Math.min( this.getRequest().maxTickRate, Math.max( this.getRequest().minTickRate, currentRate ) );
}
public long getNextTick()
{
return this.lastTick + this.currentRate;
}
public long getLastTick()
@@ -179,25 +179,29 @@ public class PartConversionMonitor extends AbstractPartMonitor
final IEnergySource energy = this.getProxy().getEnergy();
final IMEMonitor<IAEItemStack> cell = this.getProxy()
.getStorage()
.getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( allItems )
{
final IAEItemStack input = this.getDisplayed().copy();
IItemHandler inv = new PlayerMainInvWrapper( player.inventory );
for( int x = 0; x < inv.getSlots(); x++ )
if( this.getDisplayed() != null )
{
final ItemStack targetStack = inv.getStackInSlot( x );
if( input.equals( targetStack ) )
final IAEItemStack input = this.getDisplayed().copy();
IItemHandler inv = new PlayerMainInvWrapper( player.inventory );
for( int x = 0; x < inv.getSlots(); x++ )
{
final ItemStack canExtract = inv.extractItem( x, targetStack.getCount(), true );
if( !canExtract.isEmpty() )
final ItemStack targetStack = inv.getStackInSlot( x );
if( input.equals( targetStack ) )
{
input.setStackSize( canExtract.getCount() );
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) );
inv.extractItem( x, failedToInsert == null ? canExtract.getCount() : canExtract.getCount() - (int) failedToInsert.getStackSize(),
false );
final ItemStack canExtract = inv.extractItem( x, targetStack.getCount(), true );
if( !canExtract.isEmpty() )
{
input.setStackSize( canExtract.getCount() );
final IAEItemStack failedToInsert = Platform.poweredInsert( energy, cell, input, new PlayerSource( player, this ) );
inv.extractItem( x,
failedToInsert == null ? canExtract.getCount() : canExtract.getCount() - (int) failedToInsert.getStackSize(),
false );
}
}
}
}
@@ -38,12 +38,14 @@ final class AESharedItemStack implements Comparable<AESharedItemStack>
private final ItemStack itemStack;
private final int itemId;
private final int itemDamage;
private final int hashCode;
public AESharedItemStack( final ItemStack itemStack )
{
this.itemStack = itemStack;
this.itemId = Item.getIdFromItem( itemStack.getItem() );
this.itemDamage = itemStack.getItemDamage();
this.hashCode = this.makeHashCode();
}
Bounds getBounds( final FuzzyMode fuzzy, final boolean ignoreMeta )
@@ -69,7 +71,7 @@ final class AESharedItemStack implements Comparable<AESharedItemStack>
@Override
public int hashCode()
{
return Objects.hash( this.itemId, this.itemDamage, this.itemStack.hasTagCompound() ? this.itemStack.getTagCompound() : 0 );
return this.hashCode;
}
@Override
@@ -144,6 +146,11 @@ final class AESharedItemStack implements Comparable<AESharedItemStack>
return System.identityHashCode( this.itemStack.getTagCompound() ) - System.identityHashCode( b.getTagCompound() );
}
private int makeHashCode()
{
return Objects.hash( this.itemId, this.itemDamage, this.itemStack.hasTagCompound() ? this.itemStack.getTagCompound() : 0 );
}
/**
* Creates the lower and upper bounds for a specific shared itemstack.
*/
@@ -10,22 +10,22 @@
{
"faces": {
"down": {
"texture": "#block"
"texture": "#block", "cullface": "down"
},
"east": {
"texture": "#block"
"texture": "#block", "cullface": "east"
},
"north": {
"texture": "#block"
"texture": "#block", "cullface": "north"
},
"south": {
"texture": "#block"
"texture": "#block", "cullface": "south"
},
"up": {
"texture": "#block"
"texture": "#block", "cullface": "up"
},
"west": {
"texture": "#block"
"texture": "#block", "cullface": "west"
}
},
"from": [
@@ -43,6 +43,7 @@
"faces": {
"down": {
"texture": "#quartz",
"cullface": "down",
"uvlightmap": {
"block": 0.007,
"sky": 0.007
@@ -50,6 +51,7 @@
},
"east": {
"texture": "#quartz",
"cullface": "east",
"uvlightmap": {
"block": 0.007,
"sky": 0.007
@@ -57,6 +59,7 @@
},
"north": {
"texture": "#quartz",
"cullface": "north",
"uvlightmap": {
"block": 0.007,
"sky": 0.007
@@ -64,6 +67,7 @@
},
"south": {
"texture": "#quartz",
"cullface": "south",
"uvlightmap": {
"block": 0.007,
"sky": 0.007
@@ -71,6 +75,7 @@
},
"up": {
"texture": "#quartz",
"cullface": "up",
"uvlightmap": {
"block": 0.007,
"sky": 0.007
@@ -78,6 +83,7 @@
},
"west": {
"texture": "#quartz",
"cullface": "west",
"uvlightmap": {
"block": 0.007,
"sky": 0.007