Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
org.gradle.jvmargs=-Xmx2G
# Gradle Plugins
android_git_version_version=0.4.14
loom_version=1.11-SNAPSHOT
loom_version=1.13.3
shadow_version=7.1.2
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.10
yarn_mappings=1.21.10+build.2
loader_version=0.17.3
minecraft_version=1.21.11
yarn_mappings=1.21.11+build.4
loader_version=0.18.4
# Dependencies
# check these on https://modmuss50.me/fabric.html
fabric_version=0.136.0+1.21.10
fabric_version=0.141.1+1.21.11
msgpack_java_version=0.9.3
# Test dependencies
junit_version=5.9.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
import arm32x.minecraft.commandblockide.server.command.EditFunctionCommand;
import arm32x.minecraft.commandblockide.server.function.FunctionIO;
import arm32x.minecraft.commandblockide.util.PacketMerger;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.command.permission.Permission;
import net.minecraft.command.permission.PermissionLevel;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
Expand All @@ -22,6 +21,10 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

public final class CommandBlockIDE implements ModInitializer {
@Override
public void onInitialize() {
Expand All @@ -31,7 +34,7 @@ public void onInitialize() {
final PacketMerger functionMerger = new PacketMerger();
PayloadTypeRegistry.playC2S().register(Packets.APPLY_FUNCTION, ApplyFunctionPayload.CODEC);
ServerPlayNetworking.registerGlobalReceiver(Packets.APPLY_FUNCTION, (payload, context) -> {
if (!context.player().hasPermissionLevel(2)) {
if (!context.player().getPermissions().hasPermission(new Permission.Level(PermissionLevel.GAMEMASTERS))) {
return;
}
Optional<PacketByteBuf> maybeMerged = Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,15 @@ private void renderSelection(DrawContext context, int x, int y) {

if (startY == endY) {
// Selection spans one line
context.drawSelection(startX, startY, endX, endY + lineHeight - 1);
context.drawSelection(startX, startY, endX, endY + lineHeight - 1, false);
} else {
// Selection spans two or more lines
context.drawSelection(startX, startY, rightEdge, startY + lineHeight);
context.drawSelection(startX, startY, rightEdge, startY + lineHeight, false);
if (!(startY - lineHeight == endY || endY - lineHeight == startY)) {
// Selection spans three or more lines
context.drawSelection(leftEdge, startY + lineHeight, rightEdge, endY);
context.drawSelection(leftEdge, startY + lineHeight, rightEdge, endY, false);
}
context.drawSelection(leftEdge, endY, endX, endY + lineHeight - 1);
context.drawSelection(leftEdge, endY, endX, endY + lineHeight - 1, false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.block.entity.CommandBlockBlockEntity;
import net.minecraft.client.gl.RenderPipelines;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.cursor.StandardCursors;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.input.AbstractInput;
import net.minecraft.text.MutableText;
Expand Down Expand Up @@ -76,7 +75,7 @@ protected Identifier getTexture() {
}

@Override
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
public void drawIcon(DrawContext context, int mouseX, int mouseY, float delta) {
var texture = getTexture();

int color = active ? 0xFFFFFFFF : 0x7FFFFFFF;
Expand All @@ -91,11 +90,6 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY, float delt
int x1 = getX(), x2 = x1 + 16, y1 = getY(), y2 = y1 + 16;
float u1 = 0.0f, u2 = 1.0f, v1 = 0.0f, v2 = 0.25f;
((DrawContextAccessor)context).invokeDrawTexturedQuad(RenderPipelines.GUI_TEXTURED, texture, x1, x2, y1, y2, u2, u1, v2, v1, color);

// super.renderWidget does this as well, but we don't call that here
if (isHovered()) {
context.setCursor(isInteractable() ? StandardCursors.POINTING_HAND : StandardCursors.NOT_ALLOWED);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public boolean drawsBackground() {
}

@Override
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
public void drawIcon(DrawContext context, int mouseX, int mouseY, float delta) {
boolean drawsBackground = drawsBackground();
if (drawsBackground) {
super.renderWidget(context, mouseX, mouseY, delta);
this.drawButton(context);
}

var texture = getTexture();
Expand Down Expand Up @@ -78,12 +78,6 @@ public void renderWidget(DrawContext context, int mouseX, int mouseY, float delt
// RenderSystem.disableDepthTest();
// RenderSystem.disableBlend();
}

// super.renderWidget does this as well, but that is only called for
// icon buttons with a background
if (isHovered()) {
context.setCursor(isInteractable() ? StandardCursors.POINTING_HAND : StandardCursors.NOT_ALLOWED);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import arm32x.minecraft.commandblockide.client.gui.button.CommandBlockTypeButton;
import arm32x.minecraft.commandblockide.client.storage.MultilineCommandStorage;
import arm32x.minecraft.commandblockide.client.update.DataCommandUpdateRequester;
import java.util.Objects;
import java.util.stream.Stream;
import net.minecraft.block.entity.CommandBlockBlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
Expand All @@ -18,9 +16,11 @@
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.network.packet.c2s.play.UpdateCommandBlockC2SPacket;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.CommandBlockExecutor;

import java.util.Objects;
import java.util.stream.Stream;

public final class CommandBlockEditor extends CommandEditor {
private final CommandBlockBlockEntity blockEntity;

Expand Down Expand Up @@ -67,7 +67,7 @@ public void save(ClientPlayNetworkHandler networkHandler) {
if (isLoaded() && isDirty()) {
CommandBlockExecutor executor = blockEntity.getCommandExecutor();
networkHandler.sendPacket(new UpdateCommandBlockC2SPacket(
BlockPos.ofFloored(executor.getPos()),
blockEntity.getPos(),
getSingleLineCommand(),
typeButton.getBlockType(),
trackOutputButton.isTrackingOutput(),
Expand Down Expand Up @@ -101,7 +101,7 @@ public void update() {
client.isInSingleplayer()
? Objects.requireNonNull(client.getServer()).getSaveProperties().getLevelName()
: Objects.requireNonNull(client.getCurrentServerEntry()).name,
BlockPos.ofFloored(executor.getPos())
blockEntity.getPos()
));
typeButton.setBlockType(blockEntity.getCommandBlockType());
typeButton.setConditional(blockEntity.isConditionalCommandBlock());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import com.mojang.brigadier.suggestion.SuggestionProvider;
import com.mojang.datafixers.util.Either;
import java.util.List;
import java.util.Optional;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.command.CommandSource;
import net.minecraft.command.argument.CommandFunctionArgumentType;
import static net.minecraft.command.argument.CommandFunctionArgumentType.commandFunction;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;
import net.minecraft.command.permission.Permission;
import net.minecraft.command.permission.PermissionLevel;
import net.minecraft.server.command.FunctionCommand;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.function.CommandFunction;
import net.minecraft.server.function.CommandFunctionManager;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;

import java.util.List;
import java.util.Optional;

import static net.minecraft.command.argument.CommandFunctionArgumentType.commandFunction;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;

public final class EditFunctionCommand {
/**
* Like {@link FunctionCommand#SUGGESTION_PROVIDER}, but only returns
Expand All @@ -43,7 +47,11 @@ public final class EditFunctionCommand {

public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(literal("editfunction")
.requires(source -> source.hasPermissionLevel(2))
.requires(source ->
source.getPermissions().hasPermission(
new Permission.Level(PermissionLevel.GAMEMASTERS)
)
)
.then(argument("name", commandFunction())
.suggests(SUGGESTION_PROVIDER)
.executes(ctx -> {
Expand Down