Skip to content

Commit

Permalink
Fix ActAdd version detection.
Browse files Browse the repository at this point in the history
Fixes #13
pushed version to 0.9.4
  • Loading branch information
XDjackieXD committed Nov 13, 2016
1 parent b310539 commit b6378b8
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 60 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ apply plugin: 'idea'
apply plugin: 'net.minecraftforge.gradle.forge'


version = "0.9.3-MC1.10.2"
version = "0.9.4-MC1.10.2"
group = "at.chaosfield.openradio"
archivesBaseName = "OpenRadio"

if(hasProperty('buildnumber')){
if (hasProperty('buildnumber')) {
version = "${version}-${this.properties['buildnumber']}"
}

minecraft {
version = " 1.10.2-12.18.1.2011"
version = "1.10.2-12.18.2.2099"
runDir = "run"

mappings = "snapshot_20160606"
Expand All @@ -44,7 +44,7 @@ repositories {

dependencies {
compile "li.cil.oc:OpenComputers:MC1.9.4-1.6.+:api"
provided "de.ellpeck.actuallyadditions:ActuallyAdditions-unstable:1.10.2-r71-260:api"
compile "de.ellpeck.actuallyadditions:ActuallyAdditions-unstable:1.10.2-r71-260:api"

//no 1.10.2 version of ae yet :(
//compile "appeng:appliedenergistics2:rv2-stable-10:dev"
Expand Down
26 changes: 17 additions & 9 deletions src/main/java/at/chaosfield/openradio/OpenRadio.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import at.chaosfield.openradio.integration.actuallyAdditions.BookletEntry;
import at.chaosfield.openradio.proxy.CommonProxy;
import at.chaosfield.openradio.util.Settings;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.*;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
Expand All @@ -22,7 +21,7 @@
* Created by Jakob Riepler (XDjackieXD)
*/

@Mod(name = "Open Radio", modid = OpenRadio.MODID, version = "0.9.3", modLanguage = "java", dependencies = "required-after:OpenComputers@[1.6.0,)")
@Mod(name = "Open Radio", modid = OpenRadio.MODID, version = "0.9.4", modLanguage = "java", dependencies = "required-after:OpenComputers@[1.6.0,)")
public class OpenRadio{

public static final String MODID = "openradio";
Expand All @@ -44,10 +43,19 @@ public class OpenRadio{
public void preInit(FMLPreInitializationEvent event){
settings = new Settings(event.getSuggestedConfigurationFile());

for(ModContainer modAPI: ModAPIManager.INSTANCE.getAPIList()){
if(modAPI.getModId().equals("actuallyadditionsapi") && Loader.isModLoaded("actuallyadditions")){
Init.loadedActAddVersion = Integer.parseInt(modAPI.getVersion());
}
}

Blocks.init(); //Register all Blocks
Items.init(); //Register all Items
proxy.preInit(event); //Register Variants
logger.info("Pre init complete.");

Init.preInitIntegration(event);

logger.info(MODID + " pre init complete.");
}

//FML Init
Expand All @@ -58,15 +66,15 @@ public void init(FMLInitializationEvent event){
Crafting.init(); //Register the crafting recipes
proxy.init(event); //Register TileEntities, Renders and other things

logger.info("Init complete.");
Init.initIntegration(event);

logger.info(MODID + " init complete.");
}

//FML Init
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event){
if(Init.isActAddLoaded)
BookletEntry.postInit();

logger.info("Post init complete.");
Init.postInitIntegration(event);
logger.info(MODID + " post init complete.");
}
}
20 changes: 18 additions & 2 deletions src/main/java/at/chaosfield/openradio/integration/Init.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
package at.chaosfield.openradio.integration;

import net.minecraftforge.fml.common.Loader;
import at.chaosfield.openradio.integration.actuallyAdditions.BookletEntry;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

/**
* Created by Jakob Riepler (XDjackieXD)
*/
public class Init{
public static boolean isActAddLoaded = Loader.isModLoaded("actuallyadditions");
public static int minActAddVersion = 28;
public static int loadedActAddVersion = 0;
public static String[] actAddLaserRelayEnergy = {"actuallyadditions:blockLaserRelay", "actuallyadditions:blockLaserRelayAdvanced", "actuallyadditions:blockLaserRelayExtreme"};
public static String[] actAddLaserRelayItem = {"actuallyadditions:blockLaserRelayItem", "actuallyadditions:blockLaserRelayItemWhitelist"};
public static String[] actAddLaserRelayFluid = {"actuallyadditions:blockLaserRelayFluids"};

public static void preInitIntegration(FMLPreInitializationEvent event){

}

public static void initIntegration(FMLInitializationEvent event){

}

public static void postInitIntegration(FMLPostInitializationEvent event){
if(Init.loadedActAddVersion >= Init.minActAddVersion)
BookletEntry.postInit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import at.chaosfield.openradio.OpenRadio;
import at.chaosfield.openradio.init.Items;
import at.chaosfield.openradio.integration.Init;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
Expand All @@ -12,12 +11,11 @@
*/
public class BookletEntry{
public static void postInit(){
if(Integer.parseInt(ActuallyAdditionsAPI.API_VERSION) >= Init.minActAddVersion)
ActuallyAdditionsAPI.methodHandler.generateBookletChapter(
"openradio.laserrelay",
ActuallyAdditionsAPI.entryLaserRelays,
new ItemStack(Items.laserItem),
ActuallyAdditionsAPI.methodHandler.generatePicturePage(1, new ResourceLocation(OpenRadio.MODID, "textures/gui/actAddPageLaserRelay.png"), 118).addTextReplacement("<laserMaxDistance>", Integer.toString((int)((OpenRadio.instance.settings.LensMultiplierTier[2] + 1) * 2 * OpenRadio.instance.settings.LaserMaxDistanceTier[2])))
);
ActuallyAdditionsAPI.methodHandler.generateBookletChapter(
"openradio.laserrelay",
ActuallyAdditionsAPI.entryLaserRelays,
new ItemStack(Items.laserItem),
ActuallyAdditionsAPI.methodHandler.generatePicturePage(1, new ResourceLocation(OpenRadio.MODID, "textures/gui/actAddPageLaserRelay.png"), 118).addTextReplacement("<laserMaxDistance>", Integer.toString((int) ((OpenRadio.instance.settings.LensMultiplierTier[2] + 1) * 2 * OpenRadio.instance.settings.LaserMaxDistanceTier[2])))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public LaserRelay(TileEntity laserRelayTile){
this.laserRelayTile = laserRelayTile;
String tileName = laserRelayTile.getBlockType().getRegistryName().toString();

for(String name: Init.actAddLaserRelayEnergy)
for(String name : Init.actAddLaserRelayEnergy)
if(name.equals(tileName))
this.addonName = "LaserRelayEnergy";
for(String name: Init.actAddLaserRelayItem)
for(String name : Init.actAddLaserRelayItem)
if(name.equals(tileName))
this.addonName = "LaserRelayItem";
for(String name: Init.actAddLaserRelayFluid)
for(String name : Init.actAddLaserRelayFluid)
if(name.equals(tileName))
this.addonName = "LaserRelayFluid";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
/**
* Created by Jakob Riepler (XDjackieXD)
*/
public interface ILaserAddon {
public interface ILaserAddon{
void connectToLaser(LaserTileEntity laser);

void disconnectFromLaser(LaserTileEntity laser);

void laserConnectionStatusChanged(boolean connected);

int getEnergyUsage();

TileEntity getTile();

String getAddonName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,22 @@ public void setDestination(int dim, BlockPos pos, double distance){
if(!this.getWorld().isRemote){
this.otherLaser = new Location(dim, pos);
this.distance = distance;
for(ILaserAddon addon: getAddons())
for(ILaserAddon addon : getAddons())
if(addon != null)
addon.laserConnectionStatusChanged(true);
this.markDirty();
}
}

public void disconnect(){
for(ILaserAddon addon: getAddons())
for(ILaserAddon addon : getAddons())
if(addon != null)
addon.laserConnectionStatusChanged(false);
this.otherLaser = null;
}

public void breakLaser(){
for(EnumFacing side: EnumFacing.VALUES){
for(EnumFacing side : EnumFacing.VALUES){
disconnectAddon(side);
}
}
Expand Down Expand Up @@ -335,12 +335,12 @@ public void onNeighbourChanged(){
}

addonEnergyUsage = 0;
for(ILaserAddon addon: connectedAddons){
for(ILaserAddon addon : connectedAddons){
if(addon != null)
addonEnergyUsage += addon.getEnergyUsage();
}

for(ILaserAddon addon: getAddons())
for(ILaserAddon addon : getAddons())
if(addon != null)
addon.laserConnectionStatusChanged(isConnected());
}
Expand All @@ -350,12 +350,12 @@ public void update(){
super.update();
if(!worldObj.isRemote){
if(hasNeededComponents()){
tryUsePower((int)(calculateBasicEnergyUsage() + addonEnergyUsage));
tryUsePower((int) (calculateBasicEnergyUsage() + addonEnergyUsage));
}

if(first){
onNeighbourChanged();
first=false;
first = false;
}

if(hasNeededComponents() && isPowered()){
Expand All @@ -365,7 +365,7 @@ public void update(){
sendEntity();
}
}else{
for(ILaserAddon addon: getAddons())
for(ILaserAddon addon : getAddons())
if(addon != null)
addon.laserConnectionStatusChanged(false);
disconnect();
Expand All @@ -379,17 +379,18 @@ private String checkAddon(TileEntity tile, EnumFacing side){
if(tile instanceof ILaserAddon)
return ((ILaserAddon) tile).getAddonName();

if(tile != null && Init.isActAddLoaded && side == EnumFacing.UP){
if(tile.getBlockType().getRegistryName().toString().equals("actuallyadditions:blockLaserRelay"))
return "LaserRelay";
else if(tile.getBlockType().getRegistryName().toString().equals("actuallyadditions:blockLaserRelayAdvanced"))
return "LaserRelay";
else if(tile.getBlockType().getRegistryName().toString().equals("actuallyadditions:blockLaserRelayExtreme"))
return "LaserRelay";
else if(tile.getBlockType().getRegistryName().toString().equals("actuallyadditions:blockLaserRelayItem"))
return "LaserRelay";
else if(tile.getBlockType().getRegistryName().toString().equals("actuallyadditions:blockLaserRelayItemWhitelist"))
return "LaserRelay";
if(tile != null && (Init.loadedActAddVersion >= Init.minActAddVersion) && side == EnumFacing.UP){
String tileName = tile.getBlockType().getRegistryName().toString();

for(String name : Init.actAddLaserRelayEnergy)
if(name.equals(tileName))
return "LaserRelayEnergy";
for(String name : Init.actAddLaserRelayItem)
if(name.equals(tileName))
return "LaserRelayItem";
for(String name : Init.actAddLaserRelayFluid)
if(name.equals(tileName))
return "LaserRelayFluid";
}

return null;
Expand All @@ -399,20 +400,18 @@ private ILaserAddon getAddon(TileEntity tile, EnumFacing side){
if(tile instanceof ILaserAddon)
return (ILaserAddon) tile;

if(tile != null && Init.isActAddLoaded && side == EnumFacing.UP){
if(Integer.parseInt(ActuallyAdditionsAPI.API_VERSION) >= Init.minActAddVersion){
String tileName = tile.getBlockType().getRegistryName().toString();

for(String name : Init.actAddLaserRelayEnergy)
if(name.equals(tileName))
return new LaserRelay(tile);
for(String name : Init.actAddLaserRelayItem)
if(name.equals(tileName))
return new LaserRelay(tile);
for(String name : Init.actAddLaserRelayFluid)
if(name.equals(tileName))
return new LaserRelay(tile);
}
if(tile != null && (Init.loadedActAddVersion >= Init.minActAddVersion) && side == EnumFacing.UP){
String tileName = tile.getBlockType().getRegistryName().toString();

for(String name : Init.actAddLaserRelayEnergy)
if(name.equals(tileName))
return new LaserRelay(tile);
for(String name : Init.actAddLaserRelayItem)
if(name.equals(tileName))
return new LaserRelay(tile);
for(String name : Init.actAddLaserRelayFluid)
if(name.equals(tileName))
return new LaserRelay(tile);
}
return null;
}
Expand Down

0 comments on commit b6378b8

Please sign in to comment.