Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Applied Energistics Support for 1.10 (rv4) #2465

Merged
merged 1 commit into from
Sep 9, 2017

Conversation

28Smiles
Copy link

I have reintegrated the support for Applied Energistics (Now rv4).
Please note that the Code compiles, but due issues between tile-registration-names (tis3d controller and ae controller) you are not able to run the build in the dev enviroment. Also i should point out, that i have added the libary for ae2-rv4, because there is no maven repository for ae right now.
Now, here are some screenshots, for testing i used FTB-Beyond and substituted the Open-Computers mod:
2017-07-18_14 35 17
2017-07-18_14 35 27
2017-07-18_14 36 37
2017-07-18_14 38 00
2017-07-18_14 38 06
2017-07-18_14 38 11

As you can see I tested the fundamental functions of the API, but I haven't checkt every function. Also this is the first time I programmed in Scala, so my code may not be very genius, but it is functional and isn't Scala a functional language... 🤣

Please let me know what you think

@@ -208,7 +209,11 @@ dependencies {
provided "appeng:RotaryCraft:${config.rotc.version}:api"
provided ("appeng:appliedenergistics2:${config.ae2.version}:dev") {
exclude module: 'buildcraft'
}
}*/

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should only need to use the API jar. Even if that means some code changes (I can see some usages of an internal interface).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok, should I rewrite the whole thing? I'm confused, in the old Version also the whole Mod was used

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No not the whole thing, just the bits that use things not in the API as they may change. I know the old code uses the whole thing but it's generally not a good idea. And I do recall the reason this code is not already back in OC is because Alpha mods are not supported

Copy link
Author

@28Smiles 28Smiles Jul 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now looked into the api and there are many things which aren't accessible via api.
The api is made for creating new devices not accessing the existing ones

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just because it uses things that aren't in the api, doesn't mean there aren't other ways of doing it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@28Smiles Thanks for updating the integration! What's the status here, i.e. do you think you can port the bits that currently require non-api classes to use the API?

Copy link
Author

@28Smiles 28Smiles Jul 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fnuecke

What's the status here, i.e. do you think you can port the bits that currently require non-api classes to use the API?

You could modify some Code to use the AE2-API Interfaces, but this wouldn't work for everything, so the lack of upgradeability stays due not completely using the api. I suggest to use this for now and update the whole AE2 integration to the api by using the Open-Computer adapter or adding an network access block or something like this. For now I think this is the simplest and best solution.

Edit: If you agree with me, I will start Programming something like this

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment on the main conversation thread with alternatives, if there are other non-api usages you can't work out I'd be happy to assist

def getFluidsInNetwork(context: Context, args: Arguments): Array[AnyRef] =
result(tile.getProxy.getStorage.getFluidInventory.getStorageList.filter(stack =>
!Mods.ExtraCells.isAvailable || ECUtil.canSeeFluidInNetwork(stack)).
map(_.getFluidStack).toArray)
!Mods.ExtraCells.isModAvailable || ECUtil.canSeeFluidInNetwork(stack)).
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EC is not needed to see fluids in the network. You can just remove the filter.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I see

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ECUtil is excluded and not available for compiling, and also Applied Energistics on it's own doesn't support Fluids

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API itself does support fluids. Any mod can add them

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DrummerMC care to comment on this, seeing as you did the original fluid integration? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the filter to hide the gas fluids. EC is not updated. You can remove it.

@thiakil
Copy link

thiakil commented Jul 23, 2017

IGridProxyable.getProxy().get<blah> -> IGridHost.getGridNode(<side>).getGrid().getCache(<blah>.class) (does need null checks)

isInstanceOf[Part<Blah>] -> AEApi.definitions().parts().<blah>().isSameAs(IPart.getItemStack(PartItemStack.PICK))

AEItemStack.loadItemStackFromNBT - the one instance I can find right now doesn't seem to need to store the AE stack, as the only function I can see referencing it just calls getItemStack() to return a vanilla stack.

