prevent dedicated server crash (#100)

This commit is contained in:
Alexdoru authored and GitHub committed 2026-05-05 03:51:45 -04:00
1 parent 8dc27474ec
commit 9009b1372a
11 files changed
+95 -61

No files matched your search

@@ -393,6 +393,7 @@ public final class ClientProxy extends CommonProxy {
return this.clientHandler.getEnergyCrystalAlpha(); return this.clientHandler.getEnergyCrystalAlpha();
} }
@Override
public void tryRepositionPlayerOnMount(int entityId) { public void tryRepositionPlayerOnMount(int entityId) {
this.clientHandler.tryRepositionPlayerOnMount(entityId); this.clientHandler.tryRepositionPlayerOnMount(entityId);
} }
@@ -16,6 +16,8 @@ import com.brandon3055.draconicevolution.common.utils.DataUtils;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public final class ShieldRenderHandler { public final class ShieldRenderHandler {
@@ -31,6 +33,7 @@ public final class ShieldRenderHandler {
} }
} }
@SideOnly(Side.CLIENT)
@SubscribeEvent @SubscribeEvent
public void tickEnd(TickEvent.ClientTickEvent event) { public void tickEnd(TickEvent.ClientTickEvent event) {
if (event.phase == TickEvent.Phase.END && !shieldStatus.isEmpty()) { if (event.phase == TickEvent.Phase.END && !shieldStatus.isEmpty()) {
@@ -335,6 +335,8 @@ public class CommonProxy {
return dragonChunkLoader; return dragonChunkLoader;
} }
public void tryRepositionPlayerOnMount(int entityId) {}
public void registerInhibitor(TileDislocatorInhibitor tile) { public void registerInhibitor(TileDislocatorInhibitor tile) {
if (tile.hasWorldObj()) { if (tile.hasWorldObj()) {
registerInhibitor(this.serverInhibitorsMap, tile); registerInhibitor(this.serverInhibitorsMap, tile);
@@ -8,6 +8,9 @@ import net.minecraft.world.World;
import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.DraconicEvolution;
import com.brandon3055.draconicevolution.client.render.particle.Particles; import com.brandon3055.draconicevolution.client.render.particle.Particles;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/** /**
* Created by brandon3055 on 30/9/2015. * Created by brandon3055 on 30/9/2015.
*/ */
@@ -62,18 +65,14 @@ public class EntityChaosBolt extends Entity {
if (ticks == 10 && !burst) { if (ticks == 10 && !burst) {
if (worldObj.isRemote) { if (worldObj.isRemote) {
DraconicEvolution.clientProxy().spawnParticle( spawnParticles(10);
new Particles.ChaosBoltParticle(worldObj, posX, posY, posZ, shardX, shardY, shardZ, 10),
32);
} }
setDead(); setDead();
} else if (ticks > 10) { } else if (ticks > 10) {
if (ticks < 25) { if (ticks < 25) {
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
if (worldObj.isRemote) { if (worldObj.isRemote) {
DraconicEvolution.clientProxy().spawnParticle( spawnParticles(0);
new Particles.ChaosBoltParticle(worldObj, posX, posY, posZ, shardX, shardY, shardZ, 0),
32);
} }
} }
} }
@@ -86,6 +85,13 @@ public class EntityChaosBolt extends Entity {
ticks++; ticks++;
} }
@SideOnly(Side.CLIENT)
private void spawnParticles(int mode) {
DraconicEvolution.clientProxy().spawnParticle(
new Particles.ChaosBoltParticle(worldObj, posX, posY, posZ, shardX, shardY, shardZ, mode),
32);
}
@Override @Override
protected void readEntityFromNBT(NBTTagCompound compound) { protected void readEntityFromNBT(NBTTagCompound compound) {
// if (compound.hasKey("ShardPos")){ // if (compound.hasKey("ShardPos")){
@@ -13,6 +13,8 @@ import com.brandon3055.draconicevolution.common.network.GenericParticlePacket;
import com.brandon3055.draconicevolution.common.utils.handlers.ProcessHandler; import com.brandon3055.draconicevolution.common.utils.handlers.ProcessHandler;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/** /**
* Created by brandon3055 on 3/10/2015. * Created by brandon3055 on 3/10/2015.
@@ -41,12 +43,10 @@ public class EntityChaosVortex extends Entity {
else ticksExisted = dataWatcher.getWatchableObjectInt(20); else ticksExisted = dataWatcher.getWatchableObjectInt(20);
if (ticksExisted < 30 && ticksExisted % 5 == 0 && worldObj.isRemote) { if (ticksExisted < 30 && ticksExisted % 5 == 0 && worldObj.isRemote) {
DraconicEvolution.clientProxy() spawnChaosParticles(false);
.spawnParticle(new Particles.ChaosExpansionParticle(worldObj, posX, posY, posZ, false), 512);
} }
if (ticksExisted >= 100 && ticksExisted < 130 && ticksExisted % 5 == 0 && worldObj.isRemote) { if (ticksExisted >= 100 && ticksExisted < 130 && ticksExisted % 5 == 0 && worldObj.isRemote) {
DraconicEvolution.clientProxy() spawnChaosParticles(true);
.spawnParticle(new Particles.ChaosExpansionParticle(worldObj, posX, posY, posZ, true), 512);
} }
if (ticksExisted < 100) return; if (ticksExisted < 100) return;
@@ -55,9 +55,7 @@ public class EntityChaosVortex extends Entity {
double y = posY - 8 + rand.nextDouble() * 16; double y = posY - 8 + rand.nextDouble() * 16;
double z = posZ - 18 + rand.nextDouble() * 36; double z = posZ - 18 + rand.nextDouble() * 36;
if (worldObj.isRemote) { if (worldObj.isRemote) {
DraconicEvolution.clientProxy().spawnParticle( spawnSeekerParticles(x, y, z);
new Particles.AdvancedSeekerParticle(worldObj, x, y, z, posX, posY, posZ, 2, 1f, 1f, 1f, 100),
128);
} }
} }
@@ -73,6 +71,19 @@ public class EntityChaosVortex extends Entity {
if (ticksExisted > 620) setDead(); if (ticksExisted > 620) setDead();
} }
@SideOnly(Side.CLIENT)
private void spawnChaosParticles(boolean shrink) {
DraconicEvolution.clientProxy()
.spawnParticle(new Particles.ChaosExpansionParticle(worldObj, posX, posY, posZ, shrink), 512);
}
@SideOnly(Side.CLIENT)
private void spawnSeekerParticles(double x, double y, double z) {
DraconicEvolution.clientProxy().spawnParticle(
new Particles.AdvancedSeekerParticle(worldObj, x, y, z, posX, posY, posZ, 2, 1f, 1f, 1f, 100),
128);
}
private void shakeScreen() { private void shakeScreen() {
double intensity = (ticksExisted - 130) / 100D; double intensity = (ticksExisted - 130) / 100D;
if (intensity > 1D) intensity = 1D; if (intensity > 1D) intensity = 1D;
@@ -45,7 +45,7 @@ public class MountUpdatePacket implements IMessage {
return null; return null;
} }
DraconicEvolution.clientProxy().tryRepositionPlayerOnMount(message.entityID); DraconicEvolution.proxy.tryRepositionPlayerOnMount(message.entityID);
return null; return null;
} }
} }
@@ -55,9 +55,9 @@ public class TileChaosShard extends TileEntity {
public void detonate() { public void detonate() {
if (!worldObj.isRemote if (!worldObj.isRemote
&& locationHash != getLocationHash(xCoord, yCoord, zCoord, worldObj.provider.dimensionId)) && locationHash != getLocationHash(xCoord, yCoord, zCoord, worldObj.provider.dimensionId)) {
worldObj.setBlockToAir(xCoord, yCoord, zCoord); worldObj.setBlockToAir(xCoord, yCoord, zCoord);
else { } else {
EntityChaosVortex vortex = new EntityChaosVortex(worldObj); EntityChaosVortex vortex = new EntityChaosVortex(worldObj);
vortex.setPosition(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); vortex.setPosition(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
worldObj.spawnEntityInWorld(vortex); worldObj.spawnEntityInWorld(vortex);
@@ -47,19 +47,16 @@ public class TileEnergyRelay extends TileRemoteEnergyBase {
super.updateEntity(); super.updateEntity();
if (worldObj.isRemote) { if (worldObj.isRemote) {
ring = DraconicEvolution.clientProxy().energyField( spawnEnergyField();
worldObj,
xCoord + 0.5,
yCoord + 0.5,
zCoord + 0.5,
0,
powerTier == 1,
ring,
inView > 0);
return;
} }
} }
@SideOnly(Side.CLIENT)
private void spawnEnergyField() {
ring = DraconicEvolution.clientProxy()
.energyField(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0, powerTier == 1, ring, inView > 0);
}
@Override @Override
public void writeToNBT(NBTTagCompound compound) { public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound); super.writeToNBT(compound);
@@ -78,7 +78,14 @@ public class TileEnergyTransceiver extends TileRemoteEnergyBase {
} }
} }
if (worldObj.isRemote) particle = DraconicEvolution.clientProxy() if (worldObj.isRemote) {
spawnParticle();
}
}
@SideOnly(Side.CLIENT)
private void spawnParticle() {
particle = DraconicEvolution.clientProxy()
.energyField(worldObj, getBeamX(), getBeamY(), getBeamZ(), 1, powerTier == 1, particle, inView > 0); .energyField(worldObj, getBeamX(), getBeamY(), getBeamZ(), 1, powerTier == 1, particle, inView > 0);
} }
@@ -100,19 +100,7 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
rType = 1; rType = 1;
else rType = 0; else rType = 0;
} }
device.beam = DraconicEvolution.clientProxy().energyBeam( updateBeam(device, remoteTile, rType);
worldObj,
getBeamX(),
getBeamY(),
getBeamZ(),
remoteTile.getBeamX(),
remoteTile.getBeamY(),
remoteTile.getBeamZ(),
(int) device.energyFlow,
getPowerTier() == 1,
device.beam,
true,
rType);
} else { } else {
double difference = getCapacity() - remoteTile.getCapacity(); double difference = getCapacity() - remoteTile.getCapacity();
double energyToEqual = Math double energyToEqual = Math
@@ -137,6 +125,23 @@ public abstract class TileRemoteEnergyBase extends TileObjectSync implements IRe
} }
} }
@SideOnly(Side.CLIENT)
private void updateBeam(LinkedEnergyDevice device, IRemoteEnergyHandler remoteTile, int rType) {
device.beam = DraconicEvolution.clientProxy().energyBeam(
worldObj,
getBeamX(),
getBeamY(),
getBeamZ(),
remoteTile.getBeamX(),
remoteTile.getBeamY(),
remoteTile.getBeamZ(),
(int) device.energyFlow,
getPowerTier() == 1,
device.beam,
true,
rType);
}
protected void detectAndSendChanges(int index) { protected void detectAndSendChanges(int index) {
if (worldObj.isRemote) return; if (worldObj.isRemote) return;
@@ -62,32 +62,13 @@ public class TileWirelessEnergyTransceiver extends TileRemoteEnergyBase {
super.updateEntity(); super.updateEntity();
if (worldObj.isRemote) { if (worldObj.isRemote) {
ring = DraconicEvolution.clientProxy().energyField( spawnEnergyField();
worldObj,
xCoord + 0.5,
yCoord + 0.5,
zCoord + 0.5,
2,
powerTier == 1,
ring,
inView > 0);
for (LinkedReceiver receiver : receiverList) { for (LinkedReceiver receiver : receiverList) {
int particleValue = 200; int particleValue = 200;
if (receiver.particleEnergyCounter > particleValue) { if (receiver.particleEnergyCounter > particleValue) {
receiver.particleEnergyCounter -= particleValue; receiver.particleEnergyCounter -= particleValue;
spawnParticles(receiver);
// todo detect box size
DraconicEvolution.clientProxy().spawnParticle(
new Particles.TransceiverParticle(
worldObj,
xCoord + 0.5,
yCoord + 0.3 + (worldObj.rand.nextDouble() * 0.4),
zCoord + 0.5,
receiver.xCoord + worldObj.rand.nextDouble(),
receiver.yCoord + worldObj.rand.nextDouble(),
receiver.zCoord + worldObj.rand.nextDouble()),
64);
} }
} }
} else { } else {
@@ -120,6 +101,27 @@ public class TileWirelessEnergyTransceiver extends TileRemoteEnergyBase {
} }
} }
@SideOnly(Side.CLIENT)
private void spawnEnergyField() {
ring = DraconicEvolution.clientProxy()
.energyField(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 2, powerTier == 1, ring, inView > 0);
}
@SideOnly(Side.CLIENT)
private void spawnParticles(LinkedReceiver receiver) {
// todo detect box size
DraconicEvolution.clientProxy().spawnParticle(
new Particles.TransceiverParticle(
worldObj,
xCoord + 0.5,
yCoord + 0.3 + (worldObj.rand.nextDouble() * 0.4),
zCoord + 0.5,
receiver.xCoord + worldObj.rand.nextDouble(),
receiver.yCoord + worldObj.rand.nextDouble(),
receiver.zCoord + worldObj.rand.nextDouble()),
64);
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
public void receiveObjectFromServer(int index, Object object) { public void receiveObjectFromServer(int index, Object object) {