Java 类net.minecraft.util.MovementInput 实例源码

项目:ForgeHax    文件:BoatFly.java   
public static void setMoveSpeedEntity(double speed) {
    if (MC.player != null && MC.player.getRidingEntity() != null) {
        MovementInput movementInput = MC.player.movementInput;
        double forward = movementInput.moveForward;
        double strafe = movementInput.moveStrafe;
        float yaw = MC.player.rotationYaw;

        if ((forward == 0.0D) && (strafe == 0.0D)) {
            MC.player.getRidingEntity().motionX = (0.0D);
            MC.player.getRidingEntity().motionZ = (0.0D);
        } else {
            if (forward != 0.0D) {
                if (strafe > 0.0D) yaw += (forward > 0.0D ? -45 : 45);
                else if (strafe < 0.0D) yaw += (forward > 0.0D ? 45 : -45);

                strafe = 0.0D;

                if (forward > 0.0D) forward = 1.0D;
                else if (forward < 0.0D) forward = -1.0D;
            }
            MC.player.getRidingEntity().motionX = (forward * speed * Math.cos(Math.toRadians(yaw + 90.0F)) + strafe * speed * Math.sin(Math.toRadians(yaw + 90.0F)));
            MC.player.getRidingEntity().motionZ = (forward * speed * Math.sin(Math.toRadians(yaw + 90.0F)) - strafe * speed * Math.cos(Math.toRadians(yaw + 90.0F)));

        }
    }
}
项目:MinecraftForge-BotAPI    文件:PlayerMovementController.java   
public boolean moveStraightTo(final double x,final double y,final double z,boolean autoFace)
{
    System.out.println("Movin to "+x+","+y+","+z);
    if(autoFace)faceTowards(x,y+getPlayer().getEyeHeight(),z);
    MovementInput m = new MovementInput(){
        @Override
        public void updatePlayerMoveState() {
            super.updatePlayerMoveState();
            if((int)(getPlayer().posX)==(int)x&&(int)(getPlayer().posY)==(int)y&&(int)(getPlayer().posZ)==(int)z){
                resetPlayerInput();System.out.println("Player Reached");}
        }
    };
    m.forwardKeyDown=true;
    m.moveForward=1;
    setPlayerInput(m);
    return true;
}
项目:burlapcraft    文件:HelperActions.java   
public static boolean moveForward(boolean jump) {
    MovementInput movement = new MovementInput();
    movement.moveForward = (float) 0.55D;
    movement.jump = jump;

    snapToGrid();

    overrideMovement(movement);

    final Timer timer = new Timer();
    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            resetAllInputs();
            timer.cancel();
        }
    }, 440, 10);

    return true;
}
项目:Farrago    文件:ToolBlockRenderer.java   
@PaneEventHandler
public void onDisplay(PaneDisplayEvent e) {
    oldRenderDistance = mc.gameSettings.renderDistanceChunks;
    mc.gameSettings.renderDistanceChunks = 3;
    fakeWorld = new WorldClient(new NetHandlerPlayClient(Minecraft.getMinecraft(), null, new NetworkManager(true)), new WorldSettings(new WorldInfo(new NBTTagCompound())), 0, EnumDifficulty.EASY, Minecraft.getMinecraft().mcProfiler);
    for (int x = -1; x <= 1; x++) {
        for (int z = -1; z <= 1; z++) {
            fakeWorld.getChunkProvider().loadChunk(x, z);
        }
    }
    fakeWorld.setBlock(0, 64, 0, Blocks.lit_furnace);
    fakeWorld.getGameRules().setOrCreateGameRule("doDaylightCycle", "false");
    fakeWorld.setWorldTime(6000);
    mc.thePlayer = new EntityClientPlayerMP(mc, fakeWorld,
            new FakeSession(), new FakeNetHandler(mc, null, new FakeNetManager(true)),
            new FakeStatFileWriter());
    mc.thePlayer.sendQueue.getNetworkManager().setNetHandler(mc.thePlayer.sendQueue);
    mc.thePlayer.movementInput = new MovementInput();
    mc.playerController = new PlayerControllerMP(mc, mc.thePlayer.sendQueue);
    mc.renderViewEntity = mc.thePlayer;
    mc.theWorld = fakeWorld;
    mc.renderGlobal.setWorldAndLoadRenderers(fakeWorld);
    MinecraftForge.EVENT_BUS.register(this);
}
项目:Zombe-Modpack    文件:DummyPlayer.java   
public DummyPlayer(EntityPlayer player) {
    super(getWorld(player), getProfile(player));
    this.playerBody = player;
    this.inventory = player.inventory;
    this.movementInput = new MovementInput();
    placeAt(player);
}
项目:Backmemed    文件:EntitySpeed.java   
@Override
public void onUpdate(EntityPlayerSP player) {
    if(isEnabled()) {
        if (player.ridingEntity != null) {
            MovementInput movementInput = player.movementInput;
            double forward = movementInput.moveForward;
            double strafe = movementInput.moveStrafe;
            float yaw = player.rotationYaw;
            if ((forward == 0.0D) && (strafe == 0.0D)) {
                player.ridingEntity.motionX = 0.0D;
                player.ridingEntity.motionZ = 0.0D;
            }else{
                if (forward != 0.0D) {
                    if (strafe > 0.0D) {
                        yaw += (forward > 0.0D ? -45 : 45);
                    }else if (strafe < 0.0D) {
                        yaw += (forward > 0.0D ? 45 : -45);
                    }
                    strafe = 0.0D;
                    if (forward > 0.0D) {
                        forward = 1.0D;
                    }else if (forward < 0.0D) {
                        forward = -1.0D;
                    }
                }
                player.ridingEntity.motionX = (forward * entitySpeed.getValue() * Math.cos(Math.toRadians(yaw + 90.0F)) + strafe * entitySpeed.getValue() * Math.sin(Math.toRadians(yaw + 90.0F)));
                player.ridingEntity.motionZ = (forward * entitySpeed.getValue() * Math.sin(Math.toRadians(yaw + 90.0F)) - strafe * entitySpeed.getValue() * Math.cos(Math.toRadians(yaw + 90.0F)));
            }
        }
    }
}
项目:parachute    文件:EntityParachute.java   
public void updateInputs(MovementInput input) {
    if (isBeingRidden() && world.isRemote) {
        double motionFactor = 0.0f;

        if (input.forwardKeyDown) {
            motionFactor += forwardMomentum;
        }
        if (input.backKeyDown) {
            motionFactor -= backMOmentum;
        }
        if (input.leftKeyDown) {
            deltaRotation += -(rotationMomentum);
        }
        if (input.rightKeyDown) {
            deltaRotation += rotationMomentum;
        }

        // slight forward momentum while turning
        if (input.rightKeyDown != input.leftKeyDown && !input.forwardKeyDown && !input.backKeyDown) {
            motionFactor += slideMomentum;
        }

        ascendMode = input.jump;

        motionY -= currentDescentRate();
        rotationYaw += deltaRotation;

        motionX += MathHelper.sin((float) Math.toRadians(-rotationYaw)) * motionFactor;
        motionZ += MathHelper.cos((float) Math.toRadians(rotationYaw)) * motionFactor;

        if (((ConfigHandler.getWeatherAffectsDrift() && isBadWeather()) || allowTurbulence) && rand.nextBoolean()) {
            applyTurbulence(world.isThundering());
        }
    }
}
项目:OpenModsLib    文件:PlayerMovementManager.java   
@SubscribeEvent
public static void updateMovementState(InputUpdateEvent evt) {
    final MovementInput input = evt.getMovementInput();
    final EntityPlayer owner = evt.getEntityPlayer();
    if (input.jump && !wasJumping) input.jump = postMovementEvent(owner, PlayerMovementEvent.Type.JUMP);
    if (input.sneak && !wasSneaking) input.sneak = postMovementEvent(owner, PlayerMovementEvent.Type.SNEAK);

    wasJumping = input.jump;
    wasSneaking = input.sneak;
}
项目:EnderIO    文件:TravelController.java   
@SideOnly(Side.CLIENT)
private void onInput(@Nonnull EntityPlayerSP player) {

  MovementInput input = player.movementInput;
  BlockPos target = TravelController.instance.selectedCoord;
  if (target == null) {
    return;
  }

  TileEntity te = player.world.getTileEntity(target);
  if (te instanceof ITravelAccessable) {
    ITravelAccessable ta = (ITravelAccessable) te;
    if (ta.getRequiresPassword(player)) {
      PacketOpenAuthGui p = new PacketOpenAuthGui(target);
      PacketHandler.INSTANCE.sendToServer(p);
      return;
    }
  }

  if (travelToSelectedTarget(player, Prep.getEmpty(), EnumHand.MAIN_HAND, TravelSource.BLOCK, false)) {
    input.jump = false;
    try {
      ObfuscationReflectionHelper.setPrivateValue(EntityPlayer.class, (EntityPlayer) player, 0, "flyToggleTimer", "field_71101_bC");
    } catch (Exception e) {
      // ignore
    }
  }

}
项目:Proyecto-DASI    文件:CommandForWheeledRobotNavigationImplementation.java   
/** Provide access to the MovementInput object we are using to control the player.<br>
 * This is required by the unit tests.
 * @return our MovementInput object.
 */
