API additions.

This commit is contained in:
Lizbeth Rika committed 2014-08-06 18:10:15 +01:00
1 parent e32a5a91d1
commit 2cec34a139
8 files changed
+70 -13

No files matched your search

@@ -0,0 +1,25 @@
/**
* This class was created by <Vazkii>. 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Aug 6, 2014, 6:02:29 PM (GMT)]
*/
package vazkii.botania.api.item;
/**
* An interface that defines an instance of PlayerControllerMP with
* the ability to modify reach. See vazkii.botania.client.core.handler.BotaniaPlayerController
*/
public interface IExtendedPlayerController {
/**
* Sets the extra reach the player should have.
*/
public void setReachDistanceExtension(float f);
}
@@ -0,0 +1,30 @@
/**
* This class was created by <Vazkii>. 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Aug 6, 2014, 6:06:27 PM (GMT)]
*/
package vazkii.botania.api.item;
import net.minecraft.item.ItemStack;
/**
* Any item that implements this allows for pixies to be spawned when the player takes damage when...<br>
* - Case the item is armor, having it equipped.<br>
* - Case the item is a bauble, having it worn.<br>
* - On any other case, having the item being the current held item.
*/
public interface IPixieSpawner {
/**
* The chance this item adds for pixies to be spawned. From 0.0 to 1.0. All values
* are put together when calculating.
*/
public float getPixieChance(ItemStack stack);
}
@@ -11,6 +11,7 @@
*/
package vazkii.botania.client.core.handler;
import vazkii.botania.api.item.IExtendedPlayerController;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.client.network.NetHandlerPlayClient;
@@ -18,9 +19,9 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class BotaniaPlayerController extends PlayerControllerMP {
public class BotaniaPlayerController extends PlayerControllerMP implements IExtendedPlayerController {
public float distance = 0F;
private float distance = 0F;
public BotaniaPlayerController(Minecraft p_i45062_1_, NetHandlerPlayClient p_i45062_2_) {
super(p_i45062_1_, p_i45062_2_);
@@ -31,4 +32,9 @@ public class BotaniaPlayerController extends PlayerControllerMP {
return super.getBlockReachDistance() + distance;
}
@Override
public void setReachDistanceExtension(float f) {
distance = f;
}
}
@@ -22,6 +22,7 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldSettings.GameType;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
import vazkii.botania.api.item.IExtendedPlayerController;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.client.core.handler.BotaniaPlayerController;
import vazkii.botania.client.core.handler.BoundTileRenderer;
@@ -164,7 +165,7 @@ public class ClientProxy extends CommonProxy {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
if(entity == player) {
if(!(mc.playerController instanceof BotaniaPlayerController)) {
if(!(mc.playerController instanceof IExtendedPlayerController)) {
GameType type = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.CURRENT_GAME_TYPE);
NetHandlerPlayClient net = ReflectionHelper.getPrivateValue(PlayerControllerMP.class, mc.playerController, LibObfuscation.NET_CLIENT_HANDLER);
BotaniaPlayerController controller = new BotaniaPlayerController(mc, net);
@@ -172,7 +173,7 @@ public class ClientProxy extends CommonProxy {
mc.playerController = controller;
}
((BotaniaPlayerController) mc.playerController).distance = reach;
((IExtendedPlayerController) mc.playerController).setReachDistanceExtension(reach);
}
}
@@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import vazkii.botania.api.item.IPixieSpawner;
import vazkii.botania.common.entity.EntityPixie;
import vazkii.botania.common.item.ModItems;
import baubles.common.container.InventoryBaubles;
@@ -52,10 +53,4 @@ public class PixieHandler {
return 0F;
}
public static interface IPixieSpawner {
public float getPixieChance(ItemStack stack);
}
}
@@ -3,8 +3,8 @@ package vazkii.botania.common.item.equipment.armor.elementium;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.item.IPixieSpawner;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.handler.PixieHandler.IPixieSpawner;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.armor.manasteel.ItemManasteelArmor;
@@ -12,7 +12,7 @@
package vazkii.botania.common.item.equipment.bauble;
import net.minecraft.item.ItemStack;
import vazkii.botania.common.core.handler.PixieHandler.IPixieSpawner;
import vazkii.botania.api.item.IPixieSpawner;
import vazkii.botania.common.lib.LibItemNames;
import baubles.api.BaubleType;
@@ -2,7 +2,7 @@ package vazkii.botania.common.item.equipment.tool.elementium;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.common.core.handler.PixieHandler.IPixieSpawner;
import vazkii.botania.api.item.IPixieSpawner;
import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelSword;
import vazkii.botania.common.lib.LibItemNames;