コード例 #1
0
 public static void zoom(float value) {
   try {
     ObfuscationReflectionHelper.setPrivateValue(
         EntityRenderer.class, FMLClientHandler.instance().getClient().entityRenderer, value, 15);
     ObfuscationReflectionHelper.setPrivateValue(
         EntityRenderer.class, FMLClientHandler.instance().getClient().entityRenderer, value, 16);
   } catch (final Exception ex) {
     ex.printStackTrace();
   }
 }
コード例 #2
0
  public boolean onUpdate(EntityLiving par1EntityLiving) {
    if (this.getDuration() < fadeTime) {
      fadeTime = 0;
      int amp = Math.max(this.getAmplifier() - 1, 0);
      ObfuscationReflectionHelper.setPrivateValue(PotionEffect.class, this, (Integer) amp, 2);

      if (!ObfuscationReflectionHelper.obfuscation)
        ObfuscationReflectionHelper.setPrivateValue(
            EntityLiving.class, par1EntityLiving, true, "potionsNeedUpdate");
      else
        ObfuscationReflectionHelper.setPrivateValue(
            EntityLiving.class, par1EntityLiving, true, "h");
    }
    return super.onUpdate(par1EntityLiving);
  }
コード例 #3
0
 static {
   ArrayList<String> q = new ArrayList<String>();
   q.add("recentlyHit");
   q.addAll(
       Arrays.asList(
           ObfuscationReflectionHelper.remapFieldNames(
               "net.minecraft.entity.EntityLiving", new String[] {"field_70718_bc"})));
   recentlyHit = ReflectionHelper.findField(EntityLiving.class, q.toArray(new String[q.size()]));
 }
コード例 #4
0
ファイル: FMLClientHandler.java プロジェクト: smcv/FML
 @Override
 public void serverStopped() {
   // If the server crashes during startup, it might hang the client- reset the client so it can
   // abend properly.
   if (!getServer().func_71200_ad()) {
     ObfuscationReflectionHelper.setPrivateValue(
         MinecraftServer.class, getServer(), true, "field_71296" + "_Q", "serverIs" + "Running");
   }
 }
コード例 #5
0
ファイル: Proxy.java プロジェクト: RustyXXL/DenPipes
 public void registerPipe(ItemPipe pipe, Class c, String name) {
   ValvePipeManagers.PipeManager.registerPipe(pipe, name);
   Item i = (Item) pipe;
   try {
     ObfuscationReflectionHelper.setPrivateValue(Item.class, i, "cl", name);
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
コード例 #6
0
 public void registerAsResourceLocation() {
   // List<IResourcePack> values = ReflectionHelper.getPrivateValue(Minecraft.class,
   // Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao");
   // values.add(this);
   // ReflectionHelper.setPrivateValue(Minecraft.class, Minecraft.getMinecraft(), values,
   // "defaultResourcePacks", "field_110449_ao");
   List<IResourcePack> defaultResourcePacks =
       ObfuscationReflectionHelper.getPrivateValue(
           Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao");
   defaultResourcePacks.add(this);
 }
コード例 #7
0
ファイル: PotionTimers.java プロジェクト: kevinwchang/zyinhud
  /**
   * Disables the potion effects from rendering by telling the Gui that the player has no potion
   * effects applied. Uses reflection to grab the class's private variable.
   *
   * @param guiScreen the screen the player is looking at which extends InventoryEffectRenderer
   */
  public static void DisableInventoryPotionEffects(InventoryEffectRenderer guiScreen) {
    if (PotionTimers.Enabled && HidePotionEffectsInInventory) {
      // Note for future Forge versions: field "field_147045_u" will probably be renamed to
      // something like "playerHasPotionEffects"
      boolean playerHasPotionEffects =
          ObfuscationReflectionHelper.getPrivateValue(
              InventoryEffectRenderer.class, (InventoryEffectRenderer) guiScreen, "field_147045_u");

      if (playerHasPotionEffects) {
        int guiLeftPx = (guiScreen.width - 176) / 2;

        ObfuscationReflectionHelper.setPrivateValue(
            GuiContainer.class, (GuiContainer) guiScreen, guiLeftPx, "field_147003_i", "guiLeft");
        ObfuscationReflectionHelper.setPrivateValue(
            InventoryEffectRenderer.class,
            (InventoryEffectRenderer) guiScreen,
            false,
            "field_147045_u");
      }
    }
  }
コード例 #8
0
 @Override
 public void renderTick(EntityPlayerCustom playerCustom) {
   if (playerCustom.isRolling
       || (Util.isCube(
               Minecraft.getMinecraft()
                   .theWorld
                   .getBlock(
                       MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posX),
                       MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posY),
                       MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posZ)))
           && playerCustom.wasRolling)) {
     int x1 = MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posX);
     int y1 = MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posY);
     int z1 = MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posZ);
     ExtendedBlockStorage ebs =
         ((ExtendedBlockStorage[])
                 ObfuscationReflectionHelper.getPrivateValue(
                     Chunk.class,
                     Minecraft.getMinecraft().thePlayer.worldObj.getChunkFromBlockCoords(x1, z1),
                     2))
             [y1 >> 4];
     if (ebs.getExtSkylightValue((x1 & 15), y1 & 15, (z1 & 15)) == 0) {
       ebs.setExtSkylightValue((x1 & 15), y1 & 15, (z1 & 15), playerCustom.lastLightValue);
     }
     playerCustom.lastLightValue = (byte) ebs.getExtSkylightValue((x1 & 15), y1 & 15, (z1 & 15));
     KeyBinding.setKeyBindState(
         Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), true);
     if (renderer == null) {
       renderer = new EntityRendererCustom(Minecraft.getMinecraft());
     }
     if (Minecraft.getMinecraft().entityRenderer != renderer) {
       // be sure to store the previous renderer
       prevRenderer = Minecraft.getMinecraft().entityRenderer;
       Minecraft.getMinecraft().entityRenderer = renderer;
     }
   } else if (prevRenderer != null
       && Minecraft.getMinecraft().entityRenderer != prevRenderer
       && playerCustom.wasRolling) {
     // reset the renderer
     KeyBinding.setKeyBindState(
         Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), false);
     Minecraft.getMinecraft().entityRenderer = prevRenderer;
     playerCustom.wasRolling = false;
   }
   if (!playerCustom.wasRolling) {
     playerCustom.wasRolling = playerCustom.isRolling;
   }
 }
