Skip to content

Commit

Permalink
2.4.0 multi player fix
Browse files Browse the repository at this point in the history
  • Loading branch information
baguchi committed Mar 14, 2024
1 parent 8deaa26 commit d080103
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 163 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ halplibe_version=3.4.14
dragonfly_version=1.4.4-7.1
terrain_api_version=1.4.2-7.1
# Mod
mod_version=2.3.0
mod_version=2.4.0
mod_group=baguchan
mod_name=better_with_aquatic
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import baguchan.better_with_aquatic.entity.EntityFish;
import baguchan.better_with_aquatic.entity.EntityFrog;
import baguchan.better_with_aquatic.item.ModItems;
import baguchan.better_with_aquatic.packet.AABBPacket;
import baguchan.better_with_aquatic.packet.SizePacket;
import baguchan.better_with_aquatic.packet.SwimPacket;
import net.fabricmc.api.ModInitializer;
import net.minecraft.client.gui.guidebook.mobs.MobInfoRegistry;
Expand Down Expand Up @@ -49,8 +47,6 @@ public class BetterWithAquatic implements GameStartEntrypoint, ModInitializer {
@Override
public void onInitialize() {
NetworkHelper.register(SwimPacket.class, true, false);
NetworkHelper.register(AABBPacket.class, true, false);
NetworkHelper.register(SizePacket.class, true, false);
}
@Override
public void beforeGameStart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ public EntityPlayerMixin(World world) {

public void setSwimming(boolean p_20274_) {
if (p_20274_ && !this.swimming) {
this.heightOffset = 0.5f;
this.setSize(0.6F, 0.6F);
float center = this.bbWidth / 2.0f;
float heightOfMob = this.bbHeight;
this.bb.setBounds(x - (double) center, y - (double) this.heightOffset + (double) this.ySlideOffset, z - (double) center, x + (double) center, y - (double) this.heightOffset + (double) this.ySlideOffset + (double) heightOfMob, z + (double) center);

this.heightOffset = 0.42f;
this.setPos(this.x, this.y - 1.2, this.z);
} else if (!p_20274_ && this.swimming) {
this.heightOffset = 1.62f;
this.setSize(0.6F, 1.8F);

this.heightOffset = 1.62f;
this.setPos(this.x, this.y + 1.2F, this.z);
}
this.swimming = p_20274_;
Expand Down Expand Up @@ -71,7 +69,7 @@ public void moveEntityWithHeading(float moveStrafing, float moveForward, Callbac
double d4 = d3 < -0.2 ? 0.04 : 0.1;
if (d3 <= 0.0
|| this.isJumping
|| this.world.getBlockMaterial(MathHelper.floor_double(this.x), MathHelper.floor_double(this.y + 1.0 - 0.5), MathHelper.floor_double(this.z)) == Material.water) {
|| this.world.isMaterialInBB(this.bb, Material.water)) {
this.yd += (d3 - yd) * d4;
}
this.xd += (this.getLookAngle().xCoord - xd) * 0.025F;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package baguchan.better_with_aquatic.mixin;

import baguchan.better_with_aquatic.packet.AABBPacket;
import baguchan.better_with_aquatic.packet.ISwimPacket;
import baguchan.better_with_aquatic.packet.SizePacket;
import baguchan.better_with_aquatic.packet.SwimPacket;
import net.minecraft.core.net.handler.NetHandler;
import net.minecraft.core.net.packet.Packet;
Expand All @@ -19,14 +17,4 @@ public class NetHandlerMixin implements ISwimPacket {
@Shadow
public void handleInvalidPacket(Packet packet) {
}

@Override
public void betterWithAquatic$handleAABB(AABBPacket packet) {
this.handleInvalidPacket(packet);
}

@Override
public void betterWithAquatic$handleSize(SizePacket packet) {
this.handleInvalidPacket(packet);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package baguchan.better_with_aquatic.mixin;

import baguchan.better_with_aquatic.api.ISwiming;
import baguchan.better_with_aquatic.packet.AABBPacket;
import baguchan.better_with_aquatic.packet.ISwimPacket;
import baguchan.better_with_aquatic.packet.SizePacket;
import baguchan.better_with_aquatic.packet.SwimPacket;
import net.minecraft.server.entity.player.EntityPlayerMP;
import net.minecraft.server.net.handler.NetServerHandler;
Expand All @@ -21,16 +19,4 @@ public class NetServerHandlerMixin implements ISwimPacket {
}

}

@Override
public void betterWithAquatic$handleAABB(AABBPacket packet) {
playerEntity.bb.setBounds(packet.aabbMinX, packet.aabbMinY, packet.aabbMinZ, packet.aabbMaxX, packet.aabbMaxY, packet.aabbMaxZ);
playerEntity.heightOffset = packet.offset;
}

@Override
public void betterWithAquatic$handleSize(SizePacket packet) {
playerEntity.bbWidth = packet.width;
playerEntity.bbHeight = packet.height;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package baguchan.better_with_aquatic.mixin.client;

import baguchan.better_with_aquatic.api.ISwiming;
import baguchan.better_with_aquatic.packet.AABBPacket;
import baguchan.better_with_aquatic.packet.SizePacket;
import baguchan.better_with_aquatic.packet.SwimPacket;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.EntityClientPlayerMP;
Expand Down Expand Up @@ -38,19 +36,6 @@ public void func_4056_N(CallbackInfo callbackInfo) {
EntityClientPlayerMP clientPlayerMP = (EntityClientPlayerMP) (Object) this;
clientPlayerMP.sendQueue.addToSendQueue(new SwimPacket(this.isSwimming()));
}
if (this.oldAABB != this.bb || this.oldOffset != this.heightOffset) {
this.oldAABB = this.bb;
this.oldOffset = this.heightOffset;
EntityClientPlayerMP clientPlayerMP = (EntityClientPlayerMP) (Object) this;
clientPlayerMP.sendQueue.addToSendQueue(new AABBPacket(this.bb.minX, this.bb.minY, this.bb.minZ, this.bb.maxX, this.bb.maxY, this.bb.maxZ, this.heightOffset));
}

if (this.oldWidth != this.bbWidth || this.oldHeight != this.bbHeight) {
this.oldWidth = this.bbWidth;
this.oldHeight = this.bbHeight;
EntityClientPlayerMP clientPlayerMP = (EntityClientPlayerMP) (Object) this;
clientPlayerMP.sendQueue.addToSendQueue(new SizePacket(this.bbWidth, this.bbHeight));
}
}

}
63 changes: 0 additions & 63 deletions src/main/java/baguchan/better_with_aquatic/packet/AABBPacket.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@

public interface ISwimPacket {
void betterWithAquatic$handleSwim(SwimPacket packet);

void betterWithAquatic$handleAABB(AABBPacket packet);

void betterWithAquatic$handleSize(SizePacket packet);
}
43 changes: 0 additions & 43 deletions src/main/java/baguchan/better_with_aquatic/packet/SizePacket.java

This file was deleted.

0 comments on commit d080103

Please sign in to comment.