diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2022-08-29 16:04:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-29 16:04:28 +0200 |
commit | 7d1f51a8937e0a86486267437d444696e81e8aa0 (patch) | |
tree | a5b145e7271998f7b4b968a2212ed487e54a92b5 /src/main/java/gtPlusPlus/xmod/sc2 | |
parent | 5267969156d30b4bb5f4cb2279ebb49db6bd40e2 (diff) | |
download | GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.gz GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.tar.bz2 GT5-Unofficial-7d1f51a8937e0a86486267437d444696e81e8aa0.zip |
Buildscript + Spotless (#318)
* Convert AES.java to readable class
* Buildscript
* Spotless
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/sc2')
-rw-r--r-- | src/main/java/gtPlusPlus/xmod/sc2/HANDLER_SC2.java | 18 | ||||
-rw-r--r-- | src/main/java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java | 196 |
2 files changed, 102 insertions, 112 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/sc2/HANDLER_SC2.java b/src/main/java/gtPlusPlus/xmod/sc2/HANDLER_SC2.java index f39a69dfbc..0f249b29e8 100644 --- a/src/main/java/gtPlusPlus/xmod/sc2/HANDLER_SC2.java +++ b/src/main/java/gtPlusPlus/xmod/sc2/HANDLER_SC2.java @@ -5,17 +5,13 @@ import vswe.stevescarts.ModuleData.GppModuleData; public class HANDLER_SC2 { - public synchronized static void preInit() { - if (LoadedMods.StevesCarts){ - GppModuleData.loadGpp(); - } - } - - public static void init(){ - } - - public static void postInit(){ - } + public static synchronized void preInit() { + if (LoadedMods.StevesCarts) { + GppModuleData.loadGpp(); + } + } + public static void init() {} + public static void postInit() {} } diff --git a/src/main/java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java b/src/main/java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java index dfaec8b703..762697b419 100644 --- a/src/main/java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java +++ b/src/main/java/gtPlusPlus/xmod/sc2/modules/ModuleExoticSeeds.java @@ -1,117 +1,111 @@ package gtPlusPlus.xmod.sc2.modules; -import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import static net.minecraft.init.Blocks.farmland; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import java.lang.reflect.Field; - import net.minecraft.block.Block; import net.minecraft.block.BlockCrops; import net.minecraft.item.Item; import net.minecraft.item.ItemSeeds; import net.minecraft.item.ItemStack; import net.minecraft.world.World; - import vswe.stevescarts.Carts.MinecartModular; -import vswe.stevescarts.Modules.ICropModule; import vswe.stevescarts.Modules.Addons.ModuleAddon; +import vswe.stevescarts.Modules.ICropModule; public class ModuleExoticSeeds extends ModuleAddon implements ICropModule { - public ModuleExoticSeeds(MinecartModular cart) { - super(cart); - } - - private synchronized Block getBlockFromItemSeeds(ItemStack seed) { - try { - - Item seedItem = seed.getItem(); - if (!(seedItem instanceof ItemSeeds)) return null; - - Block cropBlock = (Block) ReflectionUtils.getField(ItemSeeds.class, "field_150925_a").get(seedItem); - - return cropBlock; - } catch (Throwable t) { - - } - return null; - } - - @Override - public boolean isSeedValid(ItemStack seed) { - return getBlockFromItemSeeds(seed) != null; - } - - @Override - public Block getCropFromSeed(ItemStack seed) { - return getBlockFromItemSeeds(seed); - } - - @Override - public boolean isReadyToHarvest(int x, int y, int z) { - World world = getCart().worldObj; - Block b = world.getBlock(x, y, z); - int m = world.getBlockMetadata(x, y, z); - - //If Forestry is loaded, let's make this upgrade convert farmland to Humus. - /*if (LoadedMods.Forestry) { - Block mFarmLand = world.getBlock(x, y-1, z); - if (mFarmLand == farmland) { - Block h = tryGetHumus(); - if (h != farmland) { - world.setBlock(x, y-1, z, h); - } - } - }*/ - - - return b instanceof BlockCrops && m == 7; - } - - - - /** - * Static Class & Block References for Forestry content. - * Stops Forestry being a hard requirement for this feature without having to make @Optional annotations. - */ - - private static Class<?> mForestryHumusBlockClass; - private static Class<?> mForestryBlockRegistryCoreClass; - private static Block mForestryHumusBlock; - - private synchronized Block tryGetHumus() { - if (!LoadedMods.Forestry) { - return farmland; - } - else { - if (mForestryHumusBlockClass == null || mForestryHumusBlock == null) { - try { - mForestryHumusBlockClass = ReflectionUtils.getClass("forestry.plugins.PluginCore"); - Field blocks = ReflectionUtils.getField(mForestryHumusBlockClass, "blocks"); - if (blocks != null) { - Object blockRegistryCoreObject = blocks.get(null); - mForestryBlockRegistryCoreClass = ReflectionUtils.getClass("forestry.core.blocks.BlockRegistryCore"); - if (mForestryBlockRegistryCoreClass != null && blockRegistryCoreObject != null) { - Field soil = ReflectionUtils.getField(mForestryBlockRegistryCoreClass, "soil"); - if (soil != null) { - Block testHumus = (Block) soil.get(blockRegistryCoreObject); - if (testHumus != null) { - mForestryHumusBlock = testHumus; - } - } - } - } - } - catch (Throwable t) { - t.printStackTrace(); - } - } - if (mForestryHumusBlock != null) { - return mForestryHumusBlock; - } - } - return farmland; - } - -}
\ No newline at end of file + public ModuleExoticSeeds(MinecartModular cart) { + super(cart); + } + + private synchronized Block getBlockFromItemSeeds(ItemStack seed) { + try { + + Item seedItem = seed.getItem(); + if (!(seedItem instanceof ItemSeeds)) return null; + + Block cropBlock = (Block) + ReflectionUtils.getField(ItemSeeds.class, "field_150925_a").get(seedItem); + + return cropBlock; + } catch (Throwable t) { + + } + return null; + } + + @Override + public boolean isSeedValid(ItemStack seed) { + return getBlockFromItemSeeds(seed) != null; + } + + @Override + public Block getCropFromSeed(ItemStack seed) { + return getBlockFromItemSeeds(seed); + } + + @Override + public boolean isReadyToHarvest(int x, int y, int z) { + World world = getCart().worldObj; + Block b = world.getBlock(x, y, z); + int m = world.getBlockMetadata(x, y, z); + + // If Forestry is loaded, let's make this upgrade convert farmland to Humus. + /*if (LoadedMods.Forestry) { + Block mFarmLand = world.getBlock(x, y-1, z); + if (mFarmLand == farmland) { + Block h = tryGetHumus(); + if (h != farmland) { + world.setBlock(x, y-1, z, h); + } + } + }*/ + + return b instanceof BlockCrops && m == 7; + } + + /** + * Static Class & Block References for Forestry content. + * Stops Forestry being a hard requirement for this feature without having to make @Optional annotations. + */ + private static Class<?> mForestryHumusBlockClass; + + private static Class<?> mForestryBlockRegistryCoreClass; + private static Block mForestryHumusBlock; + + private synchronized Block tryGetHumus() { + if (!LoadedMods.Forestry) { + return farmland; + } else { + if (mForestryHumusBlockClass == null || mForestryHumusBlock == null) { + try { + mForestryHumusBlockClass = ReflectionUtils.getClass("forestry.plugins.PluginCore"); + Field blocks = ReflectionUtils.getField(mForestryHumusBlockClass, "blocks"); + if (blocks != null) { + Object blockRegistryCoreObject = blocks.get(null); + mForestryBlockRegistryCoreClass = + ReflectionUtils.getClass("forestry.core.blocks.BlockRegistryCore"); + if (mForestryBlockRegistryCoreClass != null && blockRegistryCoreObject != null) { + Field soil = ReflectionUtils.getField(mForestryBlockRegistryCoreClass, "soil"); + if (soil != null) { + Block testHumus = (Block) soil.get(blockRegistryCoreObject); + if (testHumus != null) { + mForestryHumusBlock = testHumus; + } + } + } + } + } catch (Throwable t) { + t.printStackTrace(); + } + } + if (mForestryHumusBlock != null) { + return mForestryHumusBlock; + } + } + return farmland; + } +} |