mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-09-27 03:52:38 +02:00
implement new wood detection
This commit is contained in:
parent
217ca3f4df
commit
ba75403f3b
@ -66,7 +66,6 @@ public class Barrel implements InventoryHolder {
|
|||||||
/**
|
/**
|
||||||
* Load from File
|
* Load from File
|
||||||
* <p>If async: true, The Barrel Bounds will not be recreated when missing/corrupt, getBody().getBounds() will be null if it needs recreating
|
* <p>If async: true, The Barrel Bounds will not be recreated when missing/corrupt, getBody().getBounds() will be null if it needs recreating
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public Barrel(Block spigot, byte sign, BoundingBox bounds, Map<String, Object> items, float time, boolean async) {
|
public Barrel(Block spigot, byte sign, BoundingBox bounds, Map<String, Object> items, float time, boolean async) {
|
||||||
this.spigot = spigot;
|
this.spigot = spigot;
|
||||||
|
@ -5,6 +5,7 @@ import com.dre.brewery.Brew;
|
|||||||
import com.dre.brewery.P;
|
import com.dre.brewery.P;
|
||||||
import com.dre.brewery.filedata.BConfig;
|
import com.dre.brewery.filedata.BConfig;
|
||||||
import com.dre.brewery.utility.BUtil;
|
import com.dre.brewery.utility.BUtil;
|
||||||
|
import com.dre.brewery.utility.LegacyUtil;
|
||||||
import com.dre.brewery.utility.StringParser;
|
import com.dre.brewery.utility.StringParser;
|
||||||
import com.dre.brewery.utility.Tuple;
|
import com.dre.brewery.utility.Tuple;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
@ -181,7 +182,8 @@ public class BRecipe {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
List<RecipeItem> ingredients = new ArrayList<>(ingredientsList.size());
|
List<RecipeItem> ingredients = new ArrayList<>(ingredientsList.size());
|
||||||
listLoop: for (String item : ingredientsList) {
|
listLoop:
|
||||||
|
for (String item : ingredientsList) {
|
||||||
String[] ingredParts = item.split("/");
|
String[] ingredParts = item.split("/");
|
||||||
int amount = 1;
|
int amount = 1;
|
||||||
if (ingredParts.length == 2) {
|
if (ingredParts.length == 2) {
|
||||||
@ -325,7 +327,7 @@ public class BRecipe {
|
|||||||
P.p.errorLog("Invalid distilltime '" + distillTime + "' in Recipe: " + getRecipeName());
|
P.p.errorLog("Invalid distilltime '" + distillTime + "' in Recipe: " + getRecipeName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (wood < 0 || wood > 11) {
|
if (wood < 0 || wood > LegacyUtil.TOTAL_WOOD_TYPES) {
|
||||||
P.p.errorLog("Invalid wood type '" + wood + "' in Recipe: " + getRecipeName());
|
P.p.errorLog("Invalid wood type '" + wood + "' in Recipe: " + getRecipeName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,9 @@ import org.bukkit.material.Wood;
|
|||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.dre.brewery.BCauldron.EMPTY;
|
import static com.dre.brewery.BCauldron.EMPTY;
|
||||||
@ -45,34 +47,74 @@ public class LegacyUtil {
|
|||||||
// EnumSet not supposed to be used anymore
|
// EnumSet not supposed to be used anymore
|
||||||
// See https://www.spigotmc.org/threads/spigot-bungeecord-1-19.559742/
|
// See https://www.spigotmc.org/threads/spigot-bungeecord-1-19.559742/
|
||||||
Set<Material> planks = new HashSet<>();
|
Set<Material> planks = new HashSet<>();
|
||||||
|
Set<String> allWoodTypes = new HashSet<>();
|
||||||
|
List<String> unknownWoodTypes = new ArrayList<>();
|
||||||
for (Material m : Material.values()) {
|
for (Material m : Material.values()) {
|
||||||
if (m.name().endsWith("PLANKS")) {
|
String name = m.name();
|
||||||
|
if (name.endsWith("PLANKS")) {
|
||||||
|
String woodName = name.substring(0, name.lastIndexOf("_"));
|
||||||
planks.add(m);
|
planks.add(m);
|
||||||
|
allWoodTypes.add(woodName);
|
||||||
|
if (!name.startsWith("OAK") &&
|
||||||
|
!name.startsWith("SPRUCE") &&
|
||||||
|
!name.startsWith("BIRCH") &&
|
||||||
|
!name.startsWith("JUNGLE") &&
|
||||||
|
!name.startsWith("ACACIA") &&
|
||||||
|
!name.startsWith("DARK_OAK") &&
|
||||||
|
!name.startsWith("CRIMSON") &&
|
||||||
|
!name.startsWith("WARPED") &&
|
||||||
|
!name.startsWith("MANGROVE") &&
|
||||||
|
!name.startsWith("CHERRY") &&
|
||||||
|
!name.startsWith("BAMBOO")) {
|
||||||
|
|
||||||
|
unknownWoodTypes.add(woodName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
unknownWoodTypes.sort(null);
|
||||||
PLANKS = planks;
|
PLANKS = planks;
|
||||||
|
UNKNOWN_WOOD = unknownWoodTypes;
|
||||||
|
TOTAL_WOOD_TYPES = allWoodTypes.size();
|
||||||
|
|
||||||
|
if (!unknownWoodTypes.isEmpty()) {
|
||||||
|
P.p.log("New wood types detected. Assigning recipe numbers:");
|
||||||
|
int lastKnownNumber = 12;
|
||||||
|
for (int i = 0; i < unknownWoodTypes.size(); i++) {
|
||||||
|
P.p.log(" " + unknownWoodTypes.get(i) + ": " + (i + lastKnownNumber));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Set<Material> woodStairs = new HashSet<>();
|
Set<Material> woodStairs = new HashSet<>();
|
||||||
Material[] gotStairs = {
|
for (String wood : allWoodTypes) {
|
||||||
get("OAK_STAIRS", "WOOD_STAIRS"),
|
Material stair = get(wood + "_STAIRS");
|
||||||
get("SPRUCE_STAIRS", "SPRUCE_WOOD_STAIRS"),
|
|
||||||
get("BIRCH_STAIRS", "BIRCH_WOOD_STAIRS"),
|
|
||||||
get("JUNGLE_STAIRS", "JUNGLE_WOOD_STAIRS"),
|
|
||||||
get("ACACIA_STAIRS"),
|
|
||||||
get("DARK_OAK_STAIRS"),
|
|
||||||
get("CRIMSON_STAIRS"),
|
|
||||||
get("WARPED_STAIRS"),
|
|
||||||
get("MANGROVE_STAIRS"),
|
|
||||||
get("CHERRY_STAIRS"),
|
|
||||||
get("BAMBOO_STAIRS"),
|
|
||||||
};
|
|
||||||
for (Material stair : gotStairs) {
|
|
||||||
if (stair != null) {
|
if (stair != null) {
|
||||||
woodStairs.add(stair);
|
woodStairs.add(stair);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!P.use1_13) {
|
||||||
|
Material[] legacyStairs = {
|
||||||
|
get("OAK_STAIRS", "WOOD_STAIRS"),
|
||||||
|
get("SPRUCE_STAIRS", "SPRUCE_WOOD_STAIRS"),
|
||||||
|
get("BIRCH_STAIRS", "BIRCH_WOOD_STAIRS"),
|
||||||
|
get("JUNGLE_STAIRS", "JUNGLE_WOOD_STAIRS"),
|
||||||
|
};
|
||||||
|
for (Material stair : legacyStairs) {
|
||||||
|
if (stair != null) {
|
||||||
|
woodStairs.add(stair);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
WOOD_STAIRS = woodStairs;
|
WOOD_STAIRS = woodStairs;
|
||||||
|
|
||||||
|
// Special case for Bamboo mosaic, which simply counts as bamboo in recipes
|
||||||
|
if (get("BAMBOO_MOSAIC") != null) {
|
||||||
|
planks.add(get("BAMBOO_MOSAIC"));
|
||||||
|
}
|
||||||
|
if (get("BAMBOO_MOSAIC_STAIRS") != null) {
|
||||||
|
woodStairs.add(get("BAMBOO_MOSAIC_STAIRS"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Set<Material> fences = new HashSet<>();
|
Set<Material> fences = new HashSet<>();
|
||||||
for (Material m : Material.values()) {
|
for (Material m : Material.values()) {
|
||||||
@ -92,6 +134,8 @@ public class LegacyUtil {
|
|||||||
public static final Set<Material> PLANKS;
|
public static final Set<Material> PLANKS;
|
||||||
public static final Set<Material> WOOD_STAIRS;
|
public static final Set<Material> WOOD_STAIRS;
|
||||||
public static final Set<Material> FENCES;
|
public static final Set<Material> FENCES;
|
||||||
|
public static final List<String> UNKNOWN_WOOD;
|
||||||
|
public static final int TOTAL_WOOD_TYPES;
|
||||||
|
|
||||||
// Materials removed in 1.13
|
// Materials removed in 1.13
|
||||||
public static final Material STATIONARY_LAVA = get("STATIONARY_LAVA");
|
public static final Material STATIONARY_LAVA = get("STATIONARY_LAVA");
|
||||||
@ -197,6 +241,13 @@ public class LegacyUtil {
|
|||||||
return 10;
|
return 10;
|
||||||
} else if (material.startsWith("BAMBOO")) {
|
} else if (material.startsWith("BAMBOO")) {
|
||||||
return 11;
|
return 11;
|
||||||
|
} else if (!UNKNOWN_WOOD.isEmpty()) {
|
||||||
|
for (int i = 0; i < UNKNOWN_WOOD.size(); i++) {
|
||||||
|
if (material.startsWith(UNKNOWN_WOOD.get(i))) {
|
||||||
|
return (byte) (i + 12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user