Merge branch '1.20.4' into 1.20.1

# Conflicts:
#	gradle.properties
#	src/main/java/one/oth3r/sit/utl/Utl.java
This commit is contained in:
Oth3r 2025-02-23 15:44:13 -06:00
commit a878e2b41e
10 changed files with 303 additions and 41 deletions

View file

@ -28,6 +28,12 @@ public class CustomBlock {
this.blockStates = blockStates;
}
public CustomBlock(CustomBlock customBlock) {
this.blockIds = new ArrayList<>(customBlock.blockIds);
this.blockTags = new ArrayList<>(customBlock.blockTags);
this.blockStates = new ArrayList<>(customBlock.blockStates);
}
public ArrayList<String> getBlockIds() {
return blockIds;
}

View file

@ -89,9 +89,12 @@ public class FileData {
));
public static final ArrayList<CustomBlock> INTERACTION_BLOCKS = new ArrayList<>(Arrays.asList(
new CustomBlock(new ArrayList<>(Arrays.asList("minecraft:crafter")),new ArrayList<>(Arrays.asList(
new CustomBlock(new ArrayList<>(Arrays.asList(
"minecraft:crafter","minecraft:repeating_command_block","minecraft:chain_command_block","minecraft:command_block")),
new ArrayList<>(Arrays.asList(
"#minecraft:shulker_boxes","#c:player_workstations/furnaces","#c:player_workstations/crafting_tables",
"#c:villager_job_sites","#minecraft:trapdoors","#c:chests")),new ArrayList<>())
"#c:villager_job_sites","#minecraft:trapdoors","#c:chests")),
new ArrayList<>())
));
public static final HandSetting MAIN_HAND = new HandSetting(HandSetting.SittingRequirement.EMPTY, new HandSetting.Filter(

View file

@ -16,25 +16,33 @@ import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Properties;
import java.util.stream.Collectors;
public class ServerConfig implements CustomFile<ServerConfig> {
@SerializedName("version")
private Double version = 2.1;
private Double version = 2.2;
@SerializedName("lang")
private String lang = "en_us";
@SerializedName("lang-options")
private final String langOptions = "en_us, it_it, pt_br, tr_tr, zh_tw";
private final String langOptions = "en_us, it_it, pt_br, tr_tr, zh_tw, zh_ch, de_de";
@SerializedName("keep-active")
private Boolean keepActive = true;
@SerializedName("sit-while-seated")
private Boolean sitWhileSeated = false;
@SerializedName("preset-blocks")
private PresetBlocks presetBlocks = new PresetBlocks();
@SerializedName("height-difference-limit")
private YDifferenceLimit yDifferenceLimit = new YDifferenceLimit();
@SerializedName("custom-enabled")
private Boolean customEnabled = false;
@SerializedName("custom-blocks")
private ArrayList<SittingBlock> sittingBlocks = FileData.Defaults.SITTING_BLOCKS;
@SerializedName("blacklisted-blocks")
private ArrayList<CustomBlock> blacklistedBlocks = FileData.Defaults.BLACKLISTED_BLOCKS;
@SerializedName("interaction-blocks")
@ -43,15 +51,7 @@ public class ServerConfig implements CustomFile<ServerConfig> {
public ServerConfig() {}
public ServerConfig(ServerConfig serverConfig) {
this.version = serverConfig.version;
this.lang = serverConfig.lang;
this.keepActive = serverConfig.keepActive;
this.sitWhileSeated = serverConfig.sitWhileSeated;
this.presetBlocks = serverConfig.presetBlocks;
this.customEnabled = serverConfig.customEnabled;
this.sittingBlocks = serverConfig.sittingBlocks;
this.blacklistedBlocks = serverConfig.blacklistedBlocks;
this.interactionBlocks = serverConfig.interactionBlocks;
loadFileData(serverConfig);
}
public ServerConfig(Double version, String lang, boolean keepActive, boolean sitWhileSeated,
@ -89,6 +89,10 @@ public class ServerConfig implements CustomFile<ServerConfig> {
return presetBlocks;
}
public YDifferenceLimit getYDifferenceLimit() {
return yDifferenceLimit;
}
public Boolean isCustomEnabled() {
return customEnabled;
}
@ -125,6 +129,13 @@ public class ServerConfig implements CustomFile<ServerConfig> {
this.fullBlocks = fullBlocks;
}
public PresetBlocks(PresetBlocks presetBlocks) {
this.stairs = presetBlocks.stairs;
this.slabs = presetBlocks.slabs;
this.carpets = presetBlocks.carpets;
this.fullBlocks = presetBlocks.fullBlocks;
}
public boolean isStairs() {
return stairs;
}
@ -142,6 +153,42 @@ public class ServerConfig implements CustomFile<ServerConfig> {
}
}
public static class YDifferenceLimit {
@SerializedName("above")
private Double above = 1.0;
@SerializedName("below")
private Double below = 1.0;
public YDifferenceLimit() {
}
public YDifferenceLimit(Double above, Double below) {
this.above = above;
this.below = below;
}
public YDifferenceLimit(YDifferenceLimit yDifferenceLimit) {
this.above = yDifferenceLimit.above;
this.below = yDifferenceLimit.below;
}
public Double getAbove() {
return above;
}
public void setAbove(Double above) {
this.above = above;
}
public Double getBelow() {
return below;
}
public void setBelow(Double below) {
this.below = below;
}
}
@Override
public void reset() {
loadFileData(new ServerConfig());
@ -158,17 +205,23 @@ public class ServerConfig implements CustomFile<ServerConfig> {
this.lang = newFile.lang;
this.keepActive = newFile.keepActive;
this.sitWhileSeated = newFile.sitWhileSeated;
this.presetBlocks = newFile.presetBlocks;
this.presetBlocks = new PresetBlocks(newFile.presetBlocks);
this.yDifferenceLimit = new YDifferenceLimit(newFile.yDifferenceLimit);
this.customEnabled = newFile.customEnabled;
this.sittingBlocks = newFile.sittingBlocks;
this.blacklistedBlocks = newFile.blacklistedBlocks;
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.interactionBlocks = newFile.interactionBlocks.stream().map(CustomBlock::new).collect(Collectors.toCollection(ArrayList::new));
}
@Override
public void update() {
/// update to 2.1, just a new list, nothing to change
if (version == 2.0) {
version = 2.1;
/// update to 2.2, new settings, no changes
if (version >= 2.0 && version <= 2.1) {
version = 2.2;
}
}

View file

@ -22,4 +22,9 @@ public class SittingBlock extends CustomBlock {
super(blockIds, blockTags, blockStates);
this.sittingHeight = sittingHeight;
}
public SittingBlock(SittingBlock sittingBlock) {
super(sittingBlock);
this.sittingHeight = sittingBlock.sittingHeight;
}
}

View file

@ -10,6 +10,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import one.oth3r.sit.file.FileData;
import one.oth3r.sit.file.ServerConfig;
import one.oth3r.sit.file.SittingConfig;
import one.oth3r.sit.file.HandSetting;
import org.jetbrains.annotations.Nullable;
@ -27,6 +28,9 @@ public class Logic {
if (!checkHands(player)) return false;
}
// check if the block is in the right y level limits from the config
if (!checkYLimits(player, blockPos)) return false;
ServerWorld serverWorld = player.getServerWorld();
BlockState blockState = serverWorld.getBlockState(blockPos);
@ -74,6 +78,26 @@ public class Logic {
return canSit;
}
/**
* check if the Y-level of the block is within the limits of the player, bounds are set in the {@link ServerConfig}
*/
public static boolean checkYLimits(ServerPlayerEntity player, BlockPos blockPos) {
double playerY = player.getBlockY();
double blockY = blockPos.getY();
// if the block is above the eye height
boolean isAbove = playerY < blockY;
// return true if equal
if (playerY == blockY) return true;
// get the height difference (positive)
double heightDifference = Math.abs(playerY - blockY);
// get the config limits
ServerConfig.YDifferenceLimit yDifferenceLimit = FileData.getServerConfig().getYDifferenceLimit();
return (isAbove? yDifferenceLimit.getAbove() : yDifferenceLimit.getBelow()) >= heightDifference;
}
/**
* removes the entity bound to the player from the game, using the player
*/
@ -170,11 +194,11 @@ public class Logic {
// get the message settings
String messageKey = "sit!.chat.sit_toggle."+(config.getEnabled()?"on":"off");
String messageKey = "sit!.chat.toggle_sit."+(config.getEnabled()?"on":"off");
Formatting messageColor = config.getEnabled()?Formatting.GREEN:Formatting.RED;
// send the player the actionbar message
return Utl.lang("sit!.chat.sit_toggle",
return Utl.lang("sit!.chat.toggle_sit",
Utl.lang(messageKey).formatted(messageColor));
} else {
// unsupported server message if not in a Sit! server

View file

@ -204,6 +204,10 @@ public class Utl {
}
public static class Entity {
/**
* the customizable y height of the entity, as some versions have different sitting heights on the entity
*/
private static final double Y_ADJUSTMENT = 0.2;
/**
* checks if the entity's block is still there, & is valid
@ -220,11 +224,10 @@ public class Utl {
* gets the bound block pos of the sit entity
*/
public static BlockPos getBlockPos(DisplayEntity.TextDisplayEntity entity) {
// adjustment, the opposite of the offset in Entity.create()
/// ADD .2 AS 1.20.1 is offset by .2
double adjustmentY = 0.2;
// the entity Y level, adjusted
// the adjustment - is the opposite of the offset applied in Entity.create()
double entityY = entity.getY() + (Y_ADJUSTMENT*-1);
double entityY = entity.getY() + adjustmentY;
// get the block pos
BlockPos pos = new BlockPos(entity.getBlockX(),(int)entityY,entity.getBlockZ());
// if above the block, subtract 1
@ -258,23 +261,19 @@ public class Utl {
entity.setInvulnerable(true);
entity.setInvisible(true);
// get the entities y level
double entityY = blockPos.getY();
entityY += sitHeight;
// set the entities position
entity.updatePositionAndAngles(blockPos.getX()+.5, entityY, blockPos.getZ()+.5, 0, 0);
entity.updatePosition(blockPos.getX()+.5, entityY, blockPos.getZ()+.5);
// change pitch based on if player is sitting below block height or not (full block height only)
if (entity.getY() == blockPos.getY() + 1) entity.setPitch(90); // below
else entity.setPitch(-90); // above
// make a double for adjusting the entity height if some versions change the player sit height on entities again
/// 1.20.1 SITTING OFF BY -0.2
double adjustmentY = -0.2;
entity.updatePosition(entity.getX(),entity.getY()+adjustmentY,entity.getZ());
// adjusting the entity height after doing the main calculations, for correct player visuals
entity.updatePosition(entity.getX(),entityY+Y_ADJUSTMENT,entity.getZ());
return entity;
}

View file

@ -0,0 +1,83 @@
{
"category.sit!": "Sit!",
"config.entry.exclusion": "Setze ein `!` vor einen Eintrag um ihn auszuschließen!",
"config.entry.example": "Beispiel eingeben: %s",
"config.server": "Server Konfiguration",
"config.server.description": "Konfiguriert die Einstellung des Servers.",
"config.server.lang": "Sprache",
"config.server.lang.description": "Die Sprache, die für die Sit! Mod benutzt wird.",
"config.server.keep-active": "Aktiv lassen",
"config.server.keep-active.description": "Stellt ein ob die Sit! Entität bleiben soll, selbst wenn der Spieler/Server offline ist.\nWenn nein, wird der Spieler nicht mehr sitzen, wenn er sich wieder einloggt.",
"config.server.sit-while-seated": "Setzten während reiten",
"config.server.sit-while-seated.description": "Stellt die Fähigkeit ein auf einem anderem Sit! Block zu sitzen, wenn man bereits auf einem sitzt.",
"config.server.preset-blocks": "Vorhandene Blöcke",
"config.server.preset-blocks.description": "Stellt die Standard Sit! Blöcke ein.",
"config.server.preset-blocks.stairs": "Treppen",
"config.server.preset-blocks.slabs": "Stufen",
"config.server.preset-blocks.carpets": "Teppiche",
"config.server.preset-blocks.full-blocks": "Volle Blöcke",
"config.server.custom-enabled": "Benutzerdefiniert",
"config.server.custom-enabled.description": "Stellt das Benutzen von Benutzerdefinierten Blöcken zum Sitzen ein.",
"config.server.custom-blocks": "Benutzerdefinierte Blöcke",
"config.server.custom-blocks.description": "Die Liste Benutzerdefinierter Sitz-Blöcke",
"config.server.custom-block.block-ids": "Block IDs",
"config.server.custom-block.block-ids.description": "Die Block-ID(s) für Benutzerdefinierte Sitzt-Blöcke.",
"config.server.custom-block.block-tags": "Block Tags",
"config.server.custom-block.block-tags.description": "Die Block-Tag(s) für Benutzerdefinierte Sitzt-Blöcke.",
"config.server.custom-block.blockstates": "Blockstates",
"config.server.custom-block.blockstates.description": "Die Blockstates, die ein Block haben muss, um ein eigener Sitz-Block zu sein.",
"config.server.custom-block.sitting-height": "Sitzt Höhe",
"config.server.custom-block.sitting-height.description": "Die Spieler Sitzhöhe von den eigenen Blöcken.",
"config.server.blacklisted-blocks": "Gesperrte Blöcke",
"config.server.blacklisted-blocks.description": "Die Liste der Blöcke auf denen man nicht sitzen kann.",
"config.sitting": "Sitzt Konfiguration",
"config.sitting.description": "Konfiguriert die Sitzfähigkeit. Auf dem Server kann jeder Spieler seine eigene Sitzkonfiguration haben, wenn er den Mod benutzt.",
"config.sitting.enabled": "Aktiviert",
"config.sitting.enabled.description": "Stellt die Fähigkeit zum Sitzen ein.",
"config.sitting.hand-sitting": "Hand Sitzen",
"config.sitting.hand-sitting.description": "Stellt die Fähigkeit ein, mit der Hilfe von Hand-Interaktionen zu sitzen.",
"config.sitting.hand.main": "Haupthand",
"config.sitting.hand.main.description": "Haupthand",
"config.sitting.hand.off": "Zweithand",
"config.sitting.hand.off.description": "Zweithand",
"config.sitting.hand.description": "Konfiguriert die %s sitzt Einstellungen.",
"config.sitting.hand.requirement": "Sitzungsanforderung",
"config.sitting.hand.requirement.description": "Die Handanforderung zum Sitten. Z.B. wenn EMPTY, muss die Hand leer sein",
"config.sitting.hand.requirement.description.none": "Keine Anforderung zum Sitzen.",
"config.sitting.hand.requirement.description.empty": "Die Hand muss leer sein, um zu sitzen.",
"config.sitting.hand.requirement.description.filter": "Man kann nur sitzen, wenn der Gegenstand in der Hand einem der Filter entspricht.",
"config.sitting.hand.filter": "Filter",
"config.sitting.hand.filter.description": "Die Liste der Gegenstände für die Filter-Handvoraussetzung.",
"config.sitting.hand.filter.block": "Blöcke",
"config.sitting.hand.filter.block.description": "Der Block-Standard-Filter.",
"config.sitting.hand.filter.food": "Essen",
"config.sitting.hand.filter.food.description": "Der Essen-Standard-Filter.",
"config.sitting.hand.filter.usable": "Benutzbare Gegenstände",
"config.sitting.hand.filter.usable.description": "Die benutzbaren Gegenstände Standardfilter. (Dreizacken, Schilde, Bogen)",
"config.sitting.hand.filter.custom-items": "Benutzerdefinierte Items",
"config.sitting.hand.filter.custom-items.description": "Eine Liste von Benutzerdefinierten Elementen, die dem Filter hinzugefügt werden sollen.",
"config.sitting.hand.filter.custom-tags": "Benutzerdefinierte Tags",
"config.sitting.hand.filter.custom-tags.description": "Eine Liste von Benutzerdefinierte Item-Tags für den Filter.",
"sit!.chat.toggle_sit": "%s sitzt!",
"sit!.chat.toggle_sit.on": "Aktiviert",
"sit!.chat.toggle_sit.off": "Deaktiviert",
"sit!.chat.unsupported": "Sit! Ist auf dem Server nicht verfügbar.",
"sit!.chat.reloaded": "Konfiguration wurde neu geladen!",
"sit!.chat.purged": "Alle geladenen Sit! Entitäten gelöscht! %s",
"sit!.chat.purged.total": "(%s entfernt)",
"key.sit!.toggle": "Sitzen umschalten",
"key.sit!.sit": "Sitzen",
"key.sit!.config": "Konfiguration öffnen",
"sit!.screen.config": "Sit! Konfiguration",
"sit!.gui.button.file": "Datei öffnen",
"sit!.gui.button.folder": "Ordner öffnen",
"sit!.gui.button.reset": "Zurücksetzen",
"sit!.gui.button.issues": "Probleme",
"sit!.gui.button.donate": "Spenden",
"sit!.gui.button.revert": "Änderungen rückgängig machen",
"sit!.gui.button.save": "Speichern und schließen",
"sit!.gui.button.website": "Website",
"sit!.console.connected": "Verbunden mit Sit! Server: %s",
"sit!.console.player_settings": "Benutzerdefinierte Sitzungseinstellungen von %s erhalten!",
"modmenu.descriptionTranslation.sit-oth3r": "Fügt die Möglichkeit hinzu, in Minecraft zu sitzen! Endlose Anpassungsmöglichkeiten für Handbeschränkungen und sitzbare Blöcke.\nSpieler können ihre eigenen Sitzeinstellungen verwenden, wenn sie den Sit!-Client auf dem Server nutzen!"
}

View file

@ -0,0 +1,83 @@
{
"category.sit!": "Sit!",
"config.entry.exclusion": "在条目前加上“!”以排除。",
"config.entry.example": "条目示例:%s",
"config.server": "服务端配置",
"config.server.description": "在此更改服务端的设置。",
"config.server.lang": "语言",
"config.server.lang.description": "用于 Sit! 模组的语言",
"config.server.keep-active": "保持激活状态",
"config.server.keep-active.description": "设置 Sit! 模组的实体是否在玩家或者服务器离线之时仍然保留。\n如果为False玩家重新上线时将不会保持坐下的状态。",
"config.server.sit-while-seated": "处于坐下状态时重新坐下",
"config.server.sit-while-seated.description": "设置是否能够在坐下的时候在另一个 Sit! 方块上重新坐下。",
"config.server.preset-blocks": "预设方块",
"config.server.preset-blocks.description": "开启与关闭默认的 Sit! 方块。",
"config.server.preset-blocks.stairs": "楼梯",
"config.server.preset-blocks.slabs": "台阶",
"config.server.preset-blocks.carpets": "地毯",
"config.server.preset-blocks.full-blocks": "完整方块",
"config.server.custom-enabled": "自定义",
"config.server.custom-enabled.description": "切换是能够坐在自定义方块上。",
"config.server.custom-blocks": "自定义方块",
"config.server.custom-blocks.description": "可供坐下的自定义方块的列表。",
"config.server.custom-block.block-ids": "方块 ID",
"config.server.custom-block.block-ids.description": "可供坐下的自定义方块的 ID。",
"config.server.custom-block.block-tags": "方块标签",
"config.server.custom-block.block-tags.description": "可供坐下的自定义方块的标签。",
"config.server.custom-block.blockstates": "方块状态",
"config.server.custom-block.blockstates.description": "自定义的可供坐下的方块所必须具有的方块状态。",
"config.server.custom-block.sitting-height": "坐下高度",
"config.server.custom-block.sitting-height.description": "玩家坐在自定义方块上的高度。",
"config.server.blacklisted-blocks": "黑名单方块",
"config.server.blacklisted-blocks.description": "不允许坐下的方块列表。",
"config.sitting": "坐下配置",
"config.sitting.description": "每个玩家都能够在此配置各自的坐下能力,在多人服务器中也适用。",
"config.sitting.enabled": "开启",
"config.sitting.enabled.description": "启用坐下的能力。",
"config.sitting.hand-sitting": "手动坐下",
"config.sitting.hand-sitting.description": "启用通过手部交互来坐下。",
"config.sitting.hand.main": "主手",
"config.sitting.hand.main.description": "主手",
"config.sitting.hand.off": "副手",
"config.sitting.hand.off.description": "副手",
"config.sitting.hand.description": "配置%s的设置。",
"config.sitting.hand.requirement": "坐下要求",
"config.sitting.hand.requirement.description": "坐下的手部要求,如:设定为 EMPTY则空手才能坐下。",
"config.sitting.hand.requirement.description.none": "无要求。",
"config.sitting.hand.requirement.description.empty": "必须空手才能坐下。",
"config.sitting.hand.requirement.description.filter": "必须手持与过滤器之一匹配的物品才能坐下。",
"config.sitting.hand.filter": "过滤器",
"config.sitting.hand.filter.description": "支持坐下的过滤器的物品列表。",
"config.sitting.hand.filter.block": "方块",
"config.sitting.hand.filter.block.description": "方块的预设过滤器。",
"config.sitting.hand.filter.food": "食物",
"config.sitting.hand.filter.food.description": "食物的预设过滤器。",
"config.sitting.hand.filter.usable": "可用",
"config.sitting.hand.filter.usable.description": "可用的默认过滤器(三叉戟、盾牌、弓)。",
"config.sitting.hand.filter.custom-items": "自定义物品",
"config.sitting.hand.filter.custom-items.description": "要添加到过滤器的自定义物品的列表。",
"config.sitting.hand.filter.custom-tags": "自定义标签",
"config.sitting.hand.filter.custom-tags.description": "要添加到过滤器的自定义标签的列表。",
"sit!.chat.toggle_sit": "%s 坐下!",
"sit!.chat.toggle_sit.on": "开启",
"sit!.chat.toggle_sit.off": "关闭",
"sit!.chat.unsupported": "Sit! 在此服务器上不可用。",
"sit!.chat.reloaded": "配置已重新加载。",
"sit!.chat.purged": "已清除所有已加载的 Sit! 实体。%s",
"sit!.chat.purged.total": "(已移除 %s个",
"key.sit!.toggle": "调整设置",
"key.sit!.sit": "坐下",
"key.sit!.config": "打开配置",
"sit!.screen.config": "Sit! 配置",
"sit!.gui.button.file": "打开文件",
"sit!.gui.button.folder": "打开文件夹",
"sit!.gui.button.reset": "重置",
"sit!.gui.button.issues": "问题反馈",
"sit!.gui.button.donate": "赞助",
"sit!.gui.button.revert": "还原更改",
"sit!.gui.button.save": "保存并关闭",
"sit!.gui.button.website": "网站",
"sit!.console.connected": "已连接到 Sit! 服务器: %s",
"sit!.console.player_settings": "已从 %s 获得自定义坐下设置。",
"modmenu.descriptionTranslation.sit-oth3r": "在 Minecraft 中添加了坐下的动作,在手部交互与可坐方块等多个方面高度可配置。\n客户端安装 Sit! 模组以后,玩家加入装有 Sit! 的服务器可以拥有自己的坐下配置。"
}