@Override
  public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
    if (world.isRemote || !(entity instanceof EntityMinecartEmpty)) {
      return;
    }
    EntityMinecart minecart = (EntityMinecart) entity;
    if (minecart.riddenByEntity != null) {
      return;
    }

    AxisAlignedBB bb =
        AxisAlignedBB.getBoundingBox(
            x - MFRConfig.getInstance().passengerRailSearchMaxHorizontal,
            y - MFRConfig.getInstance().passengerRailSearchMaxVertical,
            z - MFRConfig.getInstance().passengerRailSearchMaxHorizontal,
            x + MFRConfig.getInstance().passengerRailSearchMaxHorizontal + 1,
            y + MFRConfig.getInstance().passengerRailSearchMaxVertical + 1,
            z + MFRConfig.getInstance().passengerRailSearchMaxHorizontal + 1);

    @SuppressWarnings("rawtypes")
    List entities = world.getEntitiesWithinAABB(EntityPlayer.class, bb);

    for (Object o : entities) {
      if (!(o instanceof EntityPlayer)) {
        continue;
      }
      ((EntityPlayer) o).mountEntity(minecart);
      return;
    }
  }
  private void func_110237_h(EntityPlayer p_110237_1_) {
    p_110237_1_.rotationYaw = this.rotationYaw;
    p_110237_1_.rotationPitch = this.rotationPitch;
    this.setEatingHaystack(false);
    this.setRearing(false);

    if (!this.worldObj.isRemote) {
      p_110237_1_.mountEntity(this);
    }
  }
예제 #3
0
 @Override
 public void updateTask() {
   super.updateTask();
   World world = minime.worldObj;
   if (!world.isRemote && canRidePlayer(targetPlayer)) {
     if (minime.getDistanceToEntity(targetPlayer) < 1.0) {
       targetPlayer.mountEntity(minime);
     }
   }
 }
예제 #4
0
  @Override
  public boolean interactFirst(EntityPlayer var1) {
    if (this.worldObj.isRemote) {
      if (this.riddenByEntity == null) {
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCKeyHandler.leftKey.keyCode)
                    + " / "
                    + Keyboard.getKeyName(GCKeyHandler.rightKey.keyCode)
                    + "  - "
                    + LanguageRegistry.instance().getStringLocalization("gui.buggy.turn.name")));
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCKeyHandler.accelerateKey.keyCode)
                    + "       - "
                    + LanguageRegistry.instance().getStringLocalization("gui.buggy.accel.name")));
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCKeyHandler.decelerateKey.keyCode)
                    + "       - "
                    + LanguageRegistry.instance().getStringLocalization("gui.buggy.decel.name")));
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCKeyHandler.openSpaceshipInv.keyCode)
                    + "       - "
                    + LanguageRegistry.instance().getStringLocalization("gui.buggy.inv.name")));
      }

      return true;
    } else {
      if (this.riddenByEntity != null) {
        var1.mountEntity(null);
        return true;
      } else {
        var1.mountEntity(this);
        return true;
      }
    }
  }
  @Override
  public boolean interactFirst(EntityPlayer var1) {
    if (this.worldObj.isRemote) {
      if (this.riddenByEntity == null) {
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCCoreKeyHandlerClient.leftKey.keyCode)
                    + " / "
                    + Keyboard.getKeyName(GCCoreKeyHandlerClient.rightKey.keyCode)
                    + "  - "
                    + StatCollector.translateToLocal("gui.buggy.turn.name")));
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCCoreKeyHandlerClient.accelerateKey.keyCode)
                    + "       - "
                    + StatCollector.translateToLocal("gui.buggy.accel.name")));
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCCoreKeyHandlerClient.decelerateKey.keyCode)
                    + "       - "
                    + StatCollector.translateToLocal("gui.buggy.decel.name")));
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCCoreKeyHandlerClient.openSpaceshipInv.keyCode)
                    + "       - "
                    + StatCollector.translateToLocal("gui.buggy.inv.name")));
      }

      return true;
    } else {
      if (this.riddenByEntity != null) {
        var1.mountEntity(null);
        return true;
      } else {
        var1.mountEntity(this);
        return true;
      }
    }
  }
