public static void setVillagerCareer(EntityVillager merchant, int c) { ObfuscationReflectionHelper.setPrivateValue(EntityVillager.class, merchant, c, "careerId", "field_175563_bv"); }
/** * 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"); } } }
protected void initBlockState() { BlockStateContainer stateContainer = createStateContainer(); ObfuscationReflectionHelper.setPrivateValue(Block.class, this, stateContainer, 21); //this.stateContainer setDefaultState(stateContainer.getBaseState()); }
protected void initBlockState() { BlockStateContainer stateContainer = createStateContainer(); ObfuscationReflectionHelper.setPrivateValue(Block.class, this, stateContainer, 21); //this.stateContainer setDefaultState(stateContainer.getBaseState()); }
private void startConverting(EntityZombieVillager v, int t) { // v.conversionTime = t; ObfuscationReflectionHelper.setPrivateValue(EntityZombieVillager.class, v, t, "conversionTime", "field_82234_d"); v.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, t, Math.min(v.world.getDifficulty().getId() - 1, 0))); v.world.setEntityState(v, (byte) 16); try { // v.getDataManager().set(CONVERTING, Boolean.valueOf(true)); DataParameter<Boolean> CONVERTING = ObfuscationReflectionHelper.getPrivateValue(EntityZombieVillager.class, v, "CONVERTING", "field_184739_bx"); v.getDataManager().set(CONVERTING, Boolean.valueOf(true)); } catch (Exception e) {} } }
@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 } } }
ObfuscationReflectionHelper.setPrivateValue(NetHandlerPlayServer.class, ((EntityPlayerMP) entity).connection, 0, "field_147365_f"); } catch (RuntimeException ignored) {
public void onSleepSuccess(World world, EnumHand hand, ItemStack stack, EntityPlayerMP player, final IPlayerExtendedProperties sleep) { sleep.setSleeping(true); if (doPotions) { player.addPotionEffect(new PotionEffect(MobEffects.MINING_FATIGUE, seconds * Const.TICKS_PER_SEC, Const.Potions.I)); player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, seconds * Const.TICKS_PER_SEC, Const.Potions.I)); } this.onUse(stack, player, world, hand); //hack because vanilla/forge has that java.lang.IllegalArgumentException: Cannot get property PropertyDirection error with assuming its a bed when its blocks.air ObfuscationReflectionHelper.setPrivateValue(EntityPlayer.class, player, true, "sleeping", "field_71083_bS"); ObfuscationReflectionHelper.setPrivateValue(EntityPlayer.class, player, 0, "sleepTimer", "field_71076_b"); UtilChat.sendStatusMessage(player, this.getTranslationKey() + ".trying"); //first set bed location player.bedLocation = player.getPosition(); ModCyclic.network.sendTo(new PacketSleepClient(player.bedLocation), player); //then stop player in place player.motionX = player.motionZ = player.motionY = 0; world.updateAllPlayersSleepingFlag(); //then trigger vanilla sleep event(s) // world.setBlockState(player.getPosition(), Blocks.BED.getDefaultState()); SPacketUseBed sleepPacket = new SPacketUseBed(player, player.getPosition()); player.getServerWorld().getEntityTracker().sendToTracking(player, sleepPacket); player.connection.sendPacket(sleepPacket); if (this.isOn(stack)) { player.setSpawnPoint(player.getPosition(), true);//true means it wont check for bed block } }
@Override public void setCollisionBoundingBox(EntityGate gate) { if (gate.pos1 == null || gate.pos2 == null) { return; } BlockPos min = BlockTools.getMin(gate.pos1, gate.pos2); BlockPos max = BlockTools.getMax(gate.pos1, gate.pos2); if (!(gate.getEntityBoundingBox() instanceof DualBoundingBox)) { try { ObfuscationReflectionHelper.setPrivateValue(Entity.class, gate, new DualBoundingBox(min, max), "boundingBox", "field_70121_D"); } catch (Exception ignored) { //ignored } } if (gate.edgePosition > 0) { gate.setEntityBoundingBox(new AxisAlignedBB(min.getX(), max.getY() + 0.5d, min.getZ(), max.getX() + 1, max.getY() + 1, max.getZ() + 1)); } else { gate.setEntityBoundingBox(new AxisAlignedBB(min.getX(), min.getY(), min.getZ(), max.getX() + 1, max.getY() + 1, max.getZ() + 1)); } }
@Override public void setCollisionBoundingBox(EntityGate gate) { if (gate.pos1 == null || gate.pos2 == null) { return; } BlockPos min = BlockTools.getMin(gate.pos1, gate.pos2); BlockPos max = BlockTools.getMax(gate.pos1, gate.pos2); updateRenderBoundingBox(gate); if (gate.edgePosition == 0) { gate.setEntityBoundingBox(new AxisAlignedBB(min.getX(), min.getY(), min.getZ(), max.getX() + 1, max.getY() + 1, max.getZ() + 1)); } else if (gate.edgePosition < gate.edgeMax) { if (!(gate.getEntityBoundingBox() instanceof RotateBoundingBox)) { try { ObfuscationReflectionHelper.setPrivateValue(Entity.class, gate, new RotateBoundingBox(gate.gateOrientation, min, max.add(1, 1, 1)), "boundingBox", "field_70121_D"); } catch (Exception ignored) { //noop } } if (gate.getEntityBoundingBox() instanceof RotateBoundingBox) { ((RotateBoundingBox) gate.getEntityBoundingBox()).rotate(gate.getOpeningStatus() * getMoveSpeed()); } } else { int heightAdj = max.getY() - min.getY(); BlockPos pos3 = max.up(-heightAdj).offset(gate.gateOrientation, heightAdj); max = BlockTools.getMax(min, pos3).add(1, 1, 1); min = BlockTools.getMin(min, pos3); gate.setEntityBoundingBox(new AxisAlignedBB(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ())); } }