本文整理汇总了Java中net.minecraft.inventory.Slot.getSlotIndex方法的典型用法代码示例。如果您正苦于以下问题:Java Slot.getSlotIndex方法的具体用法?Java Slot.getSlotIndex怎么用?Java Slot.getSlotIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.inventory.Slot
的用法示例。
在下文中一共展示了Slot.getSlotIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMouseClick
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@Override
protected void handleMouseClick(Slot slot, int slotId, int clickedButton, ClickType clickType) {
if (slot instanceof SlotPhantom && Minecraft.getMinecraft().player.inventory.getItemStack().isEmpty() && !slot.getHasStack() && clickedButton == 1) {
editingSlot = slot.getSlotIndex();
Minecraft.getMinecraft().displayGuiScreen(searchGui = new GuiSearcher(Minecraft.getMinecraft().player));
} else {
super.handleMouseClick(slot, slotId, clickedButton, clickType);
}
}
示例2: onContainerOpened
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@SubscribeEvent
public void onContainerOpened(PlayerContainerEvent.Open event)
{
if (!SettingsFlags.instance.enableCustomInventory)
{
return;
}
try
{
Container c = event.getContainer();
for (int i = 0; i < c.inventorySlots.size(); ++i)
{
Slot s = c.inventorySlots.get(i);
if (s.getClass().equals(Slot.class) && s.inventory instanceof InventoryPlayer && !(s instanceof ManagedSlot) && s.getSlotIndex() >= 9 && s.getSlotIndex() < 36)
{
ManagedSlot wrapper = new ManagedSlot(s);
c.inventorySlots.remove(i);
c.inventorySlots.add(i, wrapper);
}
}
}
catch (Exception ex)
{
ExPMisc.modLogger.log(LogLevel.Error, "ExPetrum was unable to initialize it's inventory system! This is most likely caused by another mod!", ex);
}
}
示例3: onOpenGui
import net.minecraft.inventory.Slot; //导入方法依赖的package包/类
@SubscribeEvent
public static void onOpenGui(GuiScreenEvent.InitGuiEvent event)
{
if (event.getGui() instanceof GuiContainer)
{
if (!SettingsFlags.instance.enableCustomInventory)
{
return;
}
GuiContainer gc = (GuiContainer) event.getGui();
if ((gc instanceof GuiInventory || gc instanceof GuiContainerCreative) && Minecraft.getMinecraft().player.capabilities.isCreativeMode)
{
return;
}
Container c = gc.inventorySlots;
for (int i = 0; i < c.inventorySlots.size(); ++i)
{
Slot s = c.inventorySlots.get(i);
if (s.getClass().equals(Slot.class) && s.inventory instanceof InventoryPlayer && !(s instanceof ManagedSlot) && s.getSlotIndex() >= 9 && s.getSlotIndex() < 36)
{
ManagedSlot wrapper = new ManagedSlot(s);
c.inventorySlots.remove(i);
c.inventorySlots.add(i, wrapper);
}
}
}
if (event.getGui() instanceof GuiCreateWorld)
{
if (!SettingsFlags.instance.enableInvasiveChanges)
{
return;
}
try
{
Field f = null;
Field[] allFlds = GuiCreateWorld.class.getDeclaredFields();
for (int i = allFlds.length - 1; i >= 0; --i)
{
if (allFlds[i].getType() == Integer.TYPE)
{
f = allFlds[i];
break;
}
}
f.setAccessible(true);
f.set(event.getGui(), ExPMisc.worldTypeExP.getId());
}
catch (Exception ex)
{
ExPMisc.modLogger.log(LogLevel.Debug, "Could not reflect GuiCreateWorld!", ex);
}
}
}