예제 #6
0
  @Override
  public boolean interact(EntityPlayer entityPlayer) {
    // Only the owner can interact with extended spiders.
    if (owner.equals(entityPlayer.getUniqueID())) {
      // Pack spider displays its inventory.
      if (spiderType == EnumSpiderType.PACK) {
        entityPlayer.displayGUIChest(inventory);
      }

      // Rider spider causes the player to mount it.
      else if (spiderType == EnumSpiderType.RIDER) {
        entityPlayer.rotationYaw = rotationYaw;
        entityPlayer.rotationPitch = rotationPitch;

        if (!worldObj.isRemote) {
          entityPlayer.mountEntity(this);
        }
      }
    }

    return true;
  }
예제 #7
0
    @Override
    public IMessage onMessage(ChocoboMount message, MessageContext ctx) {

      EntityAnimalChocobo chocobo =
          PacketHelper.getChocoboByID(message.entityID, message.dimensionId);
      if (chocobo != null && chocobo instanceof EntityChocoboRideable) {
        EntityChocoboRideable chocoboRideable = (EntityChocoboRideable) chocobo;
        if (message.playerName.isEmpty()) {
          chocoboRideable.riddenByEntity = null;
          chocoboRideable.setJumping(false);
          chocoboRideable.setStepHeight(false);
          chocoboRideable.setLandSpeedFactor(false);
          chocoboRideable.setJumpHigh(false);
        } else {
          EntityPlayer rider = PacketHelper.getPlayer(message.playerName, message.dimensionId);
          rider.setSprinting(false);
          rider.mountEntity(chocoboRideable);
          chocoboRideable.setStepHeight(true);
          chocoboRideable.setLandSpeedFactor(true);
          chocoboRideable.setJumpHigh(true);
        }
      }
      return null;
    }
