-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
1,554 additions
and
631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/com/kuba6000/ae2webintegration/ae2interface/AE2WebIntegration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.kuba6000.ae2webintegration.ae2interface; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import com.kuba6000.ae2webintegration.Tags; | ||
import com.kuba6000.ae2webintegration.core.api.IAEWebInterface; | ||
|
||
import appeng.me.cache.SecurityCache; | ||
import cpw.mods.fml.common.Mod; | ||
import cpw.mods.fml.common.event.FMLInitializationEvent; | ||
import cpw.mods.fml.common.event.FMLPostInitializationEvent; | ||
import cpw.mods.fml.common.event.FMLPreInitializationEvent; | ||
import cpw.mods.fml.common.event.FMLServerStartingEvent; | ||
|
||
@Mod( | ||
modid = AE2WebIntegration.MODID, | ||
version = Tags.VERSION, | ||
name = "AE2WebIntegration-Interface", | ||
acceptedMinecraftVersions = "[1.7.10]", | ||
acceptableRemoteVersions = "*") | ||
public class AE2WebIntegration { | ||
|
||
public static final String MODID = "ae2webintegration-interface"; | ||
public static final Logger LOG = LogManager.getLogger(MODID); | ||
|
||
@Mod.EventHandler | ||
public void preInit(FMLPreInitializationEvent event) {} | ||
|
||
@Mod.EventHandler | ||
public void init(FMLInitializationEvent event) {} | ||
|
||
@Mod.EventHandler | ||
public void postInit(FMLPostInitializationEvent event) { | ||
SecurityCache.registerOpPlayer( | ||
IAEWebInterface.getInstance() | ||
.getAEWebGameProfile()); | ||
} | ||
|
||
@Mod.EventHandler | ||
public void serverStarting(FMLServerStartingEvent event) { | ||
|
||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/kuba6000/ae2webintegration/ae2interface/CraftingMediumTracker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.kuba6000.ae2webintegration.ae2interface; | ||
|
||
import java.util.IdentityHashMap; | ||
|
||
import appeng.api.networking.IGrid; | ||
import appeng.api.networking.crafting.ICraftingMedium; | ||
import appeng.api.networking.crafting.ICraftingProvider; | ||
import appeng.api.util.IInterfaceViewable; | ||
import appeng.me.cache.CraftingGridCache; | ||
|
||
public class CraftingMediumTracker { | ||
|
||
public static final IdentityHashMap<IGrid, IdentityHashMap<ICraftingMedium, IInterfaceViewable>> mediumToViewable = new IdentityHashMap<>(); | ||
private static boolean isUpdatingPatterns = false; | ||
private static ICraftingProvider currentCraftingProvider = null; | ||
|
||
public static void updatingPatterns(CraftingGridCache craftingGrid, IGrid grid) { | ||
mediumToViewable.put(grid, new IdentityHashMap<>()); | ||
isUpdatingPatterns = true; | ||
} | ||
|
||
public static void provideCrafting(CraftingGridCache craftingGrid, IGrid grid, ICraftingProvider provider) { | ||
if (!isUpdatingPatterns) return; | ||
currentCraftingProvider = provider; | ||
} | ||
|
||
public static void addCraftingOption(CraftingGridCache craftingGrid, IGrid grid, ICraftingMedium medium) { | ||
if (!isUpdatingPatterns) return; | ||
if (currentCraftingProvider == null) return; | ||
if (currentCraftingProvider instanceof IInterfaceViewable viewable && !mediumToViewable.get(grid) | ||
.containsKey(medium)) mediumToViewable.get(grid) | ||
.put(medium, viewable); | ||
} | ||
|
||
public static void doneUpdatingPatterns(CraftingGridCache craftingGrid, IGrid grid) { | ||
isUpdatingPatterns = false; | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/com/kuba6000/ae2webintegration/ae2interface/implementations/AE.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.kuba6000.ae2webintegration.ae2interface.implementations; | ||
|
||
import java.util.Iterator; | ||
|
||
import com.kuba6000.ae2webintegration.core.interfaces.IAE; | ||
import com.kuba6000.ae2webintegration.core.interfaces.IAEGrid; | ||
import com.kuba6000.ae2webintegration.core.interfaces.IItemList; | ||
|
||
import appeng.api.AEApi; | ||
import appeng.hooks.TickHandler; | ||
import appeng.me.Grid; | ||
|
||
public class AE implements IAE { | ||
|
||
public static AE instance = new AE(); | ||
|
||
public static AE getInstance() { | ||
return instance; | ||
} | ||
|
||
static class AEGridIterable implements Iterable<IAEGrid> { | ||
|
||
@Override | ||
public java.util.Iterator<IAEGrid> iterator() { | ||
return new java.util.Iterator<>() { | ||
|
||
private final Iterator<Grid> iterator = TickHandler.INSTANCE.getGridList() | ||
.iterator(); | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return iterator.hasNext(); | ||
} | ||
|
||
@Override | ||
public IAEGrid next() { | ||
return new AEGrid(iterator.next()); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
@Override | ||
public Iterable<IAEGrid> getGrids() { | ||
return new AEGridIterable(); | ||
} | ||
|
||
@Override | ||
public IItemList createItemList() { | ||
return new ItemList( | ||
AEApi.instance() | ||
.storage() | ||
.createItemList()); | ||
} | ||
|
||
} |
108 changes: 108 additions & 0 deletions
108
...ava/com/kuba6000/ae2webintegration/ae2interface/implementations/AECraftingCPUCluster.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package com.kuba6000.ae2webintegration.ae2interface.implementations; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
|
||
import com.kuba6000.ae2webintegration.ae2interface.mixins.AE2.CraftingCPUClusterAccessor; | ||
import com.kuba6000.ae2webintegration.core.interfaces.ICraftingCPUCluster; | ||
import com.kuba6000.ae2webintegration.core.interfaces.IItemList; | ||
import com.kuba6000.ae2webintegration.core.interfaces.IItemStack; | ||
|
||
import appeng.api.networking.crafting.CraftingItemList; | ||
|
||
public class AECraftingCPUCluster extends IAEObject<appeng.me.cluster.implementations.CraftingCPUCluster> | ||
implements ICraftingCPUCluster { | ||
|
||
int id; | ||
|
||
public AECraftingCPUCluster(appeng.me.cluster.implementations.CraftingCPUCluster object) { | ||
super(object); | ||
} | ||
|
||
public AECraftingCPUCluster(appeng.me.cluster.implementations.CraftingCPUCluster object, int id) { | ||
super(object); | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public boolean hasCustomName() { | ||
return !get().getName() | ||
.isEmpty(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return hasCustomName() ? get().getName() : ("CPU #" + id); | ||
} | ||
|
||
@Override | ||
public long getAvailableStorage() { | ||
return get().getAvailableStorage(); | ||
} | ||
|
||
@Override | ||
public long getUsedStorage() { | ||
return getUsedStorageInternal(get()); | ||
} | ||
|
||
@Override | ||
public long getCoProcessors() { | ||
return get().getCoProcessors(); | ||
} | ||
|
||
@Override | ||
public boolean isBusy() { | ||
return get().isBusy(); | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
get().cancel(); | ||
} | ||
|
||
@Override | ||
public IItemStack getFinalOutput() { | ||
return new ItemStack(get().getFinalOutput()); | ||
} | ||
|
||
@Override | ||
public void getActiveItems(IItemList list) { | ||
get().getListOfItem(((ItemList) list).get(), CraftingItemList.ACTIVE); | ||
} | ||
|
||
@Override | ||
public void getPendingItems(IItemList list) { | ||
get().getListOfItem(((ItemList) list).get(), CraftingItemList.PENDING); | ||
} | ||
|
||
@Override | ||
public void getStorageItems(IItemList list) { | ||
get().getListOfItem(((ItemList) list).get(), CraftingItemList.STORAGE); | ||
} | ||
|
||
@Override | ||
public IItemList getWaitingFor() { | ||
return new ItemList(((CraftingCPUClusterAccessor) (Object) get()).getWaitingFor()); | ||
} | ||
|
||
private static boolean isUsedStorageAvailable = true; | ||
private static Method getUsedStorageMethod = null; | ||
|
||
private static long getUsedStorageInternal(appeng.me.cluster.implementations.CraftingCPUCluster cluster) { | ||
if (!isUsedStorageAvailable) return -1L; | ||
if (getUsedStorageMethod == null) { | ||
try { | ||
getUsedStorageMethod = appeng.me.cluster.implementations.CraftingCPUCluster.class | ||
.getDeclaredMethod("getUsedStorage"); | ||
} catch (NoSuchMethodException e) { | ||
isUsedStorageAvailable = false; | ||
return -1L; | ||
} | ||
} | ||
try { | ||
return (long) getUsedStorageMethod.invoke(cluster); | ||
} catch (IllegalAccessException | InvocationTargetException e) { | ||
return 0L; | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/kuba6000/ae2webintegration/ae2interface/implementations/AECraftingJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.kuba6000.ae2webintegration.ae2interface.implementations; | ||
|
||
import com.kuba6000.ae2webintegration.core.interfaces.IAECraftingJob; | ||
import com.kuba6000.ae2webintegration.core.interfaces.IItemList; | ||
|
||
import appeng.api.networking.crafting.ICraftingJob; | ||
|
||
public class AECraftingJob extends IAEStrongObject<ICraftingJob> implements IAECraftingJob { | ||
|
||
public AECraftingJob(ICraftingJob object) { | ||
super(object); | ||
} | ||
|
||
@Override | ||
public boolean isSimulation() { | ||
return get().isSimulation(); | ||
} | ||
|
||
@Override | ||
public long getByteTotal() { | ||
return get().getByteTotal(); | ||
} | ||
|
||
@Override | ||
public void populatePlan(IItemList plan) { | ||
get().populatePlan(((ItemList) plan).get()); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...com/kuba6000/ae2webintegration/ae2interface/implementations/AECraftingPatternDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.kuba6000.ae2webintegration.ae2interface.implementations; | ||
|
||
import java.util.Arrays; | ||
|
||
import com.kuba6000.ae2webintegration.core.interfaces.IAECraftingPatternDetails; | ||
import com.kuba6000.ae2webintegration.core.interfaces.IItemStack; | ||
|
||
import appeng.api.networking.crafting.ICraftingPatternDetails; | ||
|
||
public class AECraftingPatternDetails extends IAEStrongObject<ICraftingPatternDetails> | ||
implements IAECraftingPatternDetails { | ||
|
||
public AECraftingPatternDetails(ICraftingPatternDetails object) { | ||
super(object); | ||
} | ||
|
||
@Override | ||
public IItemStack[] getCondensedOutputs() { | ||
return Arrays.stream(get().getCondensedOutputs()) | ||
.map(ItemStack::new) | ||
.toArray(IItemStack[]::new); | ||
} | ||
} |
Oops, something went wrong.