@Override
  public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase player) {
    if (player.worldObj.isRemote) return true;
    if (victim instanceof EntityPlayer) {
      EntityPlayer pvp = (EntityPlayer) victim;
      if (LudicrousItems.isInfinite(pvp)) {
        victim.attackEntityFrom(
            new DamageSourceInfinitySword(player).setDamageBypassesArmor(), 4.0F);
        return true;
      }
      if (pvp.getHeldItem() != null
          && pvp.getHeldItem().getItem() == LudicrousItems.infinity_sword
          && pvp.isUsingItem()) return true;
    }

    try {
      stupidMojangProtectedVariable.setInt(victim, 60);
    } catch (Exception e) {
      Lumberjack.log(Level.ERROR, e, "The sword isn't reflecting right! Polish it!");
    }
    victim
        .func_110142_aN()
        .func_94547_a(
            new DamageSourceInfinitySword(player), victim.getHealth(), victim.getHealth());
    victim.setHealth(0);
    victim.onDeath(new EntityDamageSource("infinity", player));
    return true;
  }
 public void onServerBlockActivated(
     World world,
     EntityPlayer entityplayer,
     int x,
     int y,
     int z,
     int side,
     float hitX,
     float hitY,
     float hitZ) {
   if (!entityplayer.canPlayerEdit(x >> 3, y >> 3, z >> 3, side, entityplayer.getHeldItem())) {
     return;
   }
   if (entityplayer.getHeldItem() != null
       && entityplayer.getHeldItem().getItem() instanceof ItemLittleBlocksWand) {
     return;
   }
   if (this.canPlayerPlaceBlockOrUseItem(world, entityplayer)) {
     try {
       BlockUtil.onServerBlockActivated(
           world,
           entityplayer,
           entityplayer.getCurrentEquippedItem(),
           x,
           y,
           z,
           side,
           hitX,
           hitY,
           hitZ);
     } catch (ClassCastException e) {
       FMLCommonHandler.instance().getFMLLogger().warn(e.getLocalizedMessage());
     }
   }
 }
Exemplo n.º 3
0
  public void renderKatanaDash(
      RenderGameOverlayEvent.Pre event, int width, int height, EntityPlayer player) {
    if (player.getHeldItem() != null
        && player.getHeldItem().getItem() == TFItems.purgesKatana
        && !TFPlayerData.isInVehicleMode(player)
        && TFHelper.isPlayerPurge(player)) {
      int j =
          TFItems.purgesKatana.getMaxItemUseDuration(player.getHeldItem())
              - player.getItemInUseCount();
      double d = (double) j / 10;

      if (d > 2.0D) {
        d = 2.0D;
      }

      GL11.glDisable(GL11.GL_TEXTURE_2D);
      GL11.glEnable(GL11.GL_BLEND);
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
      GL11.glColor4f(0F, 0F, 0F, 0.15F);
      drawTexturedModalRect(width / 2 - 26, height / 2 + 9, 0, 0, 52, 12);
      GL11.glColor4f(1F, 0F, 0F, 0.25F);
      drawTexturedModalRect(width / 2 - 25, height / 2 + 10, 0, 0, (int) (d * 25), 10);
      GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
  }
 public void onUpdate(
     ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
   EntityPlayer player = (EntityPlayer) par3Entity;
   if (ItemWinnersProof.keyPressed) {
     ItemWinnersProof.keyPressed = false;
     if (player.getHeldItem() != null && player.getHeldItem().itemID == AddedItems.K65c.itemID) {}
   }
 }
Exemplo n.º 5
0
 public void onUpdate(
     ItemStack itemstack, World par2World, Entity par3Entity, int par4, boolean par5) {
   if (itemstack.isItemEnchanted() == false) {
     itemstack.addEnchantment(KingdomKeys.HarvestHearts, 1);
   }
   EntityPlayer player = (EntityPlayer) par3Entity;
   if (this.keyPressed) {
     this.keyPressed = false;
     if (player.getHeldItem() != null && player.getHeldItem().itemID == AddedItems.K99.itemID) {}
   }
 }
Exemplo n.º 6
0
  public boolean onBlockActivated(
      World world, int x, int y, int z, EntityPlayer player, int i, float a, float b, float c) {

    if (player.getHeldItem() != null) {

      if (player.getHeldItem().itemID == CheapSkateItems.oneCoin.itemID) {
        if (player.getHeldItem().stackSize == 64) {
          player.getHeldItem().stackSize = 0;

          if (!world.isRemote) {

            ItemStack ironIngot = new ItemStack(Item.ingotIron, 1);
            EntityItem entityitem = new EntityItem(world, x, y + (double) 3, z, ironIngot);
            entityitem.delayBeforeCanPickup = 10;
            world.spawnEntityInWorld(entityitem);
          }
        }
      }
      if (player.getHeldItem().itemID == CheapSkateItems.twoCoin.itemID) {
        if (player.getHeldItem().stackSize >= 32) {
          player.getHeldItem().stackSize = player.getHeldItem().stackSize - 32;

          if (!world.isRemote) {

            ItemStack ironIngot = new ItemStack(Item.ingotIron, 1);
            EntityItem entityitem = new EntityItem(world, x, y + (double) 3, z, ironIngot);
            entityitem.delayBeforeCanPickup = 10;
            world.spawnEntityInWorld(entityitem);
          }
        }
      }
    }

    return true;
  }
Exemplo n.º 7
0
 public boolean insertCalculator(EntityPlayer player, World world, int x, int y, int z) {
   if (player.getHeldItem() != null
       && TileEntityDockingStation.isCalculator(player.getHeldItem()) > 0) {
     if (world.getTileEntity(x, y, z) != null
         && world.getTileEntity(x, y, z) instanceof TileEntityDockingStation) {
       TileEntityDockingStation station = (TileEntityDockingStation) world.getTileEntity(x, y, z);
       if (station.getStackInSlot(0) == null) {
         station.setInventorySlotContents(0, player.getHeldItem().copy());
         player.getHeldItem().stackSize--;
         return true;
       }
     }
   }
   return false;
 }
Exemplo n.º 8
0
  @Override
  public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    switch (ID) {
      case GUI_TRAY:
        return new GuiTray(player, new InventoryItem(player.getHeldItem(), 1));

      case GUI_HAND_SIEVE:
        return new GuiHandSieve(player, new InventoryItem(player.getHeldItem(), 1));

      case GUI_INFERNAL_FURNACE:
        return new GuiHellfireFurnace(player, (TileHellfireFurnace) world.getTileEntity(x, y, z));
    }

    return null;
  }
