Giter VIP home page Giter VIP logo

frekby's Projects

glumpy icon glumpy

Python+Numpy+OpenGL: fast, scalable and beautiful scientific visualization

shield icon shield

package mods.battlegear2.api; import java.util.List; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.Icon; import net.minecraft.util.StatCollector; import mods.battlegear2.items.ItemShield; import mods.battlegear2.items.ItemWeapon; import mods.battlegear2.utils.BattlegearConfig; import cpw.mods.fml.common.FMLCommonHandler; import mods.battlegear2.api.IDyable; import mods.battlegear2.api.IShield; import mods.battlegear2.utils.BattlegearConfig; import mods.battlegear2.utils.EnumShield; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.Icon; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import java.util.List; public class DOOM extends Item implements IShield, IDyable { private Icon backIcon; private Icon trimIcon; public DOOM(int par1) { super(par1); new DOOM(3000); this.setCreativeTab(BattlegearConfig.customTab); this.setUnlocalizedName("DOOM"); this.func_111206_d("DOOM"); this.getShareTag(); this.setMaxDamage(1); this.setMaxStackSize(1); this.setHasSubtypes(false); } @Override public void registerIcons(IconRegister par1IconRegister) { super.registerIcons(par1IconRegister); backIcon = par1IconRegister.registerIcon("DOOM"); trimIcon = par1IconRegister.registerIcon("DOOM1"); } public int getArrowCount(ItemStack stack) { if (stack.hasTagCompound() && stack.getTagCompound().hasKey("arrows")) { return stack.getTagCompound().getShort("arrows"); } else { return 0; } } public void setArrowCount(ItemStack stack, int count) { if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } //Should never happen, you would need A LOT of arrows for this to happen if (count > Short.MAX_VALUE) { count = Short.MAX_VALUE; } stack.getTagCompound().setShort("arrows", (short)count); } public Icon getBackIcon() { return backIcon; } public Icon getTrimIcon() { return trimIcon; } @Override public float getDecayRate(ItemStack shield) { return 1F / 1F / 20F; } @Override public boolean canBlock(ItemStack shield, DamageSource source) { return !source.isUnblockable(); } @Override public float getDamageDecayRate(ItemStack shield, float amount) { return 1F / 20F * amount; } @Override public float getBlockAngle(ItemStack shield) { return 60; } @Override public int getBashTimer(ItemStack shield) { return 10; } @Override public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4); par3List.add(""); par3List.add(EnumChatFormatting.DARK_GREEN + ItemWeapon.decimal_format.format((float) 1F / (1F / 1F / 20F) / 20F) + StatCollector.translateToLocal("attribute.shield.block.time")); int arrowCount = getArrowCount(par1ItemStack); if (arrowCount > 0) { par3List.add(String.format("%s%s %s", EnumChatFormatting.GOLD, arrowCount, StatCollector.translateToLocal("attribute.shield.arrow.count"))); } } /** * Return whether the specified armor ItemStack has a color. */ public boolean hasColor(ItemStack par1ItemStack) { return (!par1ItemStack.hasTagCompound() ? false : (!par1ItemStack.getTagCompound().hasKey("display") ? false : par1ItemStack.getTagCompound().getCompoundTag("display").hasKey("color"))); } /** * Return the color for the specified armor ItemStack. */ public int getColor(ItemStack par1ItemStack) { { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); if (nbttagcompound == null) { return getDefaultColor(par1ItemStack); } else { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); return nbttagcompound1 == null ? getDefaultColor(par1ItemStack) : (nbttagcompound1.hasKey("color") ? nbttagcompound1.getInteger("color") : getDefaultColor(par1ItemStack)); } } } /** * Remove the color from the specified armor ItemStack. */ public void removeColor(ItemStack par1ItemStack) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); if (nbttagcompound != null) { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); if (nbttagcompound1.hasKey("color")) { nbttagcompound1.removeTag("color"); } } } @Override public int getDefaultColor(ItemStack par1ItemStack) { return 0xFFbc9862; } @Override public void setColor(ItemStack par1ItemStack, int par2) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); if (nbttagcompound == null) { nbttagcompound = new NBTTagCompound(); par1ItemStack.setTagCompound(nbttagcompound); } NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); if (!nbttagcompound.hasKey("display")) { nbttagcompound.setCompoundTag("display", nbttagcompound1); } nbttagcompound1.setInteger("color", par2); } }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.