mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Added hooks for subtiles to control redstone behavior and light.
This commit is contained in:
1 parent
7a144f3fcd
commit
55977e5bd9
10 files changed
+233
-1
No files matched your search
@@ -1,4 +1,4 @@
|
||||
@API(owner = "Botania", apiVersion = "49", provides = "BotaniaAPI")
|
||||
@API(owner = "Botania", apiVersion = "50", provides = "BotaniaAPI")
|
||||
package vazkii.botania.api;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
@@ -192,4 +192,27 @@ public class SubTileEntity {
|
||||
public void renderHUD(Minecraft mc, ScaledResolution res) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the light value for this SubTileEntity, this is a int (-1 to default to the flower)
|
||||
*/
|
||||
public int getLightValue() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the comparator input value for this SubTileEntity
|
||||
*/
|
||||
public int getComparatorInputOverride(int side) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the redstone power level for this SubTileEntity
|
||||
*/
|
||||
public int getPowerLevel(int side) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -13,9 +13,13 @@ package vazkii.botania.common;
|
||||
import vazkii.botania.common.core.handler.IMCHandler;
|
||||
import vazkii.botania.common.core.handler.ManaNetworkHandler;
|
||||
import vazkii.botania.common.core.proxy.CommonProxy;
|
||||
import vazkii.botania.common.integration.coloredlights.ILightHelper;
|
||||
import vazkii.botania.common.integration.coloredlights.LightHelperColored;
|
||||
import vazkii.botania.common.integration.coloredlights.LightHelperVanilla;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.ModAPIManager;
|
||||
@@ -33,6 +37,8 @@ public class Botania {
|
||||
public static boolean thaumcraftLoaded = false;
|
||||
public static boolean bcTriggersLoaded = false;
|
||||
public static boolean bloodMagicLoaded = false;
|
||||
|
||||
public static ILightHelper lightHelper;
|
||||
|
||||
@Instance(LibMisc.MOD_ID)
|
||||
public static Botania instance;
|
||||
@@ -45,10 +51,20 @@ public class Botania {
|
||||
thaumcraftLoaded = Loader.isModLoaded("Thaumcraft");
|
||||
bcTriggersLoaded = ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|statements");
|
||||
bloodMagicLoaded = Loader.isModLoaded("AWWayofTime"); // Psh, noob
|
||||
|
||||
if(lightHelper == null)
|
||||
lightHelper = new LightHelperVanilla();
|
||||
|
||||
proxy.preInit(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@Optional.Method(modid = "easycoloredlights")
|
||||
public void preInitColoredLights(FMLPreInitializationEvent event) {
|
||||
System.out.println("easycolor!");
|
||||
lightHelper = new LightHelperColored();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
proxy.init(event);
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.oredict.RecipeSorter.Category;
|
||||
@@ -35,6 +36,7 @@ import vazkii.botania.common.block.decor.BlockFloatingFlower;
|
||||
import vazkii.botania.common.block.tile.TileFloatingSpecialFlower;
|
||||
import vazkii.botania.common.block.tile.TileSpecialFlower;
|
||||
import vazkii.botania.common.crafting.recipe.SpecialFloatingFlowerRecipe;
|
||||
import vazkii.botania.common.integration.coloredlights.LightHelper;
|
||||
import vazkii.botania.common.item.block.ItemBlockFloatingSpecialFlower;
|
||||
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
@@ -49,6 +51,39 @@ public class BlockFloatingSpecialFlower extends BlockFloatingFlower implements I
|
||||
RecipeSorter.register("botania:floatingSpecialFlower", SpecialFloatingFlowerRecipe.class, Category.SHAPELESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
int currentLight = ((TileSpecialFlower) world.getTileEntity(x, y, z)).getLightValue();
|
||||
if(currentLight == -1)
|
||||
currentLight = originalLight;
|
||||
return LightHelper.getPackedColor(world.getBlockMetadata(x, y, z), currentLight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
|
||||
return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getComparatorInputOverride(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getPowerLevel(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return this.isProvidingWeakPower(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
|
||||
// NO-OP
|
||||
|
||||
@@ -41,8 +41,11 @@ import vazkii.botania.api.wand.IWandable;
|
||||
import vazkii.botania.client.lib.LibRenderIDs;
|
||||
import vazkii.botania.common.block.tile.TileSpecialFlower;
|
||||
import vazkii.botania.common.core.BotaniaCreativeTab;
|
||||
import vazkii.botania.common.integration.coloredlights.ColoredLightHelper;
|
||||
import vazkii.botania.common.integration.coloredlights.LightHelper;
|
||||
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvider, ISpecialFlower, IWandable, ILexiconable, IWandHUD {
|
||||
@@ -110,6 +113,39 @@ public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvid
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
int currentLight = ((TileSpecialFlower) world.getTileEntity(x, y, z)).getLightValue();
|
||||
if(currentLight == -1)
|
||||
currentLight = 0;
|
||||
return LightHelper.getPackedColor(world.getBlockMetadata(x, y, z), currentLight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
|
||||
return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getComparatorInputOverride(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getPowerLevel(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) {
|
||||
return this.isProvidingWeakPower(world, x, y, z, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvidePower() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return LibRenderIDs.idSpecialFlower;
|
||||
}
|
||||
|
||||
@@ -193,4 +193,22 @@ public class TileSpecialFlower extends TileMod implements IWandBindable, ISubTil
|
||||
return false;
|
||||
return subTile.bindTo(player, wand, x, y, z, side);
|
||||
}
|
||||
|
||||
public int getLightValue() {
|
||||
if(subTile == null)
|
||||
return -1;
|
||||
return subTile.getLightValue();
|
||||
}
|
||||
|
||||
public int getComparatorInputOverride(int side) {
|
||||
if(subTile == null)
|
||||
return 0;
|
||||
return subTile.getComparatorInputOverride(side);
|
||||
}
|
||||
|
||||
public int getPowerLevel(int side) {
|
||||
if(subTile == null)
|
||||
return 0;
|
||||
return subTile.getPowerLevel(side);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* This class was created by <SoundLogic>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [May 16, 2015, 8:30:41 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.integration.coloredlights;
|
||||
|
||||
/*
|
||||
* This interface is use for wrappers for compatibility with the colored lights mod.
|
||||
* It has one version for colored lights, and one version which leaves the light values unmodified for vanilla
|
||||
*/
|
||||
public interface ILightHelper {
|
||||
|
||||
public int makeRGBLightValue(float r, float g, float b, int currentLightValue);
|
||||
public int getPackedColor(int meta, int light);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* This class was created by <SoundLogic>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [May 16, 2015, 8:30:41 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.integration.coloredlights;
|
||||
|
||||
import vazkii.botania.common.Botania;
|
||||
|
||||
/*
|
||||
* This class acts as ColoredLightHelper if the colored lights mod is installed, and leaves the light values unmodified otherwise
|
||||
*/
|
||||
public class LightHelper {
|
||||
|
||||
public static int makeRGBLightValue(float r, float g, float b, float currentLightValue) {
|
||||
return Botania.lightHelper.makeRGBLightValue(r, g, b, (int) currentLightValue);
|
||||
}
|
||||
|
||||
public static int getPackedColor(int meta, int light) {
|
||||
return Botania.lightHelper.getPackedColor(meta, light);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* This class was created by <SoundLogic>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [May 16, 2015, 8:30:41 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.integration.coloredlights;
|
||||
|
||||
/*
|
||||
* This is an implementation of ILightHelper for when the colored lights mod is installed
|
||||
*/
|
||||
public class LightHelperColored implements ILightHelper {
|
||||
|
||||
@Override
|
||||
public int makeRGBLightValue(float r, float g, float b, int currentLightValue) {
|
||||
return ColoredLightHelper.makeRGBLightValue(r, g, b, currentLightValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPackedColor(int meta, int light) {
|
||||
return ColoredLightHelper.getPackedColor(meta, light);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* This class was created by <SoundLogic>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [May 16, 2015, 8:30:41 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.integration.coloredlights;
|
||||
|
||||
/*
|
||||
* This is an implementation of ILightHelper for when the colored lights mod isn't installed
|
||||
*/
|
||||
public class LightHelperVanilla implements ILightHelper {
|
||||
|
||||
@Override
|
||||
public int makeRGBLightValue(float r, float g, float b, int currentLightValue) {
|
||||
return currentLightValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPackedColor(int meta, int light) {
|
||||
return light;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user