Skip to content

Commit

Permalink
fix: force server and client to have same mod version
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed May 5, 2022
1 parent 7202c2b commit 6dea6e8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,14 @@ public void performServer(Player player, INinjaData ninjaData, int ticksActive)

Vec3 loc = ninjaData.getSubstitutionLoc();
double distance = loc != null ? player.position().distanceTo(loc) : 0;
if(loc != null && distance < 40 && player.level.dimension().location().equals(ninjaData.getSubstitutionDimension())) {
if(loc != null && distance < MAX_MARKER_DISTANCE && player.level.dimension().location().equals(ninjaData.getSubstitutionDimension())) {
spawnLogAt(player, player.position(), ninjaData);
player.teleportTo(loc.x, loc.y - 2, loc.z);
ninjaData.setSubstitutionLoc(null, null);
} else {
Vec3 originalPosition = player.position();
if(this.randomTeleportPlayer(player, ninjaData)) {
spawnLogAt(player, originalPosition, ninjaData);
} else {
// TODO add a failed teleport message or handle the tp logic in the calculation.
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void render(PoseStack matrixStack, Matrix4f worldMatrix, Vec3 cameraPos)
0, 0,
32, 32,
32, 32);
centeredTextOutlined(matrixStack, Math.round(distance) + " M", 0, 11, distance < SubstitutionJutsuAbility.MAX_MARKER_DISTANCE ? intTextColor : outOfRangeColor, intTextOutline);
centeredTextOutlined(matrixStack, Math.floor(distance) + " M", 0, 11, distance > SubstitutionJutsuAbility.MAX_MARKER_DISTANCE ? intTextColor : outOfRangeColor, intTextOutline);
matrixStack.popPose();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.network.NetworkDirection;
import net.minecraftforge.network.NetworkRegistry;
import net.minecraftforge.network.PacketDistributor;
import net.minecraftforge.network.simple.SimpleChannel;

public class PacketHandler {

public static final String PROTOCOL_VERSION = "1";
/**
* Forces the mod to have the same version as the server.
*/
public static final String PROTOCOL_VERSION = ModList.get().getModFileById(NarutoMod.MOD_ID).versionString();

public static final SimpleChannel NARUTO_CHANNEL = NetworkRegistry.ChannelBuilder
.named(new ResourceLocation(NarutoMod.MOD_ID, "naruto_data"))
Expand Down

0 comments on commit 6dea6e8

Please sign in to comment.