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
Dungeon Tweaks Compat again #228
Changes from 1 commit
a21faea
05b5f83
719caf9
7cd159d
2f2e345
82f914d
878bb77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package atomicstryker.battletowers.common; | ||
|
||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.Method; | ||
import java.util.Random; | ||
|
||
import com.evilnotch.dungeontweeks.main.world.worldgen.mobs.DungeonLocation; | ||
import com.evilnotch.dungeontweeks.main.world.worldgen.mobs.DungeonMobs; | ||
|
||
import atomicstryker.battletowers.common.AS_WorldGenTower.TowerTypes; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.tileentity.TileEntityMobSpawner; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.common.MinecraftForge; | ||
import net.minecraftforge.fml.common.eventhandler.Event; | ||
/** | ||
* this is backwards and modern dungeon tweaks compatible | ||
* @author jredfox | ||
* | ||
*/ | ||
public class DungeonTweaksCompat { | ||
|
||
public static boolean isLegacy = false; | ||
|
||
/** | ||
* make backwards compatability when isLegacy becomes true | ||
*/ | ||
public static void legacyCheck() | ||
{ | ||
try | ||
{ | ||
Class c = Class.forName("com.EvilNotch.dungeontweeks.main.Events.EventDungeon$Post"); | ||
isLegacy = true; | ||
} | ||
catch(Throwable t) | ||
{ | ||
|
||
} | ||
} | ||
/** | ||
* register all dungeon tweaks mobs to anydim towers | ||
*/ | ||
public static void registerDungeons() | ||
{ | ||
if(isLegacy) return;//I supported this mod in older versions | ||
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. Formatting 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. yes I will download your formattor again I guess |
||
try | ||
{ | ||
Method addDungeonMob = Class.forName("com.evilnotch.dungeontweeks.main.world.worldgen.mobs.DungeonMobs").getMethod("addDungeonMob", ResourceLocation.class,ResourceLocation.class,int.class); | ||
for(AS_WorldGenTower.TowerTypes tower : AS_WorldGenTower.TowerTypes.values()) | ||
{ | ||
boolean nether = tower == TowerTypes.Netherrack; | ||
addDungeonMob.invoke(null, tower.getId(), new ResourceLocation("cave_spider"), 100); | ||
addDungeonMob.invoke(null,tower.getId(), new ResourceLocation("spider"), 90); | ||
addDungeonMob.invoke(null,tower.getId(), nether ? new ResourceLocation("wither_skeleton") : new ResourceLocation("skeleton"), 120); | ||
addDungeonMob.invoke(null,tower.getId(), new ResourceLocation("zombie"), 120); | ||
|
||
if(nether) | ||
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. formatting |
||
addDungeonMob.invoke(null,tower.getId(), new ResourceLocation("blaze"), 20); | ||
} | ||
} | ||
catch(Exception e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
} | ||
/** | ||
* fire the event based upon tower definitions | ||
*/ | ||
public static void fireDungeonSpawn(TileEntityMobSpawner spawner, World world, Random random, TowerTypes towerChosen) | ||
{ | ||
ResourceLocation towerId = towerChosen.getId(); | ||
if(isLegacy) | ||
{ | ||
try | ||
{ | ||
@SuppressWarnings("unchecked") | ||
Constructor<? extends Event> constructor = (Constructor<? extends Event>) Class.forName("com.EvilNotch.dungeontweeks.main.Events.EventDungeon$Post") | ||
.getConstructor(TileEntity.class, BlockPos.class, Random.class, ResourceLocation.class, World.class); | ||
Event event = constructor.newInstance(spawner, spawner.getPos(), world.rand, towerId, | ||
world); | ||
MinecraftForge.EVENT_BUS.post(event); | ||
} | ||
catch (Throwable t) | ||
{ | ||
t.printStackTrace(); | ||
} | ||
} | ||
else | ||
{ | ||
try | ||
{ | ||
Method fireDungeonTweaks = Class.forName("com.evilnotch.dungeontweeks.main.world.worldgen.mobs.DungeonMobs").getMethod("fireDungeonTweaks",ResourceLocation.class,TileEntity.class,Random.class,World.class); | ||
fireDungeonTweaks.invoke(null, towerId, spawner, random, world); | ||
} | ||
catch(Throwable t) | ||
{ | ||
t.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"pack": { | ||
"description": "examplemod resources", | ||
"pack_format": 3, | ||
"_comment": "A pack_format of 3 should be used starting with Minecraft 1.11. All resources, including language files, should be lowercase (eg: en_us.lang). A pack_format of 2 will load your mod resources with LegacyV2Adapter, which requires language files to have uppercase letters (eg: en_US.lang)." | ||
} | ||
} |
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.
Pretty sure the idea of compat proxies is to avoid having to IMPORT the addons?
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.
ok I will remove the imports but, I don't use them. I converted them to reflection so you don't have to have my mod to compile even though it would be safe using it without the mod since loader is mod loaded