Exemplo n.º 9
0
 @Override
 public List<String> getWailaBody(
     Entity entity,
     List<String> currenttip,
     IWailaEntityAccessor accessor,
     IWailaConfigHandler config) {
   Entity currentEntity = accessor.getEntity();
   Class currentEntityClass = currentEntity.getClass();
   if (EntityList.classToStringMapping.containsKey(currentEntityClass)) {
     NBTTagCompound n = accessor.getNBTData();
     // LogHelper.info(n.toString());
     EntityPlayer player = accessor.getPlayer();
     ItemStack holdItemReal = player.getHeldItem();
     String holdItemNameReal = "";
     if (holdItemReal != null) {
       holdItemNameReal = Item.itemRegistry.getNameForObject(holdItemReal.getItem());
     }
     NBTHandler.flag = 1;
     NBTHandler.id = EntityList.getEntityString(currentEntity);
     // currenttip.add(NBTHandler.id);
     List<String> tips = NBTHandler.getTipsFromNBT(n, holdItemNameReal);
     currenttip.addAll(tips);
   }
   return currenttip;
 }
Exemplo n.º 10
0
  @SubscribeEvent
  /**
   * Used to prevent block destruction if block is a Carpenter's Block and player is holding a
   * Carpenter's tool.
   */
  public void onBlockBreakEvent(BlockEvent.BreakEvent event) {
    EntityPlayer entityPlayer = event.getPlayer();
    ItemStack itemStack = entityPlayer.getHeldItem();

    if (entityPlayer == null || itemStack == null) {
      return;
    }

    Item item = itemStack.getItem();
    if (item == null) {
      return;
    }

    if (event.block instanceof BlockCoverable) {
      if (entityPlayer.capabilities.isCreativeMode
          && (item instanceof ICarpentersHammer || item instanceof ICarpentersChisel)) {
        event.setCanceled(true);
      }
    }
  }
