initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
82
java/src/game/item/ItemGunBase.java
Executable file
82
java/src/game/item/ItemGunBase.java
Executable file
|
@ -0,0 +1,82 @@
|
|||
package game.item;
|
||||
|
||||
import game.enchantment.Enchantment;
|
||||
import game.enchantment.EnchantmentHelper;
|
||||
import game.entity.npc.EntityNPC;
|
||||
import game.entity.projectile.EntityBullet;
|
||||
import game.init.SoundEvent;
|
||||
import game.renderer.blockmodel.Transforms;
|
||||
import game.world.World;
|
||||
|
||||
public abstract class ItemGunBase extends Item
|
||||
{
|
||||
public abstract ItemAmmo getAmmo();
|
||||
public abstract float getVelocity();
|
||||
|
||||
public ItemGunBase(int durability)
|
||||
{
|
||||
this.maxStackSize = 1;
|
||||
this.setMaxDamage(durability);
|
||||
this.setTab(CheatTab.tabCombat);
|
||||
}
|
||||
|
||||
public ItemAction getItemPosition(ItemStack stack)
|
||||
{
|
||||
return ItemAction.AIM;
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World worldIn, EntityNPC playerIn)
|
||||
{
|
||||
if(stack.getItemDamage() >= this.getMaxDamage())
|
||||
return stack;
|
||||
boolean flag = // playerIn.creative ||
|
||||
EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;
|
||||
if (flag || playerIn.inventory.hasItem(this.getAmmo()))
|
||||
{
|
||||
EntityBullet bullet = new EntityBullet(worldIn, playerIn, this.getVelocity());
|
||||
bullet.setDamage(this.getAmmo().getDamage(stack));
|
||||
|
||||
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
|
||||
|
||||
if (j > 0)
|
||||
{
|
||||
bullet.setDamage(bullet.getDamage() + j);
|
||||
}
|
||||
|
||||
// int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
|
||||
//
|
||||
// if (k > 0)
|
||||
// {
|
||||
// entityarrow.setKnockbackStrength(k);
|
||||
// }
|
||||
|
||||
// if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0)
|
||||
// {
|
||||
// entityarrow.setFire(100);
|
||||
// }
|
||||
|
||||
stack.damageItem(1, playerIn);
|
||||
worldIn.playSoundAtEntity(playerIn, SoundEvent.EXPLODE_ALT, 1.0F, 1.5F);
|
||||
|
||||
if(!flag)
|
||||
playerIn.inventory.consumeInventoryItem(this.getAmmo());
|
||||
|
||||
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
|
||||
|
||||
if (!worldIn.client)
|
||||
{
|
||||
worldIn.spawnEntityInWorld(bullet);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public Transforms getTransform() {
|
||||
return Transforms.RANGED;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue