mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixes #1897
This commit is contained in:
parent
a90351a18a
commit
ccad2982ab
@ -38,6 +38,7 @@
|
|||||||
* Fixed #1851
|
* Fixed #1851
|
||||||
* Fixed #1891
|
* Fixed #1891
|
||||||
* Fixed #1893
|
* Fixed #1893
|
||||||
|
* Fixed #1897
|
||||||
|
|
||||||
## Release Candidate 11 (25 Apr 2020)
|
## Release Candidate 11 (25 Apr 2020)
|
||||||
|
|
||||||
|
@ -22,109 +22,98 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
|
|||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.MultiBlockMachine;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks.MultiBlockMachine;
|
||||||
|
|
||||||
public class OreWasher extends MultiBlockMachine {
|
public class OreWasher extends MultiBlockMachine {
|
||||||
|
|
||||||
private final boolean legacyMode;
|
private final boolean legacyMode;
|
||||||
|
|
||||||
public OreWasher(Category category) {
|
public OreWasher(Category category) {
|
||||||
super(category, SlimefunItems.ORE_WASHER,
|
super(category, SlimefunItems.ORE_WASHER, new ItemStack[] { null, new ItemStack(Material.DISPENSER), null, null, new ItemStack(Material.OAK_FENCE), null, null, new ItemStack(Material.CAULDRON), null }, new ItemStack[] { SlimefunItems.SIFTED_ORE, SlimefunItems.IRON_DUST, SlimefunItems.SIFTED_ORE, SlimefunItems.GOLD_DUST, SlimefunItems.SIFTED_ORE, SlimefunItems.COPPER_DUST, SlimefunItems.SIFTED_ORE, SlimefunItems.TIN_DUST, SlimefunItems.SIFTED_ORE, SlimefunItems.ZINC_DUST, SlimefunItems.SIFTED_ORE, SlimefunItems.ALUMINUM_DUST, SlimefunItems.SIFTED_ORE, SlimefunItems.MAGNESIUM_DUST, SlimefunItems.SIFTED_ORE, SlimefunItems.LEAD_DUST, SlimefunItems.SIFTED_ORE, SlimefunItems.SILVER_DUST }, BlockFace.SELF);
|
||||||
new ItemStack[] {null, new ItemStack(Material.DISPENSER), null, null, new ItemStack(Material.OAK_FENCE), null, null, new ItemStack(Material.CAULDRON), null},
|
|
||||||
new ItemStack[] {
|
|
||||||
SlimefunItems.SIFTED_ORE, SlimefunItems.IRON_DUST,
|
|
||||||
SlimefunItems.SIFTED_ORE, SlimefunItems.GOLD_DUST,
|
|
||||||
SlimefunItems.SIFTED_ORE, SlimefunItems.COPPER_DUST,
|
|
||||||
SlimefunItems.SIFTED_ORE, SlimefunItems.TIN_DUST,
|
|
||||||
SlimefunItems.SIFTED_ORE, SlimefunItems.ZINC_DUST,
|
|
||||||
SlimefunItems.SIFTED_ORE, SlimefunItems.ALUMINUM_DUST,
|
|
||||||
SlimefunItems.SIFTED_ORE, SlimefunItems.MAGNESIUM_DUST,
|
|
||||||
SlimefunItems.SIFTED_ORE, SlimefunItems.LEAD_DUST,
|
|
||||||
SlimefunItems.SIFTED_ORE, SlimefunItems.SILVER_DUST
|
|
||||||
},
|
|
||||||
BlockFace.SELF
|
|
||||||
);
|
|
||||||
|
|
||||||
legacyMode = SlimefunPlugin.getCfg().getBoolean("options.legacy-ore-washer");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ItemStack> getDisplayRecipes() {
|
|
||||||
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInteract(Player p, Block b) {
|
|
||||||
Block dispBlock = b.getRelative(BlockFace.UP);
|
|
||||||
Dispenser disp = (Dispenser) dispBlock.getState();
|
|
||||||
Inventory inv = disp.getInventory();
|
|
||||||
|
|
||||||
for (ItemStack current : inv.getContents()) {
|
legacyMode = SlimefunPlugin.getCfg().getBoolean("options.legacy-ore-washer");
|
||||||
if (current != null) {
|
}
|
||||||
if (SlimefunUtils.isItemSimilar(current, SlimefunItems.SIFTED_ORE, true)) {
|
|
||||||
ItemStack adding = getRandomDust();
|
|
||||||
Inventory outputInv = null;
|
|
||||||
|
|
||||||
if (!legacyMode) {
|
@Override
|
||||||
// This is a fancy way of checking if there is empty space in the inv; by checking if an unobtainable item could fit in it.
|
public List<ItemStack> getDisplayRecipes() {
|
||||||
// However, due to the way the method findValidOutputInv() functions, the dummyAdding will never actually be added to the real inventory,
|
return recipes.stream().map(items -> items[0]).collect(Collectors.toList());
|
||||||
// so it really doesn't matter what item the ItemStack is made by. SlimefunItems.DEBUG_FISH however, signals that it's
|
}
|
||||||
// not supposed to be given to the player.
|
|
||||||
ItemStack dummyAdding = SlimefunItems.DEBUG_FISH;
|
|
||||||
outputInv = findOutputInventory(dummyAdding, dispBlock, inv);
|
|
||||||
}
|
|
||||||
else outputInv = findOutputInventory(adding, dispBlock, inv);
|
|
||||||
|
|
||||||
if (outputInv != null) {
|
@Override
|
||||||
ItemStack removing = current.clone();
|
public void onInteract(Player p, Block b) {
|
||||||
removing.setAmount(1);
|
Block dispBlock = b.getRelative(BlockFace.UP);
|
||||||
inv.removeItem(removing);
|
Dispenser disp = (Dispenser) dispBlock.getState();
|
||||||
outputInv.addItem(adding);
|
Inventory inv = disp.getInventory();
|
||||||
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1, 1);
|
|
||||||
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WATER);
|
|
||||||
if (InvUtils.fits(outputInv, SlimefunItems.STONE_CHUNK)) outputInv.addItem(SlimefunItems.STONE_CHUNK);
|
|
||||||
}
|
|
||||||
else SlimefunPlugin.getLocal().sendMessage(p, "machines.full-inventory", true);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (SlimefunUtils.isItemSimilar(current, new ItemStack(Material.SAND, 4), false)) {
|
|
||||||
ItemStack adding = SlimefunItems.SALT;
|
|
||||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
|
||||||
|
|
||||||
if (outputInv != null) {
|
for (ItemStack current : inv.getContents()) {
|
||||||
ItemStack removing = current.clone();
|
if (current != null) {
|
||||||
removing.setAmount(4);
|
if (SlimefunUtils.isItemSimilar(current, SlimefunItems.SIFTED_ORE, true)) {
|
||||||
inv.removeItem(removing);
|
ItemStack output = getRandomDust();
|
||||||
outputInv.addItem(adding);
|
Inventory outputInv = null;
|
||||||
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WATER);
|
|
||||||
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1, 1);
|
|
||||||
}
|
|
||||||
else SlimefunPlugin.getLocal().sendMessage(p, "machines.full-inventory", true);
|
|
||||||
|
|
||||||
return;
|
if (!legacyMode) {
|
||||||
}
|
// This is a fancy way of checking if there is empty space in the inv; by checking if an
|
||||||
else if (SlimefunUtils.isItemSimilar(current, SlimefunItems.PULVERIZED_ORE, true)) {
|
// unobtainable item could fit in it.
|
||||||
ItemStack adding = SlimefunItems.PURE_ORE_CLUSTER;
|
// However, due to the way the method findValidOutputInv() functions, the dummyAdding will never
|
||||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
// actually be added to the real inventory,
|
||||||
|
// so it really doesn't matter what item the ItemStack is made by. SlimefunItems.DEBUG_FISH
|
||||||
|
// however, signals that it's
|
||||||
|
// not supposed to be given to the player.
|
||||||
|
ItemStack dummyAdding = SlimefunItems.DEBUG_FISH;
|
||||||
|
outputInv = findOutputInventory(dummyAdding, dispBlock, inv);
|
||||||
|
}
|
||||||
|
else outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
|
|
||||||
if (outputInv != null) {
|
if (outputInv != null) {
|
||||||
ItemStack removing = current.clone();
|
ItemStack removing = current.clone();
|
||||||
removing.setAmount(1);
|
removing.setAmount(1);
|
||||||
inv.removeItem(removing);
|
inv.removeItem(removing);
|
||||||
outputInv.addItem(adding);
|
outputInv.addItem(output);
|
||||||
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WATER);
|
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1, 1);
|
||||||
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1, 1);
|
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WATER);
|
||||||
}
|
if (InvUtils.fits(outputInv, SlimefunItems.STONE_CHUNK)) outputInv.addItem(SlimefunItems.STONE_CHUNK);
|
||||||
else SlimefunPlugin.getLocal().sendMessage(p, "machines.full-inventory", true);
|
}
|
||||||
|
else SlimefunPlugin.getLocal().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
else if (SlimefunUtils.isItemSimilar(current, new ItemStack(Material.SAND, 4), false)) {
|
||||||
}
|
ItemStack output = SlimefunItems.SALT;
|
||||||
SlimefunPlugin.getLocal().sendMessage(p, "machines.unknown-material", true);
|
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getRandomDust() {
|
if (outputInv != null) {
|
||||||
int index = ThreadLocalRandom.current().nextInt(shownRecipes.size() / 2);
|
ItemStack removing = current.clone();
|
||||||
return shownRecipes.get(index * 2 + 1).clone();
|
removing.setAmount(2);
|
||||||
}
|
inv.removeItem(removing);
|
||||||
|
outputInv.addItem(output);
|
||||||
|
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WATER);
|
||||||
|
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1, 1);
|
||||||
|
}
|
||||||
|
else SlimefunPlugin.getLocal().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (SlimefunUtils.isItemSimilar(current, SlimefunItems.PULVERIZED_ORE, true)) {
|
||||||
|
ItemStack output = SlimefunItems.PURE_ORE_CLUSTER;
|
||||||
|
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
||||||
|
|
||||||
|
if (outputInv != null) {
|
||||||
|
ItemStack removing = current.clone();
|
||||||
|
removing.setAmount(1);
|
||||||
|
inv.removeItem(removing);
|
||||||
|
outputInv.addItem(output);
|
||||||
|
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WATER);
|
||||||
|
p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1, 1);
|
||||||
|
}
|
||||||
|
else SlimefunPlugin.getLocal().sendMessage(p, "machines.full-inventory", true);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SlimefunPlugin.getLocal().sendMessage(p, "machines.unknown-material", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getRandomDust() {
|
||||||
|
int index = ThreadLocalRandom.current().nextInt(shownRecipes.size() / 2);
|
||||||
|
return shownRecipes.get(index * 2 + 1).clone();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user