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

[CI skip] Refactoring

This commit is contained in:
TheBusyBiscuit 2021-03-31 18:29:43 +02:00
parent 82366191b0
commit 32c60ad5ac
4 changed files with 31 additions and 22 deletions

View File

@ -37,15 +37,13 @@ import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
/**
* This class needs to be rewritten VERY BADLY.
* But we should focus on rewriting the recipe system first.
* This machine is disabled and has been replaced by Auto Crafters.
*
* @deprecated This has been replaced by the {@link AbstractAutoCrafter}.
*
* @author TheBusyBiscuit
*
*/
@Deprecated
public abstract class AutomatedCraftingChamber extends SlimefunItem implements InventoryBlock, EnergyNetComponent {
private final int[] border = { 0, 1, 3, 4, 5, 7, 8, 13, 14, 15, 16, 17, 50, 51, 52, 53 };

View File

@ -186,13 +186,15 @@ public class FluidPump extends SimpleSlimefunItem<BlockTicker> implements Invent
@Nonnull
private ItemStack getFilledBucket(@Nonnull Block fluid) {
if (fluid.getType() == Material.LAVA) {
return new ItemStack(Material.LAVA_BUCKET);
} else if (fluid.getType() == Material.WATER || fluid.getType() == Material.BUBBLE_COLUMN) {
return new ItemStack(Material.WATER_BUCKET);
} else {
// Fallback for any new liquids
return new ItemStack(Material.BUCKET);
switch (fluid.getType()) {
case LAVA:
return new ItemStack(Material.LAVA_BUCKET);
case WATER:
case BUBBLE_COLUMN:
return new ItemStack(Material.WATER_BUCKET);
default:
// Fallback for any new liquids
return new ItemStack(Material.BUCKET);
}
}
@ -214,6 +216,7 @@ public class FluidPump extends SimpleSlimefunItem<BlockTicker> implements Invent
return levelled.getLevel() == 0;
}
}
return false;
}

View File

@ -24,7 +24,7 @@ public class AnimalProduce extends MachineRecipe implements Predicate<LivingEnti
private final Predicate<LivingEntity> predicate;
@ParametersAreNonnullByDefault
public AnimalProduce(ItemStack input, Predicate<LivingEntity> predicate, ItemStack result) {
public AnimalProduce(ItemStack input, ItemStack result, Predicate<LivingEntity> predicate) {
super(5, new ItemStack[] { input }, new ItemStack[] { result });
Validate.notNull(predicate, "The Predicate must not be null");

View File

@ -12,7 +12,6 @@ import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Cow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -44,9 +43,8 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
*/
public class ProduceCollector extends AContainer implements RecipeDisplayItem {
private final Set<AnimalProduce> animalProduces = new HashSet<>();
private final ItemSetting<Integer> range = new IntRangeSetting(this, "range", 1, 2, 32);
private final Set<AnimalProduce> animalProduces = new HashSet<>();
@ParametersAreNonnullByDefault
public ProduceCollector(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
@ -57,8 +55,23 @@ public class ProduceCollector extends AContainer implements RecipeDisplayItem {
@Override
protected void registerDefaultRecipes() {
addProduce(new AnimalProduce(new ItemStack(Material.BUCKET), Cow.class::isInstance, new ItemStack(Material.MILK_BUCKET)));
addProduce(new AnimalProduce(new ItemStack(Material.BOWL), MushroomCow.class::isInstance, new ItemStack(Material.MUSHROOM_STEW)));
// Milk from adult cows
addProduce(new AnimalProduce(new ItemStack(Material.BUCKET), new ItemStack(Material.MILK_BUCKET), n -> {
if (n instanceof Cow) {
return ((Cow) n).isAdult();
} else {
return false;
}
}));
// Mushroom Stew from Mooshrooms
addProduce(new AnimalProduce(new ItemStack(Material.BOWL), new ItemStack(Material.MUSHROOM_STEW), n -> {
if (n instanceof MushroomCow) {
return ((MushroomCow) n).isAdult();
} else {
return false;
}
}));
}
/**
@ -132,12 +145,7 @@ public class ProduceCollector extends AContainer implements RecipeDisplayItem {
@ParametersAreNonnullByDefault
private boolean isValidAnimal(Entity n, Predicate<LivingEntity> predicate) {
if (n instanceof LivingEntity) {
if (n instanceof Ageable && !((Ageable) n).isAdult()) {
// We only take adults into consideration
return false;
} else {
return predicate.test((LivingEntity) n);
}
return predicate.test((LivingEntity) n);
} else {
return false;
}