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

Added 4 bricks -> 1 brick block recipe to the Electric Press

This commit is contained in:
TheBusyBiscuit 2020-12-01 16:37:51 +01:00
parent 5d0ed3570d
commit 96e38608f9
5 changed files with 138 additions and 2 deletions

View File

@ -33,6 +33,8 @@
* Added a config option to delete excess cargo network items
* Added an item setting to configure the Wind Staff velocity
* Added an item setting to the Infused Hopper to toggle it with redstone
* Added an item setting to prevent Reinforced Spawners from being changed by Spawn Eggs
* Added 4 bricks -> 1 brick block recipe to the Electric Press
#### Changes
* Removed 1.13 support

View File

@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.blocks;
import java.util.ArrayList;
import java.util.Collection;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
@ -12,7 +13,10 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@ -27,11 +31,31 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/
public class RepairedSpawner extends AbstractMonsterSpawner {
private final ItemSetting<Boolean> allowSpawnEggs = new ItemSetting<>("allow-spawn-eggs", true);
@ParametersAreNonnullByDefault
public RepairedSpawner(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
addItemHandler(new BlockPlaceHandler(true) {
addItemSetting(allowSpawnEggs);
addItemHandler(onInteract());
addItemHandler(onPlace());
}
@Nonnull
private BlockUseHandler onInteract() {
return e -> {
if (!allowSpawnEggs.getValue() && SlimefunTag.SPAWN_EGGS.isTagged(e.getItem().getType())) {
// Disallow spawn eggs from being used on Reinforced Spawners if disabled
e.cancel();
}
};
}
@Nonnull
private BlockPlaceHandler onPlace() {
return new BlockPlaceHandler(true) {
@Override
public void onPlayerPlace(BlockPlaceEvent e) {
@ -45,6 +69,10 @@ public class RepairedSpawner extends AbstractMonsterSpawner {
@ParametersAreNonnullByDefault
private void onPlace(ItemStack item, BlockEvent e) {
/**
* This may no longer be needed at some point but for legacy items
* we still need to set the spawned EntityType manually
*/
if (e.getBlock().getType() == Material.SPAWNER) {
getEntityType(item).ifPresent(entity -> {
CreatureSpawner spawner = (CreatureSpawner) e.getBlock().getState();
@ -53,7 +81,7 @@ public class RepairedSpawner extends AbstractMonsterSpawner {
});
}
}
});
};
}
@Override

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@ -11,8 +13,16 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
* The {@link ElectricPress} is a pretty simple electrical machine.
* It allows you to compact items into their block variant, e.g. 9 diamonds into a diamond block.
*
* @author TheBusyBiscuit
*
*/
public class ElectricPress extends AContainer implements RecipeDisplayItem {
@ParametersAreNonnullByDefault
public ElectricPress(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
}
@ -28,6 +38,7 @@ public class ElectricPress extends AContainer implements RecipeDisplayItem {
addRecipe(3, new ItemStack(Material.DRIED_KELP, 9), new ItemStack(Material.DRIED_KELP_BLOCK));
addRecipe(3, new ItemStack(Material.BONE_MEAL, 9), new ItemStack(Material.BONE_BLOCK));
addRecipe(3, new ItemStack(Material.CLAY_BALL, 4), new ItemStack(Material.CLAY));
addRecipe(3, new ItemStack(Material.BRICK, 4), new ItemStack(Material.BRICKS));
addRecipe(6, SlimefunItems.COPPER_INGOT, new CustomItem(SlimefunItems.COPPER_WIRE, 3));
addRecipe(16, new SlimefunItemStack(SlimefunItems.STEEL_INGOT, 8), SlimefunItems.STEEL_PLATE);
@ -61,6 +72,7 @@ public class ElectricPress extends AContainer implements RecipeDisplayItem {
addRecipe(8, new ItemStack(Material.DIAMOND, 9), new ItemStack(Material.DIAMOND_BLOCK));
}
@ParametersAreNonnullByDefault
private void addRecipe(int seconds, ItemStack input, ItemStack output) {
registerRecipe(seconds, new ItemStack[] { input }, new ItemStack[] { output });
}

View File

@ -62,6 +62,11 @@ public enum SlimefunTag implements Tag<Material> {
* All command block variants
*/
COMMAND_BLOCKS,
/**
* All variants of Spawn Eggs
*/
SPAWN_EGGS,
/**
* Every mushroom type, red, brown and nether ones.

View File

@ -0,0 +1,89 @@
{
"values" : [
"minecraft:bat_spawn_egg",
{
"id" : "minecraft:bee_spawn_egg",
"required" : false
},
"minecraft:blaze_spawn_egg",
"minecraft:cave_spider_spawn_egg",
"minecraft:cat_spawn_egg",
"minecraft:chicken_spawn_egg",
"minecraft:cod_spawn_egg",
"minecraft:cow_spawn_egg",
"minecraft:creeper_spawn_egg",
"minecraft:dolphin_spawn_egg",
"minecraft:donkey_spawn_egg",
"minecraft:drowned_spawn_egg",
"minecraft:elder_guardian_spawn_egg",
"minecraft:enderman_spawn_egg",
"minecraft:endermite_spawn_egg",
"minecraft:evoker_spawn_egg",
"minecraft:fox_spawn_egg",
"minecraft:ghast_spawn_egg",
"minecraft:guardian_spawn_egg",
{
"id" : "minecraft:hoglin_spawn_egg",
"required" : false
},
"minecraft:horse_spawn_egg",
"minecraft:husk_spawn_egg",
"minecraft:llama_spawn_egg",
"minecraft:magma_cube_spawn_egg",
"minecraft:mooshroom_spawn_egg",
"minecraft:mule_spawn_egg",
"minecraft:ocelot_spawn_egg",
"minecraft:panda_spawn_egg",
"minecraft:parrot_spawn_egg",
"minecraft:phantom_spawn_egg",
"minecraft:pig_spawn_egg",
{
"id" : "minecraft:piglin_spawn_egg",
"required" : false
},
{
"id" : "minecraft:piglin_brute_spawn_egg",
"required" : false
},
"minecraft:pillager_spawn_egg",
"minecraft:polar_bear_spawn_egg",
"minecraft:pufferfish_spawn_egg",
"minecraft:rabbit_spawn_egg",
"minecraft:ravager_spawn_egg",
"minecraft:salmon_spawn_egg",
"minecraft:sheep_spawn_egg",
"minecraft:shulker_spawn_egg",
"minecraft:silverfish_spawn_egg",
"minecraft:skeleton_spawn_egg",
"minecraft:skeleton_horse_spawn_egg",
"minecraft:slime_spawn_egg",
"minecraft:spider_spawn_egg",
"minecraft:squid_spawn_egg",
"minecraft:stray_spawn_egg",
{
"id" : "minecraft:strider_spawn_egg",
"required" : false
},
"minecraft:trader_llama_spawn_egg",
"minecraft:tropical_fish_spawn_egg",
"minecraft:turtle_spawn_egg",
"minecraft:vex_spawn_egg",
"minecraft:villager_spawn_egg",
"minecraft:vindicator_spawn_egg",
"minecraft:wandering_trader_spawn_egg",
"minecraft:witch_spawn_egg",
"minecraft:wither_skeleton_spawn_egg",
"minecraft:wolf_spawn_egg",
{
"id" : "minecraft:zoglin_spawn_egg",
"required" : false
},
"minecraft:zombie_spawn_egg",
"minecraft:zombie_horse_spawn_egg",
"minecraft:zombie_villager_spawn_egg",
{
"id" : "minecraft:zombified_piglin_spawn_egg",
"required" : false
}
]
}