Java Code Examples for net.minecraftforge.fml.relauncher.ReflectionHelper#setPrivateValue()

The following examples show how to use net.minecraftforge.fml.relauncher.ReflectionHelper#setPrivateValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutoReconnectMod.java    From ForgeHax with MIT License 6 votes vote down vote up
public GuiDisconnectedOverride(
    GuiScreen screen,
    String reasonLocalizationKey,
    ITextComponent chatComp,
    String reason,
    double delay) {
  super(screen, reasonLocalizationKey, chatComp);
  parent = screen;
  message = chatComp;
  reconnectTime = System.currentTimeMillis() + (long) (delay * 1000);
  // set variable 'reason' to the previous classes value
  try {
    ReflectionHelper.setPrivateValue(
        GuiDisconnected.class,
        this,
        reason,
        "reason",
        "field_146306_a",
        "a"); // TODO: Find obbed mapping name
  } catch (Exception e) {
    Helper.printStackTrace(e);
  }
  // parse server return text and find queue pos
}
 
Example 2
Source File: ChunkManagerPlanet.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
public ChunkManagerPlanet(long seed, WorldType default1, String str, DimensionProperties properties) {

		this.biomeCache = new BiomeCache(this);//new BiomeCacheExtended(this);
		//TODO: more biomes
		//TODO: remove rivers
		GenLayer[] agenlayer = initializeAllBiomeGenerators(seed, default1, str, properties);//GenLayer.initializeAllBiomeGenerators(seed, default1); //;
		agenlayer = getModdedBiomeGenerators(default1, seed, agenlayer);
		this.genBiomes = agenlayer[0];
		this.biomeIndexLayer = agenlayer[1];

		ReflectionHelper.setPrivateValue(BiomeProvider.class, this, this.genBiomes, "genBiomes", "field_76944_d");
		ReflectionHelper.setPrivateValue(BiomeProvider.class, this, this.biomeIndexLayer, "biomeIndexLayer", "field_76945_e");
		
		fBiomeCache = ReflectionHelper.findField(BiomeCache.class, "cache", "field_76841_d");
		fBiomeCache.setAccessible(true);

		fBiomeCacheMap = ReflectionHelper.findField(BiomeCache.class, "cacheMap", "field_76843_c");
		fBiomeCacheMap.setAccessible(true);
	}
 
Example 3
Source File: RenderCyberZombie.java    From Cyberware with MIT License 5 votes vote down vote up
public RenderCyberZombie(RenderManager renderManagerIn)
{
	super(renderManagerIn);
       List<LayerRenderer<EntityZombie>> defaultLayers = ReflectionHelper.getPrivateValue(RenderZombie.class, this, 10);
       defaultLayers.add(new LayerZombieHighlight(this));
       ReflectionHelper.setPrivateValue(RenderZombie.class, this, defaultLayers, 10);
}
 
Example 4
Source File: YUNoMakeGoodMap.java    From YUNoMakeGoodMap with Apache License 2.0 5 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT) //Modders should never do this, im just lazy, and I KNOW what im doing.
public void onOpenGui(GuiOpenEvent e)
{
    //If we're opening the new world screen from the world selection, default to void world.
    if (e.getGui() instanceof GuiCreateWorld && Minecraft.getMinecraft().currentScreen instanceof GuiWorldSelection)
    {
        //Auto-select void world.
        GuiCreateWorld cw = (GuiCreateWorld)e.getGui();
        ReflectionHelper.setPrivateValue(GuiCreateWorld.class, cw, worldType.getId(),
                "field_146331_K", "selectedIndex");
    }
}
 
Example 5
Source File: ItemBrainUpgrade.java    From Cyberware with MIT License 4 votes vote down vote up
@SubscribeEvent(priority=EventPriority.HIGHEST)
public void handleHurt(LivingAttackEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	
	if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 4)) && isMatrixWorking(e))
	{

		if (!e.worldObj.isRemote && event.getSource() instanceof EntityDamageSource)
		{
			Entity attacker = ((EntityDamageSource) event.getSource()).getSourceOfDamage();
			if (e instanceof EntityPlayer)
			{
				String str = e.getEntityId() + " " + e.ticksExisted + " " + attacker.getEntityId();
				if (lastHits.contains(str))
				{
					return;
				}
				else
				{
					lastHits.add(str);
				}
			}
			
			boolean armor = false;
			for (ItemStack stack : e.getArmorInventoryList())
			{
				if (stack != null && stack.getItem() instanceof ItemArmor)
				{
					if (((ItemArmor) stack.getItem()).getArmorMaterial().getDamageReductionAmount(EntityEquipmentSlot.CHEST) > 4)
					{
						return;
					}
				}
				else if (stack != null && stack.getItem() instanceof ISpecialArmor)
				{
					if (((ISpecialArmor) stack.getItem()).getProperties(e, stack, event.getSource(), event.getAmount(), 1).AbsorbRatio * 25D > 4)
					{
						return;
					}
				}
				
				if (stack != null)
				{
					armor = true;
				}
				
			}
			

			if (!((float) e.hurtResistantTime > (float) e.maxHurtResistantTime / 2.0F))
               {
				Random random = e.getRNG();
				if (random.nextFloat() < (armor ? LibConstants.DODGE_ARMOR : LibConstants.DODGE_NO_ARMOR))
				{
					event.setCanceled(true);
					e.hurtResistantTime = e.maxHurtResistantTime;
					e.hurtTime = e.maxHurtTime = 10;
					ReflectionHelper.setPrivateValue(EntityLivingBase.class, e, 9999F, 46);
					
					CyberwarePacketHandler.INSTANCE.sendToAllAround(new DodgePacket(e.getEntityId()), new TargetPoint(e.worldObj.provider.getDimension(), e.posX, e.posY, e.posZ, 50));
				}
			}
		}
	}
}