本文整理匯總了Java中net.minecraftforge.fml.relauncher.ReflectionHelper.setPrivateValue方法的典型用法代碼示例。如果您正苦於以下問題:Java ReflectionHelper.setPrivateValue方法的具體用法?Java ReflectionHelper.setPrivateValue怎麽用?Java ReflectionHelper.setPrivateValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.fml.relauncher.ReflectionHelper
的用法示例。
在下文中一共展示了ReflectionHelper.setPrivateValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
}
示例2: mouseClickedSuper
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
/**
* Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
*/
protected void mouseClickedSuper(int mouseX, int mouseY, int mouseButton) throws IOException
{
if (mouseButton == 0)
{
for (int i = 0; i < this.buttonList.size(); ++i)
{
GuiButton guibutton = (GuiButton)this.buttonList.get(i);
if (guibutton.mousePressed(this.mc, mouseX, mouseY))
{
GuiScreenEvent.ActionPerformedEvent.Pre event = new GuiScreenEvent.ActionPerformedEvent.Pre(this, guibutton, this.buttonList);
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event))
break;
guibutton = event.getButton();
ReflectionHelper.setPrivateValue(GuiScreen.class, this, guibutton, "selectedButton", "field_146290_a");
guibutton.playPressSound(this.mc.getSoundHandler());
this.actionPerformed(guibutton);
if (this.equals(this.mc.currentScreen))
MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Post(this, event.getButton(), this.buttonList));
}
}
}
}
示例3: GuiDisconnectedOverride
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
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
}
示例4: setPrivateValue
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, E value, int fieldIndex)
{
try
{
ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
}
catch (UnableToAccessFieldException e)
{
FMLLog.log(Level.ERROR, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName());
throw e;
}
}
示例5: removedByPlayer
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
TileEntity tile = world.getTileEntity(pos);
if(tile !=null && tile instanceof TileJar){
TileJar jar = (TileJar)tile;
if(jar.isShulkerLamp() && !player.capabilities.isCreativeMode){
if(!world.isRemote){
EntityShulkerBullet bullet = new EntityShulkerBullet(world);
bullet.setLocationAndAngles(pos.getX() + 0.5, pos.getY() + 1 + 0.5, pos.getZ() + 0.5, bullet.rotationYaw, bullet.rotationPitch);
ReflectionHelper.setPrivateValue(EntityShulkerBullet.class, bullet, player, 1);
ReflectionHelper.setPrivateValue(EntityShulkerBullet.class, bullet, EnumFacing.UP, 2);
try {
Method method = EntityShulkerBullet.class.getDeclaredMethod("selectNextMoveDirection", EnumFacing.Axis.class);
if(method == null){
method = EntityShulkerBullet.class.getDeclaredMethod("func_184569_a", EnumFacing.Axis.class);
}
if(method !=null){
method.setAccessible(true);
method.invoke(bullet, EnumFacing.Axis.Y);
} else {
throw new Exception("Unable to find the selectNextMoveDirection method in "+EntityShulkerBullet.class.getCanonicalName());
}
} catch (Exception e) {
e.printStackTrace();
}
world.spawnEntity(bullet);
}
jar.setShulkerLamp(false);
}
}
if (willHarvest) {
return true;
}
return super.removedByPlayer(state, world, pos, player, willHarvest);
}
示例6: BlockContainerLCMeta
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
/** A custom render type Tile Entity container. */
public BlockContainerLCMeta(Block parent, int nSubBlocks, float hardness, float resistance, EnumBlockRenderType renderType, boolean sameIcon) {
super(parent, hardness, resistance);
this.renderType = renderType;
this.isBlockContainer = true;
if(nSubBlocks > 16) throw new IllegalArgumentException("More than 16 metadata states is unsupported!");
this.nSubBlocks = nSubBlocks;
this.sameIcon = sameIcon;
ReflectionHelper.setPrivateValue(Block.class, this, createBlockState(), RefMisc.DEV ? "blockState" : "field_176227_L");
setDefaultState();
}
示例7: readEntityFromNBT
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@Override
protected void readEntityFromNBT(NBTTagCompound compound)
{
super.readEntityFromNBT(compound);
if(tileEntityData !=null){
tile = TileEntity.create(getWorldObj(), tileEntityData);
int meta = getBlock().getBlock().getMetaFromState(getBlock());
ReflectionHelper.setPrivateValue(TileEntity.class, tile, meta, 5);
}
}
示例8: handleMessage
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@Override
public void handleMessage(String messageId, NBTTagCompound messageData, boolean client) {
if(messageId.equalsIgnoreCase("BlockSync")){
setBlock(Block.getStateById(messageData.getInteger("BlockID")));
if(messageData.hasKey("TileData")){
TileEntity tile = TileEntity.create(getEntityWorld(), messageData.getCompoundTag("TileData"));
int meta = getBlock().getBlock().getMetaFromState(getBlock());
ReflectionHelper.setPrivateValue(TileEntity.class, tile, meta, 5);
setTile(tile);
}
}
}
示例9: BlockWallLC
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public BlockWallLC() {
super(Blocks.STONE);
redoState = true;
ReflectionHelper.setPrivateValue(Block.class, this, createBlockState(), RefMisc.DEV ? "blockState" : "field_176227_L");
this.setDefaultState(this.blockState.getBaseState().withProperty(UP, false).withProperty(NORTH, false).withProperty(EAST, false).
withProperty(SOUTH, false).withProperty(WEST, false));
}
示例10: BlockMeta
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
/** A block that has subblocks / metadata */
public BlockMeta(Block parent, int nSubBlocks, float hardness, float resistance, boolean sameIcon) {
super(parent, hardness, resistance);
if(nSubBlocks > 16) throw new IllegalArgumentException("More than 16 metadata states is unsupported!");
this.nSubBlocks = nSubBlocks;
this.sameIcon = sameIcon;
ReflectionHelper.setPrivateValue(Block.class, this, createBlockState(), RefMisc.DEV ? "blockState" : "field_176227_L");
setDefaultState();
}
示例11: nerfTool
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
private static void nerfTool(Item tool) {
try {
if (tool instanceof ItemTool) {
ReflectionHelper.setPrivateValue(ItemTool.class, (ItemTool) tool, null, "toolClass");// Remove tool class
Field[] fields = ItemTool.class.getDeclaredFields();
boolean s = false;
for (Field f : fields) {
f.setAccessible(true);
Object o = f.get(tool);
if (o instanceof Set) {
TomsModUtils.setFinalField(f, tool, Sets.newHashSet());
log.info("Hacked effectiveBlocks name: " + f.getName());
s = true;
} else if (o instanceof Float) {
f.setFloat(tool, 1);
}
}
if (!s)
log.error("Did't find effectiveBlocks field");
com.tom.handler.EventHandler.disabledItems.add(tool);
} else if (tool instanceof ItemSword) {
com.tom.handler.EventHandler.disabledItems.add(tool);
} else if (tool instanceof ItemHoe) {
com.tom.handler.EventHandler.disabledItems.add(tool);
}
proxy.runMethod((IClientMethod) () -> EventHandlerClient.addTooltipOverride(tool, "tomsMod.tooltip.nerfed", TextFormatting.RED));
log.info("Successfully nerfed " + tool.getUnlocalizedName());
} catch (Throwable e) {
log.error("Unable to nerf " + tool.getUnlocalizedName() + " " + tool.getClass().getName(), e);
}
}
示例12: clickWeb
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public void clickWeb(IBookGraphics nav)
{
GuiScreen parent = (GuiScreen) nav.owner();
Minecraft mc = Minecraft.getMinecraft();
if (!mc.gameSettings.chatLinks)
{
return;
}
try
{
URI uri = new URI(webTarget);
String s = uri.getScheme();
if (s == null)
{
throw new URISyntaxException(webTarget, "Missing protocol");
}
if (!PROTOCOLS.contains(s.toLowerCase(Locale.ROOT)))
{
throw new URISyntaxException(webTarget, "Unsupported protocol: " + s.toLowerCase(Locale.ROOT));
}
if (mc.gameSettings.chatLinksPrompt)
{
ReflectionHelper.setPrivateValue(GuiScreen.class, parent, uri, "field_175286_t", "clickedLinkURI");
mc.displayGuiScreen(new GuiConfirmOpenLink(parent, webTarget, 31102009, false));
}
else
{
openWebLink(uri);
}
}
catch (URISyntaxException urisyntaxexception)
{
GuidebookMod.logger.error("Can't open url {}", webTarget, urisyntaxexception);
}
}
示例13: getChestInventory
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static IInventory getChestInventory(IronChestType type) {
TileEntityIronChest chestTile = new TileEntityIronChest();
ReflectionHelper.setPrivateValue(TileEntityIronChest.class, chestTile, type, "chestType");
return chestTile;
}
示例14: getShulkerInventory
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static IInventory getShulkerInventory(IronShulkerBoxType type) {
TileEntityIronShulkerBox shulkerBoxTile = new TileEntityIronShulkerBox();
ReflectionHelper.setPrivateValue(TileEntityIronShulkerBox.class, shulkerBoxTile, type, "shulkerBoxType");
return shulkerBoxTile;
}
示例15: EntityLCItem
import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public EntityLCItem(World worldIn, double x, double y, double z, ItemStack stack) {
super(worldIn, x, y, z, stack);
ReflectionHelper.setPrivateValue(EntityItem.class, this, 500, RefMisc.DEV ? "health" : "field_70291_e"); // virtually invincible
}