Exemplo n.º 11
0
 @SubscribeEvent
 public void onPlayerInteract(PlayerInteractEvent e) {
   EntityPlayer player = e.entityPlayer;
   if (player != null && !player.worldObj.isRemote) {
     ItemStack heldItem = player.getHeldItem();
     if (heldItem != null && heldItem.getItem() == IntegrationForestry.itemStickImpregnated) {
       if (e.action == Action.RIGHT_CLICK_AIR) {
         findTarget(player);
       } else if (e.action == Action.RIGHT_CLICK_BLOCK) {
         if (player.isSneaking() && e.world.blockExists(e.x, e.y, e.z)) {
           TileEntity te = e.world.getTileEntity(e.x, e.y, e.z);
           if (te instanceof IBeeHousing) {
             makeSwarm(e, player, ((IBeeHousing) te));
           } else {
             findTarget(player);
           }
         } else {
           findTarget(player);
         }
       }
     } else if (heldItem == null && e.action == Action.RIGHT_CLICK_BLOCK) {
       if (player.isSneaking() && e.world.blockExists(e.x, e.y, e.z)) {
         TileEntity te = e.world.getTileEntity(e.x, e.y, e.z);
         if (te instanceof IBeeHousing) {
           makeSwarm(e, player, ((IBeeHousing) te));
         }
       }
     }
   }
 }
 @Override
 public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
   if (toolMaterial == ToolMaterial.EMERALD) {
     if (player.getHeldItem() != null && ZSSPlayerInfo.get(player).canBlock()) {
       Vec3 vec3 = player.getLookVec();
       double dx = player.posX + vec3.xCoord * 2.0D;
       double dy = player.posY + player.getEyeHeight() + vec3.yCoord * 2.0D;
       double dz = player.posZ + vec3.zCoord * 2.0D;
       List<EntityFireball> list =
           player.worldObj.getEntitiesWithinAABB(
               EntityFireball.class,
               AxisAlignedBB.getBoundingBox(dx - 1, dy - 1, dz - 1, dx + 1, dy + 1, dz + 1));
       for (EntityFireball fireball : list) {
         DamageSource source = DamageSource.causeFireballDamage(fireball, fireball.shootingEntity);
         if (canBlockDamage(stack, source)
             && fireball.attackEntityFrom(DamageSource.causePlayerDamage(player), 1.0F)) {
           fireball.getEntityData().setBoolean("isReflected", true);
           ZSSPlayerInfo.get(player).onAttackBlocked(stack, 1.0F);
           WorldUtils.playSoundAtEntity(player, Sounds.HAMMER, 0.4F, 0.5F);
           break;
         }
       }
     }
   }
 }
Exemplo n.º 13
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int par6,
      float par7,
      float par8,
      float par9) {
    IvTileEntityMultiBlock parent = getValidatedTotalParent(this, world, x, y, z);

    if (parent instanceof TileEntityStatue) {
      TileEntityStatue tileEntityStatue = (TileEntityStatue) parent;
      if (tileEntityStatue.tryEquipping(player.getHeldItem())) {
        return true;
      } else {
        tileEntityStatue.dropEquipment();
        return true;
      }
    }

    return super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
  }
Exemplo n.º 14
0
 @Override
 public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) {
   if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack() == player.getHeldItem()) {
     return null;
   }
   return super.slotClick(slot, button, flag, player);
 }
  @Override
  public IMessage onMessage(PacketKurosawaAttack message, MessageContext ctx) {
    EntityPlayer player = ctx.getServerHandler().playerEntity;
    Kurosawa item = (Kurosawa) player.getHeldItem().getItem();

    if (!item.getCooldown()) {
      World world = player.worldObj;
      EntityLivingBase target = (EntityLivingBase) world.getEntityByID(message.targetID);
      Vec3 targetPos = target.getPositionVector();
      Vec3 attackerPos = player.getPositionVector();

      Vec3 distance = targetPos.subtractReverse(attackerPos).normalize();
      distance = new Vec3(distance.xCoord * 3, distance.yCoord * 3, distance.zCoord * 3);

      player.setPositionAndRotation(
          target.posX - distance.xCoord,
          target.posY - distance.yCoord,
          target.posZ - distance.zCoord,
          player.rotationYaw + 180,
          player.rotationPitch);
      player.setRotationYawHead(player.rotationYawHead + 180);
      player.cameraPitch += 180;
      player.setPositionAndUpdate(
          target.posX - distance.xCoord,
          target.posY - distance.yCoord,
          target.posZ - distance.zCoord);
      target.attackEntityFrom(DamageSource.causePlayerDamage(player), 44);
      item.setCooldown();
    }
    return null;
  }
