mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
100 lines
2.6 KiB
Java
100 lines
2.6 KiB
Java
package com.hbm.items.gear;
|
|
|
|
import java.util.List;
|
|
|
|
import com.hbm.entity.particle.EntityGasFlameFX;
|
|
import com.hbm.render.model.ModelJetPack;
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
import net.minecraft.client.model.ModelBiped;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.ItemArmor;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.item.ItemArmor.ArmorMaterial;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
import net.minecraft.util.Vec3;
|
|
import net.minecraft.world.World;
|
|
|
|
public class JetpackBreak extends ItemArmor {
|
|
|
|
private ModelJetPack model;
|
|
public static int maxFuel = 1200;
|
|
|
|
public JetpackBreak(ArmorMaterial p_i45325_1_, int p_i45325_2_, int p_i45325_3_) {
|
|
super(p_i45325_1_, p_i45325_2_, p_i45325_3_);
|
|
}
|
|
|
|
@Override
|
|
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool)
|
|
{
|
|
list.add("Kerosene: " + this.getFuel(itemstack) + "mB / " + this.maxFuel + "mB");
|
|
}
|
|
|
|
|
|
@Override
|
|
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) {
|
|
return armorType == 1;
|
|
}
|
|
|
|
@Override
|
|
@SideOnly(Side.CLIENT)
|
|
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) {
|
|
if (armorSlot == 1) {
|
|
if (model == null) {
|
|
this.model = new ModelJetPack();
|
|
}
|
|
return this.model;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
|
return "hbm:textures/models/JetPackBlue.png";
|
|
}
|
|
|
|
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
|
|
|
|
if(player.motionY < -0.25 && this.getFuel(stack) > 0) {
|
|
|
|
Vec3 vec = Vec3.createVectorHelper(player.getLookVec().xCoord, 0, player.getLookVec().zCoord);
|
|
vec.normalize();
|
|
player.motionY = -0.25;
|
|
|
|
EntityGasFlameFX fx = new EntityGasFlameFX(world);
|
|
fx.posX = player.posX - vec.xCoord;
|
|
fx.posY = player.posY - 1;
|
|
fx.posZ = player.posZ - vec.zCoord;
|
|
fx.motionY = -0.5;
|
|
world.spawnEntityInWorld(fx);
|
|
|
|
player.fallDistance = 0;
|
|
|
|
this.setFuel(stack, this.getFuel(stack) - 1);
|
|
}
|
|
}
|
|
|
|
public static int getFuel(ItemStack stack) {
|
|
if(stack.stackTagCompound == null) {
|
|
stack.stackTagCompound = new NBTTagCompound();
|
|
return 0;
|
|
}
|
|
|
|
return stack.stackTagCompound.getInteger("fuel");
|
|
|
|
}
|
|
|
|
public static void setFuel(ItemStack stack, int i) {
|
|
if(stack.stackTagCompound == null) {
|
|
stack.stackTagCompound = new NBTTagCompound();
|
|
}
|
|
|
|
stack.stackTagCompound.setInteger("fuel", i);
|
|
|
|
}
|
|
}
|