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

Update to 1.19.3 #12

Merged
merged 2 commits into from
Dec 10, 2022
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
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19.1
yarn_mappings=1.19.1+build.1
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.2
loader_version=0.12.8

# Mod Properties
Expand All @@ -15,5 +15,5 @@ org.gradle.jvmargs=-Xmx1G
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
# fabric_version=0.25.1+build.416-1.16
carpet_core_version=1.4.83+v220727
carpet_minecraft_version=1.19.1
carpet_core_version=1.4.91+v221207
carpet_minecraft_version=1.19.3
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package totoscarpettweaks.fakes;

import net.minecraft.registry.RegistryKey;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;

import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
package totoscarpettweaks.mixins.returnspectators;

import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.encryption.PlayerPublicKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.Nullable;
import totoscarpettweaks.TotoCarpetSettings;
import totoscarpettweaks.fakes.ServerPlayerEntityInterface;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import totoscarpettweaks.TotoCarpetSettings;
import totoscarpettweaks.fakes.ServerPlayerEntityInterface;


@Mixin(ServerPlayerEntity.class)
Expand All @@ -43,8 +41,8 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Se
@Shadow
public ServerPlayNetworkHandler networkHandler;

public ServerPlayerEntityMixin(MinecraftServer server, ServerWorld world, GameProfile profile, @Nullable PlayerPublicKey publicKey) {
super(world, world.getSpawnPos(), world.getSpawnAngle(), profile, publicKey);
public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile) {
super(world, pos, yaw, gameProfile);
}

@Shadow
Expand Down Expand Up @@ -134,7 +132,7 @@ private void readSurvivalPosition(NbtCompound tag, CallbackInfo ci) {
if (tag.contains(NBT_SURVIVALWORLD)) {
Identifier worldId = Identifier.tryParse(tag.getString(NBT_SURVIVALWORLD));
if (worldId != null)
survivalWorldKey = RegistryKey.of(Registry.WORLD_KEY, worldId);
survivalWorldKey = RegistryKey.of(RegistryKeys.WORLD, worldId);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
package totoscarpettweaks.mixins.returnspectators;

import carpet.patches.EntityPlayerMPFake;
import totoscarpettweaks.TotoCarpetSettings;
import totoscarpettweaks.fakes.ServerPlayerEntityInterface;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.network.ServerPlayerInteractionManager;
import net.minecraft.world.GameMode;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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 totoscarpettweaks.TotoCarpetSettings;
import totoscarpettweaks.fakes.ServerPlayerEntityInterface;

@Mixin(ServerPlayerInteractionManager.class)
public abstract class ServerPlayerInteractionManagerMixin {
@Shadow
public ServerPlayerEntity player;

@Inject(method = "setGameMode(Lnet/minecraft/world/GameMode;Lnet/minecraft/world/GameMode;)V", at = @At("HEAD"))
private void onGameModeChange(GameMode gameMode, GameMode previousGameMode, CallbackInfo ci) {
if (TotoCarpetSettings.returnSpectators && gameMode != previousGameMode && !(player instanceof EntityPlayerMPFake)) {
@Shadow
private GameMode gameMode;

@Inject(
method = "changeGameMode(Lnet/minecraft/world/GameMode;)Z",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/network/ServerPlayerInteractionManager;setGameMode(Lnet/minecraft/world/GameMode;Lnet/minecraft/world/GameMode;)V",
shift = At.Shift.BEFORE))
private void onGameModeChange(GameMode gameMode, CallbackInfoReturnable<Boolean> cir) {
if (TotoCarpetSettings.returnSpectators && !(player instanceof EntityPlayerMPFake)) {
// If changing from survival mode, remember position
if (gameMode == GameMode.SURVIVAL) {
((ServerPlayerEntityInterface) player).tryReturnToSurvivalPosition();
// If changing to survival mode, teleport to previous survival position
} else if (previousGameMode == GameMode.SURVIVAL) {
// If changing to survival mode, teleport to previous survival position
} else if (this.gameMode == GameMode.SURVIVAL) {
((ServerPlayerEntityInterface) player).rememberSurvivalPosition();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.encryption.PlayerPublicKey;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -20,8 +16,8 @@

@Mixin(ServerPlayerEntity.class)
public abstract class ServerPlayerEntityMixin extends PlayerEntity {
public ServerPlayerEntityMixin(MinecraftServer server, ServerWorld world, GameProfile profile, @Nullable PlayerPublicKey publicKey) {
super(world, world.getSpawnPos(), world.getSpawnAngle(), profile, publicKey);
public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile) {
super(world, pos, yaw, gameProfile);
}

@Shadow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
package totoscarpettweaks.mixins.timeofday;

import net.minecraft.server.MinecraftServer;
import net.minecraft.server.WorldGenerationProgressListener;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.MutableWorldProperties;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionOptions;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.level.ServerWorldProperties;
import net.minecraft.world.level.storage.LevelStorage;
import net.minecraft.world.spawner.Spawner;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import totoscarpettweaks.controllers.TimeOfDayAdvanced;

import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.function.Supplier;

@Mixin(ServerWorld.class)
public abstract class ServerWorldMixin extends World {
protected ServerWorldMixin(MinecraftServer server, Executor workerExecutor, LevelStorage.Session session,
ServerWorldProperties properties, RegistryKey<World> worldKey, DimensionOptions dimensionOptions,
WorldGenerationProgressListener worldGenerationProgressListener, boolean debugWorld, long seed,
List<Spawner> spawners, boolean shouldTickTime) {
super(properties, worldKey, dimensionOptions.getDimensionTypeEntry(), server::getProfiler, false,
debugWorld, seed, server.getMaxChainedNeighborUpdates());
protected ServerWorldMixin(
MutableWorldProperties properties, RegistryKey<World> registryRef,
RegistryEntry<DimensionType> dimension, Supplier<Profiler> profiler,
boolean isClient, boolean debugWorld, long seed, int maxChainedNeighborUpdates) {
super(properties, registryRef, dimension, profiler, isClient, debugWorld, seed, maxChainedNeighborUpdates);
}

@Inject(method = "tickTime", at = @At(
Expand Down