1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Oil Pump now shows its "Bucket -> Oil" recipe.

This commit is contained in:
TheBusyBiscuit 2020-01-05 14:30:50 +01:00
parent 5d5c0cbc8a
commit 9ff093affa
9 changed files with 57 additions and 39 deletions

View File

@ -55,6 +55,7 @@ https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#4
* Removed Nether Drill
* Tweaked Enhanced Furnace Recipes
* Changed tooltips for Radiation
* Oil Pump now shows its "Bucket -> Oil" recipe
### Fixes
* Fixed Research Titles

View File

@ -6,6 +6,7 @@ import java.util.UUID;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.TileState;
import io.github.thebusybiscuit.cscorelib2.collections.OptionalMap;
@ -41,15 +42,23 @@ public class SlimefunWorld {
* @return An {@link Optional} of the requested {@link SlimefunBlock}, empty if none was found
*/
public Optional<SlimefunBlock> getBlock(Block b) {
if (b.getState() instanceof TileState) {
Optional<String> blockData = SlimefunPlugin.getBlockDataService().getBlockData((TileState) b.getState());
if (blockData.isPresent()) {
return Optional.of(new SlimefunBlock(blockData.get()));
}
}
Optional<SlimefunBlock> optional = blocks.get(new BlockLocation(b));
return blocks.get(new BlockLocation(b));
if (optional.isPresent()) {
return optional;
}
else {
BlockState state = b.getState();
if (state instanceof TileState) {
Optional<String> blockData = SlimefunPlugin.getBlockDataService().getBlockData((TileState) state);
if (blockData.isPresent()) {
return Optional.of(new SlimefunBlock(blockData.get()));
}
}
return Optional.empty();
}
}
public boolean isBlock(Block b, String id) {

View File

@ -3,6 +3,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.Ageable;
import org.bukkit.inventory.ItemStack;
@ -23,12 +24,13 @@ public class InfernalBonemeal extends SimpleSlimefunItem<ItemInteractionHandler>
public ItemInteractionHandler getItemHandler() {
return (e, p, item) -> {
if (isItem(item)) {
if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.NETHER_WART) {
Ageable ageable = (Ageable) e.getClickedBlock().getBlockData();
Block b = e.getClickedBlock();
if (b != null && b.getType() == Material.NETHER_WART) {
Ageable ageable = (Ageable) b.getBlockData();
if (ageable.getAge() < ageable.getMaximumAge()) {
ageable.setAge(ageable.getMaximumAge());
e.getClickedBlock().setBlockData(ageable);
e.getClickedBlock().getWorld().playEffect(e.getClickedBlock().getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK);
b.setBlockData(ageable);
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK);
if (p.getGameMode() != GameMode.CREATIVE) {
ItemUtils.consumeItem(item, false);

View File

@ -64,10 +64,11 @@ public class Crucible extends SlimefunGadget {
addItemHandler((ItemInteractionHandler) (e, p, item) -> {
if (e.getClickedBlock() != null) {
String id = BlockStorage.checkID(e.getClickedBlock());
if (id != null && id.equals("CRUCIBLE")) {
if (p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, e.getClickedBlock().getLocation(), ProtectableAction.ACCESS_INVENTORIES)) {
final ItemStack input = p.getInventory().getItemInMainHand();
final Block block = e.getClickedBlock().getRelative(BlockFace.UP);
ItemStack input = p.getInventory().getItemInMainHand();
Block block = e.getClickedBlock().getRelative(BlockFace.UP);
SlimefunItem machine = SlimefunItem.getByID(id);
for (ItemStack convert : RecipeType.getRecipeInputs(machine)) {
@ -79,8 +80,10 @@ public class Crucible extends SlimefunGadget {
p.getInventory().removeItem(removing);
boolean water = Tag.LEAVES.isTagged(input.getType());
if (block.getType() == (water ? Material.WATER : Material.LAVA)) {
int level = ((Levelled) block.getBlockData()).getLevel();
if (level > 7)
level -= 8;
if (level == 0) {
@ -112,8 +115,11 @@ public class Crucible extends SlimefunGadget {
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_METAL_BREAK, 1F, 1F);
return;
}
if (BlockStorage.hasBlockInfo(block))
if (BlockStorage.hasBlockInfo(block)) {
BlockStorage.clearBlockInfo(block);
}
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
}
block.setType(water ? Material.WATER : Material.LAVA);

View File

@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.blocks.Vein;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.core.utils.ChestMenuUtils;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
@ -43,14 +44,14 @@ public class FluidPump extends SimpleSlimefunItem<BlockTicker> implements Invent
private void constructMenu(BlockMenuPreset preset) {
for (int i : border) {
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "), (p, slot, item, action) -> false);
preset.addItem(i, new CustomItem(new ItemStack(Material.GRAY_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler());
}
for (int i : border_in) {
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "), (p, slot, item, action) -> false);
preset.addItem(i, new CustomItem(new ItemStack(Material.CYAN_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler());
}
for (int i : border_out) {
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "), (p, slot, item, action) -> false);
preset.addItem(i, new CustomItem(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE), " "), ChestMenuUtils.getEmptyClickHandler());
}
for (int i : getOutputSlots()) {

View File

@ -1,5 +1,6 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
import me.mrCookieSlime.Slimefun.GEO.GEOScanner;
@ -24,12 +25,14 @@ public class GEOScannerBlock extends SimpleSlimefunItem<ItemInteractionHandler>
@Override
public ItemInteractionHandler getItemHandler() {
return (e, p, stack) -> {
if (e.getClickedBlock() == null) return false;
String item = BlockStorage.checkID(e.getClickedBlock());
Block b = e.getClickedBlock();
if (b == null) return false;
String item = BlockStorage.checkID(b);
if (item == null || !item.equals(getID())) return false;
e.setCancelled(true);
GEOScanner.scanChunk(p, e.getClickedBlock().getChunk());
GEOScanner.scanChunk(p, b.getChunk());
return true;
};
}

View File

@ -1,5 +1,8 @@
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.geo;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -16,6 +19,7 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.RecipeDisplayItem;
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@ -25,7 +29,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
import me.mrCookieSlime.Slimefun.utils.MachineHelper;
public abstract class OilPump extends AContainer {
public abstract class OilPump extends AContainer implements RecipeDisplayItem {
public OilPump(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
@ -58,6 +62,11 @@ public abstract class OilPump extends AContainer {
};
}
@Override
public List<ItemStack> getDisplayRecipes() {
return Arrays.asList(new ItemStack(Material.BUCKET), SlimefunItems.BUCKET_OF_OIL);
}
@Override
public String getMachineIdentifier() {
return "OIL_PUMP";
@ -113,7 +122,7 @@ public abstract class OilPump extends AContainer {
else {
ItemStack item = inv.getItemInSlot(slot).clone();
inv.replaceExistingItem(slot, null);
pushItems(b, item);
inv.pushItem(item, getOutputSlots());
}
break;
}

View File

@ -28,11 +28,9 @@ import io.github.thebusybiscuit.slimefun4.implementation.geo.resources.OilResour
import io.github.thebusybiscuit.slimefun4.implementation.geo.resources.SaltResource;
import io.github.thebusybiscuit.slimefun4.implementation.geo.resources.UraniumResource;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.AndroidKillingListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBootsListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.AutonomousToolsListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBowListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DamageListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener;
@ -42,6 +40,8 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupLis
import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.NetworkListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.PlayerProfileListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBootsListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunBowListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunGuideListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SoulboundListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener;
@ -335,7 +335,7 @@ public final class SlimefunPlugin extends JavaPlugin {
getLogger().log(Level.SEVERE, "Could not save Slimefun Blocks for World \"" + world.getName() + "\"");
}
} catch (Exception x) {
getLogger().log(Level.SEVERE, "An Error occured while saving Slimefun-Blocks in World '" + world.getName() + "' for Slimefun " + Slimefun.getVersion());
getLogger().log(Level.SEVERE, "An Error occured while saving Slimefun-Blocks in World '" + world.getName() + "' for Slimefun " + Slimefun.getVersion(), x);
}
}

View File

@ -270,19 +270,6 @@ public final class Slimefun {
return items;
}
/**
* Binds this description to the SlimefunItem corresponding to this id.
*
* @param id the id of the SlimefunItem, not null
* @param description the description, not null
*
* @deprecated As of 4.1.10, renamed to {@link #addHint(String, String...)} for better name convenience.
*/
@Deprecated
public static void addDescription(String id, String... description) {
getItemConfig().setDefaultValue(id + ".description", Arrays.asList(description));
}
/**
* Binds this hint to the SlimefunItem corresponding to this id.
*