mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixes #1992 and changes to the fishing loot for androids
This commit is contained in:
parent
81f7eefe23
commit
2733b8a17b
@ -30,6 +30,10 @@
|
||||
* Added Cocoa Fertilizer
|
||||
* Added a configurable limit to the Pickaxe of Vein Mining
|
||||
* Added Gold Ingot to Dust recipe to the Electric Ingot Pulverizer
|
||||
* Added Saddles to possible fishing loot for the Fishing Android
|
||||
* Added Name tags to possible fishing loot for the Fishing Android
|
||||
* Added Nautilus Shell to possible fishing loot for the Fishing Android
|
||||
* Added Bamboo to possible fishing loot for the Fishing Android
|
||||
|
||||
#### Changes
|
||||
* Fixed a few memory leaks
|
||||
@ -41,6 +45,7 @@
|
||||
* The Seismic Axe now skips the first two blocks to clear your field of view
|
||||
* Auto Disenchanting is now a tiny bit faster
|
||||
* Small performance improvements
|
||||
* Dried Kelp Blocks can now be used as fuel for Tier 1 Androids
|
||||
|
||||
#### Fixes
|
||||
* Fixed Ore Washer recipes showing up twice
|
||||
@ -50,6 +55,9 @@
|
||||
* Fixed #1971
|
||||
* Fixed #1976
|
||||
* Fixed #1988
|
||||
* Fixed #1985
|
||||
* Fixed a missing texture in the Android Script Editor
|
||||
* Fixed #1992
|
||||
|
||||
## Release Candidate 12 (27 May 2020)
|
||||
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#12
|
||||
|
@ -10,6 +10,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet;
|
||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
|
||||
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
@ -22,17 +24,28 @@ public abstract class FisherAndroid extends ProgrammableAndroid {
|
||||
public FisherAndroid(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
||||
// Fish
|
||||
for (Material fish : MaterialCollections.getAllFishItems()) {
|
||||
fishingLoot.add(new ItemStack(fish), 20);
|
||||
fishingLoot.add(new ItemStack(fish), 25);
|
||||
}
|
||||
|
||||
// Junk
|
||||
fishingLoot.add(new ItemStack(Material.BONE), 10);
|
||||
fishingLoot.add(new ItemStack(Material.STRING), 10);
|
||||
fishingLoot.add(new ItemStack(Material.INK_SAC), 8);
|
||||
fishingLoot.add(new ItemStack(Material.KELP), 6);
|
||||
fishingLoot.add(new ItemStack(Material.STICK), 5);
|
||||
fishingLoot.add(new ItemStack(Material.INK_SAC), 4);
|
||||
fishingLoot.add(new ItemStack(Material.ROTTEN_FLESH), 3);
|
||||
fishingLoot.add(new ItemStack(Material.LEATHER), 2);
|
||||
|
||||
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
|
||||
fishingLoot.add(new ItemStack(Material.BAMBOO), 3);
|
||||
}
|
||||
|
||||
// "loot"
|
||||
fishingLoot.add(new ItemStack(Material.SADDLE), 1);
|
||||
fishingLoot.add(new ItemStack(Material.NAME_TAG), 1);
|
||||
fishingLoot.add(new ItemStack(Material.NAUTILUS_SHELL), 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -45,7 +58,7 @@ public abstract class FisherAndroid extends ProgrammableAndroid {
|
||||
Block water = b.getRelative(BlockFace.DOWN);
|
||||
|
||||
if (water.getType() == Material.WATER) {
|
||||
water.getWorld().playSound(water.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
|
||||
water.getWorld().playSound(water.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 0.3F, 0.7F);
|
||||
|
||||
if (ThreadLocalRandom.current().nextInt(100) < 10 * getTier()) {
|
||||
ItemStack drop = fishingLoot.getRandom();
|
||||
|
@ -193,7 +193,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
||||
});
|
||||
}
|
||||
|
||||
public void openScript(Player p, Block b, String script) {
|
||||
public void openScript(Player p, Block b, String sourceCode) {
|
||||
ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + SlimefunPlugin.getLocal().getMessage(p, "android.scripts.editor"));
|
||||
|
||||
menu.addItem(0, new CustomItem(Instruction.START.getItem(), SlimefunPlugin.getLocal().getMessage(p, "android.scripts.instructions.START"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface"));
|
||||
@ -202,70 +202,51 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
||||
return false;
|
||||
});
|
||||
|
||||
String[] commands = PatternUtils.DASH.split(script);
|
||||
String[] script = PatternUtils.DASH.split(sourceCode);
|
||||
|
||||
for (int i = 1; i < commands.length; i++) {
|
||||
for (int i = 1; i < script.length; i++) {
|
||||
int index = i;
|
||||
|
||||
if (i == commands.length - 1) {
|
||||
int additional = commands.length == 54 ? 0 : 1;
|
||||
if (i == script.length - 1) {
|
||||
boolean hasFreeSlot = script.length < 54;
|
||||
|
||||
if (additional == 1) {
|
||||
if (hasFreeSlot) {
|
||||
menu.addItem(i, new CustomItem(SlimefunUtils.getCustomHead("171d8979c1878a05987a7faf21b56d1b744f9d068c74cffcde1ea1edad5852"), "&7> Add new Command"));
|
||||
menu.addMenuClickHandler(i, (pl, slot, item, action) -> {
|
||||
openScriptComponentEditor(pl, b, script, index);
|
||||
editInstruction(pl, b, script, index);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
menu.addItem(i + additional, new CustomItem(Instruction.REPEAT.getItem(), SlimefunPlugin.getLocal().getMessage(p, "android.scripts.instructions.REPEAT"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface"));
|
||||
menu.addMenuClickHandler(i + additional, (pl, slot, item, action) -> {
|
||||
int slot = i + (hasFreeSlot ? 1 : 0);
|
||||
menu.addItem(slot, new CustomItem(Instruction.REPEAT.getItem(), SlimefunPlugin.getLocal().getMessage(p, "android.scripts.instructions.REPEAT"), "", "&7\u21E8 &eLeft Click &7to return to the Android's interface"));
|
||||
menu.addMenuClickHandler(slot, (pl, s, item, action) -> {
|
||||
BlockStorage.getInventory(b).open(pl);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
else {
|
||||
ItemStack stack = Instruction.valueOf(commands[i]).getItem();
|
||||
menu.addItem(i, new CustomItem(stack, SlimefunPlugin.getLocal().getMessage(p, "android.scripts.instructions." + Instruction.valueOf(commands[i]).name()), "", "&7\u21E8 &eLeft Click &7to edit", "&7\u21E8 &eRight Click &7to delete", "&7\u21E8 &eShift + Right Click &7to duplicate"));
|
||||
ItemStack stack = Instruction.valueOf(script[i]).getItem();
|
||||
menu.addItem(i, new CustomItem(stack, SlimefunPlugin.getLocal().getMessage(p, "android.scripts.instructions." + Instruction.valueOf(script[i]).name()), "", "&7\u21E8 &eLeft Click &7to edit", "&7\u21E8 &eRight Click &7to delete", "&7\u21E8 &eShift + Right Click &7to duplicate"));
|
||||
menu.addMenuClickHandler(i, (pl, slot, item, action) -> {
|
||||
if (action.isRightClicked() && action.isShiftClicked()) {
|
||||
if (commands.length == 54) return false;
|
||||
if (script.length == 54) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
StringBuilder builder = new StringBuilder(Instruction.START + "-");
|
||||
|
||||
for (String command : commands) {
|
||||
if (j > 0) {
|
||||
if (j == index) {
|
||||
builder.append(commands[j]).append('-').append(commands[j]).append('-');
|
||||
}
|
||||
else if (j < commands.length - 1) {
|
||||
builder.append(command).append('-');
|
||||
}
|
||||
}
|
||||
j++;
|
||||
}
|
||||
builder.append(Instruction.REPEAT);
|
||||
setScript(b.getLocation(), builder.toString());
|
||||
openScript(pl, b, builder.toString());
|
||||
String code = duplicateInstruction(script, index);
|
||||
setScript(b.getLocation(), code);
|
||||
openScript(pl, b, code);
|
||||
}
|
||||
else if (action.isRightClicked()) {
|
||||
int j = 0;
|
||||
StringBuilder builder = new StringBuilder(Instruction.START + "-");
|
||||
|
||||
for (String command : commands) {
|
||||
if (j != index && j > 0 && j < commands.length - 1) builder.append(command).append('-');
|
||||
j++;
|
||||
}
|
||||
|
||||
builder.append(Instruction.REPEAT);
|
||||
setScript(b.getLocation(), builder.toString());
|
||||
|
||||
openScript(pl, b, builder.toString());
|
||||
String code = deleteInstruction(script, index);
|
||||
setScript(b.getLocation(), code);
|
||||
openScript(pl, b, code);
|
||||
}
|
||||
else {
|
||||
openScriptComponentEditor(pl, b, script, index);
|
||||
editInstruction(pl, b, script, index);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
@ -274,6 +255,62 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
||||
menu.open(p);
|
||||
}
|
||||
|
||||
private String addInstruction(String[] script, int index, Instruction instruction) {
|
||||
int i = 0;
|
||||
StringBuilder builder = new StringBuilder(Instruction.START + "-");
|
||||
|
||||
for (String current : script) {
|
||||
if (i > 0) {
|
||||
if (i == index) {
|
||||
builder.append(instruction).append('-');
|
||||
}
|
||||
else if (i < script.length - 1) {
|
||||
builder.append(current).append('-');
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
builder.append(Instruction.REPEAT.name());
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private String duplicateInstruction(String[] script, int index) {
|
||||
int i = 0;
|
||||
StringBuilder builder = new StringBuilder(Instruction.START + "-");
|
||||
|
||||
for (String instruction : script) {
|
||||
if (i > 0) {
|
||||
if (i == index) {
|
||||
builder.append(script[i]).append('-').append(script[i]).append('-');
|
||||
}
|
||||
else if (i < script.length - 1) {
|
||||
builder.append(instruction).append('-');
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
builder.append(Instruction.REPEAT.name());
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private String deleteInstruction(String[] script, int index) {
|
||||
int i = 0;
|
||||
StringBuilder builder = new StringBuilder(Instruction.START.name() + '-');
|
||||
|
||||
for (String instruction : script) {
|
||||
if (i != index && i > 0 && i < script.length - 1) {
|
||||
builder.append(instruction).append('-');
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
builder.append(Instruction.REPEAT.name());
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
protected void openScriptDownloader(Player p, Block b, int page) {
|
||||
ChestMenu menu = new ChestMenu("Android Scripts");
|
||||
menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HAT, 0.7F, 0.7F));
|
||||
@ -316,7 +353,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
||||
return false;
|
||||
});
|
||||
|
||||
menu.addItem(53, new CustomItem(SlimefunUtils.getCustomHead("185c97dbb8353de652698d24b64327b793a3f32a98be67b719fbedab35e"), "&6> Back", "", "&7Return to the Android's interface"));
|
||||
menu.addItem(53, new CustomItem(SlimefunUtils.getCustomHead("a185c97dbb8353de652698d24b64327b793a3f32a98be67b719fbedab35e"), "&6> Back", "", "&7Return to the Android's interface"));
|
||||
menu.addMenuClickHandler(53, (pl, slot, item, action) -> {
|
||||
openScriptEditor(pl, b);
|
||||
return false;
|
||||
@ -460,61 +497,32 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
||||
return NumberUtils.getColorFromPercentage(percentage) + String.valueOf(percentage) + ChatColor.RESET + "% ";
|
||||
}
|
||||
|
||||
protected void openScriptComponentEditor(Player p, Block b, String script, int index) {
|
||||
protected void editInstruction(Player p, Block b, String[] script, int index) {
|
||||
ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + SlimefunPlugin.getLocal().getMessage(p, "android.scripts.editor"));
|
||||
String[] commands = PatternUtils.DASH.split(script);
|
||||
|
||||
ChestMenuUtils.drawBackground(menu, 0, 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
menu.addItem(9, new CustomItem(SlimefunUtils.getCustomHead("16139fd1c5654e56e9e4e2c8be7eb2bd5b499d633616663feee99b74352ad64"), "&rDo nothing"), (pl, slot, item, action) -> {
|
||||
int i = 0;
|
||||
StringBuilder builder = new StringBuilder("START-");
|
||||
|
||||
for (String command : commands) {
|
||||
if (i != index && i > 0 && i < commands.length - 1) {
|
||||
builder.append(command).append('-');
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
builder.append("REPEAT");
|
||||
setScript(b.getLocation(), builder.toString());
|
||||
|
||||
openScript(p, b, builder.toString());
|
||||
String code = deleteInstruction(script, index);
|
||||
setScript(b.getLocation(), code);
|
||||
openScript(p, b, code);
|
||||
return false;
|
||||
});
|
||||
|
||||
int i = 10;
|
||||
for (Instruction part : getValidScriptInstructions()) {
|
||||
menu.addItem(i, new CustomItem(part.getItem(), SlimefunPlugin.getLocal().getMessage(p, "android.scripts.instructions." + part.name())), (pl, slot, item, action) -> {
|
||||
addInstruction(pl, b, index, part, commands);
|
||||
for (Instruction instruction : getValidScriptInstructions()) {
|
||||
menu.addItem(i, new CustomItem(instruction.getItem(), SlimefunPlugin.getLocal().getMessage(p, "android.scripts.instructions." + instruction.name())), (pl, slot, item, action) -> {
|
||||
String code = addInstruction(script, index, instruction);
|
||||
setScript(b.getLocation(), code);
|
||||
openScript(p, b, code);
|
||||
return false;
|
||||
});
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
menu.open(p);
|
||||
}
|
||||
|
||||
private void addInstruction(Player p, Block b, int index, Instruction part, String[] commands) {
|
||||
int j = 0;
|
||||
StringBuilder builder = new StringBuilder("START-");
|
||||
|
||||
for (String command : commands) {
|
||||
if (j > 0) {
|
||||
if (j == index) builder.append(part).append('-');
|
||||
else if (j < commands.length - 1) builder.append(command).append('-');
|
||||
}
|
||||
j++;
|
||||
}
|
||||
|
||||
builder.append("REPEAT");
|
||||
setScript(b.getLocation(), builder.toString());
|
||||
|
||||
openScript(p, b, builder.toString());
|
||||
}
|
||||
|
||||
protected String getScript(Location l) {
|
||||
String script = BlockStorage.getLocationInfo(l, "script");
|
||||
return script != null ? script : DEFAULT_SCRIPT;
|
||||
@ -528,6 +536,7 @@ public abstract class ProgrammableAndroid extends SlimefunItem implements Invent
|
||||
if (getTier() == 1) {
|
||||
registerFuelType(new MachineFuel(800, new ItemStack(Material.COAL_BLOCK)));
|
||||
registerFuelType(new MachineFuel(45, new ItemStack(Material.BLAZE_ROD)));
|
||||
registerFuelType(new MachineFuel(70, new ItemStack(Material.DRIED_KELP_BLOCK)));
|
||||
|
||||
// Coal & Charcoal
|
||||
registerFuelType(new MachineFuel(8, new ItemStack(Material.COAL)));
|
||||
|
@ -127,20 +127,22 @@ public class AncientAltarListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// getting the currently placed item
|
||||
Item stack = findItem(pedestal);
|
||||
|
||||
if (stack == null) {
|
||||
// Check if the Item in hand is valid
|
||||
if (p.getInventory().getItemInMainHand().getType() != Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for pedestal obstructions
|
||||
if (pedestal.getRelative(0, 1, 0).getType() != Material.AIR) {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "machines.ANCIENT_PEDESTAL.obstructed", true);
|
||||
return;
|
||||
}
|
||||
|
||||
// place the item onto the pedestal
|
||||
insertItem(p, pedestal);
|
||||
}
|
||||
}
|
||||
else if (!removedItems.contains(stack.getUniqueId())) {
|
||||
UUID uuid = stack.getUniqueId();
|
||||
removedItems.add(uuid);
|
||||
|
Loading…
Reference in New Issue
Block a user