本文整理汇总了Java中net.minecraftforge.fml.relauncher.ReflectionHelper类的典型用法代码示例。如果您正苦于以下问题:Java ReflectionHelper类的具体用法?Java ReflectionHelper怎么用?Java ReflectionHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReflectionHelper类属于net.minecraftforge.fml.relauncher包,在下文中一共展示了ReflectionHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shutupForge
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
/**
* Make forge not spew "dangerous alternative prefix" messages in this block.
*/
public static void shutupForge(Runnable op) {
Logger log = (Logger) FMLLog.log;
try {
Object privateConfig = ReflectionHelper.findField(Logger.class, "privateConfig").get(log);
Field intLevelF = ReflectionHelper.findField(privateConfig.getClass(), "intLevel");
int intLevel = (int) intLevelF.get(privateConfig);
intLevelF.set(privateConfig, 299); // disable WARN logging
try {
op.run();
} finally {
intLevelF.set(privateConfig, intLevel);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
示例2: makeOurList
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
private void makeOurList()
{
if (serverListInternetField == null)
{
if (serverListInternetField == null)
{
serverListInternetField = ReflectionHelper.findField(ServerSelectionList.class, "field_148198_l", "serverListInternet");
serverListInternetField.setAccessible(true);
}
}
try
{
ourList = (List<ServerListEntryPublic>) serverListInternetField.get(this);
}
catch (IllegalAccessException e)
{
CreeperHost.logger.warn("Reflection to get server list failed.", e);
}
}
示例3: setServerList
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
private void setServerList(ServerListPublic serverList)
{
ourSavedServerList = serverList;
if (savedServerListField == null)
{
savedServerListField = ReflectionHelper.findField(GuiMultiplayer.class, "field_146804_i", "savedServerList");
savedServerListField.setAccessible(true);
}
try
{
savedServerListField.set(this, serverList);
}
catch (IllegalAccessException e)
{
CreeperHost.logger.error("Unable to set server list", e);
}
}
示例4: setLanServerDetector
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
private void setLanServerDetector(LanServerDetector.ThreadLanServerFind detector)
{
ourLanServerDetector = detector;
if (lanServerDetectorField == null)
{
lanServerDetectorField = ReflectionHelper.findField(GuiMultiplayer.class, "field_146800_B", "lanServerDetector");
lanServerDetectorField.setAccessible(true);
}
try
{
lanServerDetectorField.set(this, detector);
}
catch (IllegalAccessException e)
{
CreeperHost.logger.error("Unable to set server list", e);
}
}
示例5: setLanServerList
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
private void setLanServerList(LanServerDetector.LanServerList detector)
{
ourLanServerList = detector;
if (lanServerListField == null)
{
lanServerListField = ReflectionHelper.findField(GuiMultiplayer.class, "field_146799_A", "lanServerList");
lanServerListField.setAccessible(true);
}
try
{
lanServerListField.set(this, detector);
}
catch (IllegalAccessException e)
{
CreeperHost.logger.error("Unable to set server list", e);
}
}
示例6: setServerListSelector
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
private void setServerListSelector(ServerSelectionListPublic list)
{
ourServerListSelector = list;
if (serverListSelectorField == null)
{
serverListSelectorField = ReflectionHelper.findField(GuiMultiplayer.class, "field_146803_h", "serverListSelector");
serverListSelectorField.setAccessible(true);
}
try
{
serverListSelectorField.set(this, list);
}
catch (IllegalAccessException e)
{
CreeperHost.logger.error("Unable to set server list", e);
}
}
示例7: getTabLabel
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
private static String getTabLabel(CreativeTabs tab)
{
if (tabLabelField == null)
{
tabLabelField = ReflectionHelper.findField(CreativeTabs.class, "tabLabel", "field_78034_o", "o");
tabLabelField.setAccessible(true);
}
try
{
return (String) tabLabelField.get(tab);
} catch (IllegalAccessException e)
{
e.printStackTrace();
}
return null;
}
示例8: onRenderPlayer
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Post event)
{
EntityPlayer player = event.getEntityPlayer();
String uuid = player.getUUID(player.getGameProfile()).toString();
if(player instanceof AbstractClientPlayer && UUIDS.contains(uuid) && !done.contains(player))
{
AbstractClientPlayer clplayer = (AbstractClientPlayer) player;
if(clplayer.hasPlayerInfo())
{
NetworkPlayerInfo info = ReflectionHelper.getPrivateValue(AbstractClientPlayer.class, clplayer, ObfuscatedNames.PLAYER_INFO);
Map<MinecraftProfileTexture.Type, ResourceLocation> textures = ReflectionHelper.getPrivateValue(NetworkPlayerInfo.class, info, ObfuscatedNames.PLAYER_TEXTURES);
ResourceLocation loc = new ResourceLocation("proxyslib", "textures/whoknows/special_cape.png");
textures.put(MinecraftProfileTexture.Type.CAPE, loc);
textures.put(MinecraftProfileTexture.Type.ELYTRA, loc);
done.add(player);
}
}
}
示例9: onRenderPlayer
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Post event)
{
EntityPlayer player = event.getEntityPlayer();
String uuid = player.getUUID(player.getGameProfile()).toString();
if(player instanceof AbstractClientPlayer && UUIDS.contains(uuid) && !done.contains(player))
{
AbstractClientPlayer clplayer = (AbstractClientPlayer) player;
if(clplayer.hasPlayerInfo())
{
NetworkPlayerInfo info = ReflectionHelper.getPrivateValue(AbstractClientPlayer.class, clplayer, ObfuscatedNames.PLAYER_INFO);
Map<MinecraftProfileTexture.Type, ResourceLocation> textures = ReflectionHelper.getPrivateValue(NetworkPlayerInfo.class, info, ObfuscatedNames.PLAYER_TEXTURES);
ResourceLocation loc = new ResourceLocation("proxyslib", "textures/whoknows/dev_cape.png");
textures.put(MinecraftProfileTexture.Type.CAPE, loc);
textures.put(MinecraftProfileTexture.Type.ELYTRA, loc);
done.add(player);
}
}
}
示例10: onUpdate
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
if (stack.getItemDamage() != 20)
return;
if (!(entity instanceof EntityPlayer) || (entity instanceof FakePlayer))
return;
if (itemSlot < ((EntityPlayer)entity).inventory.getHotbarSize()) {
List<EntityLiving> entities = entity.worldObj.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(entity.getPosition().add(-range, -range, -range), entity.getPosition().add(range, range, range)));
for (EntityLiving ent : entities) {
List<EntityAITaskEntry> entries = new ArrayList(ent.tasks.taskEntries);
entries.addAll(new ArrayList(ent.targetTasks.taskEntries));
for (EntityAITaskEntry entry : entries) {
if (entry.action instanceof EntityAIAttackRangedBow) {
makeSkellyShootSlower((EntityAIAttackRangedBow)entry.action);
}
}
if (ent instanceof EntityCreeper)
ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper)ent, 60, this.FUSETIME);
}
}
}
示例11: GameData
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
public GameData()
{
iBlockRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BLOCKS, Block.class, new ResourceLocation("minecraft:air"), MIN_BLOCK_ID, MAX_BLOCK_ID, true, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE);
iItemRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ITEMS, Item.class, null, MIN_ITEM_ID, MAX_ITEM_ID, true, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE);
iPotionRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONS, Potion.class, null, MIN_POTION_ID, MAX_POTION_ID, false, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, null);
iBiomeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BIOMES, Biome.class, null, MIN_BIOME_ID, MAX_BIOME_ID, false, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, null);
iSoundEventRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.SOUNDEVENTS, SoundEvent.class, null, MIN_SOUND_ID, MAX_SOUND_ID, false, null, null, null, null);
ResourceLocation WATER = new ResourceLocation("water");
iPotionTypeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONTYPES, PotionType.class, WATER, MIN_POTIONTYPE_ID, MAX_POTIONTYPE_ID, false, null, null, null, null);
iEnchantmentRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ENCHANTMENTS, Enchantment.class, null, MIN_ENCHANTMENT_ID, MAX_ENCHANTMENT_ID, false, null, null, null, null);
try
{
blockField = FinalFieldHelper.makeWritable(ReflectionHelper.findField(ItemBlock.class, "block", "field_150939" + "_a"));
}
catch (Exception e)
{
FMLLog.log(Level.FATAL, e, "Cannot access the 'block' field from ItemBlock, this is fatal!");
throw Throwables.propagate(e);
}
}
示例12: findMethod
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
/** Find a method with multiple method names (old reflection helper) */
public static <E> Method findMethod(Class<? super E> clazz, E instance, String[] methodNames, Class<?>... methodTypes)
{
Exception failed = null;
for (String methodName : methodNames)
{
try
{
Method m = clazz.getDeclaredMethod(methodName, methodTypes);
m.setAccessible(true);
return m;
}
catch (Exception e)
{
failed = e;
}
}
throw new ReflectionHelper.UnableToFindMethodException(methodNames, failed);
}
示例13: initialize
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
public static void initialize()
{
inLove = ReflectionHelper.findField(EntityAnimal.class, "field_70881_d", "inLove");
//Standard
mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityCow(world)),100));
mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntitySheep(world)),100));
mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityPig(world)),100));
mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityChicken(world)),50)); //Lower chance for egg hatching animal
//Parent species
mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,mother.createChild(mother)),100));
mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,father.createChild(father)),100));
//Abominations
mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnEntityAt(world,pos,new EntitySilverfish(world)),200));
mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnEntityAt(world,pos,new EntityCaveSpider(world)),100));
mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnEntityAt(world,pos,new EntitySlime(world)),50));
//Enviroment dependent
mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnEntityAt(world,pos,new EntitySquid(world)),0).setCustomWeight(AnimalCrossbreedHandler::getSquidWeight));
mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityWolf(world)),0).setCustomWeight(AnimalCrossbreedHandler::getWolfWeight));
mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityOcelot(world)),0).setCustomWeight(AnimalCrossbreedHandler::getOcelotWeight));
}
示例14: update
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
@Override
public void update() {
World world = entity.getWorld();
if(!world.isRemote && entity.ticksExisted()==Refs.TPS*5){
//grab the list of records
Map<String,ItemRecord> recordMap = ReflectionHelper.getPrivateValue(ItemRecord.class, (ItemRecord)Items.RECORD_13, "RECORDS","field_150928_b");//XXX recheck name when update
Collection<ItemRecord> records = recordMap.values();
//select a random number
Random rand = new Random();
int idx = rand.nextInt(records.size());
//grab the record that matches our random number
Iterator<ItemRecord> it = records.iterator();
ItemRecord current=it.next();
for(int i=1;i<idx;i++){
current = it.next();
}
//spawn the record
Utils.spawnItemCentered(world, getPos(), new ItemStack(current));
//world.playSoundEffect(getPos().getX(), getPos().getY(), getPos().getZ(), "mob.chicken.plop", 0.5F, 0.8F + (world.rand.nextFloat() - world.rand.nextFloat()));
world.playSound(null,getPos().getX(), getPos().getY(), getPos().getZ(), SoundEvents.ENTITY_CHICKEN_EGG, SoundCategory.BLOCKS, 0.5F, 0.8F + (world.rand.nextFloat() - world.rand.nextFloat()));
this.onPatternBroken();//deactivate
}
}
示例15: getEntityLoot_Table
import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
private List<ItemStack> getEntityLoot_Table(EntityLiving el){
ResourceLocation location = (ResourceLocation)ReflectionHelper.getPrivateValue(EntityLiving.class, el, "deathLootTable","field_184659_bA");
if(location==null){
Method getLT = ReflectionHelper.findMethod(EntityLiving.class,"getLootTable","func_184647_J");
try {
location = (ResourceLocation)getLT.invoke(el);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
RunesofWizardry_Classics.log().error("Exception when trying to get LootTable from entity: "+el.getName(),e);
return getEntityLoot_Hacky(el);
}
}
if(location==null){
RunesofWizardry_Classics.log().warn(el.getName()+" does not have a LootTable. falling back to kill method");
return getEntityLoot_Hacky(el);
}
LootTableManager manager = el.world.getLootTableManager();
LootTable table = manager.getLootTableFromLocation(location);
return LootUtils.tableToItemStacks(table);
}