forked from Vexatos/Computronics
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add oc integration for tectech multis
- Loading branch information
1 parent
5096fc1
commit f67449e
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...main/java/pl/asie/computronics/integration/gregtech/gregtech5/DriverTTMultiblockBase.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,55 @@ | ||
package pl.asie.computronics.integration.gregtech.gregtech5; | ||
|
||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.common.util.ForgeDirection; | ||
|
||
import gregtech.api.metatileentity.BaseMetaTileEntity; | ||
import li.cil.oc.api.machine.Arguments; | ||
import li.cil.oc.api.machine.Callback; | ||
import li.cil.oc.api.machine.Context; | ||
import li.cil.oc.api.network.ManagedEnvironment; | ||
import li.cil.oc.api.prefab.DriverSidedTileEntity; | ||
import pl.asie.computronics.integration.ManagedEnvironmentOCTile; | ||
import tectech.thing.metaTileEntity.multi.base.Parameters; | ||
import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; | ||
|
||
public class DriverTTMultiblockBase extends DriverSidedTileEntity { | ||
|
||
public static class ManagedEnvironmentTTMultiblockBase extends ManagedEnvironmentOCTile<BaseMetaTileEntity> { | ||
|
||
public ManagedEnvironmentTTMultiblockBase(BaseMetaTileEntity tile, String name) { | ||
super(tile, name); | ||
} | ||
|
||
@Callback(doc = "function(hatch:int, id: int, val:double); Sets a parameter", direct = true) | ||
public Object[] setParameters(Context c, Arguments a) { | ||
Parameters p = ((TTMultiblockBase) tile.getMetaTileEntity()).parametrization; | ||
p.trySetParameters(a.checkInteger(0), a.checkInteger(1), a.checkDouble(2)); | ||
return null; | ||
} | ||
|
||
@Callback(doc = "function(hatch:int, id: int);double Returns the value of a parameter", direct = true) | ||
public Object[] getParameters(Context c, Arguments a) { | ||
return new Object[] { ((TTMultiblockBase) tile.getMetaTileEntity()).parametrization | ||
.getGroup(a.checkInteger(0)).parameterIn[a.checkInteger((1))].get() }; | ||
} | ||
} | ||
|
||
@Override | ||
public Class<?> getTileEntityClass() { | ||
return BaseMetaTileEntity.class; | ||
} | ||
|
||
@Override | ||
public boolean worksWith(World world, int x, int y, int z, ForgeDirection side) { | ||
TileEntity tileEntity = world.getTileEntity(x, y, z); | ||
return (tileEntity != null) && tileEntity instanceof BaseMetaTileEntity | ||
&& ((BaseMetaTileEntity) tileEntity).getMetaTileEntity() instanceof TTMultiblockBase; | ||
} | ||
|
||
@Override | ||
public ManagedEnvironment createEnvironment(World world, int x, int y, int z, ForgeDirection side) { | ||
return new ManagedEnvironmentTTMultiblockBase((BaseMetaTileEntity) world.getTileEntity(x, y, z), "tt_machine"); | ||
} | ||
} |
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