Skip to content

Commit

Permalink
Fix adult snails becoming small due to network desync.
Browse files Browse the repository at this point in the history
Fix #13.
Fix #14.
  • Loading branch information
LambdAurora committed Aug 14, 2023
1 parent 2291116 commit c5a16d2
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 37 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@
- Updated to 1.20.1.
- Added moss blocks and moss carpets as valid spawn blocks for snails.
- Added hanging roots, melon seeds, pumpkin seeds, torchflower seeds, and wheat seeds as snail food.

### 1.1.3

- Fixed adult snails appearing small after reconnect due to network desynchronizations
([#13](https://github.com/LambdAurora/lovely_snails/issues/13), [#14](https://github.com/LambdAurora/lovely_snails/issues/14)).
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'fabric-loom' version '1.2.+'
id 'io.github.juuxel.loom-quiltflower' version '1.8.+'
id 'io.github.juuxel.loom-vineflower' version '1.11.+'
id 'org.quiltmc.gradle.licenser' version '2.0.+'
id 'java-library'
id 'maven-publish'
Expand Down Expand Up @@ -164,6 +164,8 @@ curseforge {
addGameVersion "Quilt"
addGameVersion "Java 17"
addGameVersion "Java 18"
addGameVersion "Client"
addGameVersion "Server"

// Changelog fetching
def changelogContent = fetchChangelog()
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ org.gradle.jvmargs=-Xmx1G

# Quilt properties
minecraft_version=1.20.1
quilt_mappings=4
quilt_mappings=23
loader_version=0.14.21
fabric_api_version=0.84.0+1.20.1

# Mod properties
mod_version=1.1.2
mod_version=1.1.3
maven_group=dev.lambdaurora
archives_base_name=lovely_snails
modrinth_id=hBVVhStr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import dev.lambdaurora.lovely_snails.LovelySnails;
import dev.lambdaurora.lovely_snails.entity.goal.SnailFollowParentGoal;
import dev.lambdaurora.lovely_snails.entity.goal.SnailHideGoal;
import dev.lambdaurora.lovely_snails.mixin.DataTrackerAccessor;
import dev.lambdaurora.lovely_snails.mixin.PassiveEntityAccessor;
import dev.lambdaurora.lovely_snails.mixin.ShulkerEntityAccessor;
import dev.lambdaurora.lovely_snails.registry.LovelySnailsRegistry;
Expand Down Expand Up @@ -84,7 +83,7 @@
* Represents the snail entity.
*
* @author LambdAurora
* @version 1.1.1
* @version 1.1.3
* @since 1.0.0
*/
public class SnailEntity extends TameableEntity implements InventoryChangedListener, Saddleable {
Expand Down Expand Up @@ -339,8 +338,6 @@ public void handleStatus(byte status) {
protected void initDataTracker() {
super.initDataTracker();

((DataTrackerAccessor) this.dataTracker).lovely_snails$getEntry(CHILD).set(true); // Replace default value.

this.dataTracker.startTracking(SNAIL_FLAGS, (byte) 0);
this.dataTracker.startTracking(CHEST_FLAGS, (byte) 0);
this.dataTracker.startTracking(CARPET_COLOR, -1);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2023 LambdAurora <email@lambdaurora.dev>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package dev.lambdaurora.lovely_snails.mixin;

import dev.lambdaurora.lovely_snails.entity.SnailEntity;
import net.minecraft.entity.passive.PassiveEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

@Mixin(PassiveEntity.class)
public class PassiveEntityMixin {
@SuppressWarnings({"ConstantValue", "unchecked"})
@ModifyArg(
method = "initDataTracker",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/data/DataTracker;startTracking(Lnet/minecraft/entity/data/TrackedData;Ljava/lang/Object;)V"
),
index = 1
)
private <T> T lovely_snails$setDefaultBabyValue(T initialValue) {
if (((Object) this) instanceof SnailEntity) {
return (T) Boolean.TRUE;
} else {
return initialValue;
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/lovely_snails.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"client.ClientPlayerInteractionManagerMixin"
],
"mixins": [
"DataTrackerAccessor",
"PassiveEntityAccessor",
"PassiveEntityMixin",
"PotionEntityMixin",
"ServerPlayNetworkHandlerMixin",
"ShulkerEntityAccessor"
Expand Down

0 comments on commit c5a16d2

Please sign in to comment.