本文整理匯總了Java中cpw.mods.fml.relauncher.ReflectionHelper.getPrivateValue方法的典型用法代碼示例。如果您正苦於以下問題:Java ReflectionHelper.getPrivateValue方法的具體用法?Java ReflectionHelper.getPrivateValue怎麽用?Java ReflectionHelper.getPrivateValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cpw.mods.fml.relauncher.ReflectionHelper
的用法示例。
在下文中一共展示了ReflectionHelper.getPrivateValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCollideWithPlayer
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@Override
public void onCollideWithPlayer(EntityPlayer player) {
boolean inGround = false;
try {
inGround = ReflectionHelper.getPrivateValue(EntityArrow.class, this, "inGround", "field_70254_i");
} catch (Exception e) {
}
if (!worldObj.isRemote && inGround && arrowShake <= 0 && isEffectValid()) {
boolean flag = canBePickedUp == 1 || canBePickedUp == 2 && player.capabilities.isCreativeMode;
ItemStack stack = new ItemStack(ModItems.tipped_arrow);
TippedArrow.setEffect(stack, Potion.potionTypes[effect.getPotionID()], effect.getDuration());
if (canBePickedUp == 1 && !player.inventory.addItemStackToInventory(stack))
flag = false;
if (flag) {
playSound("random.pop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
player.onItemPickup(this, 1);
setDead();
}
}
}
示例2: processCommand
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public void processCommand(final ICommandSender icommandsender, final String[] astring) {
final File f = new File(Minecraft.getMinecraft().mcDataDir, "extrautilities_localization.txt");
final Map<String, Properties> k = (Map<String, Properties>)ReflectionHelper.getPrivateValue((Class)LanguageRegistry.class, (Object)LanguageRegistry.instance(), new String[] { "modLanguageData" });
final String lang = FMLCommonHandler.instance().getCurrentLanguage();
final Properties p = k.get(lang);
String t = "";
for (final Map.Entry<Object, Object> entry : p.entrySet()) {
t = t + entry.getKey() + "=" + entry.getValue() + "\n";
}
try {
Files.write((CharSequence)t, f, Charsets.UTF_8);
LogHelper.info("Dumped Language data to " + f.getAbsolutePath(), new Object[0]);
}
catch (Exception exception) {
exception.printStackTrace();
}
}
示例3: getSheep
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public ArrayList getSheep( final World world ) {
final List list = world.getEntitiesWithinAABB( EntitySheep.class, fairy.boundingBox.expand( 5D, 5D, 5D ) );
if ( list.size() < 1 ) {
return null;
}
final ArrayList list2 = new ArrayList();
for ( int i = 0; i < list.size(); i++ ) {
final EntitySheep entity1 = (EntitySheep) list.get( i );
final int fleeingTick = ReflectionHelper.getPrivateValue(EntityCreature.class, entity1, MCP_FLEEINGTICK);
if ( fairy.canEntityBeSeen( entity1 ) && entity1.getHealth() > 0 && entity1.getEntityToAttack() == null
&& fleeingTick <= 0 && entity1.getGrowingAge() >= 0 && !entity1.getSheared() ) {
list2.add( entity1 );
}
}
if ( list2.size() <= 0 ) {
return null;
} else {
return list2;
}
}
示例4: inject
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
/**
* Inserts the resource pack into the game. Enabling the resource pack will
* not be required, it will load automatically.
* <p>
* A cache of the pack zip will be kept in "resourcepack/[pack name].zip"
* where "resourcepack" is a folder at the same level as the directory passed
* into the constructor.
*/
public void inject() {
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
try {
if (defaultResourcePacks == null) {
defaultResourcePacks = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao", "ap");
}
File dest = new File(dir.getParent() + "/resourcepack/" + zip.getName());
EnderFileUtils.safeDelete(dest);
FileUtils.copyFile(zip, dest);
EnderFileUtils.safeDelete(zip);
writeNewFile(new File(dest.getParent() + "/readme.txt"),
EnderCore.lang.localize("resourcepack.readme") + "\n\n" + EnderCore.lang.localize("resourcepack.readme2"));
defaultResourcePacks.add(new FileResourcePack(dest));
} catch (Exception e) {
EnderCore.logger.error("Failed to inject resource pack for mod {}", modid, e);
}
} else {
EnderCore.logger.info("Skipping resource pack, we are on a dedicated server.");
}
}
示例5: SilverfishModel
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public SilverfishModel()
{
normal = new ModelSilverfish();
body = ReflectionHelper.getPrivateValue( ModelSilverfish.class, this, 0 );
wings = ReflectionHelper.getPrivateValue( ModelSilverfish.class, this, 1 );
body[ 3 ].rotateAngleX = body[ 4 ].rotateAngleX = body[ 5 ].rotateAngleX = body[ 6 ].rotateAngleX = 3.14f / 2;
body[ 3 ].rotationPointZ = body[ 4 ].rotationPointZ = body[ 5 ].rotationPointZ = body[ 6 ].rotationPointZ = 0;
body[ 6 ].offsetY = 0;
body[ 5 ].offsetY = -0.1f;
body[ 4 ].rotateAngleX *= -0.7f;
body[ 4 ].offsetZ = 0.06f;
body[ 4 ].offsetY = -0.2f;
body[ 3 ].rotateAngleX *= -0.45f;
body[ 3 ].offsetY = -0.3f;
body[ 3 ].offsetZ = -0.05f;
wings[ 1 ].rotateAngleX = body[ 5 ].rotateAngleX*1.4f;
wings[ 1 ].rotationPointZ = body[ 5 ].rotationPointZ;
wings[ 1 ].offsetY = body[ 4 ].offsetX;
wings[ 1 ].offsetZ = -0.05f;
}
示例6: write
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@Override
public void write(ByteBuf out) {
NBTTagCompound nbt = (NBTTagCompound)ReflectionHelper.getPrivateValue(S35PacketUpdateTileEntity.class, (S35PacketUpdateTileEntity)tile.getDescriptionPacket(), "field_148860_e");
out.writeInt(((Entity)entity).worldObj.provider.dimensionId);
out.writeInt(((Entity)entity).getEntityId());
out.writeInt(x);
out.writeInt(y);
out.writeInt(z);
PacketBuffer packetBuffer = new PacketBuffer(out);
try {
packetBuffer.writeNBTTagCompoundToBuffer(nbt);
} catch (IOException e) {
e.printStackTrace();
}
}
示例7: init
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static void init() {
if (Settings.Tweaks.enableEE3Tweaks) {
try {
List<RecipeAludel> aludelRecipeList = ReflectionHelper.getPrivateValue(AludelRecipeManager.class,
AludelRecipeManager.getInstance(), "aludelRecipes");
for (RecipeAludel recipe : aludelRecipeList) {
if (recipe.getRecipeOutput().getItem().equals(alchemicalTome)) {
aludelRecipeList.remove(recipe);
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例8: getSmallestFlowDecayTo
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static int getSmallestFlowDecayTo(BlockDynamicLiquid flowingBlock, World world, int x, int y, int z, int curSmallest, int fromSide)
{
int flowDecay = Hooks.getFlowDecayTo(flowingBlock, world, x, y, z, fromSide);
if (flowDecay < 0)
{
return curSmallest;
}
else
{
if (flowDecay == 0)
{
int numAdjacentSources = ReflectionHelper.getPrivateValue(BlockDynamicLiquid.class, flowingBlock, "field_149815_a", "a");
ReflectionHelper.setPrivateValue(BlockDynamicLiquid.class, flowingBlock, numAdjacentSources+1, "field_149815_a", "a");
}
if (flowDecay >= 8)
{
flowDecay = 0;
}
return curSmallest >= 0 && flowDecay >= curSmallest ? curSmallest : flowDecay;
}
}
示例9: dump
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@Override
public Iterable<String[]> dump(int mode) {
List<String[]> list = new LinkedList<String[]>();
Map<Class, String> classToNameMap = ReflectionHelper.getPrivateValue(TileEntity.class, null, "field_145853_j", "classToNameMap");
List<Class> classes = new ArrayList<Class>();
classes.addAll(classToNameMap.keySet());
Collections.sort(classes, new Comparator<Class>() {
@Override
public int compare(Class o1, Class o2) {
if (o1 == null || o2 == null) {
return 0;
}
return o1.getName().compareTo(o2.getName());
}
});
for (Class clazz : classes) {
if (clazz != null) {
list.add(new String[] { clazz.getName(), classToNameMap.get(clazz) });
}
}
return list;
}
示例10: dump
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@Override
public Iterable<String[]> dump(int mode) {
List<String[]> list = new LinkedList<String[]>();
List<Integer> ids = new ArrayList<Integer>();
ids.addAll(Arrays.asList(DimensionManager.getStaticDimensionIDs()));
Collections.sort(ids);
for (int id : ids) {
int providerId = DimensionManager.getProviderType(id);
Map<Integer, Class> providers = ReflectionHelper.getPrivateValue(DimensionManager.class, null, "providers");
Class providerClass = providers.get(providerId);
list.add(new String[] { String.valueOf(id), String.valueOf(providerId), providerClass.getName() });
}
return list;
}
示例11: actionPerformed
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@Override
protected void actionPerformed(GuiButton button) {
if (!button.enabled) return;
switch (button.id) {
case 0:
if (buttonRegenMode.enabled)
preset = regenMode;
break;
case 3:
// If going to the more options screen, hide the button.
// If going back to the main screen, show the button again.
boolean inMoreOptions = ReflectionHelper.getPrivateValue(GuiCreateWorld.class, this, "field_146344_y");
buttonRegenMode.visible = inMoreOptions;
break;
case 9:
regenMode = EnumPreset.values()[(regenMode.ordinal() + 1) % EnumPreset.values().length];
buttonRegenMode.displayString = getRegenButtonString();
break;
}
super.actionPerformed(button);
}
示例12: dumpOreDict
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
/**
* Dump ore dictionary
*/
public static void dumpOreDict() {
Map<Integer, ItemData> idMap = ReflectionHelper.getPrivateValue(GameData.class, null, "idMap");
List<String> oreNames = Arrays.asList(OreDictionary.getOreNames());
Collections.sort(oreNames);
for (String oreName : oreNames) {
StringBuffer sb = new StringBuffer();
sb.append("ore: " + oreName + ": ");
ArrayList<ItemStack> oreItems = OreDictionary.getOres(oreName);
for (ItemStack oreItem : oreItems) {
ItemData itemData = idMap.get(oreItem.itemID);
String modID = itemData.getModId();
sb.append(oreItem.itemID + ":" + oreItem.getItemDamage() + "=" + modID + ", ");
}
System.out.println(sb);
}
}
示例13: replaceDungeonLoot
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static void replaceDungeonLoot() {
try {
HashMap<String, ChestGenHooks> chestInfo = ReflectionHelper.getPrivateValue(ChestGenHooks.class, null, "chestInfo");
for (Map.Entry<String, ChestGenHooks> entry : chestInfo.entrySet()) {
ChestGenHooks chestGenHooks = entry.getValue();
ArrayList<WeightedRandomChestContent> contents = ReflectionHelper.getPrivateValue(ChestGenHooks.class, chestGenHooks, "contents");
for (WeightedRandomChestContent weightedRandomChestContent : contents) {
ItemStack output = weightedRandomChestContent.theItemId;
ItemStack newOutput = getPreferredOre(output);
if (newOutput == null) {
continue;
}
log("Modifying dungeon loot in "+entry.getKey()+", replacing "+output.itemID+":"+output.getItemDamage()+" -> "+newOutput.itemID+":"+newOutput.getItemDamage());
weightedRandomChestContent.theItemId = newOutput;
}
}
} catch (Throwable t) {
System.out.println("Failed to replace dungeon loot: " + t);
}
}
示例14: getDrinkVessels
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static LOTRItemMug.Vessel[] getDrinkVessels(LOTRTradeEntries instance) {
LOTRItemMug.Vessel[] ret = null;
try {
ret = ReflectionHelper.getPrivateValue(LOTRTradeEntries.class, instance, "drinkVessels");
} catch (Exception e) {
NeiLotr.mod.getLogger()
.error("Could not get private field value drinkVessels from LOTRTradeEntries via reflection", e);
}
return ret;
}
示例15: getStrenghts
import cpw.mods.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static float[] getStrenghts() {
float[] ret = null;
try {
ret = ReflectionHelper.getPrivateValue(LOTRItemMug.class, null, "strengths");
} catch (Exception e) {
NeiLotr.mod.getLogger()
.error("Could not get private field strengths drinkVessels from LOTRItemMug via reflection", e);
}
return ret;
}