-
Notifications
You must be signed in to change notification settings - Fork 4
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
21 changed files
with
392 additions
and
40 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
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
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,7 @@ | ||
package reobf.proghatches.gt.cover; | ||
|
||
import gregtech.api.interfaces.tileentity.ICoverable; | ||
|
||
public interface IProgrammer { | ||
public void impl(ICoverable aTileEntity) ; | ||
} |
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
62 changes: 62 additions & 0 deletions
62
src/main/java/reobf/proghatches/gt/cover/LinkedBusSlaveCover.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,62 @@ | ||
package reobf.proghatches.gt.cover; | ||
|
||
import java.util.Optional; | ||
|
||
import gregtech.api.interfaces.metatileentity.IMetaTileEntity; | ||
import gregtech.api.interfaces.tileentity.ICoverable; | ||
import gregtech.api.interfaces.tileentity.IGregTechTileEntity; | ||
import gregtech.api.util.GT_CoverBehavior; | ||
import gregtech.api.util.GT_CoverBehaviorBase; | ||
import net.glease.ggfab.mte.MTE_LinkedInputBus; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraftforge.common.util.ForgeDirection; | ||
import reobf.proghatches.gt.metatileentity.util.IProgrammingCoverBlacklisted; | ||
|
||
public class LinkedBusSlaveCover extends GT_CoverBehavior implements IProgrammer{ | ||
|
||
|
||
@Override | ||
public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { | ||
|
||
return 1; | ||
} | ||
|
||
@Override | ||
public void impl(ICoverable aTileEntity) { | ||
if(aTileEntity instanceof IGregTechTileEntity){ | ||
IMetaTileEntity x = ((IGregTechTileEntity) aTileEntity).getMetaTileEntity(); | ||
if(x instanceof MTE_LinkedInputBus){ | ||
MTE_LinkedInputBus bus=(MTE_LinkedInputBus) x; | ||
try{ | ||
ItemStack is=ProgrammingCover.sync(bus); | ||
bus.setInventorySlotContents(bus.getCircuitSlot(), is); | ||
}catch(RuntimeException e){ | ||
//expected, do nothing | ||
} | ||
} | ||
|
||
} | ||
|
||
} | ||
@Override | ||
public boolean isCoverPlaceable(ForgeDirection side, ItemStack aStack, ICoverable aTileEntity) { | ||
if (!Optional.of(aTileEntity).filter(s -> s instanceof IGregTechTileEntity) | ||
.map(s -> ((IGregTechTileEntity) s).getMetaTileEntity()) | ||
.filter(s -> s instanceof MTE_LinkedInputBus).isPresent()) | ||
return false; | ||
for(ForgeDirection d: ForgeDirection.VALID_DIRECTIONS){ | ||
GT_CoverBehaviorBase<?> beh = aTileEntity.getCoverBehaviorAtSideNew(d); | ||
if(beh!=null&&beh.getClass()==ProgrammingCover.class){return false;} | ||
} | ||
return super.isCoverPlaceable(side, aStack, aTileEntity); | ||
} | ||
|
||
@Override | ||
public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, | ||
ICoverable aTileEntity, long aTimer) { | ||
impl(aTileEntity); | ||
|
||
return aCoverVariable; | ||
} | ||
|
||
} |
Oops, something went wrong.