mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-19 07:53:22 +02:00
customblock to sittingblock & customblock base without sitting height
This commit is contained in:
parent
9e77590755
commit
a2a944da2f
5 changed files with 42 additions and 23 deletions
|
@ -17,16 +17,14 @@ public class CustomBlock {
|
|||
private ArrayList<String> blockTags = new ArrayList<>();
|
||||
@SerializedName("blockstates")
|
||||
private ArrayList<String> blockStates = new ArrayList<>();
|
||||
@SerializedName("sitting-height")
|
||||
private Double sittingHeight = 0.5;
|
||||
|
||||
|
||||
public CustomBlock() {}
|
||||
|
||||
public CustomBlock(ArrayList<String> blockIds, ArrayList<String> blockTags, ArrayList<String> blockStates, Double sittingHeight) {
|
||||
public CustomBlock(ArrayList<String> blockIds, ArrayList<String> blockTags, ArrayList<String> blockStates) {
|
||||
this.blockIds = blockIds;
|
||||
this.blockTags = blockTags;
|
||||
this.blockStates = blockStates;
|
||||
this.sittingHeight = sittingHeight;
|
||||
}
|
||||
|
||||
public ArrayList<String> getBlockIds() {
|
||||
|
@ -41,9 +39,7 @@ public class CustomBlock {
|
|||
return blockStates;
|
||||
}
|
||||
|
||||
public Double getSittingHeight() {
|
||||
return sittingHeight;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* checks if the blockstate matches the CustomBlock params
|
||||
|
|
|
@ -92,10 +92,10 @@ public class FileData {
|
|||
}
|
||||
|
||||
public static class Defaults {
|
||||
public static final ArrayList<CustomBlock> CUSTOM_BLOCKS = new ArrayList<>(Arrays.asList(
|
||||
new CustomBlock(new ArrayList<>(),new ArrayList<>(Arrays.asList("#minecraft:campfires")), new ArrayList<>(Arrays.asList("lit=false")),.43),
|
||||
new CustomBlock(new ArrayList<>(Arrays.asList("!minecraft:oak_log", "minecraft:crimson_stem")), new ArrayList<>(Arrays.asList("#minecraft:logs")), new ArrayList<>(Arrays.asList("!axis=y")),1.0),
|
||||
new CustomBlock(new ArrayList<>(Arrays.asList()), new ArrayList<>(Arrays.asList("#minecraft:beds")), new ArrayList<>(Arrays.asList("part=foot","occupied=false")),.5)
|
||||
public static final ArrayList<SittingBlock> SITTING_BLOCKS = new ArrayList<>(Arrays.asList(
|
||||
new SittingBlock(new ArrayList<>(),new ArrayList<>(Arrays.asList("#minecraft:campfires")), new ArrayList<>(Arrays.asList("lit=false")),.43),
|
||||
new SittingBlock(new ArrayList<>(Arrays.asList("!minecraft:oak_log", "minecraft:crimson_stem")), new ArrayList<>(Arrays.asList("#minecraft:logs")), new ArrayList<>(Arrays.asList("!axis=y")),1.0),
|
||||
new SittingBlock(new ArrayList<>(Arrays.asList()), new ArrayList<>(Arrays.asList("#minecraft:beds")), new ArrayList<>(Arrays.asList("part=foot","occupied=false")),.5)
|
||||
));
|
||||
|
||||
public static final HandSetting MAIN_HAND = new HandSetting(HandSetting.SittingRequirement.EMPTY, new HandSetting.Filter(
|
||||
|
|
|
@ -34,9 +34,11 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
|||
@SerializedName("custom-enabled")
|
||||
private Boolean customEnabled = false;
|
||||
@SerializedName("custom-blocks")
|
||||
private ArrayList<CustomBlock> customBlocks = FileData.Defaults.CUSTOM_BLOCKS;
|
||||
private ArrayList<SittingBlock> sittingBlocks = FileData.Defaults.SITTING_BLOCKS;
|
||||
@SerializedName("blacklisted-blocks")
|
||||
private ArrayList<String> blacklistedBlocks = new ArrayList<>();
|
||||
@SerializedName("blacklisted-interactions")
|
||||
private ArrayList<String> blacklistedInteractions = new ArrayList<>();
|
||||
|
||||
public ServerConfig() {}
|
||||
|
||||
|
@ -47,18 +49,18 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
|||
this.sitWhileSeated = serverConfig.sitWhileSeated;
|
||||
this.presetBlocks = serverConfig.presetBlocks;
|
||||
this.customEnabled = serverConfig.customEnabled;
|
||||
this.customBlocks = serverConfig.customBlocks;
|
||||
this.sittingBlocks = serverConfig.sittingBlocks;
|
||||
this.blacklistedBlocks = serverConfig.blacklistedBlocks;
|
||||
}
|
||||
|
||||
public ServerConfig(Double version, String lang, boolean keepActive, boolean sitWhileSeated, PresetBlocks presetBlocks, boolean customEnabled, ArrayList<CustomBlock> customBlocks, ArrayList<String> blacklistedBlocks) {
|
||||
public ServerConfig(Double version, String lang, boolean keepActive, boolean sitWhileSeated, PresetBlocks presetBlocks, boolean customEnabled, ArrayList<SittingBlock> sittingBlocks, ArrayList<String> blacklistedBlocks) {
|
||||
this.version = version;
|
||||
this.lang = lang;
|
||||
this.keepActive = keepActive;
|
||||
this.sitWhileSeated = sitWhileSeated;
|
||||
this.presetBlocks = presetBlocks;
|
||||
this.customEnabled = customEnabled;
|
||||
this.customBlocks = customBlocks;
|
||||
this.sittingBlocks = sittingBlocks;
|
||||
this.blacklistedBlocks = blacklistedBlocks;
|
||||
}
|
||||
|
||||
|
@ -86,8 +88,8 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
|||
return customEnabled;
|
||||
}
|
||||
|
||||
public ArrayList<CustomBlock> getCustomBlocks() {
|
||||
return customBlocks;
|
||||
public ArrayList<SittingBlock> getSittingBlocks() {
|
||||
return sittingBlocks;
|
||||
}
|
||||
|
||||
public ArrayList<String> getBlacklistedBlocks() {
|
||||
|
@ -149,7 +151,7 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
|||
this.sitWhileSeated = newFile.sitWhileSeated;
|
||||
this.presetBlocks = newFile.presetBlocks;
|
||||
this.customEnabled = newFile.customEnabled;
|
||||
this.customBlocks = newFile.customBlocks;
|
||||
this.sittingBlocks = newFile.sittingBlocks;
|
||||
this.blacklistedBlocks = newFile.blacklistedBlocks;
|
||||
}
|
||||
|
||||
|
@ -229,9 +231,9 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
|||
/**
|
||||
* gets a list of custom blocks from the legacy way of entering custom sit blocks
|
||||
*/
|
||||
private static ArrayList<CustomBlock> getCustomBlocks(ArrayList<String> fix) {
|
||||
private static ArrayList<SittingBlock> getCustomBlocks(ArrayList<String> fix) {
|
||||
//eg. minecraft:campfire|.46|1|lit=false
|
||||
ArrayList<CustomBlock> out = new ArrayList<>();
|
||||
ArrayList<SittingBlock> out = new ArrayList<>();
|
||||
for (String entry : fix) {
|
||||
String[] split = entry.split("\\|");
|
||||
// skip if not the right size
|
||||
|
@ -247,7 +249,7 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
|||
}
|
||||
|
||||
// add if everything is A-OK
|
||||
out.add(new CustomBlock(
|
||||
out.add(new SittingBlock(
|
||||
new ArrayList<>(Arrays.asList(split[0])),
|
||||
new ArrayList<>(),blockstates,Double.parseDouble(split[1])));
|
||||
}
|
||||
|
|
21
src/main/java/one/oth3r/sit/file/SittingBlock.java
Normal file
21
src/main/java/one/oth3r/sit/file/SittingBlock.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package one.oth3r.sit.file;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SittingBlock extends CustomBlock {
|
||||
@SerializedName("sitting-height")
|
||||
private Double sittingHeight = 0.5;
|
||||
|
||||
public Double getSittingHeight() {
|
||||
return sittingHeight;
|
||||
}
|
||||
|
||||
public SittingBlock() {}
|
||||
|
||||
public SittingBlock(ArrayList<String> blockIds, ArrayList<String> blockTags, ArrayList<String> blockStates, Double sittingHeight) {
|
||||
super(blockIds, blockTags, blockStates);
|
||||
this.sittingHeight = sittingHeight;
|
||||
}
|
||||
}
|
|
@ -180,9 +180,9 @@ public class Utl {
|
|||
// if the block is on the blacklist, false
|
||||
if (config.getBlacklistedBlocks().contains(getBlockID(blockState))) return null;
|
||||
|
||||
for (CustomBlock customBlock : config.getCustomBlocks()) {
|
||||
for (SittingBlock dittingBlock : config.getSittingBlocks()) {
|
||||
// if the block is valid, true
|
||||
if (customBlock.isValid(blockState)) return customBlock.getSittingHeight();
|
||||
if (dittingBlock.isValid(blockState)) return dittingBlock.getSittingHeight();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue