Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package skymine.redenergy.sow.items;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.world.World;
- import skymine.redenergy.sow.entities.EntityFlame;
- import skymine.redenergy.sow.utils.LogHelper;
- public class ItemScreamPistol extends ItemWeapon{
- public ItemScreamPistol(){
- super();
- this.setMaxDamage(100);
- this.setMaxStackSize(1);
- }
- public int getMaxItemUseDuration(ItemStack itemStack) {
- return 72000;
- }
- @Override
- public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
- checkNBT(stack);
- player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
- stack.stackTagCompound.setBoolean("isShooting", true);
- return stack;
- }
- @Override
- public void onPlayerStoppedUsing(ItemStack stack, World world,EntityPlayer player, int ticks) {
- stack.stackTagCompound.setBoolean("isShooting", false);
- }
- public void onUsingTick(ItemStack stack, EntityPlayer player, int ticksInUse) {
- if(!player.worldObj.isRemote){
- shootFire(stack, player.worldObj, player);
- }
- }
- private ItemStack shootFire(ItemStack stack, World world, EntityPlayer player){
- if(!world.isRemote && stack.getItemDamage() != 100 && stack.stackTagCompound.getBoolean("isShooting")){
- for(int i = 0; i < 8; i++){
- EntityFlame flame = new EntityFlame(world, player);
- world.spawnEntityInWorld(flame);
- }
- stack.damageItem(1, player);
- }
- return stack;
- }
- @Override
- public void switchWeaponMode(ItemStack stack, EntityPlayer player) {}
- @Override
- public void reloadWeapon(ItemStack stack, EntityPlayer player) {
- stack.setItemDamage(0);
- LogHelper.dLog("weapon reloaded");
- }
- private void checkNBT(ItemStack stack){
- if(stack.stackTagCompound == null){
- stack.stackTagCompound = new NBTTagCompound();
- stack.stackTagCompound.setBoolean("isShooting", false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment