Skip to content

Commit

Permalink
Ported project to 1.19.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Kir-Antipov committed Jun 10, 2022
1 parent 800c232 commit 38d3f9b
Show file tree
Hide file tree
Showing 23 changed files with 90 additions and 83 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Sync (Fabric)
[![GitHub tag](https://img.shields.io/github/v/tag/Kir-Antipov/sync-fabric.svg?cacheSeconds=3600&sort=date)](https://github.com/Kir-Antipov/sync-fabric/releases/latest)
[![GitHub build status](https://img.shields.io/github/workflow/status/Kir-Antipov/sync-fabric/build-artifacts/1.18.x/dev?cacheSeconds=3600)](https://github.com/Kir-Antipov/sync-fabric/actions/workflows/build-artifacts.yml)
[![GitHub build status](https://img.shields.io/github/workflow/status/Kir-Antipov/sync-fabric/build-artifacts/1.19.x/dev?cacheSeconds=3600)](https://github.com/Kir-Antipov/sync-fabric/actions/workflows/build-artifacts.yml)
[![Modrinth](https://img.shields.io/badge/dynamic/json?color=5da545&label=Modrinth&query=title&url=https://api.modrinth.com/api/v1/mod/sync-fabric&style=flat&cacheSeconds=3600&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMSAxMSIgd2lkdGg9IjE0LjY2NyIgaGVpZ2h0PSIxNC42NjciICB4bWxuczp2PSJodHRwczovL3ZlY3RhLmlvL25hbm8iPjxkZWZzPjxjbGlwUGF0aCBpZD0iQSI+PHBhdGggZD0iTTAgMGgxMXYxMUgweiIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNBKSI+PHBhdGggZD0iTTEuMzA5IDcuODU3YTQuNjQgNC42NCAwIDAgMS0uNDYxLTEuMDYzSDBDLjU5MSA5LjIwNiAyLjc5NiAxMSA1LjQyMiAxMWMxLjk4MSAwIDMuNzIyLTEuMDIgNC43MTEtMi41NTZoMGwtLjc1LS4zNDVjLS44NTQgMS4yNjEtMi4zMSAyLjA5Mi0zLjk2MSAyLjA5MmE0Ljc4IDQuNzggMCAwIDEtMy4wMDUtMS4wNTVsMS44MDktMS40NzQuOTg0Ljg0NyAxLjkwNS0xLjAwM0w4LjE3NCA1LjgybC0uMzg0LS43ODYtMS4xMTYuNjM1LS41MTYuNjk0LS42MjYuMjM2LS44NzMtLjM4N2gwbC0uMjEzLS45MS4zNTUtLjU2Ljc4Ny0uMzcuODQ1LS45NTktLjcwMi0uNTEtMS44NzQuNzEzLTEuMzYyIDEuNjUxLjY0NSAxLjA5OC0xLjgzMSAxLjQ5MnptOS42MTQtMS40NEE1LjQ0IDUuNDQgMCAwIDAgMTEgNS41QzExIDIuNDY0IDguNTAxIDAgNS40MjIgMCAyLjc5NiAwIC41OTEgMS43OTQgMCA0LjIwNmguODQ4QzEuNDE5IDIuMjQ1IDMuMjUyLjgwOSA1LjQyMi44MDljMi42MjYgMCA0Ljc1OCAyLjEwMiA0Ljc1OCA0LjY5MSAwIC4xOS0uMDEyLjM3Ni0uMDM0LjU2bC43NzcuMzU3aDB6IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGZpbGw9IiM1ZGE0MjYiLz48L2c+PC9zdmc+)](https://modrinth.com/mod/sync-fabric)
[![CurseForge](https://img.shields.io/badge/dynamic/json?color=%23f16436&label=CurseForge&query=title&url=https%3A%2F%2Fapi.cfwidget.com%2F515365&cacheSeconds=3600)](https://www.curseforge.com/minecraft/mc-mods/sync-fabric)
[![GitHub license](https://img.shields.io/github/license/Kir-Antipov/sync-fabric.svg?cacheSeconds=36000)](https://github.com/Kir-Antipov/sync-fabric#readme)
Expand Down Expand Up @@ -166,9 +166,9 @@ You can help translate the mod to additional languages here: [crowdin.com](https
## Installation

Requirements:
- Minecraft `1.18.x`
- Fabric Loader `>=0.12.0`
- Fabric API `>=0.43.1`
- Minecraft `1.19.x`
- Fabric Loader `>=0.14.0`
- Fabric API `>=0.55.1`

You can download the mod from:

Expand Down Expand Up @@ -208,7 +208,7 @@ There's [no documentation](https://www.commitstrip.com/en/2021/11/10/no-document
## Building from sources

Requirements:
- JDK `16`
- JDK `17`

### Linux/MacOS

Expand Down
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
}

plugins {
id "fabric-loom" version "0.11-SNAPSHOT"
id "fabric-loom" version "0.12-SNAPSHOT"
id "org.ajoberstar.grgit" version "4.1.0"
}

Expand Down Expand Up @@ -102,8 +102,9 @@ dependencies {
modImplementation "me.shedaniel.cloth:cloth-config-fabric:${project.cloth_version}"
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
modImplementation "dev.emi:trinkets:${project.trinkets_version}"
modImplementation "io.github.ladysnake:requiem-api:${project.requiem_version}"
modImplementation "com.github.apace100:origins-fabric:${project.origins_version}"
modCompileOnly("io.github.ladysnake:requiem-api:${project.requiem_version}", { transitive false })
modImplementation "maven.modrinth:origins:${project.origins_version}"
modImplementation "com.github.apace100:apoli:${project.apoli_version}"
modCompileOnly "maven.modrinth:haema:${project.haema_version}"
}

Expand Down
25 changes: 13 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.3
loader_version=0.12.2
minecraft_version=1.19
yarn_mappings=1.19+build.1
loader_version=0.14.7

# Mod Properties
mod_version=4.0
maven_group=dev.kir
archives_base_name=sync

# Dependencies
fabric_version=0.47.8+1.18.2
fabric_version=0.55.2+1.19
tr_energy_version=2.2.0
satin_version=1.7.2
cloth_version=6.2.57
modmenu_version=3.1.1
trinkets_version=3.3.0
requiem_version=2.0.0-beta.7
origins_version=1.4.1
satin_version=1.8.0
cloth_version=7.0.65
modmenu_version=4.0.0
trinkets_version=3.4.0
requiem_version=2.0.0-beta.8
origins_version=1.6.1
apoli_version=2.5.0
haema_version=1.9.9+1.18.2
smartrecipes_version=0.2.1+1.18.2
crowdin_translate_version=1.4+1.18.2
smartrecipes_version=0.2.1+1.19
crowdin_translate_version=1.4+1.19-pre2
11 changes: 5 additions & 6 deletions src/main/java/dev/kir/sync/api/event/PlayerSyncEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -102,9 +101,9 @@ public final class PlayerSyncEvents {
@FunctionalInterface
public interface SyncFailureReason {
SyncFailureReason OTHER_PROBLEM = () -> null;
SyncFailureReason INVALID_SHELL = create(new TranslatableText("event.sync.request.fail.invalid.shell"));
SyncFailureReason INVALID_CURRENT_LOCATION = create(new TranslatableText("event.sync.request.fail.invalid.location.current"));
SyncFailureReason INVALID_TARGET_LOCATION = create(new TranslatableText("event.sync.request.fail.invalid.location.target"));
SyncFailureReason INVALID_SHELL = create(Text.translatable("event.sync.request.fail.invalid.shell"));
SyncFailureReason INVALID_CURRENT_LOCATION = create(Text.translatable("event.sync.request.fail.invalid.location.current"));
SyncFailureReason INVALID_TARGET_LOCATION = create(Text.translatable("event.sync.request.fail.invalid.location.target"));

@Nullable
Text toText();
Expand All @@ -117,8 +116,8 @@ static SyncFailureReason create(@Nullable Text description) {
@FunctionalInterface
public interface ShellConstructionFailureReason {
ShellConstructionFailureReason OTHER_PROBLEM = () -> null;
ShellConstructionFailureReason OCCUPIED = create(new TranslatableText("event.sync.construction.fail.occupied"));
ShellConstructionFailureReason NOT_ENOUGH_HEALTH = create(new TranslatableText("event.sync.construction.fail.health"));
ShellConstructionFailureReason OCCUPIED = create(Text.translatable("event.sync.construction.fail.occupied"));
ShellConstructionFailureReason NOT_ENOUGH_HEALTH = create(Text.translatable("event.sync.construction.fail.health"));

@Nullable
Text toText();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/kir/sync/api/shell/ShellState.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private static ShellState create(ServerPlayerEntity player, BlockPos pos, DyeCol
shell.isArtificial = isArtificial;

shell.ownerUuid = player.getUuid();
shell.ownerName = player.getName().asString();
shell.ownerName = player.getName().getString();
shell.gameMode = player.interactionManager.getGameMode().getId();
shell.inventory = new SimpleInventory();
shell.component = ShellStateComponent.empty();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/dev/kir/sync/block/ShellStorageBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;

import java.util.Random;

@SuppressWarnings("deprecation")
public class ShellStorageBlock extends AbstractShellContainerBlock {
public static final BooleanProperty ENABLED = Properties.ENABLED;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/dev/kir/sync/block/TreadmillBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import net.minecraft.util.StringIdentifiable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import org.jetbrains.annotations.Nullable;

import java.util.Random;

@SuppressWarnings("deprecation")
public class TreadmillBlock extends HorizontalFacingBlock implements BlockEntityProvider {
public static final EnumProperty<Part> PART = EnumProperty.of("treadmill_part", Part.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public AbstractShellContainerBlockEntity(BlockEntityType<?> type, BlockPos pos,
@Override
public void setShellState(ShellState shell) {
this.shell = shell;
if (this.world != null && !this.world.isClient && this.pos != null && this.getCachedState() != null) {
this.checkShellState(this.world, this.pos, this.getCachedState());
}
}

@Override
Expand Down Expand Up @@ -97,6 +100,10 @@ protected Optional<AbstractShellContainerBlockEntity> getBottomPart() {

@Override
public void onServerTick(World world, BlockPos pos, BlockState state) {
this.checkShellState(world, pos, state);
}

private void checkShellState(World world, BlockPos pos, BlockState state) {
if (this.shell != null && this.shell.getColor() != this.color) {
this.shell.setColor(this.color);
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/dev/kir/sync/client/gui/ShellSelectorGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;

Expand All @@ -34,8 +33,8 @@ public class ShellSelectorGUI extends Screen {
private static final int MAX_SLOTS = 8;
private static final double MENU_RADIUS = 0.3F;
private static final int BACKGROUND_COLOR = ColorUtil.fromDyeColor(DyeColor.BLACK, 0.3F);
private static final Text TITLE = new TranslatableText("gui.sync.default.cross_button.title");
private static final Collection<Text> ARROW_TITLES = List.of(new TranslatableText("gui.sync.shell_selector.up.title"), new TranslatableText("gui.sync.shell_selector.right.title"), new TranslatableText("gui.sync.shell_selector.down.title"), new TranslatableText("gui.sync.shell_selector.left.title"));
private static final Text TITLE = Text.translatable("gui.sync.default.cross_button.title");
private static final Collection<Text> ARROW_TITLES = List.of(Text.translatable("gui.sync.shell_selector.up.title"), Text.translatable("gui.sync.shell_selector.right.title"), Text.translatable("gui.sync.shell_selector.down.title"), Text.translatable("gui.sync.shell_selector.left.title"));

private final Runnable onCloseCallback;
private final Runnable onRemovedCallback;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
import net.fabricmc.api.Environment;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.MathHelper;

@Environment(EnvType.CLIENT)
public class CrossButtonWidget extends AbstractButtonWidget {
private static final Text DEFAULT_DESCRIPTION = new TranslatableText("gui.sync.default.cross_button.title");
private static final Text DEFAULT_DESCRIPTION = Text.translatable("gui.sync.default.cross_button.title");
private static final int DEFAULT_COLOR = ColorUtil.fromDyeColor(DyeColor.WHITE);
private static final float DEFAULT_STEP = Radians.R_PI_32;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.client.render.BufferBuilderStorage;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.item.HeldItemRenderer;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.math.Matrix4f;

Expand All @@ -22,8 +23,8 @@ public final class CustomGameRenderer extends GameRenderer {

private static final ManagedCoreShader RENDER_TYPE_VOXEL_SHADER;

private CustomGameRenderer(MinecraftClient client, ResourceManager resourceManager, BufferBuilderStorage buffers) {
super(client, resourceManager, buffers);
private CustomGameRenderer(MinecraftClient client, HeldItemRenderer heldItemRenderer, ResourceManager resourceManager, BufferBuilderStorage buffers) {
super(client, heldItemRenderer, resourceManager, buffers);
}

public static void initRenderTypeEntityTranslucentPartiallyTexturedShader(float cutoutY, Matrix4f modelMatrix) {
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/dev/kir/sync/command/GhostShellsCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.Chunk;

Expand All @@ -28,7 +27,7 @@
import java.util.function.Consumer;

public class GhostShellsCommand implements Command {
private static final SimpleCommandExceptionType INVALID_ACTION_TYPE = new SimpleCommandExceptionType(new TranslatableText("command.sync.ghostshells.invalid_action"));
private static final SimpleCommandExceptionType INVALID_ACTION_TYPE = new SimpleCommandExceptionType(Text.translatable("command.sync.ghostshells.invalid_action"));

@Override
public String getName() {
Expand Down Expand Up @@ -93,7 +92,7 @@ private static int execute(CommandContext<ServerCommandSource> context) throws C
for (ServerPlayerEntity player : players) {
ShellState shellState = ((Shell)player).getAvailableShellStates().filter(x -> x.getPos().equals(finalPos)).findAny().orElse(null);
if (shellState == null) {
logger.accept(new TranslatableText("command.sync.ghostshells.not_found", player.getName().asString(), pos.toShortString()));
logger.accept(Text.translatable("command.sync.ghostshells.not_found", player.getName().getString(), pos.toShortString()));
} else {
updateShell(player, shellState, repair, canSkip, logger);
}
Expand All @@ -115,18 +114,18 @@ private static void updateShell(ServerPlayerEntity player, ShellState shellState

if (shouldRepair) {
if (tryRepair(player.server, shellState)) {
logger.accept(new TranslatableText("command.sync.ghostshells.repaired", player.getName().asString(), shellState.getPos().toShortString()));
logger.accept(Text.translatable("command.sync.ghostshells.repaired", player.getName().getString(), shellState.getPos().toShortString()));
return;
}

if (!skipOnFailure) {
logger.accept(new TranslatableText("command.sync.ghostshells.failed", player.getName().asString(), shellState.getPos().toShortString()));
logger.accept(Text.translatable("command.sync.ghostshells.failed", player.getName().getString(), shellState.getPos().toShortString()));
return;
}
}

((Shell)player).remove(shellState);
logger.accept(new TranslatableText("command.sync.ghostshells.removed", player.getName().asString(), shellState.getPos().toShortString()));
logger.accept(Text.translatable("command.sync.ghostshells.removed", player.getName().getString(), shellState.getPos().toShortString()));
}

private static boolean shellExists(MinecraftServer server, ShellState shellState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void clone(ShellStateComponent component) {
originComponent.sync();
} else {
for (OriginLayer layer : OriginLayers.getLayers()) {
if(layer.isEnabled()) {
if (layer.isEnabled()) {
originComponent.setOrigin(layer, Origin.EMPTY);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/dev/kir/sync/compat/requiem/RequiemCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

public class RequiemCompat implements ModInitializer {
@Override
Expand All @@ -16,7 +15,7 @@ public void onInitialize() {
return;
}

final Text PLAYER_IS_UNDEAD = new TranslatableText("event.sync.any.fail.undead");
final Text PLAYER_IS_UNDEAD = Text.translatable("event.sync.any.fail.undead");
PlayerSyncEvents.ALLOW_SHELL_CONSTRUCTION.register((player, __) -> isUndead(player) ? () -> PLAYER_IS_UNDEAD : null);
PlayerSyncEvents.ALLOW_SHELL_SELECTION.register((player, __) -> isUndead(player) ? () -> PLAYER_IS_UNDEAD : null);
PlayerSyncEvents.ALLOW_SYNCING.register((player, __) -> isUndead(player) ? () -> PLAYER_IS_UNDEAD : null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.entity.EntityType;
import org.jetbrains.annotations.NotNull;

public class TrinketsCompat implements EntityComponentInitializer {
@Override
public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) {
public void registerEntityComponentFactories(@NotNull EntityComponentFactoryRegistry registry) {
if (!FabricLoader.getInstance().isModLoaded("trinkets")) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.math.*;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;

import java.util.function.Consumer;

@Environment(EnvType.CLIENT)
public class PersistentCameraEntityGoal {
public static final double MAX_DISTANCE = 25;
public static final long PHASE_DELAY = 200;
public static final double MAX_Y = DimensionType.OVERWORLD.getHeight() * 1.01;
public static final double MAX_Y = 320;
public static final long MIN_PHASE_DURATION = 400;
public static final long MAX_PHASE_DURATION = 2500;

Expand Down
Loading

0 comments on commit 38d3f9b

Please sign in to comment.