If you do need the extra info, this one is an API oversight; you would need to save the MC ItemStack and potentially the IAEItemStack.getStackSize() if > MAX_INT, then load the itemstack and recreate the AEStack (though again, you'd either need to save the extra info you need and reload it)

Another way around this currently would be to write it to a packet and store the ByteBuf's bytes and then load a reconstructed ByteBuf via the API. You still might lose some info as this is intended for client sync.

@@ -15,13 +15,14 @@ import li.cil.oc.util.ExtendedArguments._
import li.cil.oc.util.ResultWrapper._
import net.minecraft.item.ItemStack
import net.minecraft.util.EnumFacing
import net.minecraft.util.math.BlockPos
import net.minecraft.world.World

object DriverBlockInterface extends DriverSidedTileEntity {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thiakil how about those?
@Callback(doc = "function([slot:number]):table -- Get the configuration of the interface.") def getInterfaceConfiguration(context: Context, args: Arguments): Array[AnyRef]
and
@Callback(doc = "function([slot:number][, database:address, entry:number[, size:number]]):boolean -- Configure the interface.") def setInterfaceConfiguration(context: Context, args: Arguments)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getInventoryByName? That's part of appeng.api.implementations.tiles.ISegmentedInventory

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which is a superclass of IInterfaceHost

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks, i will try my best

@28Smiles
Copy link
Author

@thiakil I can't find an altenative to accessing IGridProxyable it isn't part of the Api and without this i cannot access the Network

@thiakil
Copy link

thiakil commented Jul 25, 2017

I mentioned in one of my previous comments how you need to get around that. All of the GridProxyable methods are just wrappers for methods available on IGrid, you should be able to accesss the Grid by using IGridHost.getGridNode(<side>).getGrid() - each TE/Part should be an instanceof IGridHost

@28Smiles
Copy link
Author

28Smiles commented Jul 25, 2017

@thiakil Thanks for your help
I now have rewritten DriverController and DriverInterface but I have trouble at the Parts.
export.getConfigManager.getClass.getMethod
How should I get/bypass the ConfigManager
(Line 65 at DriverExportBus)

@thiakil
Copy link

thiakil commented Jul 25, 2017

That particular method should be fine, it's in IConfigurableObject - so as long as you know it is an export bus (and can then test for IConfigurableObject) calling that method is ok

The hardest part I can see for Parts is testing which part it is. e.g.

EnumFacing.VALUES.map(container.getPart).exists(_.isInstanceOf[PartExportBus])

would need to be something like (please forgive my terrible Scala) EnumFacing.VALUES.map(container.getPart).exists(AEApi.definitions.parts.exportBus.isSameAs(_.getItemStack(PartItemStack.PICK))

@28Smiles
Copy link
Author

28Smiles commented Jul 25, 2017

Now everything is working! Big thanks to @thiakil in supporting me during the conversion of the code to fully use the API.
The AE2 integration is now fully Ported to Api, building and so far I can tell working properly.
@fnuecke I think now we can merge

def createEnvironment(world: World, x: Int, y: Int, z: Int, side: EnumFacing): ManagedEnvironment =
new Environment(world.getTileEntity(x, y, z).asInstanceOf[TileInterface])
def createEnvironment(world: World, pos: BlockPos, side: EnumFacing): ManagedEnvironment =
new Environment(world.getTileEntity(pos).asInstanceOf[TileEntity with ISegmentedInventory with IGridHost with IActionHost])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IActionHost extends IGridHost ;)

}
// We need reflection here to avoid compiling against the return and
// argument type, which has changed in rv2-beta-20 or so.
val fuzzyMode = (try export.getConfigManager.getClass.getMethod("getSetting", classOf[Enum[_]]) catch {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this reflection could be removed? rv2 is long gone

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea i will change this

itemStorage.getStorageList.findFuzzy(filter, fuzzyMode).toArray.toSeq
else
Seq(itemStorage.getStorageList.findPrecise(filter))
for (ais <- stacks.filter(_ != null) if count > 0) { //TODO: Savety Copy removed no public clone function
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't understand the Scala here; which object doesn't have a public copy method?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AEStack, it's protected

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forget it, my fault

Now fully using the AE2-Api
@28Smiles
Copy link
Author

@fnuecke Sorry Florian, but I don't get the error. Can you please tell my why the CI build failed?
Locally the Commit builds

@thiakil
Copy link

thiakil commented Jul 27, 2017

Something on Travis is killing the process, possibly it's using "too much" memory, or taking too long

@payonel
Copy link
Member

payonel commented Jul 27, 2017

These CI builds posted by PRs have been failing for a long time. I wouldn't worry about it. Give @fnuecke some time to return and review the work. We've discussed this work you've been doing and we do plan to merge it.

@asiekierka
Copy link
Contributor

Please note that AE2 now has a 1.12 release, too!

@28Smiles
Copy link
Author

Since this Implementation uses the Api it works(should) for all AE2 versions and MC versions

@Donny208
Copy link

Looks great, really hoping this is added.

@xarses xarses mentioned this pull request Aug 28, 2017
@stephan48
Copy link

Hi, are there still any blockers left which could prevent this from being included? Currently thinking about porting my existing FTB Beyond RS System to AE cause I like AE way more so far - feels not as OP. But I would really like an OpenComputers Integration :) -- Stephan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants