1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
This commit is contained in:
TheBusyBiscuit 2020-10-12 11:52:23 +02:00
parent 14e18d2962
commit 3b7dd68164
4 changed files with 58 additions and 8 deletions

View File

@ -77,6 +77,7 @@
* Fixed #2422
* Fixed #2433
* Fixed #2455
* Fixed #2450
## Release Candidate 16 (07 Sep 2020)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16

View File

@ -2,6 +2,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.altar;
import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -17,7 +21,9 @@ import org.bukkit.util.Vector;
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener;
import io.github.thebusybiscuit.slimefun4.implementation.tasks.AncientAltarTask;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
@ -39,10 +45,11 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
* @see AncientAltarTask
*
*/
public class AncientPedestal extends SlimefunItem {
public class AncientPedestal extends SimpleSlimefunItem<BlockDispenseHandler> {
public static final String ITEM_PREFIX = ChatColors.color("&dALTAR &3Probe - &e");
@ParametersAreNonnullByDefault
public AncientPedestal(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, recipeType, recipe, recipeOutput);
@ -63,7 +70,13 @@ public class AncientPedestal extends SlimefunItem {
});
}
public Optional<Item> getPlacedItem(Block pedestal) {
@Override
public BlockDispenseHandler getItemHandler() {
return (e, d, block, machine) -> e.setCancelled(true);
}
@Nonnull
public Optional<Item> getPlacedItem(@Nonnull Block pedestal) {
Location l = pedestal.getLocation().add(0.5, 1.2, 0.5);
for (Entity n : l.getWorld().getNearbyEntities(l, 0.5, 0.5, 0.5, this::testItem)) {
@ -75,7 +88,7 @@ public class AncientPedestal extends SlimefunItem {
return Optional.empty();
}
private boolean testItem(Entity n) {
private boolean testItem(@Nullable Entity n) {
if (n instanceof Item && n.isValid()) {
Item item = (Item) n;
ItemMeta meta = item.getItemStack().getItemMeta();
@ -86,7 +99,8 @@ public class AncientPedestal extends SlimefunItem {
}
}
public ItemStack getOriginalItemStack(Item item) {
@Nonnull
public ItemStack getOriginalItemStack(@Nonnull Item item) {
ItemStack stack = item.getItemStack().clone();
String customName = item.getCustomName();
@ -108,7 +122,7 @@ public class AncientPedestal extends SlimefunItem {
return stack;
}
public void placeItem(Player p, Block b) {
public void placeItem(@Nonnull Player p, @Nonnull Block b) {
ItemStack hand = p.getInventory().getItemInMainHand();
ItemStack displayItem = new CustomItem(hand, ITEM_PREFIX + System.nanoTime());
displayItem.setAmount(1);

View File

@ -0,0 +1,34 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
* The {@link AndroidInterface} are inventories used to interact with a {@link ProgrammableAndroid}.
* There are two variants of interfaces, fuel and items.
*
* @author TheBusyBiscuit
*
* @see ProgrammableAndroid
*
*/
public class AndroidInterface extends SimpleSlimefunItem<BlockDispenseHandler> {
@ParametersAreNonnullByDefault
public AndroidInterface(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}
@Override
public BlockDispenseHandler getItemHandler() {
return (e, d, block, machine) -> e.setCancelled(true);
}
}

View File

@ -26,6 +26,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AdvancedFarmerAndroid;
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInterface;
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ButcherAndroid;
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FarmerAndroid;
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FisherAndroid;
@ -110,11 +111,11 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors
import io.github.thebusybiscuit.slimefun4.implementation.items.food.BirthdayCake;
import io.github.thebusybiscuit.slimefun4.implementation.items.food.DietCookie;
import io.github.thebusybiscuit.slimefun4.implementation.items.food.FortuneCookie;
import io.github.thebusybiscuit.slimefun4.implementation.items.food.HeavyCream;
import io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice;
import io.github.thebusybiscuit.slimefun4.implementation.items.food.MagicSugar;
import io.github.thebusybiscuit.slimefun4.implementation.items.food.MeatJerky;
import io.github.thebusybiscuit.slimefun4.implementation.items.food.MonsterJerky;
import io.github.thebusybiscuit.slimefun4.implementation.items.food.HeavyCream;
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump;
@ -2181,11 +2182,11 @@ public final class SlimefunItemSetup {
new ItemStack[] {null, SlimefunItems.ELECTRO_MAGNET, null, null, SlimefunItems.GPS_TRANSMITTER, null, null, SlimefunItems.ESSENCE_OF_AFTERLIFE, null})
.register(plugin);
new SlimefunItem(categories.androids, SlimefunItems.ANDROID_INTERFACE_ITEMS, RecipeType.ENHANCED_CRAFTING_TABLE,
new AndroidInterface(categories.androids, SlimefunItems.ANDROID_INTERFACE_ITEMS, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.PLASTIC_SHEET, SlimefunItems.STEEL_INGOT, SlimefunItems.PLASTIC_SHEET, SlimefunItems.STEEL_INGOT, SlimefunItems.BASIC_CIRCUIT_BOARD, new ItemStack(Material.BLUE_STAINED_GLASS), SlimefunItems.PLASTIC_SHEET, SlimefunItems.STEEL_INGOT, SlimefunItems.PLASTIC_SHEET})
.register(plugin);
new SlimefunItem(categories.androids, SlimefunItems.ANDROID_INTERFACE_FUEL, RecipeType.ENHANCED_CRAFTING_TABLE,
new AndroidInterface(categories.androids, SlimefunItems.ANDROID_INTERFACE_FUEL, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.PLASTIC_SHEET, SlimefunItems.STEEL_INGOT, SlimefunItems.PLASTIC_SHEET, new ItemStack(Material.RED_STAINED_GLASS), SlimefunItems.BASIC_CIRCUIT_BOARD, SlimefunItems.STEEL_INGOT, SlimefunItems.PLASTIC_SHEET, SlimefunItems.STEEL_INGOT, SlimefunItems.PLASTIC_SHEET})
.register(plugin);