Skip to content

Commit

Permalink
1.18.2 port (#26)
Browse files Browse the repository at this point in the history
* Update self to 1.18.2

* Quick 'n' dirty update to Smart Recipes

* Un-forget to bump version

* Fixed teleport method

* Bumped Smart Recipes

* Fixed cape rendering

* Fixed warnings

* Downgraded minimum fabric api and fabric loader versions to the lowest possible

Co-authored-by: Kir_Antipov <[email protected]>
  • Loading branch information
slapjd and Kir-Antipov authored Jun 1, 2022
1 parent 9de148b commit 2f4d6e8
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 27 deletions.
2 changes: 1 addition & 1 deletion 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.10-SNAPSHOT"
id "fabric-loom" version "0.11-SNAPSHOT"
id "org.ajoberstar.grgit" version "4.1.0"
}

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

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

# Mod Properties
mod_version=3.1
mod_version=3.2
maven_group=dev.kir
archives_base_name=sync

# Dependencies
fabric_version=0.44.0+1.18
tr_energy_version=2.0.0-beta1
cloth_version=6.1.48
modmenu_version=3.0.1
trinkets_version=3.1.0
requiem_version=2.0.0-beta.3
origins_version=1.3.1
smartrecipes_version=0.2.0+1.18
crowdin_translate_version=1.4+1.18
fabric_version=0.47.8+1.18.2
tr_energy_version=2.2.0
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
smartrecipes_version=0.2.0+1.18.2
crowdin_translate_version=1.4+1.18.2
8 changes: 4 additions & 4 deletions src/main/java/dev/kir/sync/client/gui/ShellSelectorGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void init() {

this.wasClosed = false;
this.arrowButtons = createArrowButtons(this.width, this.height, ARROW_TITLES, List.of(this::previousSection, this::nextPage, this::nextSection, this::previousPage));
this.crossButton = createCrossButton(this.width, this.height, this::onClose);
this.crossButton = createCrossButton(this.width, this.height, this::close);
this.pageDisplay = createPageDisplay(this.width, this.height, data, selectedWorld, MAX_SLOTS, this::onPageChange);
Stream.concat(this.arrowButtons.stream(), Stream.of(this.crossButton, this.pageDisplay)).forEach(this::addDrawableChild);

Expand Down Expand Up @@ -196,7 +196,7 @@ public boolean shouldCloseOnEsc() {
}

@Override
public boolean isPauseScreen() {
public boolean shouldPause() {
return false;
}

Expand Down Expand Up @@ -235,13 +235,13 @@ private void previousPage() {
}

@Override
public void onClose() {
public void close() {
HudController.restore();
if (this.onCloseCallback != null) {
this.onCloseCallback.run();
}
this.wasClosed = true;
super.onClose();
super.close();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected void onMouseClick(double mouseX, double mouseY, int button) {
PlayerSyncEvents.SyncFailureReason failureReason = ((ClientShell)client.player).beginSync(this.shell);
if (failureReason != null) {
if (client.currentScreen != null) {
client.currentScreen.onClose();
client.currentScreen.close();
}
client.player.sendMessage(failureReason.toText(), true);
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/dev/kir/sync/entity/ShellEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public ShellEntity(ClientWorld world, ShellState state) {
state.getInventory().copyTo(this.getInventory());
this.playerEntry = getPlayerEntry(state);
this.refreshPositionAndAngles(state.getPos(), 0, 0);
this.prevCapeX = this.capeX = getX() + 0.5;
this.prevCapeY = this.capeY = getY();
this.prevCapeZ = this.capeZ = getZ() + 0.5;

if (this.onInitialized != null) {
this.onInitialized.run();
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/dev/kir/sync/mixin/ServerPlayerEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@
import dev.kir.sync.util.BlockPosUtil;
import dev.kir.sync.util.WorldUtil;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.network.MessageType;
import net.minecraft.network.packet.s2c.play.DeathMessageS2CPacket;
import net.minecraft.network.packet.s2c.play.DifficultyS2CPacket;
import net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket;
import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket;
import net.minecraft.network.packet.s2c.play.*;
import net.minecraft.scoreboard.AbstractTeam;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PlayerManager;
Expand Down Expand Up @@ -367,6 +365,9 @@ private void sendEmptyDeathMessageInChat() {
@Shadow
protected abstract void forgiveMobAnger();

@Shadow
protected abstract void worldChanged(ServerWorld origin);

@Inject(method = "writeCustomDataToNbt", at = @At("TAIL"))
private void writeCustomDataToNbt(NbtCompound nbt, CallbackInfo ci) {
NbtList shellList = new NbtList();
Expand Down Expand Up @@ -440,7 +441,8 @@ private void teleport(ServerWorld targetWorld, BlockPos pos) {
ServerPlayerEntity serverPlayer = (ServerPlayerEntity)(Object)this;

WorldProperties worldProperties = targetWorld.getLevelProperties();
serverPlayer.networkHandler.sendPacket(new PlayerRespawnS2CPacket(targetWorld.getDimension(), targetWorld.getRegistryKey(), BiomeAccess.hashSeed(targetWorld.getSeed()), serverPlayer.interactionManager.getGameMode(), serverPlayer.interactionManager.getPreviousGameMode(), targetWorld.isDebugWorld(), targetWorld.isFlat(), true));
// method_40134() -> GetDimensionRegistryKey()
serverPlayer.networkHandler.sendPacket(new PlayerRespawnS2CPacket(targetWorld.method_40134(), targetWorld.getRegistryKey(), BiomeAccess.hashSeed(targetWorld.getSeed()), serverPlayer.interactionManager.getGameMode(), serverPlayer.interactionManager.getPreviousGameMode(), targetWorld.isDebugWorld(), targetWorld.isFlat(), true));
serverPlayer.networkHandler.sendPacket(new DifficultyS2CPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked()));
PlayerManager playerManager = Objects.requireNonNull(this.world.getServer()).getPlayerManager();
playerManager.sendCommandTree(serverPlayer);
Expand All @@ -450,8 +452,12 @@ private void teleport(ServerWorld targetWorld, BlockPos pos) {
targetWorld.onPlayerChangeDimension(serverPlayer);
this.setRotation(yaw, pitch);
this.refreshPositionAfterTeleport(x, y, z);
this.worldChanged(targetWorld);
serverPlayer.networkHandler.sendPacket(new PlayerAbilitiesS2CPacket(serverPlayer.getAbilities()));
playerManager.sendWorldInfo(serverPlayer, targetWorld);
playerManager.sendPlayerStatus(serverPlayer);
for (StatusEffectInstance statusEffectInstance : this.getStatusEffects()) {
this.networkHandler.sendPacket(new EntityStatusEffectS2CPacket(this.getId(), statusEffectInstance));
}
}
}
5 changes: 2 additions & 3 deletions src/main/java/dev/kir/sync/util/ItemUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

import dev.kir.sync.Sync;
import dev.kir.sync.config.SyncConfig;
import net.fabricmc.fabric.api.tag.TagFactory;
import net.minecraft.block.DispenserBlock;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.item.*;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

public final class ItemUtil {
private static final Tag<Item> WRENCHES = TagFactory.ITEM.create(new Identifier("c:wrenches"));
private static final TagKey<Item> WRENCHES = TagKey.of(Registry.ITEM_KEY, new Identifier("c:wrenches"));

public static boolean isWrench(ItemStack itemStack) {
if (itemStack.isIn(WRENCHES)) {
Expand Down

0 comments on commit 2f4d6e8

Please sign in to comment.