Exemplo n.º 16
0
  @Override
  public boolean onUse(final EntityPlayer player) {
    if (player.worldObj.isRemote) {
      return false;
    }

    Entity targetCl = Minecraft.getMinecraft().pointedEntity;
    Entity targetSr = null;

    if (targetCl != null) {
      targetSr = player.worldObj.getEntityByID(targetCl.getEntityId());
    }

    float base =
        (float) player.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
    float extra = new Random().nextFloat() * 1024 / (2048 - this.getExperience(player));

    if (targetSr instanceof EntityLivingBase) {
      EntityLivingBase entity = (EntityLivingBase) targetSr;
      if (entity instanceof EntitySlime) {
        base = Math.min(base / 5, entity.getHealth() - 0.1F);
        extra = 0F;
      }
      entity.attackEntityFrom(DamageSource.causePlayerDamage(player), base);
      entity.attackEntityFrom(NullaDamageSource.CauseAuroraDamage(player), base * extra);
      double vx = 0.2D * (entity.posX - player.posX);
      double vy = 0.2D * (entity.posY - player.posY + 2D);
      double vz = 0.2D * (entity.posZ - player.posZ);
      Minecraft.getMinecraft().thePlayer.setVelocity(vx, vy, vz);

    } else {
      return false;
    }

    if (player.getHeldItem() != null) {
      player.getHeldItem().damageItem(16, player);
    }

    // 随机事件只在服务器发生
    if (!player.worldObj.isRemote) {
      Random rand = new Random();
      int exp = rand.nextInt(5) + 1;
      modifyExperience(player, exp);
    }

    return true;
  }
Exemplo n.º 17
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    if (world.isRemote) {
      return true;
    }

    ItemStack held = player.getHeldItem();
    FluidStack fluidHeld = FluidContainerRegistry.getFluidForFilledItem(held);
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (fluidHeld != null
        && fluidHeld.getFluid() == FluidRegistry.getFluid("water")
        && tileEntity instanceof TileSolarCollector) {
      TileSolarCollector tank = (TileSolarCollector) tileEntity;
      if (tank.canReceiveWaterBucket()) {
        tank.addBucketOfWater();
        if (FluidContainerRegistry.isBucket(held)
            && !(((EntityPlayerMP) player).theItemInWorldManager.isCreative())) {
          int heldLocation = player.inventory.currentItem;
          player.inventory.decrStackSize(heldLocation, 1);
          world.spawnEntityInWorld(
              new EntityItem(
                  world, player.posX, player.posY, player.posZ, new ItemStack(Items.bucket, 1)));
          //                    player.inventory.setInventorySlotContents(heldLocation, new
          // ItemStack(Items.bucket, 1));
        }
      }
      return true;
    }
    if (held != null
        && held.getItem() == Items.bucket
        && tileEntity instanceof TileSolarCollector) {
      TileSolarCollector tank = (TileSolarCollector) tileEntity;
      if (tank.canGiveSolarWater()) {
        ItemStack filledBucket =
            FluidContainerRegistry.fillFluidContainer(
                new FluidStack(ModFluids.fluidSolarWater, 1000), new ItemStack(Items.bucket, 1));
        tank.removeBucketOfSolarWater();
        if (!(((EntityPlayerMP) player).theItemInWorldManager.isCreative())) {
          player.inventory.decrStackSize(player.inventory.currentItem, 1);
          // player.inventory.setInventorySlotContents(player.inventory.getFirstEmptyStack(),
          // filledBucket);
          world.spawnEntityInWorld(
              new EntityItem(world, player.posX, player.posY, player.posZ, filledBucket));
        }
        return true;
      }
    }

    return false;
  }
