本文整理汇总了Java中net.minecraftforge.client.event.GuiOpenEvent.getGui方法的典型用法代码示例。如果您正苦于以下问题:Java GuiOpenEvent.getGui方法的具体用法?Java GuiOpenEvent.getGui怎么用?Java GuiOpenEvent.getGui使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.client.event.GuiOpenEvent
的用法示例。
在下文中一共展示了GuiOpenEvent.getGui方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onGuiOpened
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onGuiOpened(GuiOpenEvent event) {
if (!hasAutoLogged)
if(event.getGui() instanceof GuiDisconnected &&
!(event.getGui() instanceof GuiDisconnectedOverride)) {
updateLastConnectedServer();
GuiDisconnected disconnected = (GuiDisconnected)event.getGui();
event.setGui(new GuiDisconnectedOverride(
FastReflection.Fields.GuiDisconnected_parentScreen.get(disconnected),
"connect.failed",
FastReflection.Fields.GuiDisconnected_message.get(disconnected),
FastReflection.Fields.GuiDisconnected_reason.get(disconnected),
delay.get()
));
}
}
示例2: onGuiOpenEvent
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onGuiOpenEvent(GuiOpenEvent event)
{
if (event.getGui() == null)
{
// a gui has been closed -- reset remote gui
if (Minecraft.getMinecraft().world instanceof HookedClientWorld)
{
((HookedClientWorld)Minecraft.getMinecraft().world).ClearRemoteGui();
}
else
{
Util.logger.error("Minecraft.getMinecraft().world is not instance of RemoteGuiEnabledClientWorld!");
}
}
}
示例3: onGuiOpen
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onGuiOpen(GuiOpenEvent event)
{
if(event.getGui() instanceof GuiMainMenu && !played)
{
played = true;
if(playOn == 1 || playOn == 3)
{
SoundEvent sound = SoundEvent.REGISTRY.getObject(new ResourceLocation(name));
if(sound != null)
{
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(sound, (float)pitch));
}
else
{
logger.log(Level.WARN, "Could not find sound: %s", new ResourceLocation(name));
}
}
}
}
示例4: onGuiOpen
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event)
{
GuiScreen gui = event.getGui();
if(gui !=null && gui instanceof GuiScreenHorseInventory){
GuiScreenHorseInventory horseGui = (GuiScreenHorseInventory)gui;
EntityHorse horse = (EntityHorse)ReflectionUtils.getPrivateValue(horseGui, GuiScreenHorseInventory.class, ObfuscatedNames.GuiScreenHorseInventory_horseEntity);
if(horse !=null && HorseAccessories.hasEnderChest(horse)){
ContainerHorseChest animalchest = new ContainerHorseChest("HorseChest", 2);
animalchest.setCustomName(horse.getName());
event.setGui(new GuiHorseEnderChest(CrystalMod.proxy.getClientPlayer().inventory, animalchest, horse));
PacketGuiMessage pkt = new PacketGuiMessage("Gui");
pkt.setOpenGui(GuiHandler.GUI_ID_ENTITY, horse.getEntityId(), 0, 0);
CrystalModNetwork.sendToServer(pkt);
}
}
}
示例5: onGuiOpen
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void onGuiOpen(@Nonnull final GuiOpenEvent event) {
if (!hasPlayed && event.getGui() instanceof GuiMainMenu) {
hasPlayed = true;
final String[] possibles = ModOptions.startupSoundList;
if (possibles == null || possibles.length == 0)
return;
final String res = possibles[XorShiftRandom.current().nextInt(possibles.length)];
if (!StringUtils.isEmpty(res)) {
final SoundEvent se = SoundEvent.REGISTRY.getObject(new ResourceLocation(res));
if (se != null)
SoundEngine.instance().playSound(new AdhocSound(se, SoundCategory.MASTER));
else
DSurround.log().warn("Unable to locate startup sound [%s]", res);
} else {
DSurround.log().warn("Improperly formatted startup sound list!");
}
}
}
示例6: guiOpenEvent
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void guiOpenEvent(GuiOpenEvent event) {
if (event.getGui() instanceof GuiContainer) {
if (lastGui != event.getGui()) {
if (event.getGui() == null) {
instanceTooltipHandlers = null;
} else {
instanceTooltipHandlers = new LinkedList<>();
if (event.getGui() instanceof IContainerTooltipHandler) {
instanceTooltipHandlers.add(((IContainerTooltipHandler) event.getGui()));
}
instanceTooltipHandlers.addAll(tooltipHandlers);
}
lastGui = event.getGui();
}
}
}
示例7: onGuiOpenEvent
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onGuiOpenEvent(GuiOpenEvent event)
{
// Reset the scrolling modifier when the player opens a GUI.
// Otherwise the key up event will get eaten and our scrolling mode will get stuck on
// until the player sneaks again.
// FIXME Apparently there are key input events for GUI screens in 1.8,
// so this probably can be removed then.
InputEventHandler.resetModifiers();
// Opening the player's Inventory GUI
if (event.getGui() != null && event.getGui().getClass() == GuiInventory.class)
{
EntityPlayer player = FMLClientHandler.instance().getClientPlayerEntity();
if (this.handyBagShouldOpen && player != null && ItemHandyBag.getOpenableBag(player).isEmpty() == false)
{
if (event.isCancelable())
{
event.setCanceled(true);
}
PacketHandler.INSTANCE.sendToServer(new MessageOpenGui(player.dimension, ReferenceGuiIds.GUI_ID_HANDY_BAG));
}
}
}
示例8: onOpenGui
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onOpenGui(GuiOpenEvent evt) {
GuiScreen gui = evt.getGui();
if (gui instanceof GuiMainMenu) {
try {
GuiMainMenu menu = (GuiMainMenu) gui;
String splash = mainMenuGetSplashText(menu);
if (splash.equals("Kind of dragon free!")) {
splash = "Not really dragon free!";
mainMenuSetSplashText(menu, splash);
} else if (splashLines != null && !splashLines.isEmpty() && rand.nextInt(10) == 0) {
splash = splashLines.get(rand.nextInt(splashLines.size()));
mainMenuSetSplashText(menu, splash);
}
} catch (Throwable t) {
L.warn("Can't override splash", t);
}
}
}
示例9: onOpenGui
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onOpenGui(GuiOpenEvent event) {
Minecraft mc = Minecraft.getMinecraft();
if (mc.player != null && mc.player.getHealth() <= 0f) {
mc.player.setSneaking(false);
if (event.getGui() instanceof GuiChat && mc.gameSettings.keyBindSneak.isKeyDown()) {
event.setGui(new GuiChat("/team "));
}
}
}
示例10: onOpenGui
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onOpenGui(GuiOpenEvent event) {
Minecraft mc = Minecraft.getMinecraft();
if (mc.player != null) {
if (event.getGui() instanceof GuiGameOver && isKnockedOut && !acceptedDeath) { // Minor hack: isKnockedOut is always set AFTER the game over screen pops up, so we can abuse that here
event.setGui(null);
} else if (isKnockedOut && event.getGui() instanceof GuiInventory) {
event.setGui(null);
}
}
}
示例11: guiInit
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void guiInit(GuiOpenEvent e) {
if(e.getGui() instanceof GuiVideoSettings) {
e.setGui(new GuiNewVideoSettings(Minecraft.getMinecraft().currentScreen, Minecraft.getMinecraft().gameSettings));
} else if(e.getGui() instanceof GuiOptions) {
e.setGui(new GuiNewOptions(((GuiOptions) e.getGui()).lastScreen, Minecraft.getMinecraft().gameSettings));
}
}
示例12: guiOpenEvent
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void guiOpenEvent(GuiOpenEvent event){
System.out.println(event.getGui());
if(event.getGui() instanceof GuiInventory){
event.setCanceled(true);
Minecraft.getMinecraft().thePlayer.openGui(Main.instance, 21, Minecraft.getMinecraft().theWorld, (int) Minecraft.getMinecraft().thePlayer.posX, (int) Minecraft.getMinecraft().thePlayer.posY, (int) Minecraft.getMinecraft().thePlayer.posZ);
}
}
示例13: onGuiOpen
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
/**
* Refresh models, skins and morphs upon entering in Metamorph and/or
* Blockbuster GUIs.
*/
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event)
{
if (!Blockbuster.proxy.config.auto_refresh_models)
{
return;
}
GuiScreen gui = event.getGui();
boolean isMetamorph = gui instanceof GuiCreativeMenu || gui instanceof GuiSurvivalMenu;
boolean isBlockbuster = gui instanceof GuiDirector || gui instanceof GuiActor;
boolean exitME = gui == null && Minecraft.getMinecraft().currentScreen instanceof GuiModelEditor;
if (isMetamorph || isBlockbuster || exitME)
{
/* Reload models and skin */
ModelPack pack = Blockbuster.proxy.models.pack;
if (pack == null)
{
pack = Blockbuster.proxy.getPack();
if (Minecraft.getMinecraft().isSingleplayer())
{
pack.addFolder(DimensionManager.getCurrentSaveRootDirectory() + "/blockbuster/models");
}
}
Blockbuster.proxy.loadModels(pack);
ClientProxy.actorPack.pack.reload();
}
}
示例14: onGuiOpen
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@Method(modid = "aperture")
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event)
{
if (Minecraft.getMinecraft().thePlayer == null)
{
return;
}
GuiScreen current = Minecraft.getMinecraft().currentScreen;
GuiScreen toOpen = event.getGui();
BlockPos pos = getDirectorPos();
if (pos != null)
{
int tick = ClientProxy.cameraEditor.scrub.value;
if (current != ClientProxy.cameraEditor && toOpen instanceof GuiCameraEditor)
{
/* Camera editor opens */
CameraHandler.tick = tick;
if (CameraHandler.reload)
{
Dispatcher.sendToServer(new PacketDirectorPlay(pos, PacketDirectorPlay.START, tick));
}
Dispatcher.sendToServer(new PacketRequestLength(pos));
}
}
}
示例15: onMainMenuOpen
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onMainMenuOpen(GuiOpenEvent event) {
if (!dumped && event.getGui() instanceof GuiMainMenu) {
dumped = true;
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
for (Map.Entry<ResourceLocation, ITextureObject> entry : textureManager.mapTextureObjects.entrySet()) {
ITextureObject textureObject = entry.getValue();
if (textureObject instanceof TextureMap) {
String name = entry.getKey().toString().replace(':', '_').replace('/', '_');
dumpTextureMap((TextureMap) textureObject, name);
}
}
}
}