diff --git a/src/main/java/cr0s/warpdrive/WarpDrive.java b/src/main/java/cr0s/warpdrive/WarpDrive.java index 6ba22f5c..ed8173d7 100644 --- a/src/main/java/cr0s/warpdrive/WarpDrive.java +++ b/src/main/java/cr0s/warpdrive/WarpDrive.java @@ -88,11 +88,11 @@ import cr0s.warpdrive.block.passive.BlockIridium; import cr0s.warpdrive.block.passive.BlockTransportBeacon; import cr0s.warpdrive.block.passive.ItemBlockDecorative; import cr0s.warpdrive.block.weapon.BlockLaserCamera; -import cr0s.warpdrive.command.DebugCommand; -import cr0s.warpdrive.command.GenerateCommand; -import cr0s.warpdrive.command.InvisibleCommand; -import cr0s.warpdrive.command.JumpgateCommand; -import cr0s.warpdrive.command.SpaceTpCommand; +import cr0s.warpdrive.command.CommandDebug; +import cr0s.warpdrive.command.CommandGenerate; +import cr0s.warpdrive.command.CommandInvisible; +import cr0s.warpdrive.command.CommandJumpgates; +import cr0s.warpdrive.command.CommandSpace; import cr0s.warpdrive.conf.WarpDriveConfig; import cr0s.warpdrive.data.CamerasRegistry; import cr0s.warpdrive.data.CloakManager; @@ -733,11 +733,11 @@ public class WarpDrive implements LoadingCallback { cloaks = new CloakManager(); MinecraftForge.EVENT_BUS.register(new CloakChunkWatcher()); - event.registerServerCommand(new GenerateCommand()); - event.registerServerCommand(new SpaceTpCommand()); - event.registerServerCommand(new InvisibleCommand()); - event.registerServerCommand(new JumpgateCommand()); - event.registerServerCommand(new DebugCommand()); + event.registerServerCommand(new CommandGenerate()); + event.registerServerCommand(new CommandSpace()); + event.registerServerCommand(new CommandInvisible()); + event.registerServerCommand(new CommandJumpgates()); + event.registerServerCommand(new CommandDebug()); } public Ticket registerChunkLoadTE(TileEntityAbstractChunkLoading te, boolean refreshLoading) { diff --git a/src/main/java/cr0s/warpdrive/command/DebugCommand.java b/src/main/java/cr0s/warpdrive/command/CommandDebug.java similarity index 99% rename from src/main/java/cr0s/warpdrive/command/DebugCommand.java rename to src/main/java/cr0s/warpdrive/command/CommandDebug.java index 79936ac4..f79e10ae 100644 --- a/src/main/java/cr0s/warpdrive/command/DebugCommand.java +++ b/src/main/java/cr0s/warpdrive/command/CommandDebug.java @@ -15,7 +15,7 @@ import cr0s.warpdrive.conf.WarpDriveConfig; * /wdebug */ -public class DebugCommand extends CommandBase +public class CommandDebug extends CommandBase { @Override public String getCommandName() diff --git a/src/main/java/cr0s/warpdrive/command/GenerateCommand.java b/src/main/java/cr0s/warpdrive/command/CommandGenerate.java similarity index 98% rename from src/main/java/cr0s/warpdrive/command/GenerateCommand.java rename to src/main/java/cr0s/warpdrive/command/CommandGenerate.java index 1eabd65e..4110c3f5 100644 --- a/src/main/java/cr0s/warpdrive/command/GenerateCommand.java +++ b/src/main/java/cr0s/warpdrive/command/CommandGenerate.java @@ -17,7 +17,7 @@ import cr0s.warpdrive.world.WorldGenStation; * moon, ship, asteroid, astfield, gascloud, star */ -public class GenerateCommand extends CommandBase { +public class CommandGenerate extends CommandBase { @Override public String getCommandName() { return "generate"; diff --git a/src/main/java/cr0s/warpdrive/command/InvisibleCommand.java b/src/main/java/cr0s/warpdrive/command/CommandInvisible.java similarity index 95% rename from src/main/java/cr0s/warpdrive/command/InvisibleCommand.java rename to src/main/java/cr0s/warpdrive/command/CommandInvisible.java index bb1cffc6..7eb11173 100644 --- a/src/main/java/cr0s/warpdrive/command/InvisibleCommand.java +++ b/src/main/java/cr0s/warpdrive/command/CommandInvisible.java @@ -9,7 +9,7 @@ import net.minecraft.server.MinecraftServer; import cr0s.warpdrive.WarpDrive; -public class InvisibleCommand extends CommandBase { +public class CommandInvisible extends CommandBase { @Override public int getRequiredPermissionLevel() { return 4; diff --git a/src/main/java/cr0s/warpdrive/command/JumpgateCommand.java b/src/main/java/cr0s/warpdrive/command/CommandJumpgates.java similarity index 92% rename from src/main/java/cr0s/warpdrive/command/JumpgateCommand.java rename to src/main/java/cr0s/warpdrive/command/CommandJumpgates.java index c605f0eb..7c27035c 100644 --- a/src/main/java/cr0s/warpdrive/command/JumpgateCommand.java +++ b/src/main/java/cr0s/warpdrive/command/CommandJumpgates.java @@ -5,7 +5,7 @@ import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayerMP; import cr0s.warpdrive.WarpDrive; -public class JumpgateCommand extends CommandBase { +public class CommandJumpgates extends CommandBase { @Override public int getRequiredPermissionLevel() { return 4; diff --git a/src/main/java/cr0s/warpdrive/command/SpaceTpCommand.java b/src/main/java/cr0s/warpdrive/command/CommandSpace.java similarity index 97% rename from src/main/java/cr0s/warpdrive/command/SpaceTpCommand.java rename to src/main/java/cr0s/warpdrive/command/CommandSpace.java index bd0fcaa5..9fa7a942 100644 --- a/src/main/java/cr0s/warpdrive/command/SpaceTpCommand.java +++ b/src/main/java/cr0s/warpdrive/command/CommandSpace.java @@ -13,7 +13,7 @@ import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.conf.WarpDriveConfig; import cr0s.warpdrive.world.SpaceTeleporter; -public class SpaceTpCommand extends CommandBase { +public class CommandSpace extends CommandBase { @Override public int getRequiredPermissionLevel() { return 2; diff --git a/src/main/java/cr0s/warpdrive/network/MessageBeamEffect.java b/src/main/java/cr0s/warpdrive/network/MessageBeamEffect.java new file mode 100644 index 00000000..c2d9943d --- /dev/null +++ b/src/main/java/cr0s/warpdrive/network/MessageBeamEffect.java @@ -0,0 +1,110 @@ +package cr0s.warpdrive.network; + +import net.minecraft.client.Minecraft; +import net.minecraft.world.World; +import io.netty.buffer.ByteBuf; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cr0s.warpdrive.WarpDrive; +import cr0s.warpdrive.conf.WarpDriveConfig; +import cr0s.warpdrive.data.Vector3; +import cr0s.warpdrive.render.EntityFXBeam; + + +public class MessageBeamEffect implements IMessage, IMessageHandler { + + private Vector3 source; + private Vector3 target; + private float red; + private float green; + private float blue; + private int age; + private int energy; + + public MessageBeamEffect() { + // required on receiving side + } + + public MessageBeamEffect(final Vector3 source, final Vector3 target, final float red, final float green, final float blue, final int age, final int energy) { + this.source = source; + this.target = target; + this.red = red; + this.green = green; + this.blue = blue; + this.age = age; + this.energy = energy; + } + + public MessageBeamEffect( + final double sourceX, final double sourceY, final double sourceZ, + final double targetX, final double targetY, final double targetZ, + final float red, final float green, final float blue, + final int age, final int energy) { + this.source = new Vector3(sourceX, sourceY, sourceZ); + this.target = new Vector3(targetX, targetY, targetZ); + this.red = red; + this.green = green; + this.blue = blue; + this.age = age; + this.energy = energy; + } + + @Override + public void fromBytes(ByteBuf buffer) { + double x = buffer.readDouble(); + double y = buffer.readDouble(); + double z = buffer.readDouble(); + source = new Vector3(x, y, z); + + x = buffer.readDouble(); + y = buffer.readDouble(); + z = buffer.readDouble(); + target = new Vector3(x, y, z); + + red = buffer.readFloat(); + green = buffer.readFloat(); + blue = buffer.readFloat(); + age = buffer.readByte(); + energy = buffer.readInt(); + } + + @Override + public void toBytes(ByteBuf buffer) { + buffer.writeDouble(source.x); + buffer.writeDouble(source.y); + buffer.writeDouble(source.z); + buffer.writeDouble(target.x); + buffer.writeDouble(target.y); + buffer.writeDouble(target.z); + buffer.writeFloat(red); + buffer.writeFloat(green); + buffer.writeFloat(blue); + buffer.writeByte(age); + buffer.writeInt(energy); + } + + private void handle(World worldObj) { + FMLClientHandler.instance().getClient().effectRenderer.addEffect(new EntityFXBeam(worldObj, source.clone(), target.clone(), red, green, blue, age, energy)); + } + + @Override + public IMessage onMessage(MessageBeamEffect beamEffectMessage, MessageContext context) { + // skip in case player just logged in + if (Minecraft.getMinecraft().theWorld == null) { + WarpDrive.logger.error("WorldObj is null, ignoring beam packet"); + return null; + } + + if (WarpDriveConfig.G_DEBUGMODE) { + WarpDrive.debugPrint("Received beam packet from " + beamEffectMessage.source + " to " + beamEffectMessage.target + + " as RGB " + beamEffectMessage.red + " " + beamEffectMessage.green + " " + beamEffectMessage.blue + + " age " + beamEffectMessage.age +" energy " + beamEffectMessage.energy); + } + + beamEffectMessage.handle(Minecraft.getMinecraft().theWorld); + + return null; // no response + } +} diff --git a/src/main/java/cr0s/warpdrive/network/CloakMessage.java b/src/main/java/cr0s/warpdrive/network/MessageCloak.java similarity index 94% rename from src/main/java/cr0s/warpdrive/network/CloakMessage.java rename to src/main/java/cr0s/warpdrive/network/MessageCloak.java index 930a0de5..0306dec9 100644 --- a/src/main/java/cr0s/warpdrive/network/CloakMessage.java +++ b/src/main/java/cr0s/warpdrive/network/MessageCloak.java @@ -18,10 +18,10 @@ import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.conf.WarpDriveConfig; import cr0s.warpdrive.data.Vector3; -import cr0s.warpdrive.render.FXBeam; +import cr0s.warpdrive.render.EntityFXBeam; -public class CloakMessage implements IMessage, IMessageHandler { +public class MessageCloak implements IMessage, IMessageHandler { private int minX; private int minY; private int minZ; @@ -31,11 +31,11 @@ public class CloakMessage implements IMessage, IMessageHandler { +public class MessageFrequency implements IMessage, IMessageHandler { private int x; private int y; private int z; private int frequency; - public FrequencyMessage() { + public MessageFrequency() { // required on receiving side } - public FrequencyMessage(final Vector3 target, final int frequency) { + public MessageFrequency(final Vector3 target, final int frequency) { this.x = target.intX(); this.y = target.intY(); this.z = target.intZ(); this.frequency = frequency; } - public FrequencyMessage(final int x, final int y, final int z, final int frequency) { + public MessageFrequency(final int x, final int y, final int z, final int frequency) { this.x = x; this.y = y; this.z = z; @@ -73,7 +73,7 @@ public class FrequencyMessage implements IMessage, IMessageHandler { +public class MessageTargeting implements IMessage, IMessageHandler { private int x; private int y; private int z; private float yaw; private float pitch; - public TargetingMessage() { + public MessageTargeting() { // required on receiving side } - public TargetingMessage(final Vector3 target, final float yaw, final float pitch) { + public MessageTargeting(final Vector3 target, final float yaw, final float pitch) { this.x = target.intX(); this.y = target.intY(); this.z = target.intZ(); @@ -31,7 +31,7 @@ public class TargetingMessage implements IMessage, IMessageHandler list = worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, aabb); for (Entity entity : list) { @@ -79,21 +79,21 @@ public class PacketHandler { // Monitor/Laser/Camera updating its frequency to client side public static void sendFreqPacket(int dimensionId, int xCoord, int yCoord, int zCoord, int frequency) { - FrequencyMessage frequencyMessage = new FrequencyMessage(xCoord, yCoord, zCoord, frequency); + MessageFrequency frequencyMessage = new MessageFrequency(xCoord, yCoord, zCoord, frequency); simpleNetworkManager.sendToAllAround(frequencyMessage, new TargetPoint(dimensionId, xCoord, yCoord, zCoord, 100)); WarpDrive.debugPrint("Sent frequency packet (" + xCoord + ", " + yCoord + ", " + zCoord + ") frequency " + frequency); } // LaserCamera shooting at target (client -> server) public static void sendLaserTargetingPacket(int x, int y, int z, float yaw, float pitch) { - TargetingMessage targetingMessage = new TargetingMessage(x, y, z, yaw, pitch); + MessageTargeting targetingMessage = new MessageTargeting(x, y, z, yaw, pitch); simpleNetworkManager.sendToServer(targetingMessage); WarpDrive.debugPrint("Sent targeting packet (" + x + ", " + y + ", " + z + ") yaw " + yaw + " pitch " + pitch); } // Sending cloaking area definition (server -> client) public static void sendCloakPacket(EntityPlayer player, AxisAlignedBB aabb, int tier, boolean decloak) { - CloakMessage cloakMessage = new CloakMessage(aabb, tier, decloak); + MessageCloak cloakMessage = new MessageCloak(aabb, tier, decloak); simpleNetworkManager.sendTo(cloakMessage, (EntityPlayerMP) player); WarpDrive.debugPrint("Sent cloak packet (aabb " + aabb + ") tier " + tier + " decloak " + decloak); } diff --git a/src/main/java/cr0s/warpdrive/render/CameraOverlay.java b/src/main/java/cr0s/warpdrive/render/CameraOverlay.java index 17abe670..e27e1bd3 100644 --- a/src/main/java/cr0s/warpdrive/render/CameraOverlay.java +++ b/src/main/java/cr0s/warpdrive/render/CameraOverlay.java @@ -12,8 +12,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.conf.WarpDriveConfig; -public class CameraOverlay -{ +public class CameraOverlay { private Minecraft mc; private int frameCount = 0; private static int ANIMATION_FRAMES = 200; diff --git a/src/main/java/cr0s/warpdrive/render/FXBeam.java b/src/main/java/cr0s/warpdrive/render/EntityFXBeam.java similarity index 96% rename from src/main/java/cr0s/warpdrive/render/FXBeam.java rename to src/main/java/cr0s/warpdrive/render/EntityFXBeam.java index 8174dacb..a2707bfb 100644 --- a/src/main/java/cr0s/warpdrive/render/FXBeam.java +++ b/src/main/java/cr0s/warpdrive/render/EntityFXBeam.java @@ -17,7 +17,7 @@ import cpw.mods.fml.relauncher.SideOnly; import cr0s.warpdrive.data.Vector3; @SideOnly(Side.CLIENT) -public class FXBeam extends EntityFX +public class EntityFXBeam extends EntityFX { private static ResourceLocation TEXTURE = null; @@ -40,7 +40,7 @@ public class FXBeam extends EntityFX boolean a = false; - public FXBeam(World par1World, Vector3 position, float yaw, float pitch, float red, float green, float blue, int age, int energy) + public EntityFXBeam(World par1World, Vector3 position, float yaw, float pitch, float red, float green, float blue, int age, int energy) { super(par1World, position.x, position.y, position.z, 0.0D, 0.0D, 0.0D); a = true; @@ -79,7 +79,7 @@ public class FXBeam extends EntityFX } } - public FXBeam(World par1World, Vector3 position, Vector3 target, float red, float green, float blue, int age, int energy) + public EntityFXBeam(World par1World, Vector3 position, Vector3 target, float red, float green, float blue, int age, int energy) { super(par1World, position.x, position.y, position.z, 0.0D, 0.0D, 0.0D); this.setRGB(red, green, blue);