mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixes #2856
This commit is contained in:
parent
0be442bc07
commit
0fa862314f
@ -51,6 +51,7 @@
|
|||||||
* Fixed some issues with the Book Binder
|
* Fixed some issues with the Book Binder
|
||||||
* Fixed #2805
|
* Fixed #2805
|
||||||
* Fixed #2861
|
* Fixed #2861
|
||||||
|
* Fixed #2856
|
||||||
|
|
||||||
## Release Candidate 20 (30 Jan 2021)
|
## Release Candidate 20 (30 Jan 2021)
|
||||||
|
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.implementation.items.blocks;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.Dropper;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link IgnitionChamber} is used to re-ignite a {@link Smeltery}.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
* @see Smeltery
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class IgnitionChamber extends SimpleSlimefunItem<BlockBreakHandler> {
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
public IgnitionChamber(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
|
super(category, item, recipeType, recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockBreakHandler getItemHandler() {
|
||||||
|
/*
|
||||||
|
* Explosions don't need explicit handling here.
|
||||||
|
* The default of "destroy the dispenser and drop the contents" is
|
||||||
|
* fine for our purposes already.
|
||||||
|
*/
|
||||||
|
return new BlockBreakHandler(false, true) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List<ItemStack> drops) {
|
||||||
|
// Fixes #2856 - Manually drop inventory contents
|
||||||
|
Block b = e.getBlock();
|
||||||
|
BlockState state = PaperLib.getBlockState(b, false).getState();
|
||||||
|
|
||||||
|
if (state instanceof Dropper) {
|
||||||
|
for (ItemStack stack : ((Dropper) state).getInventory()) {
|
||||||
|
if (stack != null && !stack.getType().isAir()) {
|
||||||
|
drops.add(stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,6 +3,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -17,6 +19,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
|
|
||||||
public class MakeshiftSmeltery extends AbstractSmeltery {
|
public class MakeshiftSmeltery extends AbstractSmeltery {
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
public MakeshiftSmeltery(Category category, SlimefunItemStack item) {
|
public MakeshiftSmeltery(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] { null, new ItemStack(Material.OAK_FENCE), null, new ItemStack(Material.BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN);
|
super(category, item, new ItemStack[] { null, new ItemStack(Material.OAK_FENCE), null, new ItemStack(Material.BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import java.util.Objects;
|
|||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -26,6 +28,7 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
|||||||
import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting;
|
import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.IgnitionChamber;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
@ -36,6 +39,7 @@ public class Smeltery extends AbstractSmeltery {
|
|||||||
private final BlockFace[] faces = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
|
private final BlockFace[] faces = { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
|
||||||
private final ItemSetting<Integer> fireBreakingChance = new IntRangeSetting("fire-breaking-chance", 0, 34, 100);
|
private final ItemSetting<Integer> fireBreakingChance = new IntRangeSetting("fire-breaking-chance", 0, 34, 100);
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
public Smeltery(Category category, SlimefunItemStack item) {
|
public Smeltery(Category category, SlimefunItemStack item) {
|
||||||
super(category, item, new ItemStack[] { null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.NETHER_BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.NETHER_BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN);
|
super(category, item, new ItemStack[] { null, new ItemStack(Material.NETHER_BRICK_FENCE), null, new ItemStack(Material.NETHER_BRICKS), new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), new ItemStack(Material.NETHER_BRICKS), null, new ItemStack(Material.FLINT_AND_STEEL), null }, BlockFace.DOWN);
|
||||||
|
|
||||||
@ -73,6 +77,7 @@ public class Smeltery extends AbstractSmeltery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
private void consumeFire(Player p, Block dispenser, Block b) {
|
private void consumeFire(Player p, Block dispenser, Block b) {
|
||||||
Inventory chamber = findIgnitionChamber(dispenser);
|
Inventory chamber = findIgnitionChamber(dispenser);
|
||||||
|
|
||||||
@ -103,9 +108,12 @@ public class Smeltery extends AbstractSmeltery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private Inventory findIgnitionChamber(@Nonnull Block b) {
|
private Inventory findIgnitionChamber(@Nonnull Block b) {
|
||||||
for (BlockFace face : faces) {
|
for (BlockFace face : faces) {
|
||||||
if (b.getRelative(face).getType() == Material.DROPPER && BlockStorage.check(b.getRelative(face), "IGNITION_CHAMBER")) {
|
Block block = b.getRelative(face);
|
||||||
|
|
||||||
|
if (block.getType() == Material.DROPPER && BlockStorage.check(block) instanceof IgnitionChamber) {
|
||||||
BlockState state = PaperLib.getBlockState(b.getRelative(face), false).getState();
|
BlockState state = PaperLib.getBlockState(b.getRelative(face), false).getState();
|
||||||
|
|
||||||
if (state instanceof Dropper) {
|
if (state instanceof Dropper) {
|
||||||
|
@ -52,6 +52,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.Crucible;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.EnhancedFurnace;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.EnhancedFurnace;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HardenedGlass;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HardenedGlass;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HologramProjector;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HologramProjector;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.IgnitionChamber;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.OutputChest;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.OutputChest;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RainbowBlock;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RainbowBlock;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RepairedSpawner;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RepairedSpawner;
|
||||||
@ -402,7 +403,7 @@ public final class SlimefunItemSetup {
|
|||||||
new MakeshiftSmeltery(categories.basicMachines, SlimefunItems.MAKESHIFT_SMELTERY).register(plugin);
|
new MakeshiftSmeltery(categories.basicMachines, SlimefunItems.MAKESHIFT_SMELTERY).register(plugin);
|
||||||
new Smeltery(categories.basicMachines, SlimefunItems.SMELTERY).register(plugin);
|
new Smeltery(categories.basicMachines, SlimefunItems.SMELTERY).register(plugin);
|
||||||
|
|
||||||
new SlimefunItem(categories.basicMachines, SlimefunItems.IGNITION_CHAMBER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
new IgnitionChamber(categories.basicMachines, SlimefunItems.IGNITION_CHAMBER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||||
new ItemStack[] {new ItemStack(Material.IRON_INGOT), new ItemStack(Material.FLINT_AND_STEEL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), SlimefunItems.BASIC_CIRCUIT_BOARD, new ItemStack(Material.IRON_INGOT), null, new ItemStack(Material.OBSERVER), null})
|
new ItemStack[] {new ItemStack(Material.IRON_INGOT), new ItemStack(Material.FLINT_AND_STEEL), new ItemStack(Material.IRON_INGOT), new ItemStack(Material.IRON_INGOT), SlimefunItems.BASIC_CIRCUIT_BOARD, new ItemStack(Material.IRON_INGOT), null, new ItemStack(Material.OBSERVER), null})
|
||||||
.register(plugin);
|
.register(plugin);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user