本文整理汇总了Java中net.minecraftforge.client.event.GuiOpenEvent.setGui方法的典型用法代码示例。如果您正苦于以下问题:Java GuiOpenEvent.setGui方法的具体用法?Java GuiOpenEvent.setGui怎么用?Java GuiOpenEvent.setGui使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.client.event.GuiOpenEvent
的用法示例。
在下文中一共展示了GuiOpenEvent.setGui方法的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: 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);
}
}
}
示例3: 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 "));
}
}
}
示例4: 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);
}
}
}
示例5: 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));
}
}
示例6: guiOpen
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
/** Alters which vanilla Gui is opened. */
@SubscribeEvent
public void guiOpen(GuiOpenEvent event) {
EntityPlayer player = Minecraft.getMinecraft().player;
if (event.getGui() instanceof
net.minecraft.client.gui.inventory.GuiInventory &&
player.inventoryContainer instanceof ContainerInventory) {
event.setGui(new jayavery.geomastery.gui.GuiInventory(
(ContainerInventory) player.inventoryContainer));
}
}
示例7: onGui
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onGui(GuiOpenEvent event) {
if (event.getGui() == null || !GuiEnchantment.class.equals(event.getGui().getClass())) {
// Only hook the enchantment GUI. We don't use instanceof, because we *only* want to
// hook the unmodified GUI.
return;
}
event.setGui(GuiEnchantmentWrapper.wrap((GuiEnchantment) event.getGui(), worker, lastInteractPos));
}
示例8: npcTradeOpen
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void npcTradeOpen(GuiOpenEvent event){
if(event.getGui() instanceof GuiMerchant){
if(((GuiMerchant) event.getGui()).getMerchant() instanceof NPCShop){
lastOpened = (NPCShop) ((GuiMerchant) event.getGui()).getMerchant();
}else{
Minecraft mc = Minecraft.getMinecraft();
event.setGui(new GuiNPCMerchant(mc.player.inventory, lastOpened, mc.world));
}
}
}
示例9: openMainMenu
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SideOnly( Side.CLIENT )
public void openMainMenu(final GuiOpenEvent event ) {
// if the max shades has changed in form the user of the new usage.
if ((!detectedSdVersion.equals(config.lastSDVersionWarned)) && (sdMajorMismatch || sdMinorMismatch || sdVersionCheckFailed)) {
event.setGui(new GuiScreenStartup());
}
}
示例10: checkMainMenu
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void checkMainMenu(GuiOpenEvent event) {
String update = getUpdate();
if (event.getGui() instanceof GuiMainMenu && update != null) {
event.setGui(new UiUpdate(event.getGui(), update));
MinecraftForge.EVENT_BUS.unregister(this);
}
}
示例11: checkMultiplayer
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void checkMultiplayer(GuiOpenEvent event) {
System.out.println("Checking for multiplayer.");
if (event.getGui() instanceof GuiMultiplayer)
event.setGui(new UiMultiplayer(new GuiMainMenu()));
}
示例12: applyForgeEventPatch
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@Override
public <T extends Event> boolean applyForgeEventPatch(T e) {
GuiOpenEvent event = (GuiOpenEvent) e;
String prefilledText = ReflectionHelper.get(ObfuscatedField.GuiChat_defaultInputFieldText, (net.minecraft.client.gui.GuiChat) event.getGui());
if (event.getGui() instanceof net.minecraft.client.gui.GuiSleepMP) event.setGui(new GuiSleepMP());
else event.setGui(prefilledText == null ? new GuiChat() : new GuiChat(prefilledText));
PatchManager.instance().getGlobalAppliedPatches().setPatchSuccessfullyApplied(this.displayName, true);
return true;
}
示例13: applyGuiOpenPatches
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
private boolean applyGuiOpenPatches(GuiOpenEvent event) {
if (event.getGui() instanceof GuiMainMenu && this.startupServerName != null) {
GuiScreen screen = connectToServerAtStartup(this.startupServerName, this.startupServerPort);
this.startupServerName = null;
if (screen == null) {
FMLClientHandler.instance().connectToServerAtStartup(this.startupServerName, this.startupServerPort);
PatchManager.instance().getGlobalAppliedPatches().setPatchSuccessfullyApplied(this.displayName, false);
return false;
}
else {
event.setGui(screen);
PatchManager.instance().getGlobalAppliedPatches().setPatchSuccessfullyApplied(this.displayName, true);
return true;
}
}
else if (event.getGui() instanceof net.minecraft.client.gui.GuiMultiplayer) {
if (parentScreenField == null) {
PatchManager.instance().getGlobalAppliedPatches().setPatchSuccessfullyApplied(this.displayName, false);
return false;
}
GuiScreen parentScreen = ReflectionHelper.get(ObfuscatedField.GuiMultiplayer_parentScreen, parentScreenField, (net.minecraft.client.gui.GuiMultiplayer) event.getGui());
event.setGui(new GuiMultiplayer(parentScreen));
PatchManager.instance().getGlobalAppliedPatches().setPatchSuccessfullyApplied(this.displayName, true);
return true;
}
else throw new IllegalArgumentException("Invalid argument: GuiOpenEvent with GuiMainMenu or GuiMultiplayer required");
}
示例14: openGui
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void openGui(GuiOpenEvent e) throws Exception {
if (EasyEditorsApi.isEasyEditorsActive && e.getGui() != null) {
Class<? extends GuiScreen> oldClass = e.getGui().getClass();
if (replacementMap.containsKey(oldClass)) {
e.setGui(replacementMap.get(oldClass).getConstructor(oldClass).newInstance(e.getGui()));
}
}
}
示例15: guiOpen
import net.minecraftforge.client.event.GuiOpenEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void guiOpen(GuiOpenEvent event)
{
GuiScreen gui = event.getGui();
GuiScreen curGui = Minecraft.getMinecraft().currentScreen;
if (gui instanceof GuiDisconnected)
{
GuiDisconnected dc = (GuiDisconnected) gui;
try
{
if (reasonField == null)
{
reasonField = ReflectionHelper.findField(gui.getClass(), "field_146306_a", "reason");
reasonField.setAccessible(true);
}
if (messageField == null)
{
messageField = ReflectionHelper.findField(gui.getClass(), "field_146304_f", "message");
messageField.setAccessible(true);
}
if (parentField == null)
{
parentField = ReflectionHelper.findField(gui.getClass(), "field_146307_h", "parentScreen");
parentField.setAccessible(true);
}
String reason = (String) reasonField.get(dc);
ITextComponent message = (ITextComponent) messageField.get(dc);
if (curGui instanceof GuiProgressDisconnected)
{
if (message.getUnformattedText().contains("Server is still pre-generating!"))
{
GuiProgressDisconnected curDiscon = (GuiProgressDisconnected) curGui;
curDiscon.update(reason, message);
event.setCanceled(true);
}
}
else if (message.getUnformattedText().contains("Server is still pre-generating!"))
{
event.setGui(new GuiProgressDisconnected((GuiScreen) parentField.get(dc), reason, message, lastNetworkManager));
lastNetworkManager = null;
}
}
catch (Throwable e)
{
}
}
else if (gui instanceof GuiConnecting)
{
//lastNetworkManager = getNetworkManager((GuiConnecting) gui);
}
}