コード例 #9
0
  @Override
  protected boolean checkHotbarKeys(final int keyCode) {
    final Slot theSlot;

    try {
      theSlot =
          ObfuscationReflectionHelper.getPrivateValue(
              GuiContainer.class, this, "theSlot", "field_147006_u", "f");
    } catch (final Throwable t) {
      return false;
    }

    if (this.mc.thePlayer.inventory.getItemStack() == null && theSlot != null) {
      for (int j = 0; j < 9; ++j) {
        if (keyCode == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode()) {
          final List<Slot> slots = this.getInventorySlots();
          for (final Slot s : slots) {
            if (s.getSlotIndex() == j
                && s.inventory == ((AEBaseContainer) this.inventorySlots).getPlayerInv()) {
              if (!s.canTakeStack(((AEBaseContainer) this.inventorySlots).getPlayerInv().player)) {
                return false;
              }
            }
          }

          if (theSlot.getSlotStackLimit() == 64) {
            this.handleMouseClick(theSlot, theSlot.slotNumber, j, 2);
            return true;
          } else {
            for (final Slot s : slots) {
              if (s.getSlotIndex() == j
                  && s.inventory == ((AEBaseContainer) this.inventorySlots).getPlayerInv()) {
                NetworkHandler.instance.sendToServer(
                    new PacketSwapSlots(s.slotNumber, theSlot.slotNumber));
                return true;
              }
            }
          }
        }
      }
    }

    return false;
  }
