本文整理匯總了Java中me.mrCookieSlime.Slimefun.api.inventory.BlockMenu類的典型用法代碼示例。如果您正苦於以下問題:Java BlockMenu類的具體用法?Java BlockMenu怎麽用?Java BlockMenu使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BlockMenu類屬於me.mrCookieSlime.Slimefun.api.inventory包,在下文中一共展示了BlockMenu類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setBlockInfo
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
public static void setBlockInfo(Location l, String json, boolean updateTicker) {
BlockStorage storage = getStorage(l.getWorld());
storage.storage.put(l, json);
Map<String, String> parsed = parseJSON(json);
if (BlockMenuPreset.isInventory(parsed.get("id"))) {
if (BlockMenuPreset.isUniversalInventory(parsed.get("id"))) {
if (!universal_inventories.containsKey(parsed.get("id"))) storage.loadUniversalInventory(BlockMenuPreset.getPreset(parsed.get("id")));
}
else if (!storage.hasInventory(l)) {
File file = new File("data-storage/Slimefun/stored-inventories/" + serializeLocation(l) + ".sfi");
if (file.exists()) storage.inventories.put(l, new BlockMenu(BlockMenuPreset.getPreset(parsed.get("id")), l, new Config(file)));
else storage.loadInventory(l, BlockMenuPreset.getPreset(parsed.get("id")));
}
}
refreshCache(getStorage(l.getWorld()), l, parsed.get("id"), json, updateTicker);
}
示例2: register
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
@Override
public void register(boolean slimefun) {
addItemHandler(new BlockTicker() {
@Override
public void uniqueTick() {
}
@Override
public void tick(Block b, SlimefunItem item, Config data) {
BlockMenu menu = BlockStorage.getInventory(b);
for (int slot: getInputSlots()) {
menu.replaceExistingItem(slot, null);
}
}
@Override
public boolean isSynchronized() {
return false;
}
});
super.register(slimefun);
}
示例3: getAccessPort
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
public BlockMenu getAccessPort(Location l)
{
Location portL = new Location(l.getWorld(), l.getX(), l.getY() + 3D, l.getZ());
if(BlockStorage.check(portL, "REACTOR_ACCESS_PORT"))
return BlockStorage.getInventory(portL);
else
return null;
}
示例4: ChargingBench
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
public ChargingBench(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack recipe[])
{
super(category, item, name, recipeType, recipe);
new BlockMenuPreset(name, getInventoryTitle()) {
final ChargingBench this$0;
public void init()
{
constructMenu(this);
}
public void newInstance(BlockMenu blockmenu, Block block)
{
}
public boolean canOpen(Block b, Player p)
{
return p.hasPermission("slimefun.inventory.bypass") || CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true);
}
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow)
{
if(flow.equals(ItemTransportFlow.INSERT))
return getInputSlots();
else
return getOutputSlots();
}
{
this$0 = ChargingBench.this;
super($anonymous0, $anonymous1);
}
}
;
}
示例5: FluidPump
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
public FluidPump(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack recipe[])
{
super(category, item, name, recipeType, recipe);
new BlockMenuPreset(name, getInventoryTitle()) {
final FluidPump this$0;
public void init()
{
constructMenu(this);
}
public void newInstance(BlockMenu blockmenu, Block block)
{
}
public boolean canOpen(Block b, Player p)
{
return p.hasPermission("slimefun.inventory.bypass") || CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true);
}
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow)
{
if(flow.equals(ItemTransportFlow.INSERT))
return getInputSlots();
else
return getOutputSlots();
}
{
this$0 = FluidPump.this;
super($anonymous0, $anonymous1);
}
}
;
}
示例6: tick
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
protected void tick(Block b) {
if (BlockStorage.getBlockInfo(b, "enabled").equals("false")) return;
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
BlockMenu menu = BlockStorage.getInventory(b);
StringBuilder builder = new StringBuilder();
int i = 0;
for (int j = 0; j < 9; j++) {
if (i > 0) {
builder.append(" </slot> ");
}
ItemStack item = menu.getItemInSlot(getInputSlots()[j]);
if (item != null && item.getAmount() == 1) return;
builder.append(CustomItemSerializer.serialize(item, ItemFlag.DATA, ItemFlag.ITEMMETA_DISPLAY_NAME, ItemFlag.ITEMMETA_LORE, ItemFlag.MATERIAL));
i++;
}
String input = builder.toString();
if (recipes.containsKey(input)) {
ItemStack output = recipes.get(input).clone();
if (fits(b, new ItemStack[] {output})) {
pushItems(b, new ItemStack[] {output});
ChargableBlock.addCharge(b, -getEnergyConsumption());
for (int j = 0; j < 9; j++) {
if (menu.getItemInSlot(getInputSlots()[j]) != null) menu.replaceExistingItem(getInputSlots()[j], InvUtils.decreaseItem(menu.getItemInSlot(getInputSlots()[j]), 1));
}
}
}
}
示例7: TrashCan
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
public TrashCan(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack recipe[])
{
super(category, item, name, recipeType, recipe);
new BlockMenuPreset(name, getInventoryTitle()) {
final TrashCan this$0;
public void init()
{
constructMenu(this);
}
public void newInstance(BlockMenu blockmenu, Block block)
{
}
public boolean canOpen(Block b, Player p)
{
return true;
}
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow)
{
if(flow.equals(ItemTransportFlow.INSERT))
return getInputSlots();
else
return new int[0];
}
{
this$0 = TrashCan.this;
super($anonymous0, $anonymous1);
}
}
;
}
示例8: register
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
public void register(boolean slimefun)
{
addItemHandler(new ItemHandler[] {
new BlockTicker() {
final TrashCan this$0;
public void uniqueTick()
{
}
public void tick(Block b, SlimefunItem item, Config data)
{
BlockMenu menu = BlockStorage.getInventory(b);
int ai[];
int j = (ai = getInputSlots()).length;
for(int i = 0; i < j; i++)
{
int slot = ai[i];
menu.replaceExistingItem(slot, null);
}
}
public boolean isSynchronized()
{
return false;
}
{
this$0 = TrashCan.this;
super();
}
}
});
super.register(slimefun);
}
示例9: _integrated_moveBlockInfo
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
public static void _integrated_moveBlockInfo(Block block, Block newBlock) {
if (!hasBlockInfo(block)) return;
BlockStorage storage = getStorage(block.getWorld());
setBlockInfo(newBlock, getBlockInfo(block), true);
if (storage.inventories.containsKey(block.getLocation())) {
BlockMenu menu = storage.inventories.get(block.getLocation());
storage.inventories.put(newBlock.getLocation(), menu);
storage.clearInventory(block.getLocation());
menu.move(newBlock);
}
refreshCache(storage, block, getBlockInfo(block).getString("id"), null, true);
storage.storage.remove(block.getLocation());
try {
if (ticking_chunks.containsKey(block.getChunk().toString())) {
Set<Block> blocks = ticking_chunks.get(block.getChunk().toString());
blocks.remove(block);
if (blocks.isEmpty()) {
ticking_chunks.remove(block.getChunk().toString());
loaded_tickers.remove(block.getChunk().toString());
}
else ticking_chunks.put(block.getChunk().toString(), blocks);
}
}
catch(IllegalStateException x) {
}
}
示例10: clearInventory
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
public void clearInventory(Location l) {
BlockMenu menu = getInventory(l);
for(HumanEntity human: new ArrayList<>(menu.toInventory().getViewers())) {
human.closeInventory();
}
inventories.get(l).delete(l);
inventories.remove(l);
}
示例11: register
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
@Override
public void register(boolean slimefun) {
addItemHandler(new BlockTicker() {
final ItemStack item = new CustomItem(new MaterialData(Material.BARRIER), "�4No Cargo Net connected!");
final MenuClickHandler click = new MenuClickHandler() {
@Override
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
return false;
}
};
@Override
public void tick(Block b, SlimefunItem sf, Config data) {
if (!CargoNet.isConnected(b)) {
BlockMenu menu = BlockStorage.getInventory(b);
for (int slot: CargoNet.terminal_slots) {
menu.replaceExistingItem(slot, item);
menu.addMenuClickHandler(slot, click);
}
}
}
@Override
public void uniqueTick() {
}
@Override
public boolean isSynchronized() {
return true;
}
});
super.register(slimefun);
}
示例12: getBlockMenu
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
public BlockMenu getBlockMenu(Block b) {
return BlockStorage.getInventory(b);
}
示例13: OilPump
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
public OilPump(Category category, ItemStack item, String name, RecipeType recipeType, ItemStack recipe[])
{
super(category, item, name, recipeType, recipe);
new BlockMenuPreset(name, getInventoryTitle()) {
final OilPump this$0;
public void init()
{
constructMenu(this);
}
public void newInstance(BlockMenu blockmenu, Block block)
{
}
public boolean canOpen(Block b, Player p)
{
if(!p.hasPermission("slimefun.inventory.bypass") && !CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true))
return false;
if(!OreGenSystem.wasResourceGenerated(OreGenSystem.getResource("Oil"), b.getChunk()))
{
Messages.local.sendTranslation(p, "gps.geo.scan-required", true, new Variable[0]);
return false;
} else
{
return true;
}
}
public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow)
{
if(flow.equals(ItemTransportFlow.INSERT))
return getInputSlots();
else
return getOutputSlots();
}
{
this$0 = OilPump.this;
super($anonymous0, $anonymous1);
}
}
;
}
示例14: loadInventory
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
public BlockMenu loadInventory(Location l, BlockMenuPreset preset) {
BlockMenu menu = new BlockMenu(preset, l);
inventories.put(l, menu);
return menu;
}
示例15: getInventory
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; //導入依賴的package包/類
public static BlockMenu getInventory(Block b) {
return getInventory(b.getLocation());
}