Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Fixed crash with Funky Locomotion
Browse files Browse the repository at this point in the history
  • Loading branch information
Tri0de committed Sep 28, 2020
1 parent 316d289 commit 8124fd9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 84 deletions.
64 changes: 31 additions & 33 deletions src/main/java/org/valkyrienskies/mod/client/EventsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,19 @@
import org.joml.Vector3d;
import org.joml.Vector3dc;
import org.lwjgl.opengl.GL11;
import org.valkyrienskies.mod.client.render.GibsModelRegistry;
import org.valkyrienskies.mod.common.config.VSConfig;
import org.valkyrienskies.mod.common.entity.EntityShipMovementData;
import org.valkyrienskies.mod.common.ships.ship_transform.ShipTransform;
import org.valkyrienskies.mod.fixes.SoundFixWrapper;
import org.valkyrienskies.mod.client.better_portals_compatibility.ClientWorldTracker;
import org.valkyrienskies.mod.client.render.GibsModelRegistry;
import org.valkyrienskies.mod.common.ships.entity_interaction.EntityDraggable;
import org.valkyrienskies.mod.common.ships.QueryableShipData;
import org.valkyrienskies.mod.common.ships.ShipData;
import org.valkyrienskies.mod.common.ships.entity_interaction.EntityDraggable;
import org.valkyrienskies.mod.common.ships.ship_transform.ShipTransform;
import org.valkyrienskies.mod.common.ships.ship_world.IHasShipManager;
import org.valkyrienskies.mod.common.ships.ship_world.IPhysObjectWorld;
import org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject;
import org.valkyrienskies.mod.common.ships.ShipData;
import org.valkyrienskies.mod.common.util.VSRenderUtils;
import org.valkyrienskies.mod.common.util.ValkyrienUtils;
import org.valkyrienskies.mod.fixes.SoundFixWrapper;
import valkyrienwarfare.api.TransformType;

import java.util.Optional;
Expand All @@ -50,35 +49,34 @@ public class EventsClient {

@SubscribeEvent
public void onClientTick(ClientTickEvent event) {
for (World world : ClientWorldTracker.getWorlds()) {
if (world == null) {
// There's no world, so there's nothing to run.
return;
}
// Pretend this is the world tick, because diesieben07 doesn't want WorldClient to make world tick events.
switch (event.phase) {
case START:
// Nothing for now
final World world = Minecraft.getMinecraft().world;
if (world == null) {
// There's no world, so there's nothing to run.
return;
}
// Pretend this is the world tick, because diesieben07 doesn't want WorldClient to make world tick events.
switch (event.phase) {
case START:
// Nothing for now

for (PhysicsObject wrapper : ((IHasShipManager) world).getManager().getAllLoadedPhysObj()) {
// This is necessary because Minecraft will run a raytrace right after this
// event to determine what the player is looking at for interaction purposes.
// That raytrace will use the render transform, so we must have the render
// transform set to a partialTick of 1.0.
wrapper.getShipTransformationManager()
.updateRenderTransform(1.0);
}
for (PhysicsObject wrapper : ((IHasShipManager) world).getManager().getAllLoadedPhysObj()) {
// This is necessary because Minecraft will run a raytrace right after this
// event to determine what the player is looking at for interaction purposes.
// That raytrace will use the render transform, so we must have the render
// transform set to a partialTick of 1.0.
wrapper.getShipTransformationManager()
.updateRenderTransform(1.0);
}

break;
case END:
if (!Minecraft.getMinecraft().isGamePaused()) {
// Tick the IShipManager on the world client.
IHasShipManager shipManager = (IHasShipManager) world;
shipManager.getManager().tick();
EntityDraggable.tickAddedVelocityForWorld(world);
}
break;
}
break;
case END:
if (!Minecraft.getMinecraft().isGamePaused()) {
// Tick the IShipManager on the world client.
IHasShipManager shipManager = (IHasShipManager) world;
shipManager.getManager().tick();
EntityDraggable.tickAddedVelocityForWorld(world);
}
break;
}
}

Expand Down

This file was deleted.

5 changes: 0 additions & 5 deletions src/main/java/org/valkyrienskies/mod/common/EventsCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.logging.log4j.Logger;
import org.joml.Vector3d;
import org.joml.Vector3dc;
import org.valkyrienskies.mod.client.better_portals_compatibility.ClientWorldTracker;
import org.valkyrienskies.mod.common.config.VSConfig;
import org.valkyrienskies.mod.common.entity.EntityMountable;
import org.valkyrienskies.mod.common.ships.entity_interaction.EntityDraggable;
Expand Down Expand Up @@ -155,7 +154,6 @@ public static void onWorldLoad(WorldEvent.Load event) {
shipManager.setManager(WorldServerShipManager::new);
} else {
shipManager.setManager(WorldClientShipManager::new);
ClientWorldTracker.onWorldLoad(event.getWorld());
}
}

Expand All @@ -165,9 +163,6 @@ public static void onWorldUnload(WorldEvent.Unload event) {
lastPositions.clear();
IHasShipManager shipManager = (IHasShipManager) event.getWorld();
shipManager.getManager().onWorldUnload();
if (event.getWorld().isRemote) {
ClientWorldTracker.onWorldUnload(event.getWorld());
}
}

@SubscribeEvent(priority = EventPriority.HIGHEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import org.valkyrienskies.mod.client.better_portals_compatibility.ClientWorldTracker;
import org.valkyrienskies.mod.common.ships.QueryableShipData;
import org.valkyrienskies.mod.common.ships.ship_world.IPhysObjectWorld;
import org.valkyrienskies.mod.common.ships.ShipData;
Expand All @@ -25,7 +24,7 @@ public IMessage onMessage(ShipIndexDataMessage message, MessageContext ctx) {
mainThread.addScheduledTask(new Runnable() {
@Override
public void run() {
World world = ClientWorldTracker.getWorldFor(message.dimensionID);
World world = Minecraft.getMinecraft().world;
IPhysObjectWorld physObjectWorld = ValkyrienUtils.getPhysObjWorld(world);
QueryableShipData worldData = QueryableShipData.get(world);
for (ShipData shipData : message.indexedData) {
Expand Down

0 comments on commit 8124fd9

Please sign in to comment.