Exemplo n.º 18
0
 @Override
 public boolean continueExecuting() {
   if (entity.worldObj != null) {
     if (targetEntity != null
         && targetEntity.getHeldItem(EnumHand.MAIN_HAND) != null) { // TODO Allow Left hand
       if (entity.isValidForPickup(targetEntity.getHeldItem(EnumHand.MAIN_HAND).getItem())
           && entity.isAnySpaceForItemPickup(targetEntity.getHeldItem(EnumHand.MAIN_HAND))
           && !targetEntity.isInWater()
           && !(entity.getDistanceToEntity(targetEntity) > 8)) return true;
     }
   }
   if (entity.worldObj != null && targetEntity != null) {
     switch (randInt) {
       case 0:
         pathFinder.tryMoveToXYZ(
             targetEntity.posX + (rand.nextInt(12) + 8),
             targetEntity.posY,
             targetEntity.posZ + (rand.nextInt(12) + 8),
             this.speed);
         break;
       case 1:
         pathFinder.tryMoveToXYZ(
             targetEntity.posX - (rand.nextInt(12) + 8),
             targetEntity.posY,
             targetEntity.posZ + (rand.nextInt(12) + 8),
             this.speed);
         break;
       case 2:
         pathFinder.tryMoveToXYZ(
             targetEntity.posX + (rand.nextInt(12) + 8),
             targetEntity.posY,
             targetEntity.posZ - (rand.nextInt(12) + 8),
             this.speed);
         break;
       case 3:
         pathFinder.tryMoveToXYZ(
             targetEntity.posX - (rand.nextInt(12) + 8),
             targetEntity.posY,
             targetEntity.posZ - (rand.nextInt(12) + 8),
             this.speed);
         break;
     }
   }
   targetEntity = null;
   return false;
 }
  public boolean interact(EntityPlayer user, boolean leftClk) {
    boolean use = true;
    ItemStack held = user.getHeldItem();
    if (!worldObj.isRemote
        && held != null
        && held.getItem() != null
        && held.getItem() instanceof IUtensil) // BUILD SURFACE
    {
      String type = ((IUtensil) held.getItem()).getType(held);

      if (type.equalsIgnoreCase("mallet")
          && inv[0] != null
          && inv[0].getItem() instanceof ItemBlock) {
        held.damageItem(1, user);
        worldObj.playSoundEffect(
            xCoord + 0.5F,
            yCoord,
            zCoord + 0.5F,
            data_minefantasy.sound("mallet_build"),
            1.0F,
            0.8F + rand.nextFloat() * 0.2F);
        inv[1] = inv[0].copy();
        return true;
      }
    }

    if (!worldObj.isRemote && inv[0] == null && !leftClk) // PUT ITEM
    {
      if (held != null) {
        inv[0] = held.copy();
        inv[0].stackSize = 1;

        if (!user.capabilities.isCreativeMode) {
          held.stackSize--;
          time = 0;
          if (held.stackSize <= 0) {
            held = null;
          }
        }
      } else {
        use = false;
      }
    } else if (!worldObj.isRemote
        && UtensilManager.getTypeOfTool(held) == "Null"
        && !leftClk) // TAKE ITEM
    {
      if (!user.capabilities.isCreativeMode) {
        worldObj.spawnEntityInWorld(
            new EntityItem(worldObj, user.posX, user.posY, user.posZ, inv[0]));
      }
      time = 0;
      inv[0] = null;
    }

    tryToCraft(held, user);

    return use;
  }
Exemplo n.º 20
0
 public static IInventory getBackpackInventory(EntityPlayer player) {
   SimpleInventory inv = null;
   ItemStack held = player.getHeldItem();
   if (held != null && held.itemID == ProjectRedExploration.itemBackpack.itemID) {
     inv = new BagInventory(player, held);
     inv.readFromNBT(held.getTagCompound(), "conents");
   }
   return inv;
 }