コード例 #10
0
ファイル: MovementGrab.java プロジェクト: Almamu/CubesEdge
  @Override
  public void control(EntityPlayerCustom playerCustom, EntityPlayer player, Side side) {
    int x = MathHelper.floor_double(player.posX);
    int y = MathHelper.floor_double(player.posY);
    int z = MathHelper.floor_double(player.posZ);
    int heading = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    if (!playerCustom.isSneaking) {
      if (((((Util.isCube(player.worldObj.getBlock(x, y, z - 1)) && heading == 2)
                  || (Util.isCube(player.worldObj.getBlock(x, y, z + 1)) && heading == 0)
                  || (Util.isCube(player.worldObj.getBlock(x - 1, y, z)) && heading == 1)
                  || (Util.isCube(player.worldObj.getBlock(x + 1, y, z)) && heading == 3))
              && ((!Util.isCube(player.worldObj.getBlock(x, y + 1, z - 1)) && heading == 2)
                  || (!Util.isCube(player.worldObj.getBlock(x, y + 1, z + 1)) && heading == 0)
                  || (!Util.isCube(player.worldObj.getBlock(x - 1, y + 1, z)) && heading == 1)
                  || (!Util.isCube(player.worldObj.getBlock(x + 1, y + 1, z)) && heading == 3))
              && (!Util.isCube(player.worldObj.getBlock(x, y - 2, z)))))
          && player.worldObj.getBlock(x, y, z) != Blocks.ladder
          && player.getCurrentEquippedItem() == null) {
        playerCustom.isGrabbing = true;
        playerCustom.rotationYaw = player.rotationYaw;
        playerCustom.rotationPitch = player.rotationPitch;
        playerCustom.prevRotationPitch = player.prevRotationPitch;
        playerCustom.prevRotationYaw = player.prevRotationYaw;
        playerCustom.grabbingDirections[heading] = true;
        if (heading == 0) {
          playerCustom.grabbingDirections[3] = true;
        } else {
          playerCustom.grabbingDirections[heading - 1] = true;
        }

        if (heading == 3) {
          playerCustom.grabbingDirections[0] = true;
        } else {
          playerCustom.grabbingDirections[heading + 1] = true;
        }
      } else {
        playerCustom.isGrabbing = false;
        playerCustom.rotationYaw = 0;
        if (!playerCustom.isRolling) {
          playerCustom.rotationPitch = 0;
        }
        playerCustom.prevRotationPitch = 0;
        playerCustom.prevRotationYaw = 0;
        playerCustom.grabbingDirections[0] = false;
        playerCustom.grabbingDirections[1] = false;
        playerCustom.grabbingDirections[2] = false;
        playerCustom.grabbingDirections[3] = false;
      }
      if (playerCustom.isGrabbing && !playerCustom.wasSneaking && player.isSneaking()) {
        playerCustom.wasSneaking = true;
      }
      if (!playerCustom.isGrabbing) {
        playerCustom.wasSneaking = false;
      }
      if (playerCustom.wasSneaking) {
        return;
      }
      if (!player.isSneaking()
          && !(Boolean)
              ObfuscationReflectionHelper.getPrivateValue(
                  EntityLivingBase.class, (EntityLivingBase) player, 41)
          && playerCustom.isGrabbing) {
        if (heading == 1 || heading == 3) {
          player.setPosition(x + 0.5F, y + 0.9F, player.posZ);
          player.motionX = 0;
        }
        if (heading == 2 || heading == 0) {
          player.setPosition(player.posX, y + 0.9F, z + 0.5F);
          player.motionZ = 0;
        }
        player.motionY = 0.0;
        if (player.isSprinting()) {
          player.setSprinting(false);
        }
      } else if ((Boolean)
              ObfuscationReflectionHelper.getPrivateValue(
                  EntityLivingBase.class, (EntityLivingBase) player, 41)
          && playerCustom.isGrabbing) {
        player.motionY = 0.55D;
      }
    }

    //		if(side == Side.CLIENT){
    ////			Util.channel.sendToServer(new CPacketPlayerAction(playerCustom.isGrabbing ? 0 : 1));
    //		}
    //
    //		if(side == Side.SERVER){
    //			System.out.println("1 : " + playerCustom.isGrabbing);
    //		}
    /*    CLIENT    */
    if (!player.worldObj.isRemote) {
      if (playerCustom.isGrabbing && !player.capabilities.isCreativeMode) {
        PotionEffect potioneffect = player.getActivePotionEffect(Potion.jump);
        float f1 = potioneffect != null ? (float) (potioneffect.getAmplifier() + 1) : 0.0F;
        int i = MathHelper.ceiling_float_int(player.fallDistance - 3.0F - f1);
        if (i > 0) {
          player.playSound(
              i > 4 ? "game.neutral.hurt.fall.big" : "game.neutral.hurt.fall.small", 1.0F, 1.0F);
          damageEntity(EntityLivingBase.class, player, DamageSource.fall, (float) i);
        }
        player.fallDistance = 0;
      }
    }
  }
