Skip to content

Commit

Permalink
Potential Fix for Console Log Spam
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Sep 10, 2024
1 parent 889793e commit c87cff3
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import io.github.drmanganese.topaddons.elements.ElementTankGauge;
import io.netty.buffer.ByteBuf;
import mcjty.theoneprobe.network.NetworkTools;

/**
* Fixes Localization of Fluid Names. (Client Only)
Expand All @@ -25,8 +26,47 @@ public class ElementTankGaugeMixin {
@Final
private int amount;

@Shadow
@Final
private int capacity;

@Shadow
@Final
private String tankName;

@Shadow
@Final
private String suffix;

@Shadow
@Final
private int color1;

@Shadow
@Final
private boolean sneaking;

@Unique
private String labs$originalName;

@Inject(method = "<init>(Lio/netty/buffer/ByteBuf;)V", at = @At("RETURN"))
private void translateFluidName(ByteBuf buf, CallbackInfo ci) {
labs$originalName = fluidName;
fluidName = LabsFluidNameElement.translateFluid(fluidName, amount, "ElementTankGauge");
}

/**
* Replace the Whole Method, safer for such a critical method
*/
@Inject(method = "toBytes", at = @At("HEAD"), cancellable = true)
private void writeOriginalName(ByteBuf buf, CallbackInfo ci) {
NetworkTools.writeString(buf, tankName);
NetworkTools.writeString(buf, labs$originalName);
buf.writeInt(amount);
buf.writeInt(capacity);
NetworkTools.writeString(buf, suffix);
buf.writeInt(color1);
buf.writeBoolean(sneaking);
ci.cancel();
}
}

0 comments on commit c87cff3

Please sign in to comment.