Exemplo n.º 21
0
  @Override
  public IMessage onMessage(MessageRangeAttack message, MessageContext ctx) {
    EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity;

    ItemStack stack = entityPlayer.getHeldItem();
    if (stack != null && stack.getItem() instanceof ItemSlashBlade) {
      ((ItemSlashBlade) stack.getItem()).doRangeAttack(stack, entityPlayer, message.mode);
    }
    return null;
  }
  private void stealItems(Entity EntityAvaritia) {
    AxisAlignedBB box = EntityAvaritia.boundingBox.expand(RANGE, RANGE, RANGE);
    Class<EntityPlayer> players = EntityPlayer.class;

    List<EntityPlayer> inbox = EntityAvaritia.worldObj.getEntitiesWithinAABB(players, box);

    for (EntityPlayer entityPlayer : inbox) {
      Random rand1 = new Random();
      int random1 = rand1.nextInt(32) + 1;
      Random rand2 = new Random();
      int random2 = rand2.nextInt(5) + 1;

      if (random1 == 1 && counter >= 20 && !worldObj.isRemote) {
        if (random2 == 1 && entityPlayer.getCurrentArmor(0) != null) {
          ItemStack helm = entityPlayer.getCurrentArmor(0).copy();
          entityPlayer.setCurrentItemOrArmor(1, null);
          entityPlayer.entityDropItem(helm, 1);
        }
        if (random2 == 2 && entityPlayer.getCurrentArmor(1) != null) {
          ItemStack torso = entityPlayer.getCurrentArmor(1).copy();
          entityPlayer.setCurrentItemOrArmor(2, null);
          entityPlayer.entityDropItem(torso, 1);
        }
        if (random2 == 3 && entityPlayer.getCurrentArmor(2) != null) {
          ItemStack leggings = entityPlayer.getCurrentArmor(2).copy();
          entityPlayer.setCurrentItemOrArmor(3, null);
          entityPlayer.entityDropItem(leggings, 1);
        }
        if (random2 == 4 && entityPlayer.getCurrentArmor(3) != null) {
          ItemStack boots = entityPlayer.getCurrentArmor(3).copy();
          entityPlayer.setCurrentItemOrArmor(4, null);
          entityPlayer.entityDropItem(boots, 1);
        }
        if (random2 == 5 && entityPlayer.getHeldItem() != null) {
          ItemStack hand = entityPlayer.getHeldItem().copy();
          entityPlayer.setCurrentItemOrArmor(0, null);
          entityPlayer.entityDropItem(hand, 1);
        }
        counter = 0;
      }
    }
  }
Exemplo n.º 23
0
 public boolean onBlockActivated(
     World world,
     int x,
     int y,
     int z,
     EntityPlayer player,
     int side,
     float xOffset,
     float yOffset,
     float zOffset) {
   if (!world.isRemote) {
     TileEntityFruit teFruit = (TileEntityFruit) world.getBlockTileEntity(x, y, z);
     boolean worked = teFruit.rightClick(player.getHeldItem(), player);
     if (worked && !player.capabilities.isCreativeMode) {
       player.getHeldItem().stackSize--;
     }
   }
   world.markBlockForUpdate(x, y, z);
   return true;
 }
Exemplo n.º 24
0
 @Override
 public boolean itemInteractionForEntity(
     ItemStack itemstack, EntityPlayer player, EntityLivingBase entity) {
   if (this == ToolListMF.bucketwood_empty && entity instanceof EntityCow) {
     ItemStack newStack =
         createNewInstance(player.getHeldItem(), player, ToolListMF.bucketwood_water, 0);
     player.setCurrentItemOrArmor(0, newStack);
     return true;
   }
   return super.itemInteractionForEntity(itemstack, player, entity);
 }
Exemplo n.º 25
0
 @Override
 public boolean shouldExecute() {
   if (!pathFinder.noPath()) {
     return false;
   }
   if (entity.worldObj != null) {
     EntityPlayer player = entity.worldObj.getClosestPlayerToEntity(entity, 8);
     if (player != null
         && player.getHeldItem(EnumHand.MAIN_HAND) != null) { // TODO Allow Left hand
       if (entity.getEntitySenses().canSee(player)
           && entity.isValidForPickup(player.getHeldItem(EnumHand.MAIN_HAND).getItem())
           && entity.isAnySpaceForItemPickup(player.getHeldItem(EnumHand.MAIN_HAND))
           && !player.isInWater()) {
         targetEntity = player;
         randInt = rand.nextInt(4);
         return true;
       }
     }
   }
   return false;
 }
 @Override
 public void renderTileEntityAt(
     TileEntity te, double x, double y, double z, float partialTicks, int destroyStage) {
   EntityPlayer player = Minecraft.getMinecraft().thePlayer;
   if (player.getHeldItem(EnumHand.MAIN_HAND) == null
       || !(player.getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemLightDebugTool)
       || te instanceof TileEntityUVLightBlock) {
     return;
   }
   try {
     GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
     GL11.glPushMatrix();
     GL11.glColor3f(1F, 1F, 0.0F);
     GL11.glLineWidth(2.0F);
     GL11.glDisable(GL11.GL_TEXTURE_2D);
     GL11.glTranslatef((float) x, (float) y, (float) z);
     AxisAlignedBB boundingBox = new AxisAlignedBB(0.002D, 0.002D, 0.002D, 0.998D, 0.998D, 0.998D);
     drawCube(boundingBox);
   } finally {
     GL11.glPopMatrix();
     GL11.glPopAttrib();
   }
 }