예제 #8
0
  @SubscribeEvent
  public void sleepInBed(PlayerSleepInBedEvent event) {
    SettingEntry se = null;
    if (event.entityPlayer.worldObj.isRemote) {
      se = PerfectSpawnClientHandler.currentServerSettings;
    } else {
      se = PerfectSpawn.settings.getValidSettingEntry();
    }

    if (se != null && se.forceBed) {
      WorldProvider provider = event.entityPlayer.worldObj.provider;
      EntityPlayer player = event.entityPlayer;
      World worldObj = player.worldObj;

      if (provider.dimensionId == se.spawnDimension) {
        event.result = EntityPlayer.EnumStatus.OK;
        if (player.isPlayerSleeping() || !player.isEntityAlive()) {
          event.result = EntityPlayer.EnumStatus.OTHER_PROBLEM;
        }

        if (!player.worldObj.isDaytime() && provider.isSurfaceWorld()) {
          event.result = EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW;
        }

        if (Math.abs(player.posX - (double) event.x) > 3.0D
            || Math.abs(player.posY - (double) event.y) > 2.0D
            || Math.abs(player.posZ - (double) event.z) > 3.0D) {
          event.result = EntityPlayer.EnumStatus.TOO_FAR_AWAY;
        }

        double d0 = 8.0D;
        double d1 = 5.0D;
        List list =
            player.worldObj.getEntitiesWithinAABB(
                EntityMob.class,
                AxisAlignedBB.getBoundingBox(
                    (double) event.x - d0,
                    (double) event.y - d1,
                    (double) event.z - d0,
                    (double) event.x + d0,
                    (double) event.y + d1,
                    (double) event.z + d0));

        if (!list.isEmpty()) {
          event.result = EntityPlayer.EnumStatus.NOT_SAFE;
        }
      }

      if (player.isRiding()) {
        player.mountEntity((Entity) null);
      }

      this.setSize(player, 0.2F, 0.2F);
      player.yOffset = 0.2F;

      if (player.worldObj.blockExists(event.x, event.y, event.z)) {
        int l =
            worldObj
                .getBlock(event.x, event.y, event.z)
                .getBedDirection(worldObj, event.x, event.y, event.z);
        float f1 = 0.5F;
        float f = 0.5F;

        switch (l) {
          case 0:
            f = 0.9F;
            break;
          case 1:
            f1 = 0.1F;
            break;
          case 2:
            f = 0.1F;
            break;
          case 3:
            f1 = 0.9F;
        }

        this.func_71013_b(player, l);
        player.setPosition(
            (double) ((float) event.x + f1),
            (double) ((float) event.y + 0.9375F),
            (double) ((float) event.z + f));
      } else {
        player.setPosition(
            (double) ((float) event.x + 0.5F),
            (double) ((float) event.y + 0.9375F),
            (double) ((float) event.z + 0.5F));
      }

      try {
        sleepTimer.set(player, 0);
        sleeping.set(player, true);
      } catch (Exception e) {
        PerfectSpawn.instance.logger.log(Level.ERROR, "Couldn't reflect on player bed data");
        e.printStackTrace();
      }

      player.playerLocation = new ChunkCoordinates(event.x, event.y, event.z);
      player.motionX = player.motionZ = player.motionY = 0.0D;

      if (!player.worldObj.isRemote) {
        player.worldObj.updateAllPlayersSleepingFlag();
      }
    }
  }
  @Override
  public ItemStack onItemRightClick(
      ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    PropertyDoom doom = PropertyDoom.get(par3EntityPlayer);

    if (!par3EntityPlayer.isSneaking()
        || !TragicWeapon.canUseAbility(doom, TragicConfig.doomAbilityCost[5])) {
      ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);
      MinecraftForge.EVENT_BUS.post(event);
      if (event.isCanceled()) return event.result;

      if (par3EntityPlayer.capabilities.isCreativeMode
          || par3EntityPlayer.inventory.hasItem(Items.arrow)) {
        par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
      }
    } else {
      if (TragicWeapon.getStackCooldown(par1ItemStack) == 0 && TragicConfig.doomAbility[8]) {
        float f = 1.0F;
        float f1 =
            par3EntityPlayer.prevRotationPitch
                + (par3EntityPlayer.rotationPitch - par3EntityPlayer.prevRotationPitch) * f;
        float f2 =
            par3EntityPlayer.prevRotationYaw
                + (par3EntityPlayer.rotationYaw - par3EntityPlayer.prevRotationYaw) * f;
        double d0 =
            par3EntityPlayer.prevPosX + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * f;
        double d1 =
            par3EntityPlayer.prevPosY
                + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * f
                + (par3EntityPlayer.worldObj.isRemote
                    ? par3EntityPlayer.getEyeHeight() - par3EntityPlayer.getDefaultEyeHeight()
                    : par3EntityPlayer
                        .getEyeHeight()); // isRemote check to revert changes to ray trace position
        // due to adding the eye height clientside and player
        // yOffset differences
        double d2 =
            par3EntityPlayer.prevPosZ + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * f;
        Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
        float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
        float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
        float f5 = -MathHelper.cos(-f1 * 0.017453292F);
        float f6 = MathHelper.sin(-f1 * 0.017453292F);
        float f7 = f4 * f5;
        float f8 = f3 * f5;
        double d3 = 50.0D;

        if (par3EntityPlayer instanceof EntityPlayerMP) {
          d3 =
              ((EntityPlayerMP) par3EntityPlayer).theItemInWorldManager.getBlockReachDistance()
                  + 46.0;
        }

        Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
        MovingObjectPosition mop =
            par3EntityPlayer.worldObj.func_147447_a(vec3, vec31, true, false, true);

        if (mop == null) {
          if (!par2World.isRemote)
            par3EntityPlayer.addChatMessage(new ChatComponentText("Out of range to teleport to!"));
          return par1ItemStack;
        }

        if (mop.typeOfHit == MovingObjectType.BLOCK
            && par3EntityPlayer instanceof EntityPlayerMP
            && ((EntityPlayerMP) par3EntityPlayer)
                .playerNetServerHandler
                .func_147362_b()
                .isChannelOpen()) {
          if (par3EntityPlayer.isRiding()) par3EntityPlayer.mountEntity((Entity) null);

          double d4 = WorldHelper.getXPositionFromSide(mop.sideHit, mop.hitVec.xCoord);
          double d5 = WorldHelper.getYPositionFromSide(mop.sideHit, mop.hitVec.yCoord);
          double d6 = WorldHelper.getZPositionFromSide(mop.sideHit, mop.hitVec.zCoord);

          par3EntityPlayer.setPositionAndUpdate(d4, d5, d6);
          par3EntityPlayer.fallDistance = 0.0F;
          if (!par3EntityPlayer.capabilities.isCreativeMode)
            doom.increaseDoom(-TragicConfig.doomAbilityCost[8]);
          TragicWeapon.setStackCooldown(par1ItemStack, 5);
        }
      }
    }
    return par1ItemStack;
  }