mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-20 00:13:21 +02:00
1.20.1 port
This commit is contained in:
parent
1298e1940a
commit
de1e7d8d65
7 changed files with 48 additions and 78 deletions
|
@ -12,13 +12,12 @@ import java.nio.ByteBuffer;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class PacketSender {
|
||||
private final PacketByteBuf data;
|
||||
private final PacketByteBuf data = PacketByteBufs.create();
|
||||
private final PacketType type;
|
||||
|
||||
public PacketSender(PacketType type, String data) {
|
||||
this.type = type;
|
||||
this.data = PacketByteBufs.create()
|
||||
.writeBytes(ByteBuffer.wrap(data.getBytes(StandardCharsets.UTF_8)));
|
||||
this.data.writeBytes(ByteBuffer.wrap(data.getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
public void sendToPlayer(ServerPlayerEntity player) {
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ClickableImageWidget extends ButtonWidget {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
protected void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
context.setShaderColor(1.0f, 1.0f, 1.0f, this.alpha);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.enableDepthTest();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package one.oth3r.sit.screen;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.terraformersmc.modmenu.gui.ModMenuOptionsScreen;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.ConfirmLinkScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
@ -24,23 +25,23 @@ public class ConfigScreen extends Screen {
|
|||
int spacing = 36;
|
||||
TextureButtonWidget serverConfigButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("config.server"),
|
||||
(button) -> client.setScreen(new UnderConstructionScreen(this, FileData.getServerConfig())), false)
|
||||
.dimensions(250,30).texture(Identifier.of(Data.MOD_ID, "server_button"), 246, 26).build());
|
||||
.dimensions(250,30).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/server_button.png"), 246, 26).build());
|
||||
serverConfigButton.setPosition(this.width / 2 - (serverConfigButton.getWidth()/2), startY);
|
||||
|
||||
TextureButtonWidget sittingConfigButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("config.sitting"),
|
||||
(button) -> client.setScreen(new UnderConstructionScreen(this, FileData.getSittingConfig())), false)
|
||||
.dimensions(250,30).texture(Identifier.of(Data.MOD_ID, "sitting_button"), 246, 26).build());
|
||||
.dimensions(250,30).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/sitting_button.png"), 246, 26).build());
|
||||
sittingConfigButton.setPosition(this.width / 2 - (sittingConfigButton.getWidth()/2), startY+36);
|
||||
|
||||
|
||||
TextureButtonWidget issuesButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.issues"),
|
||||
ConfirmLinkScreen.opening(this, "https://github.com/Oth3r/Sit/issues"), true)
|
||||
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "issues"), 15, 15).build());
|
||||
ConfirmLinkScreen.opening("https://github.com/Oth3r/Sit/issues",this,true), true)
|
||||
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/issues.png"), 15, 15).build());
|
||||
issuesButton.setPosition(this.width / 2 - 125, startY + 72 + 12);
|
||||
|
||||
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.translatable("sit!.gui.button.website"),
|
||||
ConfirmLinkScreen.opening(this, "https://modrinth.com/mod/sit!")
|
||||
ConfirmLinkScreen.opening("https://modrinth.com/mod/sit!",this,true)
|
||||
).dimensions(this.width / 2 - 100, startY + 72 + 12, 98, 20).build());
|
||||
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.translatable("gui.done"), (button) -> {
|
||||
|
@ -48,17 +49,21 @@ public class ConfigScreen extends Screen {
|
|||
}).dimensions(this.width / 2 + 2, startY + 72 + 12, 98, 20).build());
|
||||
|
||||
TextureButtonWidget donateButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.donate"),
|
||||
ConfirmLinkScreen.opening(this, "https://Ko-fi.com/oth3r"), true)
|
||||
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "donate"), 15, 15).build());
|
||||
ConfirmLinkScreen.opening("https://Ko-fi.com/oth3r",this,true), true)
|
||||
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/donate.png"), 15, 15).build());
|
||||
donateButton.setPosition(this.width / 2 + 105, startY + 72 + 12);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
|
||||
// render the background because you have to in this version
|
||||
this.renderBackground(context);
|
||||
// todo fade in like the title screen on first load?
|
||||
renderBanner(context,width/2 - 64,this.height / 4 -38,1);
|
||||
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,11 +25,11 @@ public class TextureButtonWidget extends ButtonWidget {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
super.renderWidget(context, mouseX, mouseY, delta);
|
||||
protected void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
super.renderButton(context, mouseX, mouseY, delta);
|
||||
int x = this.getX() + this.getWidth() / 2 - this.textureWidth / 2;
|
||||
int y = this.getY() + this.getHeight() / 2 - this.textureHeight / 2;
|
||||
context.drawGuiTexture(this.texture, x, y, this.textureWidth, this.textureHeight);
|
||||
context.drawTexture(this.texture, x, y, 0, 0, this.textureWidth, this.textureHeight, this.textureWidth, this.textureHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package one.oth3r.sit.screen;
|
||||
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.ConfirmLinkScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.tooltip.Tooltip;
|
||||
|
@ -29,7 +30,7 @@ public class UnderConstructionScreen<T extends CustomFile<T>> extends Screen {
|
|||
protected void init() {
|
||||
int startY = this.height / 5-4;
|
||||
ButtonWidget foxPNG = this.addDrawableChild(new ClickableImageWidget(70,70,140,140, Tooltip.of(Text.of("Art by @bunnestbun")),
|
||||
Identifier.of(Data.MOD_ID, "textures/gui/fox.png"), ConfirmLinkScreen.opening(this, "https://www.instagram.com/bunnestbun/")));
|
||||
Identifier.of(Data.MOD_ID, "textures/gui/fox.png"), ConfirmLinkScreen.opening("https://www.instagram.com/bunnestbun/",this, true)));
|
||||
foxPNG.setPosition(this.width / 2 - (foxPNG.getWidth()/2), startY-35);
|
||||
|
||||
ButtonWidget openFileButton = this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("sit!.gui.button.file"),
|
||||
|
@ -38,8 +39,8 @@ public class UnderConstructionScreen<T extends CustomFile<T>> extends Screen {
|
|||
openFileButton.setPosition(this.width / 2 - 70, startY+110);
|
||||
|
||||
TextureButtonWidget folderButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.folder"),
|
||||
(button) -> Util.getOperatingSystem().open(this.file.getFile().getParent()), true)
|
||||
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "folder"), 15, 15).build());
|
||||
(button) -> Util.getOperatingSystem().open(this.file.getFile().getParentFile().toURI()), true)
|
||||
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/folder.png"), 15, 15).build());
|
||||
folderButton.setPosition(this.width / 2 + 50, startY + 110);
|
||||
|
||||
TextureButtonWidget resetButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.reset"),
|
||||
|
@ -47,7 +48,7 @@ public class UnderConstructionScreen<T extends CustomFile<T>> extends Screen {
|
|||
this.file.reset();
|
||||
this.file.save();
|
||||
}, true)
|
||||
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "reset_file"), 15, 15).build());
|
||||
.dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/reset_file.png"), 15, 15).build());
|
||||
resetButton.setPosition(this.width / 2 -70, startY + 135);
|
||||
|
||||
ButtonWidget revertButton = this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("sit!.gui.button.revert"),
|
||||
|
@ -72,6 +73,13 @@ public class UnderConstructionScreen<T extends CustomFile<T>> extends Screen {
|
|||
saveExitButton.setPosition(this.width / 2 - 70, startY+168);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
// render the background because you have to in this version
|
||||
this.renderBackground(context);
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
this.client.setScreen(parent);
|
||||
|
|
|
@ -220,8 +220,13 @@ 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;
|
||||
|
||||
double entityY = entity.getY() + adjustmentY;
|
||||
// get the block pos
|
||||
BlockPos pos = new BlockPos(entity.getBlockX(),entity.getBlockY(),entity.getBlockZ());
|
||||
BlockPos pos = new BlockPos(entity.getBlockX(),(int)entityY,entity.getBlockZ());
|
||||
// if above the block, subtract 1
|
||||
if (isAboveBlockHeight(entity)) {
|
||||
pos = pos.add(0,-1,0);
|
||||
|
@ -253,12 +258,10 @@ public class Utl {
|
|||
entity.setInvulnerable(true);
|
||||
entity.setInvisible(true);
|
||||
|
||||
/// make a double for adjusting the entity height if some versions change the player sit height on entities again
|
||||
double adjustmentY = 0;
|
||||
|
||||
// get the entities y level
|
||||
double entityY = blockPos.getY();
|
||||
entityY += sitHeight + adjustmentY;
|
||||
entityY += sitHeight;
|
||||
|
||||
// set the entities position
|
||||
entity.updatePositionAndAngles(blockPos.getX()+.5, entityY, blockPos.getZ()+.5, 0, 0);
|
||||
|
@ -267,6 +270,12 @@ public class Utl {
|
|||
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());
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
@ -312,7 +321,7 @@ public class Utl {
|
|||
// send a message if needed
|
||||
if (message) {
|
||||
player.sendMessage(messageTag().append(Utl.lang("sit!.chat.purged",Utl.lang("sit!.chat.purged.total",count).styled(
|
||||
style -> style.withColor(Colors.LIGHT_GRAY).withItalic(true)
|
||||
style -> style.withColor(Formatting.GRAY).withItalic(true)
|
||||
)).styled(
|
||||
style -> style.withColor(Formatting.GREEN)
|
||||
)));
|
||||
|
@ -322,7 +331,7 @@ public class Utl {
|
|||
|
||||
public static MutableText messageTag() {
|
||||
return Text.literal("[").append(Text.literal("Sit!").styled(
|
||||
style -> style.withColor(TextColor.parse("#c400ff").result().orElse(TextColor.fromFormatting(Formatting.DARK_PURPLE))))
|
||||
style -> style.withColor(TextColor.parse("#c400ff")))
|
||||
).append("] ");
|
||||
}
|
||||
|
||||
|
@ -458,7 +467,7 @@ public class Utl {
|
|||
// extend ray by the range
|
||||
Vec3d rayEnd = rayStart.add(player.getRotationVector().multiply(range));
|
||||
|
||||
BlockHitResult hitResult = world.raycast(new RaycastContext(rayStart, rayEnd, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, ShapeContext.absent()));
|
||||
BlockHitResult hitResult = world.raycast(new RaycastContext(rayStart, rayEnd, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, player));
|
||||
|
||||
if (hitResult.getType() == HitResult.Type.BLOCK) {
|
||||
return hitResult.getBlockPos();
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
{
|
||||
"config.sit.empty": "空",
|
||||
"config.sit.restrictive": "限制",
|
||||
"config.sit.none": "無",
|
||||
"config.sit.category.general": "一般",
|
||||
"config.sit.category.general.tooltip": "一般設定",
|
||||
"config.sit.category.main_hand": "慣用手",
|
||||
"config.sit.category.main_hand.tooltip": "慣用手設定",
|
||||
"config.sit.category.off_hand": "非慣用手",
|
||||
"config.sit.category.off_hand.tooltip": "非慣用手設定",
|
||||
"config.sit.general.keep_active": "保持活躍",
|
||||
"config.sit.general.keep_active.description": "即使在登出/關閉時,也保持實體處於活躍狀態",
|
||||
"config.sit.general.sittable": "可坐的方塊",
|
||||
"config.sit.general.sittable.description": "切換坐在不同方塊類型上的能力。",
|
||||
"config.sit.general.sit_while_seated": "坐下時坐下",
|
||||
"config.sit.general.sit_while_seated.description": "切換已經坐在一個方塊上時,坐在其他方塊上的能力。",
|
||||
"config.sit.general.sittable.stairs": "階梯",
|
||||
"config.sit.general.sittable.slabs": "半磚",
|
||||
"config.sit.general.sittable.carpets": "地毯",
|
||||
"config.sit.general.sittable.full_blocks": "完整方塊",
|
||||
"config.sit.general.sittable.custom": "自訂",
|
||||
"config.sit.general.sittable.custom.description": "啟用新增自訂方塊以供坐下。",
|
||||
"config.sit.general.sittable_blocks": "自訂可坐方塊",
|
||||
"config.sit.general.sittable_blocks.description": "新增自訂可坐方塊!",
|
||||
"config.sit.general.sittable_blocks.description_2": "範例:%s",
|
||||
"config.sit.general.sittable_blocks.description_4": "第一個條目:自訂方塊",
|
||||
"config.sit.general.sittable_blocks.description_5": "第二個條目:坐姿高度(0-1 之間的數字,例如 0.52)",
|
||||
"config.sit.general.sittable_blocks.description_6": "第三個條目:碰撞箱大小(玩家下馬時在實體上方生成的位置)",
|
||||
"config.sit.general.sittable_blocks.description_7": "第四個條目(可選):坐下的必要方塊狀態(輸入「!」排除方塊狀態)",
|
||||
"config.sit.general.sittable_blocks.description_8": "使用「|」分隔不同的條目!",
|
||||
"config.sit.hand": "手部設定",
|
||||
"config.sit.hand.requirements": "需求",
|
||||
"config.sit.hand.requirements.description": "坐下的手部需求。",
|
||||
"config.sit.hand.requirements.description_2": "空 = 手必須是空的",
|
||||
"config.sit.hand.requirements.description_3": "限制 = 為手部狀態設定限制",
|
||||
"config.sit.hand.requirements.description_4": "無 = 隨時可以坐下",
|
||||
"config.sit.hand.restrictions": "限制",
|
||||
"config.sit.hand.restrictions.description": "切換預設的手部限制以供坐下。",
|
||||
"config.sit.hand.restrictions.blocks": "方塊",
|
||||
"config.sit.hand.restrictions.food": "食物",
|
||||
"config.sit.hand.restrictions.usable": "可使用的",
|
||||
"config.sit.hand.restrictions.usable.description": "例如:弓、三叉戟、盾牌",
|
||||
"config.sit.hand.whitelist": "白名單",
|
||||
"config.sit.hand.whitelist.description": "為玩家可以用來坐下的物品建立自訂白名單。",
|
||||
"config.sit.hand.blacklist": "黑名單",
|
||||
"config.sit.hand.blacklist.description": "為玩家無法用來坐下的物品建立自訂黑名單。",
|
||||
"config.sit.hand.list.description": "範例:",
|
||||
"config.sit.hand.list.description_2": "「minecraft:torch」",
|
||||
"key.sit.command.reloaded": "已重新載入設定!",
|
||||
"key.sit.command.purged": "已清除所有活躍的椅子實體!"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue