Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ private void failOnNonRandomSpawns(CallbackInfo ci, @Share("seed") LocalRef<Seed
@Inject(method = "onSpawn", at = @At("TAIL"))
private void sendErrorMessage(CallbackInfo ci) {
if (this.setSpawnError != null) {
this.sendMessage(new LiteralTextContent(this.setSpawnError + " This run is not verifiable.").setStyle(new Style().withColor(Formatting.RED)));
Text message = new LiteralTextContent(this.setSpawnError + " This run is not verifiable.");
message.getStyle().withColor(Formatting.RED);
this.sendMessage(message);
this.setSpawnError = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ private int setSpawn(Random random, int bounds, Operation<Integer> original, @Lo
return originalResult;
}

// Transform x and z coordinates into correct Random#nextInt result.
int result = ((MathHelper.floor(seedObject.getX()) - worldSpawn.getX()) + spawnRadius) + ((MathHelper.floor(seedObject.getZ()) - worldSpawn.getZ()) + spawnRadius) * (spawnRadius * 2 + 1);
// Transform x and z coordinates into corresponding Random#nextInt result.
int spawnDiameter = spawnRadius * 2 + 1;
int x = MathHelper.floor(seedObject.getX());
int z = MathHelper.floor(seedObject.getZ());
int xLocal = x - worldSpawn.getX() + spawnRadius;
int result = xLocal + (z - worldSpawn.getZ() + spawnRadius) * spawnDiameter;

if (result >= 0 && result < bounds) {
if (xLocal >=0 && xLocal < spawnDiameter && result >= 0 && result < bounds) {
// we save the original result in case the set spawn is invalid, see fallbackOnInvalidSpawn
System.out.println("Setting spawn");
originalRandomResult.set(originalResult);
Expand Down Expand Up @@ -83,7 +87,7 @@ private void failOnNonRandomSpawns(CallbackInfo ci, @Share("seed") LocalRef<Seed
@Inject(method = "listenToScreenHandler", at = @At("TAIL"))
private void sendErrorMessage(CallbackInfo ci) {
if (this.setSpawnError != null) {
this.sendMessage(new LiteralText(this.setSpawnError + " This run is not verifiable.").setStyle(new Style().setFormatting(Formatting.RED)), false);
this.sendMessage(new LiteralText(this.setSpawnError + " This run is not verifiable.").formatted(Formatting.RED), false);
this.setSpawnError = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.*;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.*;
import net.set.spawn.mod.*;
import net.set.spawn.mod.interfaces.MinecraftServerExtended;
Expand Down Expand Up @@ -47,9 +48,10 @@ private int setSpawn(Random random, int bounds, Operation<Integer> original, @Lo
int spawnDiameter = spawnRadius * 2 + 1;
int x = MathHelper.floor(seedObject.getX());
int z = MathHelper.floor(seedObject.getZ());
int result = (x - worldSpawn.getX() + spawnRadius) + (z - worldSpawn.getZ() + spawnRadius) * spawnDiameter;
int xLocal = x - worldSpawn.getX() + spawnRadius;
int result = xLocal + (z - worldSpawn.getZ() + spawnRadius) * spawnDiameter;

if (result >= 0 && result < bounds) {
if (xLocal >=0 && xLocal < spawnDiameter && result >= 0 && result < bounds) {
// we save the original result in case the set spawn is invalid, see fallbackOnInvalidSpawn
System.out.println("Setting spawn");
originalRandomResult.set(originalResult);
Expand Down Expand Up @@ -95,7 +97,7 @@ private void sendErrorMessage(CallbackInfo ci) {
@Inject(method = "method_14235(Lnet/minecraft/class_1703;)V", at = @At("TAIL"), require = 0)
private void sendErrorMessage2(CallbackInfo ci) {
if (this.setSpawnError != null) {
this.sendMessage(new LiteralText("§c" + this.setSpawnError + " This run is not verifiable."), false);
this.sendMessage(new LiteralText(this.setSpawnError + " This run is not verifiable.").formatted(Formatting.RED), false);
this.setSpawnError = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.*;
import net.minecraft.util.math.random.Random;
import net.set.spawn.mod.*;
Expand Down Expand Up @@ -50,9 +51,10 @@ private int setSpawn(Random random, int bounds, Operation<Integer> original, @Lo
int spawnDiameter = spawnRadius * 2 + 1;
int x = MathHelper.floor(seedObject.getX());
int z = MathHelper.floor(seedObject.getZ());
int result = (x - worldSpawn.getX() + spawnRadius) + (z - worldSpawn.getZ() + spawnRadius) * spawnDiameter;
int xLocal = x - worldSpawn.getX() + spawnRadius;
int result = xLocal + (z - worldSpawn.getZ() + spawnRadius) * spawnDiameter;

if (result >= 0 && result < bounds) {
if (xLocal >=0 && xLocal < spawnDiameter && result >= 0 && result < bounds) {
// we save the original result in case the set spawn is invalid, see fallbackOnInvalidSpawn
originalRandomResult.set(originalResult);
System.out.println("Setting spawn");
Expand Down Expand Up @@ -105,7 +107,7 @@ private void failOnNonRandomSpawns2(CallbackInfoReturnable<Boolean> cir, @Share(
@Inject(method = "onSpawn", at = @At("TAIL"))
private void sendErrorMessage(CallbackInfo ci) {
if (this.setSpawnError != null) {
this.sendMessage(Text.literal("§c" + this.setSpawnError + " This run is not verifiable."), false);
this.sendMessage(Text.literal(this.setSpawnError + " This run is not verifiable.").formatted(Formatting.RED), false);
this.setSpawnError = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public abstract class ServerPlayerEntityMixin {
private String setSpawnError;

@Shadow
public abstract void method_3331(String par1);
public abstract void method_3331(String message);

@WrapOperation(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/util/Random;nextInt(I)I", ordinal = 0))
private int setSpawnX(Random random, int bounds, Operation<Integer> original, @Local(argsOnly = true) MinecraftServer server, @Local BlockPos worldSpawn, @Share("seed") LocalRef<Seed> seed, @Share("zCoord") LocalRef<Integer> zCoord, @Share("isRandomSpawn") LocalBooleanRef isRandomSpawn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class ServerPlayerEntityMixin {
private String setSpawnError;

@Shadow
public abstract void method_5505(ChatMessage par1);
public abstract void method_5505(ChatMessage message);

@WrapOperation(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/util/Random;nextInt(I)I", ordinal = 0))
private int setSpawnX(Random random, int bounds, Operation<Integer> original, @Local(argsOnly = true) MinecraftServer server, @Local BlockPos worldSpawn, @Local(ordinal = 3) int spawnRadius, @Share("seed") LocalRef<Seed> seed, @Share("zCoord") LocalRef<Integer> zCoord, @Share("isRandomSpawn") LocalBooleanRef isRandomSpawn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ private void failOnNonRandomSpawns(CallbackInfo ci, @Share("seed") LocalRef<Seed
@Inject(method = "listenToScreenHandler", at = @At("TAIL"))
private void sendErrorMessage(CallbackInfo ci) {
if (this.setSpawnError != null) {
this.sendMessage(new LiteralText(this.setSpawnError + " This run is not verifiable.").setStyle(new Style().setFormatting(Formatting.RED)));
Text message = new LiteralText(this.setSpawnError + " This run is not verifiable.");
message.getStyle().setFormatting(Formatting.RED);
this.sendMessage(message);
this.setSpawnError = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ private void failOnNonRandomSpawns(CallbackInfo ci, @Share("seed") LocalRef<Seed
@Inject(method = "listenToScreenHandler", at = @At("TAIL"))
private void sendErrorMessage(CallbackInfo ci) {
if (this.setSpawnError != null) {
this.sendMessage(new LiteralText(this.setSpawnError + " This run is not verifiable.").setStyle(new Style().setFormatting(Formatting.RED)));
Text message = new LiteralText(this.setSpawnError + " This run is not verifiable.");
message.getStyle().setFormatting(Formatting.RED);
this.sendMessage(message);
this.setSpawnError = null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs = -Xmx2G
org.gradle.parallel = true
org.gradle.caching = true

mod_version = 4.1.0
mod_version = 4.1.1
archives_name = setspawnmod
base_archives_name = setspawnmod-common
maven_group = me.bdamja
Loading