public MovementInput getMover()
{
    return this.overrideMovement;
}
项目:Proyecto-DASI    文件:CommandForWheeledRobotNavigationImplementation.java   
/** Provide access to the MovementInput object we are using to control the player.<br>
 * This is required by the unit tests.
 * @return our MovementInput object.
 */
public MovementInput getMover()
{
    return this.overrideMovement;
}
项目:EMC    文件:IMovementInput.java   
private static MovementInput get() {
    return Minecraft.getMinecraft().player.movementInput;
}
项目:Wizardry    文件:NullMovementInput.java   
public NullMovementInput(MovementInput original) {
    this.original = original;
}
项目:malmo    文件:CommandForWheeledRobotNavigationImplementation.java   
/** Provide access to the MovementInput object we are using to control the player.<br>
 * This is required by the unit tests.
 * @return our MovementInput object.
 */
public MovementInput getMover()
{
    return this.overrideMovement;
}
项目:MinecraftForge-BotAPI    文件:PlayerMovementController.java   
public void setPlayerInput(MovementInput i)
{
    if(prevIn==null)prevIn = getPlayer().movementInput;
    getPlayer().movementInput = i;
}
项目:motecraft    文件:MovementInputWiimote.java   
public MovementInputWiimote(MovementInput oldMovementInput,
        WiiMoteListener listener) {
    this.oldMovementInput = oldMovementInput;
    this.listener = listener;

}
项目:morecommands    文件:EntityCamera.java   
public EntityCamera(Minecraft mcIn, World worldIn, NetHandlerPlayClient p_i46278_3_, StatisticsManager p_i46278_4_, RecipeBook p_i46278_5_, MovementInput input) {
       super(mcIn, worldIn, p_i46278_3_, p_i46278_4_, p_i46278_5_);
    this.movementInput = input;
}
项目:burlapcraft    文件:HelperActions.java   
public static void overrideMovement(MovementInput i) {
    if (resetMovementInput == null) {
        resetMovementInput = mc.thePlayer.movementInput;
    }
    mc.thePlayer.movementInput = i;
}
项目:EnderIO    文件:TravelController.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(@Nonnull TickEvent.ClientTickEvent event) {
  if (event.phase == TickEvent.Phase.END) {
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    if (NullHelper.untrust(player) == null) {
      // Log.warn("(in TickEvent.ClientTickEvent) net.minecraft.client.Minecraft.player is marked @Nonnull but it is null.");
      return;
    }
    onBlockCoord = getActiveTravelBlock(player);
    boolean onBlock = onBlockCoord != null;
    showTargets = onBlock || isTravelItemActiveForSelecting(player);
    if (showTargets) {
      updateSelectedTarget(player);
    } else {
      selectedCoord = null;
    }
    MovementInput input = player.movementInput;
    tempJump = input.jump;
    tempSneak = input.sneak;

    // Handles teleportation if a target is selected
    if ((input.jump && !wasJumping && onBlock && selectedCoord != null && delayTimer == 0)
        || (input.sneak && !wasSneaking && onBlock && selectedCoord != null && delayTimer == 0 && Config.travelAnchorSneak)) {

      onInput(player);
      delayTimer = timer;
    }
    // If there is no selected coordinate and the input is jump, go up
    if (input.jump && !wasJumping && onBlock && selectedCoord == null && delayTimer == 0) {

      updateVerticalTarget(player, 1);
      onInput(player);
      delayTimer = timer;

    }

    // If there is no selected coordinate and the input is sneak, go down
    if (input.sneak && !wasSneaking && onBlock && selectedCoord == null && delayTimer == 0) {
      updateVerticalTarget(player, -1);
      onInput(player);
      delayTimer = timer;
    }

    if (delayTimer != 0) {
      delayTimer--;
    }

    wasJumping = tempJump;
    wasSneaking = tempSneak;
    candidates.clear();
  }
}
项目:EnderIO    文件:DarkSteelController.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
  EntityPlayerSP player = Minecraft.getMinecraft().player;

  if (NullHelper.untrust(player) == null) {
    // Log.warn("(in TickEvent.ClientTickEvent) net.minecraft.client.Minecraft.player is marked @Nonnull but it is null.");
    return;
  }
  if (NullHelper.untrust(player.movementInput) == null) {
    // Log.warn("(in TickEvent.ClientTickEvent) net.minecraft.client.entity.EntityPlayerSP.movementInput is marked @Nonnull but it is null.");
    return;
  }

  if (event.phase != TickEvent.Phase.END) {
    jumpPre = player.movementInput.jump;
    return;
  }

  updateNightvision(player);
  if (player.capabilities.isFlying) {
    return;
  }

  MovementInput input = player.movementInput;
  boolean jumpHandled = false;
  if (input.jump && (!wasJumping || ticksSinceLastJump > 5)) {
    jumpHandled = doJump(player);
  }

  if (!jumpHandled && input.jump && !jumpPre && !player.onGround && player.motionY < 0.0D && !player.capabilities.isFlying && isElytraUpgradeEquipped(player)
      && !isElytraActive(player)) {
    DarkSteelController.instance.setActive(player, Type.ELYTRA, true);
    PacketHandler.INSTANCE.sendToServer(new PacketUpgradeState(Type.ELYTRA, true));
  }

  wasJumping = !player.onGround;
  if (!wasJumping) {
    jumpCount = 0;
  }
  ticksSinceLastJump++;

}