1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Added Nether Gold Pan to the Electric Gold Pan

This commit is contained in:
TheBusyBiscuit 2019-12-07 10:04:54 +01:00
parent a29016a391
commit f25bf75d67
10 changed files with 78 additions and 34 deletions

View File

@ -111,7 +111,6 @@ public class LockedCategory extends Category {
* *
* @since 4.0 * @since 4.0
*/ */
@SuppressWarnings("deprecation")
public boolean hasUnlocked(Player p) { public boolean hasUnlocked(Player p) {
return hasUnlocked(p, PlayerProfile.get(p)); return hasUnlocked(p, PlayerProfile.get(p));
} }

View File

@ -194,7 +194,10 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock
} }
else { else {
inv.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " ")); inv.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
pushItems(b, processing.get(b).getOutput().clone());
for (ItemStack output: processing.get(b).getOutput()) {
inv.pushItem(output.clone(), getOutputSlots());
}
progress.remove(b); progress.remove(b);
processing.remove(b); processing.remove(b);

View File

@ -66,7 +66,7 @@ public abstract class AutoAnvil extends AContainer {
} }
else { else {
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " ")); menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
pushItems(b, processing.get(b).getOutput()); menu.pushItem(processing.get(b).getOutput()[0].clone(), getOutputSlots());
progress.remove(b); progress.remove(b);
processing.remove(b); processing.remove(b);
@ -94,7 +94,7 @@ public abstract class AutoAnvil extends AContainer {
} }
if (recipe != null) { if (recipe != null) {
if (!fits(b, recipe.getOutput())) return; if (!menu.fits(recipe.getOutput()[0], getOutputSlots())) return;
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1)); menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));

View File

@ -107,16 +107,18 @@ public class AutoDisenchanter extends AContainer {
if (item != null && target != null && target.getType() == Material.BOOK) { if (item != null && target != null && target.getType() == Material.BOOK) {
int amount = 0; int amount = 0;
for (Map.Entry<Enchantment, Integer> e: item.getEnchantments().entrySet()) { for (Map.Entry<Enchantment, Integer> e : item.getEnchantments().entrySet()) {
enchantments.put(e.getKey(), e.getValue()); enchantments.put(e.getKey(), e.getValue());
amount++; amount++;
} }
if (SlimefunPlugin.getHooks().isEmeraldEnchantsInstalled()) { if (SlimefunPlugin.getHooks().isEmeraldEnchantsInstalled()) {
for (ItemEnchantment enchantment: EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) { for (ItemEnchantment enchantment : EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) {
amount++; amount++;
enchantments2.add(enchantment); enchantments2.add(enchantment);
} }
} }
if (amount > 0) { if (amount > 0) {
ItemStack newItem = item.clone(); ItemStack newItem = item.clone();
newItem.setAmount(1); newItem.setAmount(1);
@ -133,13 +135,14 @@ public class AutoDisenchanter extends AContainer {
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) book.getItemMeta(); EnchantmentStorageMeta meta = (EnchantmentStorageMeta) book.getItemMeta();
for (Map.Entry<Enchantment,Integer> e: enchantments.entrySet()) { for (Map.Entry<Enchantment,Integer> e : enchantments.entrySet()) {
newItem.removeEnchantment(e.getKey()); newItem.removeEnchantment(e.getKey());
meta.addStoredEnchant(e.getKey(), e.getValue(), true); meta.addStoredEnchant(e.getKey(), e.getValue(), true);
} }
book.setItemMeta(meta); book.setItemMeta(meta);
for (ItemEnchantment e: enchantments2) { for (ItemEnchantment e : enchantments2) {
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(book, e.getEnchantment(), e.getLevel()); EmeraldEnchants.getInstance().getRegistry().applyEnchantment(book, e.getEnchantment(), e.getLevel());
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, e.getEnchantment(), 0); EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, e.getEnchantment(), 0);
} }

View File

@ -212,8 +212,8 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I
if (SlimefunPlugin.getUtilities().automatedCraftingChamberRecipes.containsKey(input)) { if (SlimefunPlugin.getUtilities().automatedCraftingChamberRecipes.containsKey(input)) {
ItemStack output = SlimefunPlugin.getUtilities().automatedCraftingChamberRecipes.get(input).clone(); ItemStack output = SlimefunPlugin.getUtilities().automatedCraftingChamberRecipes.get(input).clone();
if (fits(b, output)) { if (menu.fits(output, getOutputSlots())) {
pushItems(b, output); menu.pushItem(output, getOutputSlots());
ChargableBlock.addCharge(b, -getEnergyConsumption()); ChargableBlock.addCharge(b, -getEnergyConsumption());
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {
if (menu.getItemInSlot(getInputSlots()[j]) != null) menu.replaceExistingItem(getInputSlots()[j], InvUtils.decreaseItem(menu.getItemInSlot(getInputSlots()[j]), 1)); if (menu.getItemInSlot(getInputSlots()[j]) != null) menu.replaceExistingItem(getInputSlots()[j], InvUtils.decreaseItem(menu.getItemInSlot(getInputSlots()[j]), 1));

View File

@ -59,7 +59,7 @@ public abstract class ElectricDustWasher extends AContainer {
ChargableBlock.addCharge(b, -getEnergyConsumption()); ChargableBlock.addCharge(b, -getEnergyConsumption());
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " ")); menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
pushItems(b, processing.get(b).getOutput()); menu.pushItem(processing.get(b).getOutput()[0].clone(), getOutputSlots());
progress.remove(b); progress.remove(b);
processing.remove(b); processing.remove(b);
@ -84,7 +84,7 @@ public abstract class ElectricDustWasher extends AContainer {
ItemStack adding = items[new Random().nextInt(items.length)]; ItemStack adding = items[new Random().nextInt(items.length)];
MachineRecipe r = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] {adding}); MachineRecipe r = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] {adding});
if (SlimefunPlugin.getSettings().legacyDustWasher && !fits(b, r.getOutput())) return; if (SlimefunPlugin.getSettings().legacyDustWasher && !menu.fits(r.getOutput()[0], getOutputSlots())) return;
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1)); menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
processing.put(b, r); processing.put(b, r);
progress.put(b, r.getTicks()); progress.put(b, r.getTicks());
@ -92,7 +92,7 @@ public abstract class ElectricDustWasher extends AContainer {
} }
else if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), SlimefunItems.PULVERIZED_ORE, true)) { else if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), SlimefunItems.PULVERIZED_ORE, true)) {
MachineRecipe r = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] {SlimefunItems.PURE_ORE_CLUSTER}); MachineRecipe r = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] {SlimefunItems.PURE_ORE_CLUSTER});
if (!fits(b, r.getOutput())) return; if (!menu.fits(r.getOutput()[0], getOutputSlots())) return;
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1)); menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
processing.put(b, r); processing.put(b, r);
progress.put(b, r.getTicks()); progress.put(b, r.getTicks());

