Smater magnet ring behaviour, it now goes into a 5 second cooldown whenever an item is tossed.

This commit is contained in:
Lizbeth Rika committed 2014-10-09 23:11:06 +01:00
1 parent 0d95b890b1
commit 3a96d2c2bc
4 files changed
+64 -13

No files matched your search

@@ -13,43 +13,94 @@ package vazkii.botania.common.item.equipment.bauble;
import java.util.List;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.item.ItemTossEvent;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.core.helper.MathHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.lib.LibItemNames;
import baubles.api.BaubleType;
import baubles.common.container.InventoryBaubles;
import baubles.common.lib.PlayerHandler;
public class ItemMagnetRing extends ItemBauble {
IIcon iconOff;
private static final String TAG_COOLDOWN = "cooldown";
public ItemMagnetRing() {
super(LibItemNames.MAGNET_RING);
MinecraftForge.EVENT_BUS.register(this);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister) {
itemIcon = IconHelper.forItem(par1IconRegister, this, 0);
iconOff = IconHelper.forItem(par1IconRegister, this, 1);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconIndex(ItemStack stack) {
return getCooldown(stack) <= 0 ? itemIcon : iconOff;
}
@SubscribeEvent
public void onTossItem(ItemTossEvent event) {
InventoryBaubles inv = PlayerHandler.getPlayerBaubles(event.player);
for(int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(stack != null && stack.getItem() == this)
setCooldown(stack, 100);
}
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
super.onWornTick(stack, player);
if(player.isSneaking()) {
int range = 6;
double x = player.posX;
double y = player.posY -(player.worldObj.isRemote ? 1.62 : 0) + 0.75;
double z = player.posZ;
int cooldown = getCooldown(stack);
if(cooldown <= 0) {
if(!player.isSneaking()) {
int range = 6;
double x = player.posX;
double y = player.posY -(player.worldObj.isRemote ? 1.62 : 0) + 0.75;
double z = player.posZ;
List<EntityItem> items = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range));
for(EntityItem item : items) {
MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F);
if(player.worldObj.isRemote) {
boolean red = player.worldObj.rand.nextBoolean();
Botania.proxy.sparkleFX(player.worldObj, item.posX, item.posY, item.posZ, red ? 1F : 0F, 0F, red ? 0F : 1F, 1F, 3);
List<EntityItem> items = player.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x - range, y - range, z - range, x + range, y + range, z + range));
for(EntityItem item : items) {
MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F);
if(player.worldObj.isRemote) {
boolean red = player.worldObj.rand.nextBoolean();
Botania.proxy.sparkleFX(player.worldObj, item.posX, item.posY, item.posZ, red ? 1F : 0F, 0F, red ? 0F : 1F, 1F, 3);
}
}
}
}
} else setCooldown(stack, cooldown - 1);
}
public static int getCooldown(ItemStack stack) {
return ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0);
}
public static void setCooldown(ItemStack stack, int cooldown) {
ItemNBTHelper.setInt(stack, TAG_COOLDOWN, cooldown);
}
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.RING;
+1 -1
View File
@@ -1499,7 +1499,7 @@ botania.page.miningRing1=Diggy diggy hole
# -- RING OF MAGNETIZATION
botania.entry.magnetRing=Ring of Magnetization
botania.page.magnetRing0=By turning a &1Magnetizing Lens&0 into a wearable ring, one can use it to magnetize nearby items.<br>While equipped, this ring will make any nearby items magnetize towards the wearer if they're sneaking.
botania.page.magnetRing0=By turning a &1Magnetizing Lens&0 into a wearable ring, one can use it to magnetize nearby items. While equipped, this ring will make any nearby items magnetize towards the wearer if they're not sneaking.<br>A notable feature of this piece is that it'll negate its effect for 5 seconds after the wearer tosses an item so as to not interfere with whatever means it was tossed for.
botania.page.magnetRing1=How do they work?
# -- RING OF FAR REACH
File renamed without changes.

Before

Width:  |  Height:  |  Size: 391 B

After

Width:  |  Height:  |  Size: 391 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB