Skip to content

Commit ccfcd0b

Browse files
committed
fix 1.19.4
1 parent c305c37 commit ccfcd0b

File tree

6 files changed

+52
-85
lines changed

6 files changed

+52
-85
lines changed

src/main/java/win/baruna/blockmeter/BlockMeterClient.java

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
package win.baruna.blockmeter;
22

3-
import java.util.ArrayList;
4-
import java.util.HashMap;
5-
import java.util.List;
6-
import java.util.Map;
7-
8-
import org.lwjgl.glfw.GLFW;
9-
103
import io.netty.buffer.Unpooled;
114
import me.shedaniel.autoconfig.AutoConfig;
125
import me.shedaniel.autoconfig.ConfigManager;
136
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
147
import net.fabricmc.api.ClientModInitializer;
158
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
169
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
10+
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
1711
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
1812
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
1913
import net.fabricmc.fabric.api.networking.v1.PacketSender;
@@ -35,10 +29,16 @@
3529
import net.minecraft.util.hit.BlockHitResult;
3630
import net.minecraft.util.hit.HitResult;
3731
import net.minecraft.util.math.BlockPos;
32+
import org.lwjgl.glfw.GLFW;
3833
import win.baruna.blockmeter.gui.OptionsGui;
3934
import win.baruna.blockmeter.gui.SelectBoxGui;
4035
import win.baruna.blockmeter.measurebox.ClientMeasureBox;
4136