View File

@ -2,12 +2,12 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Random;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Lists.RecipeType;
@ -18,6 +18,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecip
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.RecipeDisplayItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.RecipeDisplayItem;
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager; import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
import me.mrCookieSlime.Slimefun.api.BlockStorage; import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.Slimefun;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
@ -25,23 +26,56 @@ import me.mrCookieSlime.Slimefun.utils.MachineHelper;
public abstract class ElectricGoldPan extends AContainer implements RecipeDisplayItem { public abstract class ElectricGoldPan extends AContainer implements RecipeDisplayItem {
private Random random = new Random(); private final RandomizedSet<ItemStack> randomizer = new RandomizedSet<>();
private final RandomizedSet<ItemStack> randomizerNether = new RandomizedSet<>();
private final List<ItemStack> displayRecipes = Arrays.asList( private final List<ItemStack> displayRecipes = Arrays.asList(
new ItemStack(Material.GRAVEL), new ItemStack(Material.GRAVEL), new ItemStack(Material.FLINT),
SlimefunItems.SIFTED_ORE, new ItemStack(Material.GRAVEL), SlimefunItems.SIFTED_ORE,
new ItemStack(Material.GRAVEL), new ItemStack(Material.CLAY_BALL),
new ItemStack(Material.GRAVEL), new ItemStack(Material.IRON_NUGGET),
new ItemStack(Material.GRAVEL), new ItemStack(Material.SOUL_SAND), new ItemStack(Material.QUARTZ),
new ItemStack(Material.FLINT), new ItemStack(Material.SOUL_SAND), new ItemStack(Material.GOLD_NUGGET),
new ItemStack(Material.SOUL_SAND), new ItemStack(Material.NETHER_WART),
new ItemStack(Material.GRAVEL), new ItemStack(Material.SOUL_SAND), new ItemStack(Material.BLAZE_POWDER),
new ItemStack(Material.CLAY_BALL) new ItemStack(Material.SOUL_SAND), new ItemStack(Material.GLOWSTONE_DUST),
new ItemStack(Material.SOUL_SAND), new ItemStack(Material.GHAST_TEAR)
); );
public ElectricGoldPan(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public ElectricGoldPan(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe); super(category, item, recipeType, recipe);
} }
@Override
public void postRegister() {
super.postRegister();
String goldPan = "GOLD_PAN";
String netherGoldPan = "NETHER_GOLD_PAN";
add(false, SlimefunItems.SIFTED_ORE, (int) Slimefun.getItemValue(goldPan, "chance.SIFTED_ORE"));
add(false, new ItemStack(Material.CLAY_BALL), (int) Slimefun.getItemValue(goldPan, "chance.CLAY"));
add(false, new ItemStack(Material.FLINT), (int) Slimefun.getItemValue(goldPan, "chance.FLINT"));
add(false, new ItemStack(Material.IRON_NUGGET), (int) Slimefun.getItemValue(goldPan, "chance.IRON_NUGGET"));
add(true, new ItemStack(Material.QUARTZ), (int) Slimefun.getItemValue(netherGoldPan, "chance.QUARTZ"));
add(true, new ItemStack(Material.GOLD_NUGGET), (int) Slimefun.getItemValue(netherGoldPan, "chance.GOLD_NUGGET"));
add(true, new ItemStack(Material.NETHER_WART), (int) Slimefun.getItemValue(netherGoldPan, "chance.NETHER_WART"));
add(true, new ItemStack(Material.BLAZE_POWDER), (int) Slimefun.getItemValue(netherGoldPan, "chance.BLAZE_POWDER"));
add(true, new ItemStack(Material.GLOWSTONE_DUST), (int) Slimefun.getItemValue(netherGoldPan, "chance.GLOWSTONE_DUST"));
add(true, new ItemStack(Material.GHAST_TEAR), (int) Slimefun.getItemValue(netherGoldPan, "chance.GHAST_TEAR"));
}
private void add(boolean nether, ItemStack item, int chance) {
if (nether) {
randomizerNether.add(item, chance);
}
else {
randomizer.add(item, chance);
}
}
@Override @Override
public String getInventoryTitle() { public String getInventoryTitle() {
return "&6Electric Gold Pan"; return "&6Electric Gold Pan";
@ -74,7 +108,7 @@ public abstract class ElectricGoldPan extends AContainer implements RecipeDispla
ChargableBlock.addCharge(b, -getEnergyConsumption()); ChargableBlock.addCharge(b, -getEnergyConsumption());
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " ")); menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
pushItems(b, processing.get(b).getOutput()); menu.pushItem(processing.get(b).getOutput()[0].clone(), getOutputSlots());
progress.remove(b); progress.remove(b);
processing.remove(b); processing.remove(b);
@ -83,12 +117,22 @@ public abstract class ElectricGoldPan extends AContainer implements RecipeDispla
else { else {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), new ItemStack(Material.GRAVEL), true)) { if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), new ItemStack(Material.GRAVEL), true)) {
ItemStack output = SlimefunItems.SIFTED_ORE; ItemStack output = randomizer.getRandom();
if (random.nextInt(100) < 16) output = new ItemStack(Material.FLINT);
if (random.nextInt(100) < 16) output = new ItemStack(Material.CLAY_BALL);
MachineRecipe r = new MachineRecipe(3 / getSpeed(), new ItemStack[0], new ItemStack[] {output}); MachineRecipe r = new MachineRecipe(3 / getSpeed(), new ItemStack[0], new ItemStack[] {output});
if (!fits(b, r.getOutput())) return; if (!menu.fits(output, getOutputSlots())) return;
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
processing.put(b, r);
progress.put(b, r.getTicks());
break;
}
else if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true)) {
ItemStack output = randomizerNether.getRandom();
MachineRecipe r = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] {output});
if (!menu.fits(output, getOutputSlots())) return;
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1)); menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
processing.put(b, r); processing.put(b, r);
progress.put(b, r.getTicks()); progress.put(b, r.getTicks());

