Skip to content

Commit

Permalink
remove/suppress deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
TropheusJ committed Jul 8, 2023
1 parent 7b0dd53 commit fbe8603
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.UUID;
import java.util.function.BiConsumer;

import org.quiltmc.loader.api.minecraft.ClientOnly;
import org.quiltmc.loader.api.minecraft.MinecraftQuiltLoader;
import org.quiltmc.qsl.networking.api.PacketByteBufs;
import org.quiltmc.qsl.networking.api.PacketSender;
Expand Down Expand Up @@ -391,12 +392,12 @@ private static void executeOnServerWithCup(MinecraftServer server, ServerPlayer
}


@Environment(EnvType.CLIENT)
@ClientOnly
public static void clientNetworkingInit() {
ClientPlayNetworking.registerGlobalReceiver(SPAWN_PACKET, ClimbingSuctionCupEntity::handleSpawnOnClient);
}

@Environment(EnvType.CLIENT)
@ClientOnly
public static void handleSpawnOnClient(Minecraft client, ClientPacketListener handler, FriendlyByteBuf buf, PacketSender responseSender) {
ClientboundAddEntityPacket addPacket = new ClientboundAddEntityPacket(buf);
buf.retain(); // save until after extra data is read
Expand All @@ -408,23 +409,23 @@ public static void handleSpawnOnClient(Minecraft client, ClientPacketListener ha
});
}

@Environment(EnvType.CLIENT)
@ClientOnly
public void setSuctionFromClient(boolean suction) {
FriendlyByteBuf buf = PacketByteBufs.create();
buf.writeBoolean(suction);
buf.writeEnum(limb);
ClientPlayNetworking.send(UPDATE_SUCTION, buf);
}

@Environment(EnvType.CLIENT)
@ClientOnly
public void clientSuctionUpdate() {
LocalClimbingManager manager = LocalClimbingManager.INSTANCE;
if (manager != null) {
manager.entitySuctionUpdated(this);
}
}

@Environment(EnvType.CLIENT)
@ClientOnly
public void setMoveDirectionFromClient(SuctionCupMoveDirection direction) {
FriendlyByteBuf buf = PacketByteBufs.create();
buf.writeEnum(direction);
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/one/devos/nautical/succ/GlobalClimbingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;
import java.util.UUID;

import org.quiltmc.loader.api.minecraft.ClientOnly;
import org.quiltmc.qsl.networking.api.PacketByteBufs;
import org.quiltmc.qsl.networking.api.PacketSender;
import org.quiltmc.qsl.networking.api.PlayerLookup;
Expand All @@ -25,6 +26,7 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
Expand Down Expand Up @@ -178,8 +180,8 @@ public static void onRespawn(ServerPlayer oldPlayer, ServerPlayer newPlayer, boo
}
}

public static void onChangeWorld(ServerPlayer player, ServerLevel origin, ServerLevel destination) {
if (isClimbing(player)) {
public static void onChangeWorld(Entity original, Entity copy, ServerLevel origin, ServerLevel destination) {
if (original instanceof ServerPlayer player && isClimbing(player)) {
stopClimbing(player);
}
}
Expand Down Expand Up @@ -218,12 +220,12 @@ public static void networkingInit() {
ServerPlayNetworking.registerGlobalReceiver(REQUEST_STOP, GlobalClimbingManager::stopRequested);
}

@Environment(EnvType.CLIENT)
@ClientOnly
public static void clientNetworkingInit() {
ClientPlayNetworking.registerGlobalReceiver(STATE_CHANGE_PACKET, GlobalClimbingManager::handleChangeReceived);
}

@Environment(EnvType.CLIENT)
@ClientOnly
private static void handleChangeReceived(Minecraft mc, ClientPacketListener handler, FriendlyByteBuf buf, PacketSender responseSender) {
StateChangeType type = buf.readEnum(StateChangeType.class);
type.handle(mc, buf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Optional;

import org.apache.commons.lang3.tuple.Triple;
import org.quiltmc.loader.api.minecraft.ClientOnly;
import org.quiltmc.qsl.networking.api.PacketByteBufs;
import org.quiltmc.qsl.networking.api.client.ClientPlayNetworking;

Expand Down Expand Up @@ -35,7 +36,7 @@
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;

@Environment(EnvType.CLIENT)
@ClientOnly
public class LocalClimbingManager {
public static final Component TOO_FAR = Component.translatable("succ.tooFar");
public static final Component CUP_OBSTRUCTED_BLOCK = Component.translatable("succ.cupObstructedBlock");
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/one/devos/nautical/succ/Succ.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.quiltmc.qsl.entity.event.api.EntityWorldChangeEvents;
import org.quiltmc.qsl.item.setting.api.QuiltItemSettings;
import org.quiltmc.qsl.networking.api.ServerPlayConnectionEvents;

Expand All @@ -10,7 +11,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents;
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.minecraft.advancements.CriteriaTriggers;
Expand Down Expand Up @@ -63,8 +63,10 @@ public void onInitialize(ModContainer mod) {

ServerPlayConnectionEvents.JOIN.register(GlobalClimbingManager::onPlayerJoin);
ServerPlayConnectionEvents.DISCONNECT.register(GlobalClimbingManager::onPlayerLeave);

//noinspection deprecation - no replacement yet
ServerPlayerEvents.AFTER_RESPAWN.register(GlobalClimbingManager::onRespawn);
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register(GlobalClimbingManager::onChangeWorld);
EntityWorldChangeEvents.AFTER_ENTITY_WORLD_CHANGE.register(GlobalClimbingManager::onChangeWorld);
ClimbingSuctionCupEntity.networkingInit();
GlobalClimbingManager.networkingInit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraft.client.Options;
import net.minecraft.world.phys.Vec3;

import org.quiltmc.loader.api.minecraft.ClientOnly;

public enum SuctionCupMoveDirection {
UP_LEFT(-1, 1), UP(0, 1), UP_RIGHT(1, 1),
LEFT(-1, 0), NONE(0, 0), RIGHT(1, 0),
Expand Down Expand Up @@ -41,7 +43,7 @@ public static SuctionCupMoveDirection findFromGrid(int xOff, int yOff) {
return map.get(xOff).get(yOff);
}

@Environment(EnvType.CLIENT)
@ClientOnly
public static SuctionCupMoveDirection findFromInputs(Options options) {
int yOff = 0;
int xOff = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import net.minecraft.world.entity.Entity;
import one.devos.nautical.succ.Succ;

@Environment(EnvType.CLIENT)
import org.quiltmc.loader.api.minecraft.ClientOnly;

@ClientOnly
public class DepressedSuctionCupModel extends EntityModel<Entity> {
public static final ModelLayerLocation LAYER = new ModelLayerLocation(Succ.id("depressed_suction_cup"), "main");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import net.minecraft.world.entity.player.Player;
import one.devos.nautical.succ.Succ;

@Environment(EnvType.CLIENT)
import org.quiltmc.loader.api.minecraft.ClientOnly;

@ClientOnly
public class SuctionCupModel extends EntityModel<Player> {
public static final ModelLayerLocation LAYER = new ModelLayerLocation(Succ.id("suction_cup"), "main");
public static final ResourceLocation TEXTURE = Succ.id("textures/suction_cup.png");
Expand Down

0 comments on commit fbe8603

Please sign in to comment.