mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Added Ring of Suction
This commit is contained in:
parent
4940a6e6f9
commit
4476b3c7c2
4 changed files with 83 additions and 2 deletions
|
@ -70,7 +70,6 @@
|
|||
-Depending on the fluids, it generates more power
|
||||
|
||||
-More Effect Rings
|
||||
-Ring of Growth: Lets Plants grow, more Reach with Tier 2
|
||||
-Ring of Thorns: Hurts Attackers when they hit you with a Projectile
|
||||
-Ring of Water Walking
|
||||
-Ring of Aquadive: Fast underwater movement
|
||||
|
|
|
@ -109,6 +109,7 @@ public class InitItems{
|
|||
public static Item itemWingsOfTheBats;
|
||||
|
||||
public static Item itemGrowthRing;
|
||||
public static Item itemMagnetRing;
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Items...");
|
||||
|
@ -116,6 +117,9 @@ public class InitItems{
|
|||
itemGrowthRing = new ItemGrowthRing();
|
||||
ItemUtil.register(itemGrowthRing);
|
||||
|
||||
itemMagnetRing = new ItemMagnetRing();
|
||||
ItemUtil.register(itemMagnetRing);
|
||||
|
||||
itemHelmEmerald = new ItemArmorAA("itemHelmEmerald", InitArmorMaterials.armorMaterialEmerald, 0, "gemEmerald", "armorEmerald");
|
||||
itemChestEmerald = new ItemArmorAA("itemChestEmerald", InitArmorMaterials.armorMaterialEmerald, 1, "gemEmerald", "armorEmerald");
|
||||
itemPantsEmerald = new ItemArmorAA("itemPantsEmerald", InitArmorMaterials.armorMaterialEmerald, 2, "gemEmerald", "armorEmerald");
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Random;
|
|||
public class ItemGrowthRing extends ItemEnergy implements INameableItem{
|
||||
|
||||
private static final int RANGE = 5;
|
||||
private static final int ENERGY_USED_PER_TICK = 800;
|
||||
private static final int ENERGY_USED_PER_TICK = 500;
|
||||
//The waiting time per growth cycle
|
||||
private static final int WAIT_TIME = 30;
|
||||
//The amount of Growth Ticks given to random plants around
|
||||
|
@ -37,6 +37,7 @@ public class ItemGrowthRing extends ItemEnergy implements INameableItem{
|
|||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){
|
||||
if(!(entity instanceof EntityPlayer) || world.isRemote) return;
|
||||
|
||||
EntityPlayer player = (EntityPlayer)entity;
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
package ellpeck.actuallyadditions.items;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.actuallyadditions.util.INameableItem;
|
||||
import ellpeck.actuallyadditions.util.ModUtil;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ItemMagnetRing extends ItemEnergy implements INameableItem{
|
||||
|
||||
private static final int RANGE = 8;
|
||||
private static final int ENERGY_USED_PER_TICK = 3;
|
||||
|
||||
public ItemMagnetRing(){
|
||||
super(3000000, 5000, 1);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){
|
||||
if(this.getEnergyStored(stack) >= ENERGY_USED_PER_TICK){
|
||||
//Get all the Items in the area
|
||||
ArrayList<EntityItem> items = (ArrayList<EntityItem>)world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(entity.posX-RANGE, entity.posY-RANGE, entity.posZ-RANGE, entity.posX+RANGE, entity.posY+RANGE, entity.posZ+RANGE));
|
||||
if(!items.isEmpty()){
|
||||
for(EntityItem item : items){
|
||||
//If the Item is near enough to get picked up
|
||||
//(So it doesn't bounce around until it notices itself..)
|
||||
if(Vec3.createVectorHelper(entity.posX, entity.posY, entity.posZ).distanceTo(Vec3.createVectorHelper(item.posX, item.posY, item.posZ)) <= 1.5){
|
||||
item.onCollideWithPlayer((EntityPlayer)entity);
|
||||
}
|
||||
else{
|
||||
double speed = 0.02;
|
||||
//Move the Item closer to the Player
|
||||
item.motionX += (entity.posX+0.5-item.posX)*speed;
|
||||
item.motionY += (entity.posY+1.0-item.posY)*speed;
|
||||
item.motionZ += (entity.posZ+0.5-item.posZ)*speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Use Energy per tick
|
||||
this.extractEnergy(stack, ENERGY_USED_PER_TICK, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return EnumRarity.epic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int pass){
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconReg){
|
||||
this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(){
|
||||
return "itemSuctionRing";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue