Java Code Examples for net.minecraft.init.Items#arrow()
The following examples show how to use
net.minecraft.init.Items#arrow() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerEventHandler.java From Et-Futurum with The Unlicense | 6 votes |
@SubscribeEvent public void arrowNock(ArrowNockEvent event) { if (event.result == null) return; IInventory invt = event.entityPlayer.inventory; for (int i = 0; i < invt.getSizeInventory(); i++) { ItemStack stack = invt.getStackInSlot(i); if (stack == null || stack.stackSize <= 0) continue; if (stack.getItem() == Items.arrow) return; if (stack.getItem() == ModItems.tipped_arrow) { event.setCanceled(true); event.entityPlayer.setItemInUse(event.result, event.result.getItem().getMaxItemUseDuration(event.result)); return; } } }
Example 2
Source File: BlockTrap.java From Artifacts with MIT License | 5 votes |
/** * Ticks the block if it's been scheduled */ @Override public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (!par1World.isRemote) { TileEntity te = par1World.getTileEntity(par2, par3, par4); TileEntityDispenser dis; if(te instanceof TileEntityDispenser) { dis = ((TileEntityDispenser) te); AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(par2-0.2, par3-0.2, par4-0.2, par2+1.2, par3+1.2, par4+1.2); List<EntitySpecialArrow> arrs = par1World.getEntitiesWithinAABB(EntitySpecialArrow.class, aabb); for(int a = arrs.size()-1; a>=0; a--) { EntityArrow arr = arrs.get(a); for(int s=0; s<9; s++) { ItemStack is = dis.getStackInSlot(s); if(is == null) { dis.setInventorySlotContents(s, new ItemStack(Items.arrow, 1)); arr.setDead(); break; } else if(is != null && is.getItem() == Items.arrow) { if(is.stackSize < 64) { is.stackSize++; arr.setDead(); break; } } } } this.dispense(par1World, par2, par3, par4, par5Random.nextInt(4)+1); this.dispense(par1World, par2, par3, par4, par5Random.nextInt(4)+1); } } }
Example 3
Source File: EntityArcher.java From Electro-Magic-Tools with GNU General Public License v3.0 | 4 votes |
@Override protected Item getDropItem() { return Items.arrow; }
Example 4
Source File: TileEntityAirCannon.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
private void updateDestination(){ doneTurning = false; // take dispenser upgrade in account double payloadFrictionY = 0.98D;// this value will differ when a // dispenser upgrade is inserted. double payloadFrictionX = 0.98D; double payloadGravity = 0.04D; if(getUpgrades(ItemMachineUpgrade.UPGRADE_ENTITY_TRACKER) > 0) { payloadFrictionY = 0.98D; payloadFrictionX = 0.91D; payloadGravity = 0.08D; } else if(getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE, getUpgradeSlots()) > 0 && inventory[0] != null) {// if // there // is // a // dispenser // upgrade // inserted. Item item = inventory[0].getItem(); if(item == Items.potionitem || item == Items.experience_bottle || item == Items.egg || item == Items.snowball) {// EntityThrowable payloadFrictionY = 0.99D; payloadGravity = 0.03D; } else if(item == Items.arrow) { payloadFrictionY = 0.99D; payloadGravity = 0.05D; } else if(item == Items.minecart || item == Items.chest_minecart || item == Items.hopper_minecart || item == Items.tnt_minecart || item == Items.furnace_minecart) { payloadFrictionY = 0.95D; } // else if(itemID == Item.fireballCharge.itemID){ // payloadGravity = 0.0D; // } // family items (throwable) which only differ in gravity. if(item == Items.potionitem) payloadGravity = 0.05D; else if(item == Items.experience_bottle) payloadGravity = 0.07D; payloadFrictionX = payloadFrictionY; // items which have different frictions for each axis. if(item == Items.boat) { payloadFrictionX = 0.99D; payloadFrictionY = 0.95D; } if(item == Items.spawn_egg) { payloadFrictionY = 0.98D; payloadFrictionX = 0.91D; payloadGravity = 0.08D; } } // calculate the heading. double deltaX = gpsX - xCoord; double deltaZ = gpsZ - zCoord; float calculatedRotationAngle; if(deltaX >= 0 && deltaZ < 0) { calculatedRotationAngle = (float)(Math.atan(Math.abs(deltaX / deltaZ)) / Math.PI * 180D); } else if(deltaX >= 0 && deltaZ >= 0) { calculatedRotationAngle = (float)(Math.atan(Math.abs(deltaZ / deltaX)) / Math.PI * 180D) + 90; } else if(deltaX < 0 && deltaZ >= 0) { calculatedRotationAngle = (float)(Math.atan(Math.abs(deltaX / deltaZ)) / Math.PI * 180D) + 180; } else { calculatedRotationAngle = (float)(Math.atan(Math.abs(deltaZ / deltaX)) / Math.PI * 180D) + 270; } // calculate the height angle. double distance = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ); double deltaY = gpsY - yCoord; float calculatedHeightAngle = calculateBestHeightAngle(distance, deltaY, getForce(), payloadGravity, payloadFrictionX, payloadFrictionY); setTargetAngles(calculatedRotationAngle, calculatedHeightAngle); }