Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make run on 1.21.4 #48

Open
wants to merge 2 commits into
base: 1.21.4
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "fabric-loom" version "1.8.9" apply false
id "fabric-loom" version "1.9-SNAPSHOT" apply false
id "maven-publish"
id "org.ajoberstar.grgit" version "5.2.2"
id "org.jetbrains.kotlin.jvm" version "2.0.0"
Expand Down Expand Up @@ -101,7 +101,7 @@ dependencies {
include(modImplementation("org.yaml:snakeyaml:1.33"))

// Fabric Permissions API. To check the permissions
include(modImplementation('me.lucko:fabric-permissions-api:0.2-SNAPSHOT'))
include(modImplementation('me.lucko:fabric-permissions-api:0.3.3'))
// REI. To avoid the REI GUI overlap with the Enclosure GUI
modCompileOnly "me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}"

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ archices_preview_version=
maven_group=com.github.zly2006
archives_base_name=enclosure-fabric
# Dependencies
rei_version = 9.1.550
rei_version = 9.2.784

# check these on https://fabricmc.net/develop
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.7
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.8
loader_version=0.16.10

# Fabric API
fabric_version=0.106.0+1.21.1
fabric_version=0.115.1+1.21.4
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.zly2006.enclosure.access.ClientAccess;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.sound.MusicInstance;
import net.minecraft.sound.MusicSound;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -15,13 +16,13 @@ public class MixinClient implements ClientAccess {
@Unique @Nullable
MusicSound musicSound;
@Inject(
method = "getMusicType",
method = "getMusicInstance",
at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;player:Lnet/minecraft/client/network/ClientPlayerEntity;", ordinal = 0),
cancellable = true
)
private void modifyBgm(CallbackInfoReturnable<MusicSound> cir) {
private void modifyBgm(CallbackInfoReturnable<MusicInstance> cir) {
if (musicSound != null) {
cir.setReturnValue(musicSound);
cir.setReturnValue(new MusicInstance(musicSound));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Final;
Expand Down Expand Up @@ -36,7 +37,7 @@ private void onRender(DrawContext context, int index, int y, int x, int entryWid
);
}
}
context.drawTexture(NOTIFY_TEXTURE, x + 24, y + 24, 0, offset, 8, 8, 8, 16);
context.drawTexture(RenderLayer::getGuiTextured, NOTIFY_TEXTURE, x + 24, y + 24, 0, offset, 8, 8, 8, 16);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@
public class MixinWorldRenderer {
@Shadow @Final private MinecraftClient client;

@Inject(
method = "render",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;draw(Lnet/minecraft/client/render/RenderLayer;)V",
shift = At.Shift.AFTER
),
slice = @Slice(
from = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/render/RenderLayer;getWaterMask()Lnet/minecraft/client/render/RenderLayer;",
ordinal = 0
),
to = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;draw()V",
ordinal = 0
)
),
allow = 1
)
private void onLastRender1(CallbackInfo ci, @Local MatrixStack matrixStack, @Local Vec3d vec3d) {
render(matrixStack, vec3d);
}
// @Inject(
// method = "render",
// at = @At(
// value = "INVOKE",
// target = "Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;draw(Lnet/minecraft/client/render/RenderLayer;)V",
// shift = At.Shift.AFTER
// ),
// slice = @Slice(
// from = @At(
// value = "INVOKE",
// target = "Lnet/minecraft/client/render/RenderLayer;getWaterMask()Lnet/minecraft/client/render/RenderLayer;",
// ordinal = 0
// ),
// to = @At(
// value = "INVOKE",
// target = "Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;draw()V",
// ordinal = 0
// )
// ),
// allow = 1
// )
// private void onLastRender1(CallbackInfo ci, @Local MatrixStack matrixStack, @Local Vec3d vec3d) {
// render(matrixStack, vec3d);
// }// TODO what's this

@Unique
private void render(@Local MatrixStack matrixStack, @Local Vec3d vec3d) {
Expand All @@ -58,18 +58,15 @@ private void render(@Local MatrixStack matrixStack, @Local Vec3d vec3d) {
RenderSystem.disableBlend();
}

@Inject(
method = "render",
at = @At(
value = "INVOKE",
@Inject(method = "method_62214",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/render/WorldRenderer;renderLayer(Lnet/minecraft/client/render/RenderLayer;DDDLorg/joml/Matrix4f;Lorg/joml/Matrix4f;)V",
shift = At.Shift.AFTER
),
slice = @Slice(
from = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/render/RenderLayer;getTripwire()Lnet/minecraft/client/render/RenderLayer;",
ordinal = 1
target = "Lnet/minecraft/client/render/RenderLayer;getTripwire()Lnet/minecraft/client/render/RenderLayer;"
),
to = @At("TAIL")
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

Expand Down Expand Up @@ -45,8 +46,8 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
int height = 150;
int x = (parent.width - 200) / 2;
int y = (parent.height - height) / 2;
context.drawTexture(TEXTURE, x, y, 0, 0, 200, 150, 200, 150);
context.drawTextWrapped(textRenderer, message, x + 10, y + 10, 180, 0xFFFFFF);
context.drawTexture(RenderLayer::getGuiTextured, TEXTURE, x, y, 0, 0, 200, 150, 200, 150);
context.drawWrappedText(textRenderer, message, x + 10, y + 10, 180, 0xFFFFFF, false);
yesButton.setY(y + height - 30);
noButton.setY(y + height - 30);
yesButton.render(context, mouseX, mouseY, delta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,12 @@ public List<? extends Element> children() {
}

@Override
protected boolean isSelectButton(int button) {
protected boolean isSelectedEntry(int index) {
return super.isSelectedEntry(index);
}

@Override
public boolean isSelected() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public int getRowWidth() {
public void showPlayers() {
clearEntries();
mode = Mode.Players;
setScrollAmount(0);
setScrollY(0);
addEntry(searchEntry);
area.getPermissionsMap().keySet().stream()
.filter(uuid -> !uuid.equals(CONSOLE))
Expand All @@ -67,7 +67,7 @@ public void showPlayers() {
public void showUnlistedPlayers() {
clearEntries();
mode = Mode.Unspecified;
setScrollAmount(0);
setScrollY(0);
addEntry(searchEntry);
ClientMain.uuid2name.keySet().stream()
.filter(uuid -> !CONSOLE.equals(uuid))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private void openEditScreen(PlayerEntity player, SignBlockEntity blockEntity, bo
@SuppressWarnings("DataFlowIssue")
EnclosureArea area = ServerMain.INSTANCE.getSmallestEnclosure((ServerWorld) blockEntity.getWorld(), blockEntity.getPos());
if (area != null && !area.hasPerm((ServerPlayerEntity) player, Permission.EDIT_SIGN)) {
player.sendMessage(Permission.EDIT_SIGN.getNoPermissionMsg(player));
player.sendMessage(Permission.EDIT_SIGN.getNoPermissionMsg(player), false);
ci.cancel();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void onEating(PlayerEntity player, Hand hand, CallbackInfoReturnable<Act
}
EnclosureArea area = ServerMain.INSTANCE.getSmallestEnclosure((ServerWorld) this.getWorld(), getBlockPos());
if (area != null && !area.hasPerm((ServerPlayerEntity) player, FEED_ANIMAL)) {
player.sendMessage(FEED_ANIMAL.getNoPermissionMsg(player));
player.sendMessage(FEED_ANIMAL.getNoPermissionMsg(player), false);
cir.setReturnValue(ActionResult.FAIL);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -19,7 +20,7 @@ protected MixinArmorStandEntity(EntityType<? extends LivingEntity> entityType, W
}

@Inject(method = "damage", at = @At("HEAD"), cancellable = true)
private void onDamage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
private void onDamage(ServerWorld world, DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
if (!Utils.commonOnDamage(source, getBlockPos(), getWorld(), Permission.BREAK_BLOCK)) {
cir.setReturnValue(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.decoration.BlockAttachedEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -19,7 +20,7 @@ public MixinBlockAttachedEntity(EntityType<?> type, World world) {
}

@Inject(method = "damage", at = @At("HEAD"), cancellable = true)
private void onDamage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
private void onDamage(ServerWorld world, DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
if (!Utils.commonOnDamage(source, getBlockPos(), getWorld(), Permission.BREAK_BLOCK)) {
cir.setReturnValue(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.vehicle.AbstractBoatEntity;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
Expand All @@ -15,7 +16,7 @@

import static com.github.zly2006.enclosure.utils.Permission.VEHICLE;

@Mixin(BoatEntity.class)
@Mixin(AbstractBoatEntity.class)
public abstract class MixinBoatEntity extends Entity {
protected MixinBoatEntity(EntityType<?> entityType, World world) {
super(entityType, world);
Expand All @@ -24,7 +25,7 @@ protected MixinBoatEntity(EntityType<?> entityType, World world) {
@Inject(method = "interact", at = @At("HEAD"), cancellable = true)
private void onInteract(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
if (!ServerMain.INSTANCE.checkPermission(getWorld(), getBlockPos(), player, VEHICLE)) {
player.sendMessage(VEHICLE.getNoPermissionMsg(player));
player.sendMessage(VEHICLE.getNoPermissionMsg(player), false);
cir.setReturnValue(ActionResult.FAIL);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import static com.github.zly2006.enclosure.utils.Permission.SHOOT;

@Mixin(BowItem.class)
public class MixinBowItem {
@Inject(at = @At("HEAD"), method = "onStoppedUsing", cancellable = true)
public void checkBowPermission(ItemStack stack, World world, LivingEntity user, int remainingUseTicks, CallbackInfo ci) {
public void checkBowPermission(ItemStack stack, World world, LivingEntity user, int remainingUseTicks, CallbackInfoReturnable<Boolean> cir) {
if (user instanceof ServerPlayerEntity player) {
if (!ServerMain.INSTANCE.checkPermission(player, SHOOT, player.getBlockPos())) {
player.sendMessage(SHOOT.getNoPermissionMsg(player));
player.currentScreenHandler.syncState(); // update player's inventory
ci.cancel();
cir.setReturnValue(false);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import net.minecraft.item.BucketItem;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
Expand All @@ -27,14 +27,14 @@ public class MixinBucketItem {
@Shadow @Final private Fluid fluid;

@Inject(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;canPlayerModifyAt(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/BlockPos;)Z"), locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true)
private void onUse(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> cir, ItemStack itemStack, BlockHitResult blockHitResult, BlockPos blockPos, Direction direction, BlockPos blockPos2) {
private void onUse(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<ActionResult> cir, ItemStack itemStack, BlockHitResult blockHitResult, BlockPos blockPos, Direction direction, BlockPos blockPos2) {
if (user instanceof ServerPlayerEntity player) {
Permission permission = this.fluid == Fluids.EMPTY ? Permission.BREAK_BLOCK : Permission.PLACE_BLOCK;
if (!ServerMain.INSTANCE.checkPermission(world, blockPos, player, permission) ||
!ServerMain.INSTANCE.checkPermission(world, blockPos2, player, permission)) {
player.currentScreenHandler.syncState();
player.sendMessage(permission.getNoPermissionMsg(player));
cir.setReturnValue(TypedActionResult.fail(itemStack));
cir.setReturnValue(ActionResult.FAIL);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import com.github.zly2006.enclosure.ServerMain;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.vehicle.AbstractBoatEntity;
import net.minecraft.entity.vehicle.AbstractChestBoatEntity;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.entity.vehicle.ChestBoatEntity;
import net.minecraft.item.Item;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
Expand All @@ -14,13 +17,15 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.function.Supplier;

import static com.github.zly2006.enclosure.utils.Permission.CONTAINER;
import static com.github.zly2006.enclosure.utils.Permission.VEHICLE;

@Mixin(ChestBoatEntity.class)
public class MixinChestBoatEntity extends BoatEntity {
public MixinChestBoatEntity(EntityType<? extends BoatEntity> entityType, World world) {
super(entityType, world);
@Mixin(AbstractChestBoatEntity.class)
public abstract class MixinChestBoatEntity extends AbstractBoatEntity {
public MixinChestBoatEntity(EntityType<? extends AbstractBoatEntity> type, World world, Supplier<Item> itemSupplier) {
super(type, world, itemSupplier);
}

@Inject(method = "canPlayerUse", at = @At("HEAD"), cancellable = true)
Expand All @@ -39,10 +44,10 @@ private void canPlayerUse(PlayerEntity player, CallbackInfoReturnable<Boolean> c
@Inject(method = "interact", at = @At("HEAD"), cancellable = true)
private void onInteract(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
if (!ServerMain.INSTANCE.checkPermission(getWorld(), getBlockPos(), player, VEHICLE)) {
player.sendMessage(VEHICLE.getNoPermissionMsg(player));
player.sendMessage(VEHICLE.getNoPermissionMsg(player), false);
cir.setReturnValue(ActionResult.FAIL);
} else if (!ServerMain.INSTANCE.checkPermission(getWorld(), getBlockPos(), player, CONTAINER)) {
player.sendMessage(CONTAINER.getNoPermissionMsg(player));
player.sendMessage(CONTAINER.getNoPermissionMsg(player), false);
cir.setReturnValue(ActionResult.FAIL);
}
}
Expand Down
Loading
Loading