From 668afe21bf2f1db268963225945bcba935451714 Mon Sep 17 00:00:00 2001 From: Gabriel Harris-Rouquette Date: Sun, 22 Sep 2024 16:44:06 -0700 Subject: [PATCH] chore(update): update to 24w38a Signed-off-by: Gabriel Harris-Rouquette --- gradle.properties | 2 +- gradle/verification-metadata.xml | 3 + .../common/util/DirectionUtil.java | 275 ++++++------------ .../ServerGamePacketListenerImplMixin.java | 1 - .../level/LevelAccessorMixin_Tracker.java | 53 ---- .../resources/mixins.sponge.tracker.json | 1 - 6 files changed, 101 insertions(+), 234 deletions(-) delete mode 100644 src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/LevelAccessorMixin_Tracker.java diff --git a/gradle.properties b/gradle.properties index efebbd07d3b..07907e93000 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ mixinConfigs=mixins.sponge.accessors.json,mixins.sponge.api.json,mixins.sponge.c mixins.sponge.tracker.json,mixins.sponge.ipforward.json,mixins.sponge.optimization.json superClassChanges=common.superclasschange -minecraftVersion=24w37a +minecraftVersion=24w38a recommendedVersion=0-SNAPSHOT org.gradle.dependency.verification.console=verbose diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 66820b2590a..572a51234d3 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -1195,6 +1195,9 @@ + + + diff --git a/src/main/java/org/spongepowered/common/util/DirectionUtil.java b/src/main/java/org/spongepowered/common/util/DirectionUtil.java index dcbede764bb..d7d8dd9365f 100644 --- a/src/main/java/org/spongepowered/common/util/DirectionUtil.java +++ b/src/main/java/org/spongepowered/common/util/DirectionUtil.java @@ -25,7 +25,7 @@ package org.spongepowered.common.util; -import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; import org.spongepowered.api.util.Direction; import java.util.Objects; @@ -34,45 +34,31 @@ public final class DirectionUtil { public static net.minecraft.core.Direction getFor(final Direction direction) { Objects.requireNonNull(direction); - switch (direction) { - case UP: - return net.minecraft.core.Direction.UP; - case DOWN: - return net.minecraft.core.Direction.DOWN; - case WEST: - return net.minecraft.core.Direction.WEST; - case SOUTH: - return net.minecraft.core.Direction.SOUTH; - case EAST: - return net.minecraft.core.Direction.EAST; - case NORTH: - return net.minecraft.core.Direction.NORTH; - default: - return null; - } + return switch (direction) { + case UP -> net.minecraft.core.Direction.UP; + case DOWN -> net.minecraft.core.Direction.DOWN; + case WEST -> net.minecraft.core.Direction.WEST; + case SOUTH -> net.minecraft.core.Direction.SOUTH; + case EAST -> net.minecraft.core.Direction.EAST; + case NORTH -> net.minecraft.core.Direction.NORTH; + default -> null; + }; } public static Direction getFor(final net.minecraft.core.Direction facing) { Objects.requireNonNull(facing); - switch (facing) { - case UP: - return Direction.UP; - case DOWN: - return Direction.DOWN; - case WEST: - return Direction.WEST; - case SOUTH: - return Direction.SOUTH; - case EAST: - return Direction.EAST; - case NORTH: - return Direction.NORTH; - default: - throw new IllegalStateException(); - } + return switch (facing) { + case UP -> Direction.UP; + case DOWN -> Direction.DOWN; + case WEST -> Direction.WEST; + case SOUTH -> Direction.SOUTH; + case EAST -> Direction.EAST; + case NORTH -> Direction.NORTH; + default -> throw new IllegalStateException(); + }; } - public static net.minecraft.world.level.block.state.BlockState set(final net.minecraft.world.level.block.state.BlockState holder, final Direction value, final DirectionProperty property) { + public static net.minecraft.world.level.block.state.BlockState set(final net.minecraft.world.level.block.state.BlockState holder, final Direction value, final EnumProperty property) { final net.minecraft.core.Direction direction = DirectionUtil.getFor(value); if (direction == null || !property.getPossibleValues().contains(direction)) { return holder; @@ -81,168 +67,101 @@ public static net.minecraft.world.level.block.state.BlockState set(final net.min } public static Direction fromRotation(int i) { - switch (i) { - case 0: - return Direction.SOUTH; - case 1: - return Direction.SOUTH_SOUTHWEST; - case 2: - return Direction.SOUTHWEST; - case 3: - return Direction.WEST_SOUTHWEST; - case 4: - return Direction.WEST; - case 5: - return Direction.WEST_NORTHWEST; - case 6: - return Direction.NORTHWEST; - case 7: - return Direction.NORTH_NORTHWEST; - case 8: - return Direction.NORTH; - case 9: - return Direction.NORTH_NORTHEAST; - case 10: - return Direction.NORTHEAST; - case 11: - return Direction.EAST_NORTHEAST; - case 12: - return Direction.EAST; - case 13: - return Direction.EAST_SOUTHEAST; - case 14: - return Direction.SOUTHEAST; - case 15: - return Direction.SOUTH_SOUTHEAST; - default: - return Direction.NORTH; - } + return switch (i) { + case 0 -> Direction.SOUTH; + case 1 -> Direction.SOUTH_SOUTHWEST; + case 2 -> Direction.SOUTHWEST; + case 3 -> Direction.WEST_SOUTHWEST; + case 4 -> Direction.WEST; + case 5 -> Direction.WEST_NORTHWEST; + case 6 -> Direction.NORTHWEST; + case 7 -> Direction.NORTH_NORTHWEST; + case 8 -> Direction.NORTH; + case 9 -> Direction.NORTH_NORTHEAST; + case 10 -> Direction.NORTHEAST; + case 11 -> Direction.EAST_NORTHEAST; + case 12 -> Direction.EAST; + case 13 -> Direction.EAST_SOUTHEAST; + case 14 -> Direction.SOUTHEAST; + case 15 -> Direction.SOUTH_SOUTHEAST; + default -> Direction.NORTH; + }; } public static int toRotation(final Direction direction) { - switch (direction) { - case SOUTH: - return 0; - case SOUTH_SOUTHWEST: - return 1; - case SOUTHWEST: - return 2; - case WEST_SOUTHWEST: - return 3; - case WEST: - return 4; - case WEST_NORTHWEST: - return 5; - case NORTHWEST: - return 6; - case NORTH_NORTHWEST: - return 7; - case NORTH: - return 8; - case NORTH_NORTHEAST: - return 9; - case NORTHEAST: - return 10; - case EAST_NORTHEAST: - return 11; - case EAST: - return 12; - case EAST_SOUTHEAST: - return 13; - case SOUTHEAST: - return 14; - case SOUTH_SOUTHEAST: - return 15; - default: - return 0; - } + return switch (direction) { + case SOUTH -> 0; + case SOUTH_SOUTHWEST -> 1; + case SOUTHWEST -> 2; + case WEST_SOUTHWEST -> 3; + case WEST -> 4; + case WEST_NORTHWEST -> 5; + case NORTHWEST -> 6; + case NORTH_NORTHWEST -> 7; + case NORTH -> 8; + case NORTH_NORTHEAST -> 9; + case NORTHEAST -> 10; + case EAST_NORTHEAST -> 11; + case EAST -> 12; + case EAST_SOUTHEAST -> 13; + case SOUTHEAST -> 14; + case SOUTH_SOUTHEAST -> 15; + default -> 0; + }; } public static Direction fromHorizontalHanging(int i) { - switch (i) { - case 0: - return Direction.SOUTH; - case 1: - return Direction.WEST; - case 2: - return Direction.NORTH; - case 3: - return Direction.EAST; - default: - return Direction.NORTH; - } + return switch (i) { + case 0 -> Direction.SOUTH; + case 1 -> Direction.WEST; + case 2 -> Direction.NORTH; + case 3 -> Direction.EAST; + default -> Direction.NORTH; + }; } public static int toHorizontalHanging(Direction direction) { - switch (direction) { - case SOUTH: - return 0; - case WEST: - return 1; - case NORTH: - return 2; - case EAST: - return 3; - default: - return 0; - } + return switch (direction) { + case SOUTH -> 0; + case WEST -> 1; + case NORTH -> 2; + case EAST -> 3; + default -> 0; + }; } public static Direction fromHanging(int i) { - switch (i) { - case 0: - return Direction.DOWN; - case 1: - return Direction.UP; - case 2: - return Direction.NORTH; - case 3: - return Direction.SOUTH; - case 4: - return Direction.WEST; - case 5: - return Direction.EAST; - default: - return Direction.DOWN; - } + return switch (i) { + case 0 -> Direction.DOWN; + case 1 -> Direction.UP; + case 2 -> Direction.NORTH; + case 3 -> Direction.SOUTH; + case 4 -> Direction.WEST; + case 5 -> Direction.EAST; + default -> Direction.DOWN; + }; } public static int toHanging(Direction direction) { - switch (direction) { - case DOWN: - return 0; - case UP: - return 1; - case NORTH: - return 2; - case SOUTH: - return 3; - case WEST: - return 4; - case EAST: - return 5; - default: - return 0; - } + return switch (direction) { + case DOWN -> 0; + case UP -> 1; + case NORTH -> 2; + case SOUTH -> 3; + case WEST -> 4; + case EAST -> 5; + default -> 0; + }; } public static int directionToIndex(final Direction direction) { - switch (direction) { - case NORTH: - case NORTHEAST: - case NORTHWEST: - return 0; - case SOUTH: - case SOUTHEAST: - case SOUTHWEST: - return 1; - case EAST: - return 2; - case WEST: - return 3; - default: - throw new IllegalArgumentException("Unexpected direction"); - } + return switch (direction) { + case NORTH, NORTHEAST, NORTHWEST -> 0; + case SOUTH, SOUTHEAST, SOUTHWEST -> 1; + case EAST -> 2; + case WEST -> 3; + default -> throw new IllegalArgumentException("Unexpected direction"); + }; } private DirectionUtil() { diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/server/network/ServerGamePacketListenerImplMixin.java b/src/mixins/java/org/spongepowered/common/mixin/core/server/network/ServerGamePacketListenerImplMixin.java index 1762b453256..b5ce112479b 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/server/network/ServerGamePacketListenerImplMixin.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/server/network/ServerGamePacketListenerImplMixin.java @@ -126,7 +126,6 @@ public abstract class ServerGamePacketListenerImplMixin extends ServerCommonPack @Shadow private double vehicleFirstGoodX; @Shadow private double vehicleFirstGoodY; @Shadow private double vehicleFirstGoodZ; - @Shadow private int chatSpamTickCount; @Shadow public abstract void shadow$teleport(PositionMoveRotation pitch, Set relativeArguments); @Shadow protected abstract CompletableFuture> shadow$filterTextPacket(final List $$0); diff --git a/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/LevelAccessorMixin_Tracker.java b/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/LevelAccessorMixin_Tracker.java deleted file mode 100644 index 4ae817d3e95..00000000000 --- a/src/mixins/java/org/spongepowered/common/mixin/tracker/world/level/LevelAccessorMixin_Tracker.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This file is part of Sponge, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.common.mixin.tracker.world.level; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.LevelAccessor; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.material.Fluid; -import net.minecraft.world.level.storage.LevelData; -import net.minecraft.world.ticks.LevelTickAccess; -import net.minecraft.world.ticks.TickPriority; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(LevelAccessor.class) -public interface LevelAccessorMixin_Tracker { - - // @formatter:off - @Shadow LevelData shadow$getLevelData(); - @Shadow long shadow$nextSubTickCount(); - @Shadow LevelTickAccess shadow$getBlockTicks(); - @Shadow LevelTickAccess shadow$getFluidTicks(); - - // Shadow methods to be overridden in ServerLevelMixin_Tracker - @Shadow void shadow$scheduleTick(BlockPos pos, Block block, int $$2, TickPriority priority); - @Shadow void shadow$scheduleTick(BlockPos pos, Block block, int $$2); - @Shadow void shadow$scheduleTick(BlockPos pos, Fluid fluid, int $$2, TickPriority priority); - @Shadow void shadow$scheduleTick(BlockPos pos, Fluid fluid, int $$2); - // @formatter:on - -} diff --git a/src/mixins/resources/mixins.sponge.tracker.json b/src/mixins/resources/mixins.sponge.tracker.json index 79857ecd615..d3969c69be7 100644 --- a/src/mixins/resources/mixins.sponge.tracker.json +++ b/src/mixins/resources/mixins.sponge.tracker.json @@ -33,7 +33,6 @@ "world.item.ItemStackMixin_Tracker", "world.level.BlockEventDataMixin_Tracker", "world.level.ServerExplosionMixin_Tracker", - "world.level.LevelAccessorMixin_Tracker", "world.level.LevelHeightAccessorMixin_Tracker", "world.level.LevelMixin_Tracker", "world.level.block.BlockMixin_Tracker",