mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
parent
bacaceb22f
commit
1f3d0f5c20
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,5 +1,6 @@
|
||||
# Table of contents
|
||||
- [Release Candidate 29 (07 Nov 2021)](#release-candidate-29-06-nov-2021)
|
||||
- [Release Candidate 30 (TBD)](#release-candidate-30-tbd)
|
||||
- [Release Candidate 29 (07 Nov 2021)](#release-candidate-29-07-nov-2021)
|
||||
- [Release Candidate 28 (06 Sep 2021)](#release-candidate-28-06-sep-2021)
|
||||
- [Release Candidate 27 (03 Sep 2021)](#release-candidate-27-03-sep-2021)
|
||||
- [Release Candidate 26 (20 Jul 2021)](#release-candidate-26-20-jul-2021)
|
||||
@ -29,6 +30,16 @@
|
||||
- [Release Candidate 2 (29 Sep 2019)](#release-candidate-2-29-sep-2019)
|
||||
- [Release Candidate 1 (26 Sep 2019)](#release-candidate-1-26-sep-2019)
|
||||
|
||||
## Release Candidate 30 (TBD)
|
||||
|
||||
#### Additions
|
||||
|
||||
#### Changes
|
||||
|
||||
#### Fixes
|
||||
* Crimson and Warped Pressure Plates are now properly recognized as pressure plates
|
||||
* Fixed #3336
|
||||
|
||||
## Release Candidate 29 (07 Nov 2021)
|
||||
|
||||
#### Additions
|
||||
|
@ -67,16 +67,7 @@ public class IndustrialMiner extends MultiBlockMachine {
|
||||
}, BlockFace.UP);
|
||||
// @formatter:on
|
||||
|
||||
MinecraftVersion minecraftVersion = Slimefun.getMinecraftVersion();
|
||||
|
||||
if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_17)) {
|
||||
this.oreDictionary = new OreDictionary17();
|
||||
} else if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
|
||||
this.oreDictionary = new OreDictionary16();
|
||||
} else {
|
||||
this.oreDictionary = new OreDictionary14();
|
||||
}
|
||||
|
||||
this.oreDictionary = OreDictionary.forVersion(Slimefun.getMinecraftVersion());
|
||||
this.range = range;
|
||||
this.silkTouch = silkTouch;
|
||||
|
||||
@ -141,7 +132,7 @@ public class IndustrialMiner extends MultiBlockMachine {
|
||||
return new ItemStack(material);
|
||||
} else {
|
||||
Random random = ThreadLocalRandom.current();
|
||||
return oreDictionary.forMaterial(material, random);
|
||||
return oreDictionary.getDrops(material, random);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class MiningTask implements Runnable {
|
||||
private final int height;
|
||||
|
||||
private boolean running = false;
|
||||
private int fuel = 0;
|
||||
private int fuelLevel = 0;
|
||||
private int ores = 0;
|
||||
|
||||
private int x;
|
||||
@ -120,14 +120,6 @@ class MiningTask implements Runnable {
|
||||
* This method starts the warm-up animation for the {@link IndustrialMiner}.
|
||||
*/
|
||||
private void warmUp() {
|
||||
fuel = consumeFuel();
|
||||
|
||||
if (fuel <= 0) {
|
||||
// This Miner has not enough fuel.
|
||||
stop(MinerStoppingReason.NO_FUEL);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is our warm up animation.
|
||||
* The pistons will push after another in decreasing intervals
|
||||
@ -140,6 +132,21 @@ class MiningTask implements Runnable {
|
||||
queue.thenRun(8, () -> setPistonState(pistons[1], true));
|
||||
queue.thenRun(10, () -> setPistonState(pistons[1], false));
|
||||
|
||||
/*
|
||||
* Fixes #3336
|
||||
* Trigger each piston once, so that the structure is validated.
|
||||
* Then consume fuel.
|
||||
*/
|
||||
queue.thenRun(() -> {
|
||||
consumeFuel();
|
||||
|
||||
if (fuelLevel <= 0) {
|
||||
// This Miner has not enough fuel.
|
||||
stop(MinerStoppingReason.NO_FUEL);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
queue.thenRun(6, () -> setPistonState(pistons[0], true));
|
||||
queue.thenRun(9, () -> setPistonState(pistons[0], false));
|
||||
|
||||
@ -196,7 +203,7 @@ class MiningTask implements Runnable {
|
||||
furnace.getWorld().playSound(furnace.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 0.2F, 1F);
|
||||
|
||||
b.setType(Material.AIR);
|
||||
fuel--;
|
||||
fuelLevel--;
|
||||
ores++;
|
||||
|
||||
// Repeat the same column when we hit an ore.
|
||||
@ -251,13 +258,13 @@ class MiningTask implements Runnable {
|
||||
* @return Whether the operation was successful
|
||||
*/
|
||||
private boolean push(@Nonnull ItemStack item) {
|
||||
if (fuel < 1) {
|
||||
if (fuelLevel < 1) {
|
||||
// Restock fuel
|
||||
fuel = consumeFuel();
|
||||
consumeFuel();
|
||||
}
|
||||
|
||||
// Check if there is enough fuel to run
|
||||
if (fuel > 0) {
|
||||
if (fuelLevel > 0) {
|
||||
if (chest.getType() == Material.CHEST) {
|
||||
BlockState state = PaperLib.getBlockState(chest, false).getState();
|
||||
|
||||
@ -287,23 +294,19 @@ class MiningTask implements Runnable {
|
||||
|
||||
/**
|
||||
* This consumes fuel from the given {@link Chest}.
|
||||
*
|
||||
* @return The gained fuel value
|
||||
*/
|
||||
private int consumeFuel() {
|
||||
private void consumeFuel() {
|
||||
if (chest.getType() == Material.CHEST) {
|
||||
BlockState state = PaperLib.getBlockState(chest, false).getState();
|
||||
|
||||
if (state instanceof Chest) {
|
||||
Inventory inv = ((Chest) state).getBlockInventory();
|
||||
return consumeFuel(inv);
|
||||
this.fuelLevel = grabFuelFrom(inv);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int consumeFuel(@Nonnull Inventory inv) {
|
||||
private int grabFuelFrom(@Nonnull Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
for (MachineFuel fuelType : miner.fuelTypes) {
|
||||
ItemStack item = inv.getContents()[i];
|
||||
|
@ -8,6 +8,8 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
||||
|
||||
/**
|
||||
* Simple interface to map ore blocks to their respective item(s).
|
||||
*
|
||||
@ -18,5 +20,18 @@ interface OreDictionary {
|
||||
|
||||
@Nonnull
|
||||
@ParametersAreNonnullByDefault
|
||||
ItemStack forMaterial(Material material, Random random);
|
||||
ItemStack getDrops(Material material, Random random);
|
||||
|
||||
static @Nonnull OreDictionary forVersion(@Nonnull MinecraftVersion version) {
|
||||
if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_17)) {
|
||||
// MC 1.17 - 1.18
|
||||
return new OreDictionary17();
|
||||
} else if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
|
||||
// MC 1.16
|
||||
return new OreDictionary16();
|
||||
} else {
|
||||
// MC 1.14 - 1.15
|
||||
return new OreDictionary14();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class OreDictionary14 implements OreDictionary {
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public @Nonnull ItemStack forMaterial(Material material, Random random) {
|
||||
public @Nonnull ItemStack getDrops(Material material, Random random) {
|
||||
switch (material) {
|
||||
case COAL_ORE:
|
||||
return new ItemStack(Material.COAL);
|
||||
|
@ -18,7 +18,7 @@ class OreDictionary16 extends OreDictionary14 {
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public @Nonnull ItemStack forMaterial(Material material, Random random) {
|
||||
public @Nonnull ItemStack getDrops(Material material, Random random) {
|
||||
switch (material) {
|
||||
case NETHER_GOLD_ORE:
|
||||
// In 1.16, breaking nether gold ores should get gold nuggets
|
||||
@ -26,7 +26,7 @@ class OreDictionary16 extends OreDictionary14 {
|
||||
case ANCIENT_DEBRIS:
|
||||
return new ItemStack(Material.ANCIENT_DEBRIS);
|
||||
default:
|
||||
return super.forMaterial(material, random);
|
||||
return super.getDrops(material, random);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class OreDictionary17 extends OreDictionary16 {
|
||||
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public ItemStack forMaterial(Material material, Random random) {
|
||||
public ItemStack getDrops(Material material, Random random) {
|
||||
// In 1.17, breaking metal ores should get raw metals. Also support deepslate ores.
|
||||
switch (material) {
|
||||
case COAL_ORE:
|
||||
@ -45,7 +45,7 @@ class OreDictionary17 extends OreDictionary16 {
|
||||
case DEEPSLATE_GOLD_ORE:
|
||||
return new ItemStack(Material.RAW_GOLD);
|
||||
default:
|
||||
return super.forMaterial(material, random);
|
||||
return super.getDrops(material, random);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -504,11 +504,13 @@ public final class SlimefunUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to check if an Inventory is empty (has no items in "storage"). If the MC version is 1.16 or above
|
||||
* Helper method to check if an Inventory is empty (has no items in "storage").
|
||||
* If the MC version is 1.16 or above
|
||||
* this will call {@link Inventory#isEmpty()} (Which calls MC code resulting in a faster method).
|
||||
*
|
||||
* @param inventory
|
||||
* The {@link Inventory} to check.
|
||||
*
|
||||
* @return True if the inventory is empty and false otherwise
|
||||
*/
|
||||
public static boolean isInventoryEmpty(@Nonnull Inventory inventory) {
|
||||
|
@ -30,6 +30,11 @@ public final class WorldUtils {
|
||||
public static int getMinHeight(@Nonnull World world) {
|
||||
Validate.notNull(world, "World cannot be null!");
|
||||
|
||||
return Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16) ? world.getMinHeight() : 0;
|
||||
if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
|
||||
return world.getMinHeight();
|
||||
} else {
|
||||
// Default to zero for pre-1.16 worlds
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user