本文整理汇总了Java中net.minecraftforge.fml.common.ObfuscationReflectionHelper类的典型用法代码示例。如果您正苦于以下问题:Java ObfuscationReflectionHelper类的具体用法?Java ObfuscationReflectionHelper怎么用?Java ObfuscationReflectionHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObfuscationReflectionHelper类属于net.minecraftforge.fml.common包,在下文中一共展示了ObfuscationReflectionHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changeDimension
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
@Override
public Entity changeDimension(int dimensionIn) {
if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, dimensionIn)) {
return this;
}
ObfuscationReflectionHelper.setPrivateValue(EntityPlayerMP.class, this, true, "invulnerableDimensionChange", "field_184851_cj");
if (dimension == 1 && dimensionIn == 1) {
world.removeEntity(this);
if (!queuedEndExit) {
queuedEndExit = true;
connection.sendPacket(new SPacketChangeGameState(4, 0.0F));
}
return this;
}
else {
if (dimension == 0 && dimensionIn == 1) {
dimensionIn = 1;
}
mcServer.getPlayerList().changePlayerDimension(this, dimensionIn);
return this;
}
}
示例2: preRemoveChest
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
@Override
public void preRemoveChest(World world, BlockPos pos, EntityPlayer player, ItemStack transporter)
{
try
{
TileEntity chestTE = world.getTileEntity(pos);
Class clazz = Class.forName("factorization.weird.TileEntityDayBarrel");
Object log = ObfuscationReflectionHelper.getPrivateValue(clazz, chestTE, "woodLog");
Object slab = ObfuscationReflectionHelper.getPrivateValue(clazz, chestTE, "woodSlab");
Object type = ObfuscationReflectionHelper.getPrivateValue(clazz, chestTE, "type");
NBTTagCompound logNbt = new NBTTagCompound();
((ItemStack) log).writeToNBT(logNbt);
NBTTagCompound slabNbt = new NBTTagCompound();
((ItemStack) slab).writeToNBT(slabNbt);
transporter.getTagCompound().setTag("WoodLog", logNbt);
transporter.getTagCompound().setTag("WoodSlab", slabNbt);
transporter.getTagCompound().setString("BarrelType", type.toString());
} catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}
示例3: preRemoveChest
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
@Override
public void preRemoveChest(World world, BlockPos pos, EntityPlayer player, ItemStack transporter)
{
try
{
TileEntity chestTE = world.getTileEntity(pos);
Class clazz = Class.forName("de.sanandrew.mods.varietychests.tileentity.TileEntityCustomChest");
Class clazz1 = Class.forName("de.sanandrew.mods.varietychests.util.ChestType");
Object chestType = ObfuscationReflectionHelper.getPrivateValue(clazz, chestTE, "chestType").toString();
clazz1.getField("name").setAccessible(true);
Object chestName = clazz1.getDeclaredField("name").get(chestType);
transporter.getTagCompound().setString("VCChestType", (String) chestName);
} catch (Exception e)
{
e.printStackTrace();
}
}
示例4: onChestPlaced
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
@Override
public void onChestPlaced(World world, BlockPos pos, EntityPlayer player, ItemStack transporter)
{
try
{
TileEntity chestTE = world.getTileEntity(pos);
Class clazz = Class.forName("de.sanandrew.mods.varietychests.tileentity.TileEntityCustomChest");
String chestType = transporter.getTagCompound().getString("VCChestType");
ObfuscationReflectionHelper.setPrivateValue(clazz, chestTE, chestType, "chestType");
} catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}
示例5: getSounds
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
public List<ResourceLocation> getSounds(String filter){
if(soundCache == null){
soundCache = Lists.newArrayList();
SoundRegistry reg = null;
try{
reg = ObfuscationReflectionHelper.getPrivateValue(SoundHandler.class, Minecraft.getMinecraft().getSoundHandler(), 4);
} catch(Exception e){}
if(reg == null)return soundCache;
for(ResourceLocation loc : reg.getKeys()){
if(loc.toString().toLowerCase().contains(filter)){
soundCache.add(loc);
}
}
}
return soundCache;
}
示例6: preInit
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
@Override
public void preInit( FMLPreInitializationEvent e ){
super.preInit( e );
LogHelper.info( "Trying to load CustomAchievements Translation Resource Pack");
try {
List packs = (List) ObfuscationReflectionHelper.getPrivateValue( Minecraft.class, Minecraft.getMinecraft(), new String[]{"field_110449_ao"} ); //defaultResourcePacks
packs.add( new AchievementResourcePack() );
ObfuscationReflectionHelper.setPrivateValue( Minecraft.class, Minecraft.getMinecraft(), packs, new String[]{"field_110449_ao"} );
} catch( Exception exception ){
LogHelper.error( "Loading CustomAchievements Translation Resource Pack failed.");
exception.printStackTrace();
}
ModBlocks.loadTextures();
ClientRegistry.bindTileEntitySpecialRenderer( TileEntityTrophy.class, new RenderTrophy() );
}
示例7: onMouseClicked
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
@SubscribeEvent
public void onMouseClicked(MouseInputEvent.Post event)
{
if (event.getGui() instanceof GuiContainerCreative)
{
GuiContainerCreative guiScreen = (GuiContainerCreative) event.getGui();
List<GuiButton> buttonList = ObfuscationReflectionHelper.getPrivateValue(GuiScreen.class, (GuiScreen) guiScreen, 7);
if (previousSelectedTabIndex != guiScreen.getSelectedTabIndex())
{
if (guiScreen.getSelectedTabIndex() == CreativeTabs.INVENTORY.getTabIndex() && !buttonList.contains(ACCESSORY_BUTTON))
{
int guiLeft = ObfuscationReflectionHelper.getPrivateValue(GuiContainer.class, (GuiContainer)event.getGui(), "guiLeft", "field_147003_i");
int guiTop = ObfuscationReflectionHelper.getPrivateValue(GuiContainer.class, (GuiContainer)event.getGui(), "guiTop", "field_147009_r");
buttonList.add(ACCESSORY_BUTTON.setPosition(guiLeft + 73, guiTop + 38));
}
else if (previousSelectedTabIndex == CreativeTabs.INVENTORY.getTabIndex())
{
buttonList.remove(ACCESSORY_BUTTON);
}
previousSelectedTabIndex = guiScreen.getSelectedTabIndex();
}
}
}
示例8: activateBatch
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
public void activateBatch()
{
if(batch != null)
{
if(OpenGlHelper.shadersSupported)
{
try
{
ShaderGroup theShaderGroup = batch.toShaderGroup(resManager);
theShaderGroup.createBindFramebuffers(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
ObfuscationReflectionHelper.setPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, theShaderGroup, 51);
ObfuscationReflectionHelper.setPrivateValue(EntityRenderer.class, Minecraft.getMinecraft().entityRenderer, true, 55);
}
catch(JsonException e)
{
e.printStackTrace();
}
}
}
}
示例9: onSleepSuccess
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
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.addChatMessage(player, this.getUnlocalizedName() + ".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
}
}
示例10: serverStopped
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
@EventHandler
public void serverStopped(FMLServerStoppedEvent evt)
{
Set<IWorldGenerator> worldGens = ObfuscationReflectionHelper.getPrivateValue(GameRegistry.class, null, "worldGenerators");
Map<IWorldGenerator,Integer> worldGenIdx = ObfuscationReflectionHelper.getPrivateValue(GameRegistry.class, null, "worldGeneratorIndex");
for (TargetWorldWrapper tww : delegates.values())
{
worldGens.remove(tww);
Integer idx = worldGenIdx.remove(tww);
worldGens.add(tww.delegate);
worldGenIdx.put(tww.delegate,idx);
}
delegates.clear();
}
示例11: onDataPacket
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
readFromNBT(pkt.getNbtCompound());
//noinspection unchecked
Set<String> keys = pkt.getNbtCompound().getKeySet();
Map tagMap = ObfuscationReflectionHelper.getPrivateValue(NBTTagCompound.class, pkt.getNbtCompound(), "tagMap", "field_74784_a");
for (String key : keys) {
try {
Field f = this.getClass().getDeclaredField(key);
f.set(tagMap.get(key), this);
} catch (Exception ignored) {
// e.printStackTrace();
}
}
readExtraNBTFromPacket(pkt.getNbtCompound());
}
示例12: registerRendering
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
public void registerRendering()
{
//Entities
ModEntities.initModels();
//Register animator resource pack, where models and textures are stored, externally from the jar
List<IResourcePack> resourcePackList = ObfuscationReflectionHelper.getPrivateValue(FMLClientHandler.class, FMLClientHandler.instance(), "resourcePackList");
resourcePackList.add(new AnimationResourcePack());
}
示例13: onOutgoingPacketSent
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
@SubscribeEvent
public void onOutgoingPacketSent(PacketEvent.Incoming.Pre event) {
if (event.getPacket() instanceof SPacketPlayerPosLook) {
SPacketPlayerPosLook packet = (SPacketPlayerPosLook) event.getPacket();
try {
ObfuscationReflectionHelper.setPrivateValue(SPacketPlayerPosLook.class, packet, MC.player.rotationYaw, "yaw", "field_148936_d", "d");
ObfuscationReflectionHelper.setPrivateValue(SPacketPlayerPosLook.class, packet, MC.player.rotationPitch, "pitch", "field_148937_e", "e");
} catch (Exception e) {}
}
}
示例14: registerTileEntityWithAlternatives
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
/**
* Register a tile entity, with alternative TileEntity identifiers. Use with caution!
* This method allows for you to "rename" the 'id' of the tile entity.
*
* @param tileEntityClass The tileEntity class to register
* @param id The primary ID, this will be the ID that the tileentity saves as
* @param alternatives A list of alternative IDs that will also map to this class. These will never save, but they will load
*/
public static void registerTileEntityWithAlternatives(Class<? extends TileEntity> tileEntityClass, String id, String... alternatives)
{
TileEntity.addMapping(tileEntityClass, id);
Map<String, Class<?>> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "145855_i", "nameToClassMap");
for (String s : alternatives)
{
if (!teMappings.containsKey(s))
{
teMappings.put(s, tileEntityClass);
}
}
}
示例15: ModelWolfArmor
import net.minecraftforge.fml.common.ObfuscationReflectionHelper; //导入依赖的package包/类
public ModelWolfArmor(float scale) {
this.wolfHeadMain = new ModelRenderer(this, 0, 0);
this.wolfHeadMain.addBox(-2, -3, -2, 6, 6, 4, scale);
this.wolfHeadMain.setRotationPoint(-1, 13.5F, -7);
this.wolfBody = new ModelRenderer(this, 18, 14);
this.wolfBody.addBox(-3, -2, -3, 6, 9, 6, scale);
this.wolfBody.setRotationPoint(0, 14, 2);
this.wolfLeg1 = new ModelRenderer(this, 0, 18);
this.wolfLeg1.addBox(0, 0, -1, 2, 8, 2, scale);
this.wolfLeg1.setRotationPoint(-2.5F, 16, 7);
this.wolfLeg2 = new ModelRenderer(this, 0, 18);
this.wolfLeg2.addBox(0, 0, -1, 2, 8, 2, scale);
this.wolfLeg2.setRotationPoint(0.5F, 16, 7);
this.wolfLeg3 = new ModelRenderer(this, 0, 18);
this.wolfLeg3.addBox(0, 0, -1, 2, 8, 2, scale);
this.wolfLeg3.setRotationPoint(-2.5F, 16, -4);
this.wolfLeg4 = new ModelRenderer(this, 0, 18);
this.wolfLeg4.addBox(0, 0, -1, 2, 8, 2, scale);
this.wolfLeg4.setRotationPoint(0.5F, 16, -4);
this.wolfHeadMain.setTextureOffset(16, 14).addBox(-2, -5, 0, 2, 2, 1, scale);
this.wolfHeadMain.setTextureOffset(16, 14).addBox(2, -5, 0, 2, 2, 1, scale);
this.wolfHeadMain.setTextureOffset(0, 10).addBox(-0.5F, 0, -5, 3, 3, 4, scale);
ModelRenderer wolfMane = new ModelRenderer(this, 21, 0);
wolfMane.addBox(-3, -3, -3, 8, 6, 7, scale);
wolfMane.setRotationPoint(-1, 14, 2);
ModelRenderer wolfTail = new ModelRenderer(this, 9, 18);
wolfTail.addBox(0, 0, -1, 2, 8, 2, scale);
wolfTail.setRotationPoint(-1, 12, 8);
try {
ObfuscationReflectionHelper.setPrivateValue(ModelWolf.class, this, wolfTail, 6);
ObfuscationReflectionHelper.setPrivateValue(ModelWolf.class, this, wolfMane, 7);
} catch(Exception e){
ModLogger.error("Error while trying to access the needed fields in the ModelWolf class");
e.printStackTrace();
}
}