Skip to content

Commit

Permalink
Merge pull request #243 from MuradAkh/fix_242
Browse files Browse the repository at this point in the history
Fix 242
  • Loading branch information
EDToaster authored Oct 14, 2023
2 parents b46ea7f + d43324c commit 5162c8e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BeaconRenderer;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity;
Expand All @@ -36,16 +34,13 @@
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderLevelStageEvent;
import net.minecraftforge.event.level.LevelEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import org.joml.Matrix4f;
import org.joml.Vector2d;

import javax.annotation.Nullable;
import java.util.List;
import java.util.Optional;
import java.util.OptionalDouble;
import java.util.stream.Collectors;

/**
* Forge-wide event bus
Expand All @@ -71,6 +66,11 @@ public ModRenderType(String pName, VertexFormat pFormat, VertexFormat.Mode pMode
}
}

@SubscribeEvent
public static void onWorldUnload(LevelEvent.Unload event) {
VehicleTrackerPacketHandler.flush();
}

/**
* Returns whether we rendered a route here. Empty route also returns true
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public static void onWorldTick(TickEvent.LevelTickEvent event) {
// Don't do anything client side
if (event.level instanceof ServerLevel serverLevel) {
TrainChunkManagerManager.get(serverLevel.getServer()).getManagers(event.level.dimension()).forEach(PlayerTrainChunkManager::tick);

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class VehicleTrackerPacketHandler {

private static int id = 0;
public static void register() {
// int index, Class<MSG> messageType, BiConsumer<MSG, PacketBuffer> encoder, Function<PacketBuffer, MSG> decoder, BiConsumer<MSG, Supplier<NetworkEvent.Context>> messageConsumer
INSTANCE.registerMessage(id++, VehicleTrackerClientPacket.class, VehicleTrackerClientPacket::encode, VehicleTrackerClientPacket::new, VehicleTrackerPacketHandler::handleData);
}

Expand All @@ -45,4 +44,8 @@ public static void handleData(VehicleTrackerClientPacket packet, Supplier<Networ

ctx.get().setPacketHandled(true);
}

public static void flush() {
toRender.clear();
}
}

0 comments on commit 5162c8e

Please sign in to comment.