本文整理汇总了Java中me.mrCookieSlime.Slimefun.api.energy.ChargableBlock.getCharge方法的典型用法代码示例。如果您正苦于以下问题:Java ChargableBlock.getCharge方法的具体用法?Java ChargableBlock.getCharge怎么用?Java ChargableBlock.getCharge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类me.mrCookieSlime.Slimefun.api.energy.ChargableBlock
的用法示例。
在下文中一共展示了ChargableBlock.getCharge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
protected void tick(Block b) {
if (ChargableBlock.isChargable(b)) {
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
int i = getSize() / 2;
loop:
for (int x = -i; x <= i; x++) {
for (int z = -i; z <= i; z++) {
Block block = new Location(b.getWorld(), b.getX() + x, b.getY() + 2, b.getZ() + z).getBlock();
if (canHarvest(block)) {
ItemStack item = harvest(block);
if (!fits(block, new ItemStack[] {item})) break loop;
pushItems(b, new ItemStack[] {item});
ChargableBlock.addCharge(b, -getEnergyConsumption());
break loop;
}
}
}
}
}
示例2: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
protected void tick(Block b) throws Exception {
for (Entity n: me.mrCookieSlime.Slimefun.holograms.AutoBreeder.getArmorStand(b).getNearbyEntities(4D, 2D, 4D)) {
if (Animals.isFeedable(n)) {
for (int slot: getInputSlots()) {
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) {
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
ChargableBlock.addCharge(b, -getEnergyConsumption());
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1));
Animals.feed(n);
ParticleEffect.HEART.display(((LivingEntity) n).getEyeLocation(), 0.2F, 0.2F, 0.2F, 0, 8);
return;
}
}
}
}
}
示例3: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
protected void tick(Block b) throws Exception {
for (Entity n: me.mrCookieSlime.Slimefun.holograms.AnimalGrowthAccelerator.getArmorStand(b).getNearbyEntities(3D, 3D, 3D)) {
if (n instanceof Ageable && !((Ageable) n).isAdult()) {
for (int slot: getInputSlots()) {
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) {
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
ChargableBlock.addCharge(b, -getEnergyConsumption());
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1));
((Ageable) n).setAge(((Ageable) n).getAge() + 2000);
if (((Ageable) n).getAge() > 0) ((Ageable) n).setAge(0);
ParticleEffect.VILLAGER_HAPPY.display(((LivingEntity) n).getEyeLocation(), 0.2F, 0.2F, 0.2F, 0, 8);
return;
}
}
}
}
}
示例4: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
protected void tick(Block b)
{
if(isProcessing(b))
{
int timeleft = ((Integer)progress.get(b)).intValue();
if(timeleft > 0)
{
ItemStack item = getProgressBar().clone();
item.setDurability(MachineHelper.getDurability(item, timeleft, ((MachineRecipe)processing.get(b)).getTicks()));
ItemMeta im = item.getItemMeta();
im.setDisplayName(" ");
List lore = new ArrayList();
lore.add(MachineHelper.getProgress(timeleft, ((MachineRecipe)processing.get(b)).getTicks()));
lore.add("");
lore.add(MachineHelper.getTimeLeft(timeleft / 2));
im.setLore(lore);
item.setItemMeta(im);
BlockStorage.getInventory(b).replaceExistingItem(22, item);
if(ChargableBlock.getCharge(b) < getEnergyConsumption())
return;
ChargableBlock.addCharge(b, -getEnergyConsumption());
progress.put(b, Integer.valueOf(timeleft - 1));
} else
{
BlockStorage.getInventory(b).replaceExistingItem(22, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte)15), " ", new String[0]));
pushItems(b, ((MachineRecipe)processing.get(b)).getOutput());
progress.remove(b);
processing.remove(b);
}
} else
if(OreGenSystem.getSupplies(getOreGenResource(), b.getChunk(), false) > 0)
{
MachineRecipe r = new MachineRecipe(getProcessingTime() / getSpeed(), new ItemStack[0], getOutputItems());
if(!fits(b, r.getOutput()))
return;
processing.put(b, r);
progress.put(b, Integer.valueOf(r.getTicks()));
OreGenSystem.setSupplies(getOreGenResource(), b.getChunk(), OreGenSystem.getSupplies(getOreGenResource(), b.getChunk(), false) - 1);
}
}
示例5: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
protected void tick(Block b)
{
if(ChargableBlock.isChargable(b))
{
if(ChargableBlock.getCharge(b) < getEnergyConsumption())
return;
int i = getSize() / 2;
label0:
for(int x = -i; x <= i; x++)
{
for(int z = -i; z <= i; z++)
{
Block block = (new Location(b.getWorld(), b.getX() + x, b.getY() + 2, b.getZ() + z)).getBlock();
if(!canHarvest(block))
continue;
ItemStack item = harvest(block);
if(fits(block, new ItemStack[] {
item
}))
{
pushItems(b, new ItemStack[] {
item
});
ChargableBlock.addCharge(b, -getEnergyConsumption());
}
break label0;
}
}
}
}
示例6: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
protected void tick(Block b)
throws Exception
{
for(Iterator iterator = me.mrCookieSlime.Slimefun.holograms.XPCollector.getArmorStand(b).getNearbyEntities(4D, 4D, 4D).iterator(); iterator.hasNext();)
{
Entity n = (Entity)iterator.next();
if(n instanceof ExperienceOrb)
{
if(ChargableBlock.getCharge(b) < getEnergyConsumption())
return;
if(n.isValid())
{
int xp = getEXP(b) + ((ExperienceOrb)n).getExperience();
ChargableBlock.addCharge(b, -getEnergyConsumption());
n.remove();
int withdrawn = 0;
for(int level = 0; level < getEXP(b); level += 10)
if(fits(b, new ItemStack[] {
new CustomItem(Material.EXP_BOTTLE, "&a\u5B66\u8BC6\u4E4B\u74F6", 0)
}))
{
withdrawn += 10;
pushItems(b, new ItemStack[] {
new CustomItem(Material.EXP_BOTTLE, "&a\u5B66\u8BC6\u4E4B\u74F6", 0)
});
}
BlockStorage.addBlockInfo(b, "stored-exp", String.valueOf(xp - withdrawn));
return;
}
}
}
}
示例7: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的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));
}
}
}
}
示例8: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
protected void tick(Block b)
throws Exception
{
for(Iterator iterator = me.mrCookieSlime.Slimefun.holograms.AutoBreeder.getArmorStand(b).getNearbyEntities(4D, 2D, 4D).iterator(); iterator.hasNext();)
{
Entity n = (Entity)iterator.next();
if(Animals.isFeedable(n))
{
int ai[];
int j = (ai = getInputSlots()).length;
for(int i = 0; i < j; i++)
{
int slot = ai[i];
if(SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false))
if(ChargableBlock.getCharge(b) < getEnergyConsumption())
{
return;
} else
{
ChargableBlock.addCharge(b, -getEnergyConsumption());
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1));
Animals.feed(n);
ParticleEffect.HEART.display(((LivingEntity)n).getEyeLocation(), 0.2F, 0.2F, 0.2F, 0.0F, 8);
return;
}
}
}
}
}
示例9: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
protected void tick(Block b)
throws Exception
{
for(Iterator iterator = me.mrCookieSlime.Slimefun.holograms.AnimalGrowthAccelerator.getArmorStand(b).getNearbyEntities(3D, 3D, 3D).iterator(); iterator.hasNext();)
{
Entity n = (Entity)iterator.next();
if((n instanceof Ageable) && !((Ageable)n).isAdult())
{
int ai[];
int j = (ai = getInputSlots()).length;
for(int i = 0; i < j; i++)
{
int slot = ai[i];
if(SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false))
{
if(ChargableBlock.getCharge(b) < getEnergyConsumption())
return;
ChargableBlock.addCharge(b, -getEnergyConsumption());
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1));
((Ageable)n).setAge(((Ageable)n).getAge() + 2000);
if(((Ageable)n).getAge() > 0)
((Ageable)n).setAge(0);
ParticleEffect.VILLAGER_HAPPY.display(((LivingEntity)n).getEyeLocation(), 0.2F, 0.2F, 0.2F, 0.0F, 8);
return;
}
}
}
}
}
示例10: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
protected void tick(Block b) {
if (isProcessing(b)) {
int timeleft = progress.get(b);
if (timeleft > 0) {
ItemStack item = getProgressBar().clone();
item.setDurability(MachineHelper.getDurability(item, timeleft, processing.get(b).getTicks()));
ItemMeta im = item.getItemMeta();
im.setDisplayName(" ");
List<String> lore = new ArrayList<String>();
lore.add(MachineHelper.getProgress(timeleft, processing.get(b).getTicks()));
lore.add("");
lore.add(MachineHelper.getTimeLeft(timeleft / 2));
im.setLore(lore);
item.setItemMeta(im);
BlockStorage.getInventory(b).replaceExistingItem(22, item);
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
ChargableBlock.addCharge(b, -getEnergyConsumption());
progress.put(b, timeleft - 1);
}
else {
BlockStorage.getInventory(b).replaceExistingItem(22, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte) 15), " "));
pushItems(b, processing.get(b).getOutput());
progress.remove(b);
processing.remove(b);
}
}
else if (OreGenSystem.getSupplies(OreGenSystem.getResource("Milky Quartz"), b.getChunk(), false) > 0) {
MachineRecipe r = new MachineRecipe(24, new ItemStack[0], new ItemStack[] {ChestTerminal.quartz});
if (!fits(b, r.getOutput())) return;
processing.put(b, r);
progress.put(b, r.getTicks());
OreGenSystem.setSupplies(OreGenSystem.getResource("Milky Quartz"), b.getChunk(), OreGenSystem.getSupplies(OreGenSystem.getResource("Milky Quartz"), b.getChunk(), false) - 1);
}
}
示例11: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
protected void tick(Block b) {
if (isProcessing(b)) {
int timeleft = progress.get(b);
if (timeleft > 0) {
ItemStack item = getProgressBar().clone();
item.setDurability(MachineHelper.getDurability(item, timeleft, processing.get(b).getTicks()));
ItemMeta im = item.getItemMeta();
im.setDisplayName(" ");
List<String> lore = new ArrayList<String>();
lore.add(MachineHelper.getProgress(timeleft, processing.get(b).getTicks()));
lore.add("");
lore.add(MachineHelper.getTimeLeft(timeleft / 2));
im.setLore(lore);
item.setItemMeta(im);
BlockStorage.getInventory(b).replaceExistingItem(22, item);
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
ChargableBlock.addCharge(b, -getEnergyConsumption());
progress.put(b, timeleft - 1);
}
else {
BlockStorage.getInventory(b).replaceExistingItem(22, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte) 15), " "));
pushItems(b, processing.get(b).getOutput());
progress.remove(b);
processing.remove(b);
}
}
else if (OreGenSystem.getSupplies(getOreGenResource(), b.getChunk(), false) > 0) {
MachineRecipe r = new MachineRecipe(getProcessingTime() / getSpeed(), new ItemStack[0], this.getOutputItems());
if (!fits(b, r.getOutput())) return;
processing.put(b, r);
progress.put(b, r.getTicks());
OreGenSystem.setSupplies(getOreGenResource(), b.getChunk(), OreGenSystem.getSupplies(getOreGenResource(), b.getChunk(), false) - 1);
}
}
示例12: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
protected void tick(Block b) {
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
for (int slot: getInputSlots()) {
ItemStack stack = BlockStorage.getInventory(b).getItemInSlot(slot);
if (ItemEnergy.getMaxEnergy(stack) > 0) {
if (ItemEnergy.getStoredEnergy(stack) < ItemEnergy.getMaxEnergy(stack)) {
ChargableBlock.addCharge(b, -getEnergyConsumption());
float rest = ItemEnergy.addStoredEnergy(stack, getEnergyConsumption() / 2);
if (rest > 0F) {
if (fits(b, new ItemStack[] {stack})) {
pushItems(b, new ItemStack[] {stack});
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
else {
BlockStorage.getInventory(b).replaceExistingItem(slot, stack);
}
}
else {
BlockStorage.getInventory(b).replaceExistingItem(slot, stack);
}
}
else if (fits(b, new ItemStack[] {stack})) {
pushItems(b, new ItemStack[] {stack});
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
else {
BlockStorage.getInventory(b).replaceExistingItem(slot, stack);
}
return;
}
}
}
示例13: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
protected void tick(Block b) throws Exception {
Iterator<Entity> iterator = me.mrCookieSlime.Slimefun.holograms.XPCollector.getArmorStand(b).getNearbyEntities(4D, 4D, 4D).iterator();
while (iterator.hasNext()) {
Entity n = iterator.next();
if (n instanceof ExperienceOrb) {
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
if (n.isValid()) {
int xp = getEXP(b) + ((ExperienceOrb) n).getExperience();
ChargableBlock.addCharge(b, -getEnergyConsumption());
n.remove();
int withdrawn = 0;
for (int level = 0; level < getEXP(b); level = level + 10) {
if (fits(b, new CustomItem(Material.EXP_BOTTLE, "&aFlask of Knowledge", 0))) {
withdrawn = withdrawn + 10;
pushItems(b, new CustomItem(Material.EXP_BOTTLE, "&aFlask of Knowledge", 0));
}
}
BlockStorage.addBlockInfo(b, "stored-exp", String.valueOf(xp - withdrawn));
return;
}
}
}
}
示例14: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
protected void tick(Block b) {
if (isProcessing(b)) {
int timeleft = progress.get(b);
if (timeleft > 0) {
ItemStack item = getProgressBar().clone();
item.setDurability(MachineHelper.getDurability(item, timeleft, processing.get(b).getTicks()));
ItemMeta im = item.getItemMeta();
im.setDisplayName(" ");
List<String> lore = new ArrayList<String>();
lore.add(MachineHelper.getProgress(timeleft, processing.get(b).getTicks()));
lore.add("");
lore.add(MachineHelper.getTimeLeft(timeleft / 2));
im.setLore(lore);
item.setItemMeta(im);
BlockStorage.getInventory(b).replaceExistingItem(22, item);
if (ChargableBlock.isChargable(b)) {
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
ChargableBlock.addCharge(b, -getEnergyConsumption());
progress.put(b, timeleft - 1);
}
else progress.put(b, timeleft - 1);
}
else {
BlockStorage.getInventory(b).replaceExistingItem(22, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte) 15), " "));
pushItems(b, processing.get(b).getOutput().clone());
progress.remove(b);
processing.remove(b);
}
}
else {
MachineRecipe r = null;
Map<Integer, Integer> found = new HashMap<Integer, Integer>();
outer:
for (MachineRecipe recipe: recipes) {
for (ItemStack input: recipe.getInput()) {
slots:
for (int slot: getInputSlots()) {
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), input, true)) {
found.put(slot, input.getAmount());
break slots;
}
}
}
if (found.size() == recipe.getInput().length) {
r = recipe;
break outer;
}
else found.clear();
}
if (r != null) {
if (!fits(b, r.getOutput())) return;
for (Map.Entry<Integer, Integer> entry: found.entrySet()) {
BlockStorage.getInventory(b).replaceExistingItem(entry.getKey(), InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(entry.getKey()), entry.getValue()));
}
processing.put(b, r);
progress.put(b, r.getTicks());
}
}
}
示例15: tick
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; //导入方法依赖的package包/类
protected void tick(Block b)
{
if(ChargableBlock.getCharge(b) < getEnergyConsumption())
return;
int ai[];
int j = (ai = getInputSlots()).length;
for(int i = 0; i < j; i++)
{
int slot = ai[i];
ItemStack stack = BlockStorage.getInventory(b).getItemInSlot(slot);
if(ItemEnergy.getMaxEnergy(stack) > 0.0F)
{
if(ItemEnergy.getStoredEnergy(stack) < ItemEnergy.getMaxEnergy(stack))
{
ChargableBlock.addCharge(b, -getEnergyConsumption());
float rest = ItemEnergy.addStoredEnergy(stack, getEnergyConsumption() / 2);
if(rest > 0.0F)
{
if(fits(b, new ItemStack[] {
stack
}))
{
pushItems(b, new ItemStack[] {
stack
});
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
} else
{
BlockStorage.getInventory(b).replaceExistingItem(slot, stack);
}
} else
{
BlockStorage.getInventory(b).replaceExistingItem(slot, stack);
}
} else
if(fits(b, new ItemStack[] {
stack
}))
{
pushItems(b, new ItemStack[] {
stack
});
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
} else
{
BlockStorage.getInventory(b).replaceExistingItem(slot, stack);
}
return;
}
}
}