-
Notifications
You must be signed in to change notification settings - Fork 176
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
ComputerCraft and OpenComputers II integration #1785
Open
igentuman
wants to merge
8
commits into
Draconic-Inc:1.20
Choose a base branch
from
igentuman:master
base: 1.20
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5a6136e
Fix for ComputerCraft integration
igentuman d42c954
Github actions Workflow
igentuman 4d6fe8a
Fix local deps
igentuman f5c9234
Revert "Fix local deps"
igentuman 15fa39e
Revert "Github actions Workflow"
igentuman 67c8834
Merge branch 'master' into master
igentuman bcf84e2
Merge branch 'Draconic-Inc:master' into master
igentuman 82d06dd
Open Computers II support
igentuman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,13 +55,27 @@ configurations { | |
} | ||
|
||
repositories { | ||
flatDir { dirs 'libs' } | ||
mavenLocal() | ||
maven { url = "https://maven.covers1624.net/" } | ||
maven { url = "https://dvs1.progwml6.com/files/maven" } | ||
maven { url = "https://maven.cil.li/" } | ||
maven { url = "https://maven.theillusivec4.top/" } | ||
maven { url = "https://squiddev.cc/maven/" } | ||
maven { url = "https://maven.blamejared.com/" } | ||
maven { | ||
url "https://maven.architectury.dev" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, I would like to avoid having an arch dep. You should be able to just dep on the OC2 api, which should not require an arch dep. |
||
content { | ||
includeGroup 'dev.architectury' | ||
} | ||
} | ||
maven { | ||
name 'CurseMaven' | ||
url 'https://www.cursemaven.com' | ||
content { | ||
includeGroup 'curse.maven' | ||
} | ||
} | ||
// maven { url = "https://modmaven.dev/" } | ||
} | ||
|
||
|
@@ -85,8 +99,13 @@ dependencies { | |
|
||
compileOnly("cc.tweaked:cc-tweaked-${mc_version}-core-api:${cct_version}") | ||
compileOnly(fg.deobf("cc.tweaked:cc-tweaked-${mc_version}-forge-api:${cct_version}")) | ||
runtimeOnly(fg.deobf("cc.tweaked:cc-tweaked-${mc_version}-forge:${cct_version}")) | ||
implementation(fg.deobf("cc.tweaked:cc-tweaked-${mc_version}-forge:${cct_version}")) | ||
|
||
implementation fg.deobf("dev.architectury:architectury-forge:${architectury_version}") | ||
|
||
implementation fg.deobf("curse.maven:sedna-511276:${sedna_version}") | ||
implementation fg.deobf("curse.maven:markdownmanual-502485:${md_version}") | ||
implementation fg.deobf("curse.maven:oc2r-1037738:${oc2_version}") | ||
// For Testing | ||
// runtimeOnly fg.deobf("mekanism:Mekanism:1.18.2-10.2.5.465")// core | ||
// runtimeOnly fg.deobf("mekanism:Mekanism:1.18.2-10.2.5.465:additions")// Mekanism: Additions | ||
|
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
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
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
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
94 changes: 12 additions & 82 deletions
94
src/main/java/com/brandon3055/draconicevolution/integration/computers/CCOCIntegration.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 |
---|---|---|
@@ -1,97 +1,27 @@ | ||
package com.brandon3055.draconicevolution.integration.computers; | ||
|
||
import dan200.computercraft.api.ComputerCraftAPI; | ||
import dan200.computercraft.api.peripheral.IPeripheral; | ||
import dan200.computercraft.api.peripheral.IPeripheralProvider; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraftforge.common.util.LazyOptional; | ||
import com.brandon3055.draconicevolution.integration.computers.cc.DEPeripheralProvider; | ||
import com.brandon3055.draconicevolution.integration.computers.oc2.OC2DeviceProvider; | ||
import dan200.computercraft.api.ForgeComputerCraftAPI; | ||
import net.minecraftforge.fml.ModList; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* Created by brandon3055 on 21/9/2015. | ||
*/ | ||
public class CCOCIntegration { | ||
|
||
public static String ENERGY_PYLON = "draconic_rf_storage"; | ||
public static String FLUX_GATE = "flux_gate"; | ||
public static String FLUID_GATE = "fluid_gate"; | ||
public static String FLOW_GATE = "flow_gate"; | ||
public static String DRACONIC_REACTOR = "draconic_reactor"; | ||
|
||
public static void init() { | ||
if (ModList.get().isLoaded("computercraft")) { | ||
initCC(); | ||
ForgeComputerCraftAPI.registerPeripheralProvider(new DEPeripheralProvider()); | ||
} | ||
if (ModList.get().isLoaded("opencomputers")) { | ||
initOC(); | ||
if (ModList.get().isLoaded("oc2r")) { | ||
OC2DeviceProvider.init(); | ||
} | ||
} | ||
|
||
// @Optional.Method(modid = "computercraft") | ||
public static void initCC() { | ||
// ComputerCraftAPI.registerPeripheralProvider(new DEPeripheralProvider()); | ||
} | ||
|
||
// @Optional.Method(modid = "opencomputers") | ||
public static void initOC() { | ||
// Driver.add(new OCAdapter()); | ||
// Driver.add(new OCExtendedRFAdapter()); | ||
} | ||
|
||
// public static class OCAdapter extends DriverSidedTileEntity { | ||
// | ||
// @Override | ||
// public Class<?> getTileEntityClass() { | ||
// return IDEPeripheral.class; | ||
// } | ||
// | ||
// @Override | ||
// public AbstractManagedEnvironment createEnvironment(World world, BlockPos pos, Direction side) { | ||
// return new DEManagedPeripheral((IDEPeripheral) world.getTileEntity(pos)); | ||
// } | ||
// } | ||
// | ||
// public static class OCExtendedRFAdapter extends DriverSidedTileEntity { | ||
// | ||
// @Override | ||
// public Class<?> getTileEntityClass() { | ||
// return IExtendedRFStorage.class; | ||
// } | ||
// | ||
// @Override | ||
// public AbstractManagedEnvironment createEnvironment(World world, BlockPos pos, Direction side) { | ||
// return new IExtendedRFStoragePeripheral((IExtendedRFStorage) world.getTileEntity(pos)); | ||
// } | ||
// } | ||
// | ||
//Computercraft | ||
public static class DEPeripheralProvider implements IPeripheralProvider { | ||
private IPeripheral peripheral; | ||
private LazyOptional<IPeripheral> holderPeripheral; | ||
|
||
/** | ||
* Produce an peripheral implementation from a block location. | ||
* | ||
* @param world The world the block is in. | ||
* @param pos The position the block is at. | ||
* @param side The side to get the peripheral from. | ||
* @return A peripheral, or {@code null} if there is not a peripheral here you'd like to handle. | ||
* @see ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider) | ||
*/ | ||
@Nullable | ||
@Override | ||
public LazyOptional<IPeripheral> getPeripheral(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side) { | ||
BlockEntity tile = world.getBlockEntity(pos); | ||
if (tile instanceof IPeripheral) { | ||
setPeripheral((IPeripheral)tile); | ||
return holderPeripheral; | ||
} | ||
else return null; | ||
} | ||
|
||
protected void setPeripheral(IPeripheral peripheral) { | ||
this.peripheral = peripheral; | ||
this.holderPeripheral = LazyOptional.of(() -> peripheral); | ||
} | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
...java/com/brandon3055/draconicevolution/integration/computers/cc/DEPeripheralProvider.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,43 @@ | ||
package com.brandon3055.draconicevolution.integration.computers.cc; | ||
|
||
import dan200.computercraft.api.ForgeComputerCraftAPI; | ||
import dan200.computercraft.api.peripheral.IPeripheral; | ||
import dan200.computercraft.api.peripheral.IPeripheralProvider; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraftforge.common.util.LazyOptional; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class DEPeripheralProvider implements IPeripheralProvider { | ||
private IPeripheral peripheral; | ||
private LazyOptional<IPeripheral> holderPeripheral; | ||
|
||
/** | ||
* Produce an peripheral implementation from a block location. | ||
* | ||
* @param world The world the block is in. | ||
* @param pos The position the block is at. | ||
* @param side The side to get the peripheral from. | ||
* @return A peripheral, or {@code null} if there is not a peripheral here you'd like to handle. | ||
* @see ForgeComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider) | ||
*/ | ||
@Nullable | ||
@Override | ||
public LazyOptional<IPeripheral> getPeripheral(@Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Direction side) { | ||
BlockEntity tile = world.getBlockEntity(pos); | ||
if (tile instanceof IPeripheral) { | ||
setPeripheral((IPeripheral)tile); | ||
return holderPeripheral; | ||
} | ||
return LazyOptional.empty(); | ||
} | ||
|
||
protected void setPeripheral(IPeripheral peripheral) { | ||
this.peripheral = peripheral; | ||
this.holderPeripheral = LazyOptional.of(() -> peripheral); | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be here.