View File

@ -225,10 +225,7 @@ public final class PlayerProfile {
* *
* @param uuid The UUID of the profile you are trying to retrieve. * @param uuid The UUID of the profile you are trying to retrieve.
* @return The PlayerProfile of this player * @return The PlayerProfile of this player
*
* @deprecated Use {@link #fromUUID(UUID, Consumer)}
*/ */
@Deprecated
public static PlayerProfile fromUUID(UUID uuid) { public static PlayerProfile fromUUID(UUID uuid) {
PlayerProfile profile = SlimefunPlugin.getUtilities().profiles.get(uuid); PlayerProfile profile = SlimefunPlugin.getUtilities().profiles.get(uuid);

View File

@ -38,7 +38,6 @@ public class PlaceholderAPIHook extends PlaceholderExpansion {
return true; return true;
} }
@SuppressWarnings("deprecation")
@Override @Override
public String onRequest(OfflinePlayer p, String params) { public String onRequest(OfflinePlayer p, String params) {
if (params.equals("researches_total_xp_levels_spent")) { if (params.equals("researches_total_xp_levels_spent")) {

View File

@ -13,7 +13,6 @@ public class PlayerQuitListener implements Listener {
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
} }
@SuppressWarnings("deprecation")
@EventHandler @EventHandler
public void onDisconnect(PlayerQuitEvent e) { public void onDisconnect(PlayerQuitEvent e) {
if (PlayerProfile.isLoaded(e.getPlayer().getUniqueId())) { if (PlayerProfile.isLoaded(e.getPlayer().getUniqueId())) {