diff --git a/src/main/java/weather2/ServerTickHandler.java b/src/main/java/weather2/ServerTickHandler.java index 1f5d3052..896e1edb 100644 --- a/src/main/java/weather2/ServerTickHandler.java +++ b/src/main/java/weather2/ServerTickHandler.java @@ -139,7 +139,7 @@ public static void processIMCMessages() { wm.addStormObject(stormObject); wm.syncStormNew(stormObject); - CULog.dbg("processed imc message: " + tag); + CULog.dbg("processed imc message: " + tag + " - " + msg + " - " + wm.dimension); } else if (msg.method().equals("firenado")) { StormObject stormObject = new StormObject(wm); diff --git a/src/main/java/weather2/weathersystem/WeatherManagerClient.java b/src/main/java/weather2/weathersystem/WeatherManagerClient.java index 8f162300..6e3f24b6 100644 --- a/src/main/java/weather2/weathersystem/WeatherManagerClient.java +++ b/src/main/java/weather2/weathersystem/WeatherManagerClient.java @@ -1,5 +1,6 @@ package weather2.weathersystem; +import com.corosus.coroutil.util.CULog; import com.corosus.coroutil.util.CoroUtilMisc; import extendedrenderer.particle.entity.ParticleCube; import net.minecraft.client.Minecraft; @@ -73,10 +74,23 @@ public void nbtSyncFromServer(CompoundTag parNBT) { String command = parNBT.getString("command"); if (command.equals("syncStormNew")) { + + CULog.dbg("nbtSyncFromServer: " + parNBT); + //Weather.dbg("creating client side storm"); CompoundTag stormNBT = parNBT.getCompound("data"); long ID = stormNBT.getLong("ID"); - Weather.dbg("syncStormNew, ID: " + ID); + Weather.dbg("syncStormNewsss, ID: " + ID); + + //new check to workaround weird bug of WeatherNetworkingv2.instance().serverSendToClientsInDimension sending to every client no matter what + //turns out it was IDEA caching builds for some ungodly reason, remove this code + String dimID = stormNBT.getString("dimID"); + + /*CULog.dbg(dimID + " vs " + this.dimension.toString()); + if (!dimID.equals(this.dimension.toString())) { + CULog.dbg("dimensions dont match, aborting sync of new tornado"); + return; + }*/ EnumWeatherObjectType weatherObjectType = EnumWeatherObjectType.get(stormNBT.getInt("weatherObjectType")); diff --git a/src/main/java/weather2/weathersystem/WeatherManagerServer.java b/src/main/java/weather2/weathersystem/WeatherManagerServer.java index d5fc8473..73bdf5c4 100644 --- a/src/main/java/weather2/weathersystem/WeatherManagerServer.java +++ b/src/main/java/weather2/weathersystem/WeatherManagerServer.java @@ -677,10 +677,10 @@ public void syncStormNew(WeatherObject parStorm, @Nullable ServerPlayer entP) { data.put("data", cache.getNewNBT()); if (entP == null) { - //WeatherNetworking.HANDLER.send(PacketDistributor.DIMENSION.with(() -> getWorld().dimension()), new PacketNBTFromServer(data)); - WeatherNetworkingv2.instance().serverSendToClientAll(data); + CULog.dbg("sending syncStormNew to " + getWorld().dimension()); + WeatherNetworkingv2.instance().serverSendToClientsInDimension(data, getWorld()); } else { - //WeatherNetworking.HANDLER.sendTo(new PacketNBTFromServer(data), entP.connection.connection, NetworkDirection.PLAY_TO_CLIENT); + CULog.dbg("sending syncStormNew to " + entP.getName()); WeatherNetworkingv2.instance().serverSendToClientPlayer(data, entP); } } diff --git a/src/main/java/weather2/weathersystem/storm/StormObject.java b/src/main/java/weather2/weathersystem/storm/StormObject.java index 90d7d856..3c59a596 100644 --- a/src/main/java/weather2/weathersystem/storm/StormObject.java +++ b/src/main/java/weather2/weathersystem/storm/StormObject.java @@ -2428,7 +2428,7 @@ public void spinEntityv2(Entity entity) { } if (entity.isInWater()) { - entity.getPersistentData().putBoolean("tornado_shoot", false); + //entity.getPersistentData().putBoolean("tornado_shoot", false); } } } diff --git a/src/main/java/weather2/weathersystem/storm/WeatherObject.java b/src/main/java/weather2/weathersystem/storm/WeatherObject.java index 2ae227d8..48612a16 100644 --- a/src/main/java/weather2/weathersystem/storm/WeatherObject.java +++ b/src/main/java/weather2/weathersystem/storm/WeatherObject.java @@ -128,6 +128,10 @@ public void nbtSyncForClient() { nbt.putInt("size", size); nbt.putInt("maxSize", maxSize); nbt.putInt("weatherObjectType", this.weatherObjectType.ordinal()); + + /*if (manager != null && manager.getWorld() != null) { + nbt.putString("dimID", manager.getWorld().dimension().toString()); + }*/ } public CachedNBTTagCompound getNbtCache() { diff --git a/src/main/java/weather2/weathersystem/tornado/simple/TornadoFunnelSimple.java b/src/main/java/weather2/weathersystem/tornado/simple/TornadoFunnelSimple.java index 9684e1f1..a8cb26b0 100644 --- a/src/main/java/weather2/weathersystem/tornado/simple/TornadoFunnelSimple.java +++ b/src/main/java/weather2/weathersystem/tornado/simple/TornadoFunnelSimple.java @@ -7,6 +7,8 @@ import net.minecraft.client.ParticleStatus; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -15,6 +17,9 @@ import net.minecraft.world.phys.Vec3; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.neoforge.common.NeoForge; +import net.tropicraft.core.common.entity.TropicraftEntities; +import net.tropicraft.core.common.entity.underdasea.SharkEntity; import weather2.Weather; import weather2.weathersystem.storm.StormObject; import weather2.weathersystem.tornado.ActiveTornadoConfig; @@ -108,7 +113,7 @@ public void tick() { double dist = posLayer.distanceTo(posLayerLower); //easy way to fix the spawning at 0,0 issue if (dist > 50) { - CULog.dbg("teleporting tornado layer to lower piece"); + //CULog.dbg("teleporting tornado layer to lower piece"); listLayers.get(i).setPos(new Vec3(posLayerLower.x, posLayerLower.y, posLayerLower.z)); } else if (dist > 0.1F * (radius / radiusMax)) { double dynamicSpeed = 15F * (Math.min(30F, dist) / 30F); @@ -126,19 +131,20 @@ public void tick() { if (level.getGameTime() % 20 == 0) { Entity ent = null; if (Weather.isLoveTropicsInstalled()) { - /** - * TODO: for LT, turn back on when LT is needed, activates dependency on LTWeather / Tropicraft - */ - //ent = new SharkEntity(TropicraftEntities.HAMMERHEAD.get(), level); - } - if (ent == null) { - ent = new Dolphin(EntityType.DOLPHIN, level); + EntityType type = BuiltInRegistries.ENTITY_TYPE.get(ResourceLocation.parse("tropicraft:hammerhead")); + if (type != null) { + ent = new SharkEntity(type, level); + } + } if (ent == null) { - CULog.log("SharkEntity not spawned, enable in weather mod"); + if (Weather.isLoveTropicsInstalled()) { + CULog.dbg("failed to create shark, falling back to dolphin"); + } + ent = new Dolphin(EntityType.DOLPHIN, level); } - Vec3 posRand = new Vec3(pos.x + 0, pos.y + 3, pos.z - 5); + Vec3 posRand = new Vec3(pos.x + 0, pos.y + 25, pos.z - 5); ent.setPos(posRand); ent.setDeltaMovement(3F, 0, 0); level.addFreshEntity(ent);