コード例 #11
0
ファイル: FlansModClient.java プロジェクト: Kirby859/FlansMod
  public static void tick() {
    if (minecraft.thePlayer == null) return;

    if (minecraft.thePlayer.ridingEntity instanceof IControllable
        && minecraft.currentScreen == null)
      minecraft.displayGuiScreen(
          new GuiDriveableController((IControllable) minecraft.thePlayer.ridingEntity));
    // Guns
    if (shootTime > 0) shootTime--;
    if (scopeTime > 0) scopeTime--;
    if (playerRecoil > 0) playerRecoil *= 0.8F;
    minecraft.thePlayer.rotationPitch -= playerRecoil;
    antiRecoil += playerRecoil;

    minecraft.thePlayer.rotationPitch += antiRecoil * 0.2F;
    antiRecoil *= 0.8F;

    Item itemInHand = null;
    ItemStack itemstackInHand = minecraft.thePlayer.inventory.getCurrentItem();
    if (itemstackInHand != null) itemInHand = itemstackInHand.getItem();
    if (itemInHand != null) {
      if (!(itemInHand instanceof ItemGun && ((ItemGun) itemInHand).type.hasScope)) {
        newZoom = 1.0F;
      }
    }

    float dZoom = newZoom - playerZoom;
    playerZoom += dZoom / 3F;
    if (playerZoom < 1.1F && zoomOverlay != null) {
      minecraft.gameSettings.mouseSensitivity = originalMouseSensitivity;
      playerZoom = 1.0F;
      zoomOverlay = null;
      minecraft.gameSettings.hideGUI = originalHideGUI;
      minecraft.gameSettings.thirdPersonView = originalThirdPerson;
    }

    if (Math.abs(playerZoom - lastPlayerZoom) > 1F / 64F) {
      try {
        ObfuscationReflectionHelper.setPrivateValue(
            EntityRenderer.class,
            minecraft.entityRenderer,
            playerZoom,
            "cameraZoom",
            "Y",
            "field_78503_V");
      } catch (Exception e) {
        log("I forgot to update obfuscated reflection D:");
        throw new RuntimeException(e);
      }
    }
    lastPlayerZoom = playerZoom;
    if (minecraft.thePlayer.ridingEntity instanceof IControllable) {
      inPlane = true;
      try {
        ObfuscationReflectionHelper.setPrivateValue(
            EntityRenderer.class,
            minecraft.entityRenderer,
            ((IControllable) minecraft.thePlayer.ridingEntity).getPlayerRoll(),
            "camRoll",
            "N",
            "field_78495_O");
      } catch (Exception e) {
        log("I forgot to update obfuscated reflection D:");
        throw new RuntimeException(e);
      }
      if (minecraft.thePlayer.ridingEntity instanceof IControllable) {
        try {
          ObfuscationReflectionHelper.setPrivateValue(
              EntityRenderer.class,
              minecraft.entityRenderer,
              ((IControllable) minecraft.thePlayer.ridingEntity).getCameraDistance(),
              "thirdPersonDistance",
              "A",
              "field_78490_B");
        } catch (Exception e) {
          log("I forgot to update obfuscated reflection D:");
          throw new RuntimeException(e);
        }
      }
    } else if (inPlane) {
      try {
        ObfuscationReflectionHelper.setPrivateValue(
            EntityRenderer.class, minecraft.entityRenderer, 0F, "camRoll", "N", "field_78495_O");
      } catch (Exception e) {
        log("I forgot to update obfuscated reflection D:");
        throw new RuntimeException(e);
      }
      try {
        ObfuscationReflectionHelper.setPrivateValue(
            EntityRenderer.class,
            minecraft.entityRenderer,
            4.0F,
            "thirdPersonDistance",
            "A",
            "field_78490_B");
      } catch (Exception e) {
        log("I forgot to update obfuscated reflection D:");
        throw new RuntimeException(e);
      }
      inPlane = false;
    }
    if (controlModeSwitchTimer > 0) controlModeSwitchTimer--;
    if (errorStringTimer > 0) errorStringTimer--;
  }
コード例 #12
0
ファイル: NBTPlugin.java プロジェクト: asiekierka/Railcraft
 public NBTList(NBTTagList nbtList) {
   this.nbtList = nbtList;
   backingList = ObfuscationReflectionHelper.getPrivateValue(NBTTagList.class, nbtList, 0);
 }
コード例 #13
0
 public BlockReinforcedIronBars(
     String par2Str, String par3Str, Material par4Material, boolean par5) {
   super(par2Str, par3Str, par4Material, par5);
   ObfuscationReflectionHelper.setPrivateValue(Block.class, this, Block.soundTypeMetal, 32);
 }