37+
import java.util.ArrayList;
38+
import java.util.HashMap;
39+
import java.util.List;
40+
import java.util.Map;
41+
4242
public class BlockMeterClient implements ClientModInitializer {
4343
/**
4444
* Currently running Instance of BlockMeterClient
@@ -47,7 +47,7 @@ public class BlockMeterClient implements ClientModInitializer {
4747

4848
/**
4949
* Accessor for the BlockMeterClient Instance
50-
*
50+
*
5151
* @return running Instance of BlockMeterClient
5252
*/
5353
public static BlockMeterClient getInstance() {
@@ -61,7 +61,7 @@ public static BlockMeterClient getInstance() {
6161

6262
/**
6363
* Accessor for the ModConfigManager
64-
*
64+
*
6565
* @return ConfigManager for handling the Config
6666
*/
6767
public static ConfigManager<ModConfig> getConfigManager() {
@@ -124,6 +124,7 @@ public void disable() {
124124
public void reset() {
125125
otherUsersBoxes = null;
126126
boxes.clear();
127+
disable();
127128

128129
// Resets Color to always start with white in an other world
129130
ModConfig cfg = confMgr.getConfig();
@@ -220,7 +221,7 @@ public void onConnected() {
220221

221222
/**
222223
* Returns the currently active box
223-
*
224+
*
224225
* @return currently open box or null if none
225226
*/
226227
public ClientMeasureBox getCurrentBox() {
@@ -260,8 +261,7 @@ public void onInitializeClient() {
260261
currentItem = itemStack.getItem();
261262
e.player.sendMessage(
262263
Text.translatable("blockmeter.toggle.on",
263-
new Object[] {
264-
Text.translatable(itemStack.getTranslationKey(), new Object[0]) }),
264+
Text.translatable(itemStack.getTranslationKey(), new Object[0])),
265265
true);
266266
}
267267
}
@@ -287,15 +287,16 @@ public void onInitializeClient() {
287287

288288
UseBlockCallback.EVENT
289289
.register((playerEntity, world, hand, hitResult) -> this.onBlockMeterClick(playerEntity, hitResult));
290+
ClientPlayConnectionEvents.DISCONNECT.register((_a, _b) -> this.onDisconnected());
290291
}
291292

292293
/**
293294
* Handles the right click Event for creating and confirming new Measuring-Boxes
294-
*
295+
*
295296
* @param playerEntity the player object
296297
* @param hitResult
297298
* @return PASS if not active or wrong item, FAIL when successful, to not send
298-
* the event to the server
299+
* the event to the server
299300
*/
300301
private ActionResult onBlockMeterClick(final PlayerEntity playerEntity, final BlockHitResult hitResult) {
301302
if (!this.active) {
@@ -310,16 +311,16 @@ private ActionResult onBlockMeterClick(final PlayerEntity playerEntity, final Bl
310311
if (Screen.hasShiftDown()) {
311312
ClientMeasureBox[] boxes = findBoxes(block);
312313
switch (boxes.length) {
313-
case 0:
314-
break;
315-
case 1:
316-
boxes[0].loosenCorner(block);
317-
break;
318-
default:
319-
this.selectBoxGui.setBoxes(boxes);
320-
this.selectBoxGui.setBlock(block);
321-
MinecraftClient.getInstance().setScreen((Screen) this.selectBoxGui);
322-
break;
314+
case 0:
315+
break;
316+
case 1:
317+
boxes[0].loosenCorner(block);
318+
break;
319+
default:
320+
this.selectBoxGui.setBoxes(boxes);
321+
this.selectBoxGui.setBlock(block);
322+
MinecraftClient.getInstance().setScreen((Screen) this.selectBoxGui);
323+
break;
323324
}
324325
} else {
325326
final ClientMeasureBox box = ClientMeasureBox.getBox(block,
@@ -339,7 +340,7 @@ private ActionResult onBlockMeterClick(final PlayerEntity playerEntity, final Bl
339340

340341
/**
341342
* Finds a box to be edited when selecting this block
342-
*
343+
*
343344
* @param block selected block
344345
* @return Box to be edited
345346
*/
@@ -365,7 +366,7 @@ private void sendBoxList() {
365366
* handles the BoxList of other Players
366367
*/
367368
private void handleServerBoxList(MinecraftClient client, ClientPlayNetworkHandler handler, PacketByteBuf data,
368-
PacketSender responseSender) {
369+
PacketSender responseSender) {
369370
Map<Text, List<ClientMeasureBox>> receivedBoxes = new HashMap<>();
370371
int playerCount = data.readInt();
371372
for (int i = 0; i < playerCount; i++) {

src/main/java/win/baruna/blockmeter/gui/OptionsGui.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ public void onPress() {
142142
public void render(MatrixStack stack, final int int_1, final int int_2, final float float_1) {
143143
super.render(stack, int_1, int_2, float_1);
144144

145-
RenderSystem.disableTexture();
146145
Tessellator tessellator = Tessellator.getInstance();
147146
BufferBuilder bufferBuilder = tessellator.getBuffer();
148147
RenderSystem.setShader(GameRenderer::getPositionColorProgram);
@@ -166,7 +165,6 @@ public void render(MatrixStack stack, final int int_1, final int int_2, final fl
166165
.next();
167166
tessellator.draw();
168167

169-
RenderSystem.enableTexture();
170168

171169
if (text != null) {
172170
boolean dark = (0.299f * color.getRed() + 0.587f * color.getBlue() + 0.114f * color.getRed()) / 255f < 0.8f;

src/main/java/win/baruna/blockmeter/measurebox/ClientMeasureBox.java

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
package win.baruna.blockmeter.measurebox;
22

3-
import java.util.ArrayList;
4-
import java.util.Collections;
5-
import java.util.List;
6-
73
import com.mojang.blaze3d.systems.RenderSystem;
8-
94
import me.shedaniel.autoconfig.AutoConfig;
105
import net.minecraft.client.MinecraftClient;
116
import net.minecraft.client.font.TextRenderer;
12-
import net.minecraft.client.render.BufferBuilder;
13-
import net.minecraft.client.render.Camera;
14-
import net.minecraft.client.render.GameRenderer;
15-
import net.minecraft.client.render.Tessellator;
16-
import net.minecraft.client.render.VertexConsumerProvider;
17-
import net.minecraft.client.render.VertexFormats;
7+
import net.minecraft.client.render.*;
188
import net.minecraft.client.render.VertexFormat.DrawMode;
199
import net.minecraft.client.util.math.MatrixStack;
2010
import net.minecraft.network.PacketByteBuf;
21-
import net.minecraft.text.MutableText;
2211
import net.minecraft.text.Text;
2312
import net.minecraft.util.DyeColor;
2413
import net.minecraft.util.Identifier;
@@ -30,11 +19,15 @@
3019
import win.baruna.blockmeter.BlockMeterClient;
3120
import win.baruna.blockmeter.ModConfig;
3221

22+
import java.util.ArrayList;
23+
import java.util.Collections;
24+
import java.util.List;
25+
3326
public class ClientMeasureBox extends MeasureBox {
3427
private Box box;
3528

3629
protected ClientMeasureBox(final BlockPos blockStart, final BlockPos blockEnd, final Identifier dimension,
37-
final DyeColor color, final boolean finished, final int mode, final int orientation) {
30+
final DyeColor color, final boolean finished, final int mode, final int orientation) {
3831
super(blockStart, blockEnd, dimension, color, finished, mode, orientation);
3932
updateBoundingBox();
4033
}
@@ -52,7 +45,7 @@ public static ClientMeasureBox getBox(final BlockPos block, final Identifier dim
5245

5346
/**
5447
* Sets the second box corner
55-
*
48+
*
5649
* @param block second corner position
5750
*/
5851
public void setBlockEnd(final BlockPos block) {
@@ -62,7 +55,7 @@ public void setBlockEnd(final BlockPos block) {
6255

6356
/**
6457
* The current creation state of the MeasureBox
65-
*
58+
*
6659
* @return true if MeasureBox is completed
6760
*/
6861
public boolean isFinished() {
@@ -78,7 +71,7 @@ public void setFinished() {
7871

7972
/**
8073
* Sets the Color of the MeasureBox
81-
*
74+
*
8275
* @param color Color to be applied
8376
*/
8477
public void setColor(final DyeColor color) {
@@ -87,7 +80,7 @@ public void setColor(final DyeColor color) {
8780

8881
/**
8982
* Tests if the block is on a corner of the box
90-
*
83+
*
9184
* @param block Position to test
9285
* @return true if block is a corner
9386
*/
@@ -100,7 +93,7 @@ public boolean isCorner(final BlockPos block) {
10093
/**
10194
* Loosens the selected Corner i.e. the opposite corner gets fixed, and the
10295
* current one can be moved
103-
*
96+
*
10497
* @param block The corner to loosen, needs to be an actual corner of the box
10598
*/
10699
public void loosenCorner(final BlockPos block) {
@@ -114,7 +107,7 @@ public void loosenCorner(final BlockPos block) {
114107

115108
/**
116109
* Renders the Box
117-
*
110+
*
118111
* @param camera rendering Camera
119112
* @param stack
120113
* @param currentDimension Dimension the Player currently is in
@@ -125,24 +118,23 @@ public void render(final Camera camera, final MatrixStack stack, final Identifie
125118

126119
/**
127120
* Renders the Box
128-
*
121+
*
129122
* @param camera rendering Camera
130123
* @param stack
131124
* @param currentDimension Dimension the Player currently is in
132125
* @param boxCreatorName Name of the Player that created the Box
133126
*/
134127
public void render(final Camera camera, final MatrixStack stack, final Identifier currentDimension,
135-
final Text boxCreatorName) {
128+
final Text boxCreatorName) {
136129
if (!(currentDimension.equals(this.dimension))) {
137130
return;
138131
}
139132
final Vec3d pos = camera.getPos();
140133

141134
// FIXME This actually does nothing
142135
RenderSystem.lineWidth(2.0f);
143-
136+
144137
RenderSystem.disableDepthTest();
145-
RenderSystem.disableTexture();
146138
RenderSystem.disableBlend();
147139

148140
stack.push();
@@ -211,7 +203,6 @@ public void render(final Camera camera, final MatrixStack stack, final Identifie
211203
tess.draw();
212204

213205
}
214-
RenderSystem.enableTexture();
215206
RenderSystem.lineWidth(1.0f);
216207

217208
this.drawLengths(camera, stack, boxCreatorName);
@@ -239,7 +230,7 @@ private void updateBoundingBox() {
239230

240231
/**
241232
* Draws the length label
242-
*
233+
*
243234
* @param camera rendering Camera
244235
* @param stack
245236
* @param boxCreatorName Name of the Box creator
@@ -317,7 +308,7 @@ private void drawLengths(final Camera camera, final MatrixStack stack, final Tex
317308

318309
/**
319310
* Draws a text with orientation and position
320-
*
311+
*
321312
* @param stack
322313
* @param x
323314
* @param y
@@ -328,9 +319,8 @@ private void drawLengths(final Camera camera, final MatrixStack stack, final Tex
328319
* @param playerPos
329320
*/
330321
private void drawText(final MatrixStack stack, final double x, final double y, final double z, final float yaw,
331-
final float pitch, final String text, final Vec3d playerPos) {
332-
@SuppressWarnings("resource")
333-
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
322+
final float pitch, final String text, final Vec3d playerPos) {
323+
@SuppressWarnings("resource") final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
334324

335325
final var literalText = Text.literal(text);
336326

@@ -380,7 +370,7 @@ private void drawText(final MatrixStack stack, final double x, final double y, f
380370
!conf.backgroundForLabels, // shadow
381371
model, // matrix
382372
immediate, // draw buffer
383-
true, // seeThrough
373+
TextRenderer.TextLayerType.SEE_THROUGH,
384374
0, // backgroundColor => underlineColor,
385375
15728880 // light
386376
);
@@ -402,7 +392,7 @@ static private void incrementColor() {
402392

403393
/**
404394
* Accessor for the currently selected color
405-
*
395+
*
406396
* @return currently selected color
407397
*/
408398
static private DyeColor getSelectedColor() {
@@ -417,7 +407,7 @@ public static void setColorIndex(final int newColor) {
417407

418408
/**
419409
* Parses a ClientMeasureBox from a PacketByteBuf
420-
*
410+
*
421411
* @param attachedData a PacketByteBuf containing the ClientMeasureBox
422412
* @return the PacketByteBuf submitted
423413
*/

src/main/java/win/baruna/blockmeter/mixin/GameMixin.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/main/resources/blockmeter.mixins.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
],
88
"client": [
99
"GameRendererMixin",
10-
"GameMixin",
1110
"ClientPlayerConnectionMixin"
1211
],
1312
"server": [
@@ -16,4 +15,4 @@
1615
"defaultRequire": 1
1716
},
1817
"refmap": "blockmeter-refmap.json"
19-
}
18+
}

version.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
modVersion = 1.9
2-
minecraftVersion = 1.19.3
1+
modVersion = 1.9.1
2+
minecraftVersion = 1.19.4

0 commit comments

Comments
 (0)