Exemplo n.º 27
0
  @Override
  public Object getClientGuiElement(
      int guiId, EntityPlayer player, World world, int x, int y, int z) {
    if (guiId == Reference.GUI_INDEX_KITCREATOR) {

      GuiKitCreator gui = new GuiKitCreator(player, new InventoryKitCreator(player.getHeldItem()));
      LogHelper.info("ClentGuiElement= " + gui);

      return gui;

    } else {
      return null;
    }
  }
 @SubscribeEvent
 public void onLivingUpdate(LivingUpdateEvent event) {
   if (event.entity instanceof EntityPlayer) {
     EntityPlayer player = (EntityPlayer) event.entity;
     ZSSPlayerInfo.get(player).onUpdate();
     if (player.motionY < -0.25D) {
       boolean flag =
           player.getHeldItem() != null && player.getHeldItem().getItem() == ZSSItems.rocsFeather;
       if (flag
           || (player.getCurrentArmor(ArmorIndex.WORN_HELM) != null
               && player.getCurrentArmor(ArmorIndex.WORN_HELM).getItem() == ZSSItems.maskDeku)) {
         player.motionY = -0.25D;
         player.fallDistance = 0.0F;
       }
     }
   }
   if (event.entity instanceof EntityLivingBase) {
     ZSSEntityInfo.get((EntityLivingBase) event.entity).onUpdate();
   }
   if (event.entity instanceof EntityVillager) {
     ZSSVillagerInfo.get((EntityVillager) event.entity).onUpdate();
   }
 }
Exemplo n.º 29
0
 @Override
 public boolean onBlockActivated(
     World world,
     int x,
     int y,
     int z,
     EntityPlayer player,
     int side,
     float vecX,
     float vecY,
     float vecZ) {
   if (!world.isRemote) {
     if (player.getHeldItem() != null) {
       TileEntity entity = world.getBlockTileEntity(x, y, z);
       if (entity instanceof TileBloodDynamo) {
         if (player.getHeldItem().getItem() instanceof IToolWrench) {
           ((TileBloodDynamo) entity).rotateBlock();
         } else if (player.getHeldItem().getItem() == BloodMagic.divinationSigil) {
           player.addChatMessage(
               "Energy: "
                   + ((TileBloodDynamo) entity).getEnergyStored(null)
                   + "/"
                   + ((TileBloodDynamo) entity).getMaxEnergyStored(null));
           player.addChatMessage(
               "Blood: "
                   + ((TileBloodDynamo) entity).tank.getFluidAmount()
                   + "/"
                   + ((TileBloodDynamo) entity).tank.getInfo().capacity);
         }
       }
     } else {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 30
0
  @Override
  public boolean onBlockActivated(
      World worldIn,
      BlockPos pos,
      IBlockState state,
      EntityPlayer player,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    // we allow to insert buckets into the smeltery
    TileEntity te = worldIn.getTileEntity(pos);
    if (!(te instanceof IFluidHandler)) {
      return false;
    }
    IFluidHandler tank = (IFluidHandler) te;
    side = side.getOpposite();

    ItemStack stack = player.getHeldItem();
    if (stack == null) {
      return false;
    }

    // regular bucket
    ItemStack result = FluidUtil.tryEmptyBucket(stack, tank, side);
    if (result != null) {
      if (!player.capabilities.isCreativeMode) {
        player.inventory.decrStackSize(player.inventory.currentItem, 1);
        PlayerHelper.spawnItemAtPlayer(player, result);
      }
      return true;
    }

    // universal bucket
    ItemStack copy = stack.copy();
    if (FluidUtil.tryEmptyFluidContainerItem(stack, tank, side, player)) {
      if (player.capabilities.isCreativeMode) {
        // reset the stack that got modified
        player.inventory.setInventorySlotContents(player.inventory.currentItem, copy);
      }
      return true;
    }

    // prevent interaction of the item if it's a fluidcontainer. Prevents placing liquids when
    // interacting with the tank
    return FluidContainerRegistry.isFilledContainer(stack)
        || stack.getItem() instanceof IFluidContainerItem;
  }