mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-19 16:03:22 +02:00
added new config option: allowed-above-seat
This commit is contained in:
parent
b52b96608d
commit
202d8ac171
3 changed files with 22 additions and 4 deletions
|
@ -10,6 +10,7 @@ import one.oth3r.sit.utl.Utl;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class FileData {
|
public class FileData {
|
||||||
/**
|
/**
|
||||||
|
@ -111,6 +112,13 @@ public class FileData {
|
||||||
new ArrayList<>())
|
new ArrayList<>())
|
||||||
));
|
));
|
||||||
|
|
||||||
|
public static final ArrayList<CustomBlock> ALLOWED_ABOVE_SEAT = new ArrayList<>(List.of(
|
||||||
|
new CustomBlock(
|
||||||
|
new ArrayList<>(),
|
||||||
|
new ArrayList<>(List.of("#minecraft:trapdoors")),
|
||||||
|
new ArrayList<>())
|
||||||
|
));
|
||||||
|
|
||||||
public static final HandSetting MAIN_HAND = new HandSetting(HandSetting.SittingRequirement.EMPTY, new HandSetting.Filter(
|
public static final HandSetting MAIN_HAND = new HandSetting(HandSetting.SittingRequirement.EMPTY, new HandSetting.Filter(
|
||||||
false,new HandSetting.Filter.Presets(),
|
false,new HandSetting.Filter.Presets(),
|
||||||
new CustomItem(
|
new CustomItem(
|
||||||
|
|
|
@ -52,6 +52,8 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
private ArrayList<CustomBlock> blacklistedBlocks = FileData.Defaults.BLACKLISTED_BLOCKS;
|
private ArrayList<CustomBlock> blacklistedBlocks = FileData.Defaults.BLACKLISTED_BLOCKS;
|
||||||
@SerializedName("interaction-blocks")
|
@SerializedName("interaction-blocks")
|
||||||
private ArrayList<CustomBlock> interactionBlocks = FileData.Defaults.INTERACTION_BLOCKS;
|
private ArrayList<CustomBlock> interactionBlocks = FileData.Defaults.INTERACTION_BLOCKS;
|
||||||
|
@SerializedName("allowed-above-seat")
|
||||||
|
private ArrayList<CustomBlock> allowedAboveSeat = FileData.Defaults.ALLOWED_ABOVE_SEAT;
|
||||||
|
|
||||||
public ServerConfig() {}
|
public ServerConfig() {}
|
||||||
|
|
||||||
|
@ -62,7 +64,7 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
public ServerConfig(Double version, String lang, boolean keepActive, boolean sitWhileSeated,
|
public ServerConfig(Double version, String lang, boolean keepActive, boolean sitWhileSeated,
|
||||||
PresetBlocks presetBlocks, boolean customEnabled,
|
PresetBlocks presetBlocks, boolean customEnabled,
|
||||||
ArrayList<SittingBlock> sittingBlocks, ArrayList<CustomBlock> blacklistedBlocks,
|
ArrayList<SittingBlock> sittingBlocks, ArrayList<CustomBlock> blacklistedBlocks,
|
||||||
ArrayList<CustomBlock> interactionBlocks) {
|
ArrayList<CustomBlock> interactionBlocks, ArrayList<CustomBlock> allowedAboveSeat) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.lang = lang;
|
this.lang = lang;
|
||||||
this.keepActive = keepActive;
|
this.keepActive = keepActive;
|
||||||
|
@ -72,6 +74,7 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
this.sittingBlocks = sittingBlocks;
|
this.sittingBlocks = sittingBlocks;
|
||||||
this.blacklistedBlocks = blacklistedBlocks;
|
this.blacklistedBlocks = blacklistedBlocks;
|
||||||
this.interactionBlocks = interactionBlocks;
|
this.interactionBlocks = interactionBlocks;
|
||||||
|
this.allowedAboveSeat = allowedAboveSeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getVersion() {
|
public Double getVersion() {
|
||||||
|
@ -114,6 +117,10 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
return interactionBlocks;
|
return interactionBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<CustomBlock> getAllowedAboveSeat() {
|
||||||
|
return allowedAboveSeat;
|
||||||
|
}
|
||||||
|
|
||||||
public static class PresetBlocks {
|
public static class PresetBlocks {
|
||||||
|
|
||||||
@SerializedName("stairs")
|
@SerializedName("stairs")
|
||||||
|
@ -261,6 +268,7 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
this.sittingBlocks = newFile.sittingBlocks.stream().map(SittingBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
this.sittingBlocks = newFile.sittingBlocks.stream().map(SittingBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
||||||
this.blacklistedBlocks = newFile.blacklistedBlocks.stream().map(CustomBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
this.blacklistedBlocks = newFile.blacklistedBlocks.stream().map(CustomBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
||||||
this.interactionBlocks = newFile.interactionBlocks.stream().map(CustomBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
this.interactionBlocks = newFile.interactionBlocks.stream().map(CustomBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
this.allowedAboveSeat = newFile.allowedAboveSeat.stream().map(CustomBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -298,12 +306,12 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
ServerConfig that = (ServerConfig) o;
|
ServerConfig that = (ServerConfig) o;
|
||||||
return Objects.equals(version, that.version) && Objects.equals(lang, that.lang) && Objects.equals(keepActive, that.keepActive) && Objects.equals(sitWhileSeated, that.sitWhileSeated) && Objects.equals(presetBlocks, that.presetBlocks) && Objects.equals(yDifferenceLimit, that.yDifferenceLimit) && Objects.equals(customEnabled, that.customEnabled) && Objects.equals(sittingBlocks, that.sittingBlocks) && Objects.equals(blacklistedBlocks, that.blacklistedBlocks) && Objects.equals(interactionBlocks, that.interactionBlocks);
|
return Objects.equals(version, that.version) && Objects.equals(lang, that.lang) && Objects.equals(keepActive, that.keepActive) && Objects.equals(sitWhileSeated, that.sitWhileSeated) && Objects.equals(presetBlocks, that.presetBlocks) && Objects.equals(yDifferenceLimit, that.yDifferenceLimit) && Objects.equals(customEnabled, that.customEnabled) && Objects.equals(sittingBlocks, that.sittingBlocks) && Objects.equals(blacklistedBlocks, that.blacklistedBlocks) && Objects.equals(interactionBlocks, that.interactionBlocks) && Objects.equals(allowedAboveSeat, that.allowedAboveSeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(version, lang, langOptions, keepActive, sitWhileSeated, presetBlocks, yDifferenceLimit, customEnabled, sittingBlocks, blacklistedBlocks, interactionBlocks);
|
return Objects.hash(version, lang, langOptions, keepActive, sitWhileSeated, presetBlocks, yDifferenceLimit, customEnabled, sittingBlocks, blacklistedBlocks, interactionBlocks, allowedAboveSeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class Legacy {
|
protected static class Legacy {
|
||||||
|
@ -419,7 +427,7 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
Boolean.parseBoolean((String) properties.computeIfAbsent("custom", a -> String.valueOf(defaultConfig.isCustomEnabled()))),
|
Boolean.parseBoolean((String) properties.computeIfAbsent("custom", a -> String.valueOf(defaultConfig.isCustomEnabled()))),
|
||||||
getCustomBlocks(new Gson().fromJson((String)
|
getCustomBlocks(new Gson().fromJson((String)
|
||||||
properties.computeIfAbsent("custom-blocks", a -> "[]"), listType)),
|
properties.computeIfAbsent("custom-blocks", a -> "[]"), listType)),
|
||||||
new ArrayList<>(), FileData.Defaults.INTERACTION_BLOCKS
|
new ArrayList<>(), FileData.Defaults.INTERACTION_BLOCKS, FileData.Defaults.ALLOWED_ABOVE_SEAT
|
||||||
);
|
);
|
||||||
|
|
||||||
SittingConfig defaultSittingConfig = new SittingConfig();
|
SittingConfig defaultSittingConfig = new SittingConfig();
|
||||||
|
|
|
@ -49,6 +49,8 @@ public class Utl {
|
||||||
public static boolean isNotObstructed(World world, BlockPos blockPos) {
|
public static boolean isNotObstructed(World world, BlockPos blockPos) {
|
||||||
// get the block state at the blockPos
|
// get the block state at the blockPos
|
||||||
BlockState state = world.getBlockState(blockPos);
|
BlockState state = world.getBlockState(blockPos);
|
||||||
|
// if block is allowed to be above seat, return true
|
||||||
|
if (blockIsInList(FileData.getServerConfig().getAllowedAboveSeat(), state)) return true;
|
||||||
// make sure it doesn't have a collision
|
// make sure it doesn't have a collision
|
||||||
return state.getCollisionShape(world,blockPos).isEmpty();
|
return state.getCollisionShape(world,blockPos).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue