Energy IC2/RF conversion fix, mining laser cleanup, radar initial fix

- Fixed RF consumption giving ~16x more energy than expected (core &
cloaks energy usage are back on track)
- Fixed RF consumption leak when block was almost full
- Fixed particle booster not updating it's side texture (energy level)
- Fixed mininglaser loosing items when chest is full (it'll now drops
the extras and stop the mining)
- Fixed mininglaser & radar exceptions on bad arguments from
ComputerCraft scripts
- Fixed radar to actually scan
- Fixed mininglaser logic & timings, added a warm-up phase
- Fixed mininglaser ignoring glowstone in ore-only mode
- Improved beam FX to be generic, static (missed merge) and without log
spam
- Improved laser lift to go through signs
- Improved mininglaser to show its state with right clicking and
textures
- Improved air propagation lag (20 -> 40 ticks rate)
- Updated radar to detect all cores (previously you had to have a
controller connected)
- Updated mininglaser to match BuildCraft quarry speed and power usage
- Updated mininglaser to scan in spirals instead of stripes and show the
current layer scan
- Updated mininglaser to evaporate all liquids and stop on forcefields
- Updated mininglaser to retry same layer until it's done, notably
flowing liquids
- Added integration with AdvancedRepulsionSystem
- Added mininglaser mine & stop scripts, including support for LAN wire
connected laser (just place a advanced computer next to a mining laser
and wire all others to that one)
- Added radar ping & scan scripts, very basic for now
This commit is contained in:
LemADEC 2014-07-26 16:21:48 +02:00
parent 3eaad47212
commit 4252ba7b1c
22 changed files with 823 additions and 907 deletions

View file

@ -14,7 +14,7 @@ public class BlockAir extends Block
{ {
private final boolean TRANSPARENT_AIR = true; private final boolean TRANSPARENT_AIR = true;
private final boolean AIR_DEBUG = false; private final boolean AIR_DEBUG = false;
private final int AIR_BLOCK_TICKS = 20; private final int AIR_BLOCK_TICKS = 40;
private Icon[] iconBuffer; private Icon[] iconBuffer;
public BlockAir(int par1) { public BlockAir(int par1) {

View file

@ -1,7 +1,6 @@
package cr0s.WarpDrive; package cr0s.WarpDrive;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.particle.EntityFX; import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@ -58,29 +57,8 @@ public class FXBeam extends EntityFX
this.particleMaxAge = age; this.particleMaxAge = age;
this.energy = energy; this.energy = energy;
if (red == 1 && green == 0 && blue == 0) if (red == 1 && green == 0 && blue == 0) {
{ TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_grey.png");
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_red.png");
}
else if (red == 0 && green == 1 && blue == 0)
{
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_green.png");
}
else if (red == 0 && green == 0 && blue == 1)
{
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy.png");
}
else if (red == 1 && green == 1 && blue == 0)
{
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_yellow.png");
}
else if (red == 1 && green == 0.5 && blue == 0)
{
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_orange.png");
}
else if (red == 0.5 && green == 0 && blue == 0.5)
{
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_violet.png");
} }
/** /**
@ -122,30 +100,7 @@ public class FXBeam extends EntityFX
this.particleMaxAge = age; this.particleMaxAge = age;
this.energy = energy; this.energy = energy;
if (red == 1 && green == 0 && blue == 0) TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_grey.png");
{
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_red.png");
}
else if (red == 0 && green == 1 && blue == 0)
{
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_green.png");
}
else if (red == 0 && green == 0 && blue == 1)
{
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy.png");
}
else if (red == 1 && green == 1 && blue == 0)
{
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_yellow.png");
}
else if (red == 1 && green == 0.5 && blue == 0)
{
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_orange.png");
}
else if (red == 0.5 && green == 0 && blue == 0.5)
{
TEXTURE = new ResourceLocation("warpdrive", "textures/blocks/energy_violet.png");
}
/** /**
* Sets the particle age based on distance. * Sets the particle age based on distance.

View file

@ -209,7 +209,7 @@ public class PacketHandler implements IPacketHandler
energy = inputStream.readInt(); energy = inputStream.readInt();
// Render beam // Render beam
WarpDrive.debugPrint("Received beam packet from " + source + " to " + target + " as RGB " + r + " " + g + " " + b + " age " + age +" energy " + energy); // WarpDrive.debugPrint("Received beam packet from " + source + " to " + target + " as RGB " + r + " " + g + " " + b + " age " + age +" energy " + energy);
// To avoid NPE at logging in // To avoid NPE at logging in
if (worldObj == null) if (worldObj == null)

View file

@ -5,14 +5,11 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.client.event.sound.SoundLoadEvent; import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.ForgeSubscribe;
public class SoundHandler public class SoundHandler {
{
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ForgeSubscribe @ForgeSubscribe
public void onSoundLoad(SoundLoadEvent event) public void onSoundLoad(SoundLoadEvent event) {
{ try {
try
{
System.out.println("[WarpDrive] Registering sound files..."); System.out.println("[WarpDrive] Registering sound files...");
event.manager.addSound("warpdrive:warp_4s.ogg"); event.manager.addSound("warpdrive:warp_4s.ogg");
event.manager.addSound("warpdrive:warp_10s.ogg"); event.manager.addSound("warpdrive:warp_10s.ogg");
@ -22,9 +19,7 @@ public class SoundHandler
event.manager.addSound("warpdrive:lowlaser.ogg"); event.manager.addSound("warpdrive:lowlaser.ogg");
event.manager.addSound("warpdrive:cloak.ogg"); event.manager.addSound("warpdrive:cloak.ogg");
event.manager.addSound("warpdrive:decloak.ogg"); event.manager.addSound("warpdrive:decloak.ogg");
} } catch (Exception e) {
catch (Exception e)
{
System.err.println("Failed to register sound: " + e.getLocalizedMessage()); System.err.println("Failed to register sound: " + e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -212,9 +212,11 @@ public class SpaceWorldGenerator implements IWorldGenerator
private float binomialRandom(World world) { private float binomialRandom(World world) {
float linear = world.rand.nextFloat(); float linear = world.rand.nextFloat();
// ideal sphere repartition = linear ^ 0.5 (sqrt) // ideal sphere repartition = x ^ 0.5 (sqrt)
// Dilution but slow to compute = 0.5 * ( x ^ 0.3 + 1 + (x - 1) ^ 3 ) // Dilution but slow to compute = 0.5 * ( x ^ 0.3 + 1 + (x - 1) ^ 3 )
// Optimized form = 1.25 - 0.625 / (0.5 + 2 * x) // Optimized 'pushed out' form = 1.25 - 0.625 / (0.5 + 2 * x)
// Natural sphere with ring = (1 - x ^ 2.5) * x ^ 0.5 + x ^ 4
// rectangular approach: return 0.5F * linear + 0.5F * linear * linear; // rectangular approach: return 0.5F * linear + 0.5F * linear * linear;
return 1.25F - 0.625F / (0.5F + 2.0F * linear); return 1.25F - 0.625F / (0.5F + 2.0F * linear);
} }

View file

@ -203,6 +203,14 @@ public class Vector3 implements Cloneable
return Math.sqrt(var2 * var2 + var4 * var4 + var6 * var6); return Math.sqrt(var2 * var2 + var4 * var4 + var6 * var6);
} }
public double distanceTo_square(Vector3 vector3)
{
double var2 = vector3.x - this.x;
double var4 = vector3.y - this.y;
double var6 = vector3.z - this.z;
return var2 * var2 + var4 * var4 + var6 * var6;
}
/** /**
* Multiplies the vector by negative one. * Multiplies the vector by negative one.
*/ */

View file

@ -58,13 +58,15 @@ public class WarpCoresRegistry {
public ArrayList<TileEntityReactor> searchWarpCoresInRadius(int x, int y, int z, int radius) { public ArrayList<TileEntityReactor> searchWarpCoresInRadius(int x, int y, int z, int radius) {
ArrayList<TileEntityReactor> res = new ArrayList<TileEntityReactor>(registry.size()); ArrayList<TileEntityReactor> res = new ArrayList<TileEntityReactor>(registry.size());
printRegistry();
for (TileEntityReactor c : registry) { for (TileEntityReactor c : registry) {
double d3 = c.xCoord - x; double d3 = c.xCoord - x;
double d4 = c.yCoord - y; double d4 = c.yCoord - y;
double d5 = c.zCoord - z; double d5 = c.zCoord - z;
double distance = MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5); double distance = MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5);
if (distance <= radius && !(c.controller == null || c.controller.getMode() == 0) && !isCoreHidden(c)) { // if (distance <= radius && !(c.controller == null || c.controller.getMode() == 0) && !isCoreHidden(c)) {
if (distance <= radius && !isCoreHidden(c)) {
res.add(c); res.add(c);
} }
} }
@ -87,6 +89,7 @@ public class WarpCoresRegistry {
int randomNumber = core.worldObj.rand.nextInt(150); int randomNumber = core.worldObj.rand.nextInt(150);
if (randomNumber < LOWER_HIDE_POINT + core.isolationBlocksCount) { if (randomNumber < LOWER_HIDE_POINT + core.isolationBlocksCount) {
WarpDrive.debugPrint("" + this + " Core '" + core.coreFrequency + "' is hidden");
return true; return true;
} }
} }

View file

@ -19,6 +19,8 @@ import cr0s.WarpDrive.item.*;
import cr0s.WarpDrive.machines.*; import cr0s.WarpDrive.machines.*;
import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.ComputerCraftAPI;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -29,6 +31,8 @@ import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
@ -118,7 +122,7 @@ public class WarpDrive implements LoadingCallback {
@EventHandler @EventHandler
public void preInit(FMLPreInitializationEvent event) { public void preInit(FMLPreInitializationEvent event) {
WarpDriveConfig.Init(new Configuration(event.getSuggestedConfigurationFile())); WarpDriveConfig.preInit(new Configuration(event.getSuggestedConfigurationFile()));
if (FMLCommonHandler.instance().getSide().isClient()) { if (FMLCommonHandler.instance().getSide().isClient()) {
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();
@ -149,7 +153,7 @@ public class WarpDrive implements LoadingCallback {
@EventHandler @EventHandler
public void load(FMLInitializationEvent event) { public void load(FMLInitializationEvent event) {
WarpDriveConfig.Init2(); WarpDriveConfig.load();
// CORE CONTROLLER // CORE CONTROLLER
protocolBlock = new BlockProtocol(WarpDriveConfig.controllerID,0, Material.rock); protocolBlock = new BlockProtocol(WarpDriveConfig.controllerID,0, Material.rock);
@ -689,4 +693,80 @@ public class WarpDrive implements LoadingCallback {
for (Ticket ticket : tickets) for (Ticket ticket : tickets)
ForgeChunkManager.releaseTicket(ticket); ForgeChunkManager.releaseTicket(ticket);
} }
public static void sendLaserPacket(World worldObj, Vector3 source, Vector3 dest, float r, float g, float b, int age, int energy, int radius) {
Side side = FMLCommonHandler.instance().getEffectiveSide();
if (side == Side.SERVER) {
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
DataOutputStream outputStream = new DataOutputStream(bos);
try {
// Write source vector
outputStream.writeDouble(source.x);
outputStream.writeDouble(source.y);
outputStream.writeDouble(source.z);
// Write target vector
outputStream.writeDouble(dest.x);
outputStream.writeDouble(dest.y);
outputStream.writeDouble(dest.z);
// Write r, g, b of laser
outputStream.writeFloat(r);
outputStream.writeFloat(g);
outputStream.writeFloat(b);
// Write age
outputStream.writeByte(age);
// Write energy value
outputStream.writeInt(energy);
} catch (Exception ex) {
ex.printStackTrace();
}
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = "WarpDriveBeam";
packet.data = bos.toByteArray();
packet.length = bos.size();
if (source.distanceTo_square(dest) < 3600 /* 60 * 60 */) {
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(
(source.intX() + dest.intX()) / 2, (source.intY() + dest.intY()) / 2, (source.intZ() + dest.intZ()) / 2,
radius, worldObj.provider.dimensionId, packet);
return;
}
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(
source.intX(), source.intY(), source.intZ(),
radius, worldObj.provider.dimensionId, packet);
ByteArrayOutputStream bos2 = new ByteArrayOutputStream(8);
DataOutputStream outputStream2 = new DataOutputStream(bos2);
try {
// Write source vector
outputStream2.writeDouble(source.x);
outputStream2.writeDouble(source.y);
outputStream2.writeDouble(source.z);
// Write target vector
outputStream2.writeDouble(dest.x);
outputStream2.writeDouble(dest.y);
outputStream2.writeDouble(dest.z);
// Write r, g, b of laser
outputStream2.writeFloat(r);
outputStream2.writeFloat(g);
outputStream2.writeFloat(b);
// Write age
outputStream2.writeByte(age);
// Write energy value
outputStream2.writeInt(energy);
} catch (Exception ex) {
ex.printStackTrace();
}
Packet250CustomPayload packet2 = new Packet250CustomPayload();
packet.channel = "WarpDriveBeam";
packet.data = bos.toByteArray();
packet.length = bos.size();
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(
dest.intX(), dest.intY(), dest.intZ(),
radius, worldObj.provider.dimensionId, packet);
}
}
} }

View file

@ -39,7 +39,7 @@ public class WarpDriveConfig
public static boolean isNetherOresLoaded = false; public static boolean isNetherOresLoaded = false;
public static boolean isThermalExpansionLoaded = false; public static boolean isThermalExpansionLoaded = false;
public static boolean isMetallurgyLoaded = false; public static boolean isMetallurgyLoaded = false;
public static boolean isAdvancedRepulsionSystemsLoaded = false;
/* /*
* The variables that control which recipes should be loaded * The variables that control which recipes should be loaded
@ -50,13 +50,18 @@ public class WarpDriveConfig
public static int[] IC2_Empty; public static int[] IC2_Empty;
public static int IC2_RubberWood; public static int IC2_RubberWood;
public static ItemStack IC2_Resin; public static ItemStack IC2_Resin;
public static int CC_Computer = 0, CC_peripheral = 0, CC_Floppy = 0, CCT_Turtle = 0, CCT_Upgraded = 0, CCT_Advanced = 0, GT_Ores = 0, GT_Granite = 0, GT_Machine = 0, ASP = 0, AS_Turbine = 0, ICBM_Machine = 0, ICBM_Missile = 0, MFFS_Field = 0; public static int CC_Computer = 0, CC_peripheral = 0, CC_Floppy = 0, CCT_Turtle = 0, CCT_Upgraded = 0, CCT_Advanced = 0;
public static int GT_Ores = 0, GT_Granite = 0, GT_Machine = 0;
public static int ASP = 0;
public static int AS_Turbine = 0;
public static int ICBM_Machine = 0, ICBM_Missile = 0;
public static int UB_igneousStone = 0, UB_igneousCobblestone = 0, UB_metamorphicStone = 0, UB_metamorphicCobblestone = 0, UB_sedimentaryStone = 0; public static int UB_igneousStone = 0, UB_igneousCobblestone = 0, UB_metamorphicStone = 0, UB_metamorphicCobblestone = 0, UB_sedimentaryStone = 0;
public static int NetherOres_count; public static int NetherOres_count;
public static int[] NetherOres_block; public static int[] NetherOres_block;
public static int[][] Metallurgy_overworldOresBlock; public static int[][] Metallurgy_overworldOresBlock;
public static int[][] Metallurgy_netherOresBlock; public static int[][] Metallurgy_netherOresBlock;
public static int[][] Metallurgy_endOresBlock; public static int[][] Metallurgy_endOresBlock;
public static ArrayList<Integer> forceFieldBlocks;
public static Set<Integer> SpaceHelmets, Jetpacks, MinerOres, MinerLogs, MinerLeaves, scannerIgnoreBlocks; public static Set<Integer> SpaceHelmets, Jetpacks, MinerOres, MinerLogs, MinerLeaves, scannerIgnoreBlocks;
private static Class<?> AEBlocks; private static Class<?> AEBlocks;
@ -101,17 +106,19 @@ public class WarpDriveConfig
// Mining Laser // Mining Laser
public static int ML_MAX_BOOSTERS_NUMBER = 1; public static int ML_MAX_BOOSTERS_NUMBER = 1;
public static int ML_SCAN_DELAY = 20 * 5; public static int ML_WARMUP_DELAY_TICKS = 20;
public static int ML_MINE_DELAY = 10; public static int ML_SCAN_DELAY_TICKS = 10;
public static int ML_EU_PER_LAYER_SPACE = 100; public static int ML_MINE_DELAY_TICKS = 3;
public static int ML_EU_PER_LAYER_EARTH = 2500; public static int ML_EU_PER_LAYER_SPACE = 2000;
public static int ML_EU_PER_BLOCK_SPACE = 10; public static int ML_EU_PER_LAYER_EARTH = 10000;
public static int ML_EU_PER_BLOCK_EARTH = 50; public static int ML_EU_PER_BLOCK_SPACE = 500;
public static int ML_EU_PER_BLOCK_EARTH = 2500;
public static double ML_EU_MUL_ORESONLY = 4.0;
public static double ML_EU_MUL_SILKTOUCH = 2.5; public static double ML_EU_MUL_SILKTOUCH = 2.5;
public static double ML_EU_MUL_FORTUNE = 1.5; public static double ML_EU_MUL_FORTUNE = 2.5;
public static double ML_MAX_SPEED = 10; // public static double ML_MAX_SPEED = 10;
public static double ML_MIN_SPEED = 0.1; // public static double ML_MIN_SPEED = 0.1;
public static int ML_MAX_SIZE = 128; public static int ML_MAX_RADIUS = 6;
//Tree farm //Tree farm
public static int TF_MAX_SIZE=32; public static int TF_MAX_SIZE=32;
@ -150,58 +157,44 @@ public class WarpDriveConfig
public static int CD_FIELD_REFRESH_INTERVAL_SECONDS = 10; public static int CD_FIELD_REFRESH_INTERVAL_SECONDS = 10;
public static int CD_COIL_CAPTURE_BLOCKS = 5; public static int CD_COIL_CAPTURE_BLOCKS = 5;
public static ItemStack getIC2Item(String id) public static ItemStack getIC2Item(String id) {
{
return Items.getItem(id); return Items.getItem(id);
} }
public static ItemStack getAEBlock(String id) public static ItemStack getAEBlock(String id) {
{ try {
try
{
Object ret = AEBlocks.getField(id).get(null); Object ret = AEBlocks.getField(id).get(null);
if (ret instanceof ItemStack) if (ret instanceof ItemStack)
return (ItemStack)ret; return (ItemStack)ret;
} } catch (Exception e) {
catch (Exception e)
{
WarpDrive.debugPrint("WarpDriveConfig Call getAEBlock failed for " + id); WarpDrive.debugPrint("WarpDriveConfig Call getAEBlock failed for " + id);
} }
return null; return null;
} }
public static ItemStack getAEMaterial(String id) public static ItemStack getAEMaterial(String id) {
{ try {
try
{
Object ret = AEMaterials.getField(id).get(null); Object ret = AEMaterials.getField(id).get(null);
if (ret instanceof ItemStack) if (ret instanceof ItemStack)
return (ItemStack)ret; return (ItemStack)ret;
} } catch (Exception e) {
catch (Exception e)
{
WarpDrive.debugPrint("WarpDriveConfig Call getAEMaterial failed for " + id); WarpDrive.debugPrint("WarpDriveConfig Call getAEMaterial failed for " + id);
} }
return null; return null;
} }
public static ItemStack getAEItem(String id) public static ItemStack getAEItem(String id) {
{ try {
try
{
Object ret = AEItems.getField(id).get(null); Object ret = AEItems.getField(id).get(null);
if (ret instanceof ItemStack) if (ret instanceof ItemStack)
return (ItemStack)ret; return (ItemStack)ret;
} } catch (Exception e) {
catch (Exception e)
{
WarpDrive.debugPrint("WarpDriveConfig Call getAEItem failed for " + id); WarpDrive.debugPrint("WarpDriveConfig Call getAEItem failed for " + id);
} }
return null; return null;
} }
public static void Init(Configuration configIn) public static void preInit(Configuration configIn) {
{
config = configIn; config = configIn;
} }
@ -267,17 +260,19 @@ public class WarpDriveConfig
// Mining Laser // Mining Laser
ML_MAX_BOOSTERS_NUMBER = config.get("MiningLaser", "max_boosters_number", 1).getInt(); ML_MAX_BOOSTERS_NUMBER = config.get("MiningLaser", "max_boosters_number", 1).getInt();
ML_SCAN_DELAY = 20 * config.get("MiningLaser", "scan_delay_seconds", 5).getInt(); ML_WARMUP_DELAY_TICKS = config.get("MiningLaser", "warmup_delay_ticks", 20).getInt();
ML_MINE_DELAY = config.get("MiningLaser", "mine_delay_ticks", 10).getInt(); ML_SCAN_DELAY_TICKS = config.get("MiningLaser", "scan_delay_ticks", 10).getInt();
ML_EU_PER_LAYER_SPACE = config.get("MiningLaser", "eu_per_layer_space", 100).getInt(); ML_MINE_DELAY_TICKS = config.get("MiningLaser", "mine_delay_ticks", 3).getInt();
ML_EU_PER_LAYER_EARTH = config.get("MiningLaser", "eu_per_layer_earth", 2500).getInt(); ML_EU_PER_LAYER_SPACE = config.get("MiningLaser", "eu_per_layer_space", 2000).getInt();
ML_EU_PER_BLOCK_SPACE = config.get("MiningLaser", "eu_per_block_space", 10).getInt(); ML_EU_PER_LAYER_EARTH = config.get("MiningLaser", "eu_per_layer_earth", 10000).getInt();
ML_EU_PER_BLOCK_EARTH = config.get("MiningLaser", "eu_per_block_earth", 50).getInt(); ML_EU_PER_BLOCK_SPACE = config.get("MiningLaser", "eu_per_block_space", 500).getInt();
ML_MAX_SIZE = config.get("MiningLaser", "max_size", 128).getInt(); ML_EU_PER_BLOCK_EARTH = config.get("MiningLaser", "eu_per_block_earth", 2500).getInt();
ML_MAX_RADIUS = config.get("MiningLaser", "max_radius", 5).getInt();
ML_EU_MUL_ORESONLY = config.get("MiningLaser", "oresonly_power_mul", 4.0).getDouble(4.0);
ML_EU_MUL_SILKTOUCH = config.get("MiningLaser", "silktouch_power_mul", 2.5).getDouble(2.5); ML_EU_MUL_SILKTOUCH = config.get("MiningLaser", "silktouch_power_mul", 2.5).getDouble(2.5);
ML_EU_MUL_FORTUNE = config.get("MiningLaser", "fortune_power_base", 1.5).getDouble(1.5); ML_EU_MUL_FORTUNE = config.get("MiningLaser", "fortune_power_base", 2.5).getDouble(2.5);
ML_MAX_SPEED = config.get("MiningLaser", "max_speed_mul", 10).getDouble(10); // ML_MAX_SPEED = config.get("MiningLaser", "max_speed_mul", 10).getDouble(10);
ML_MIN_SPEED = config.get("MiningLaser", "min_speed_mul", 0.1).getDouble(0.1); // ML_MIN_SPEED = config.get("MiningLaser", "min_speed_mul", 0.1).getDouble(0.1);
// Tree Farm // Tree Farm
TF_MAX_SIZE = config.get("TreeFarm", "max_treefarm_size", 16).getInt(); TF_MAX_SIZE = config.get("TreeFarm", "max_treefarm_size", 16).getInt();
@ -296,7 +291,7 @@ public class WarpDriveConfig
recipesIC2 = config.get("Recipes", "ic2_recipes",true).getBoolean(true); recipesIC2 = config.get("Recipes", "ic2_recipes",true).getBoolean(true);
} }
public static void Init2() { public static void load() {
CommonWorldGenOres = new ArrayList<int[]>(30); CommonWorldGenOres = new ArrayList<int[]>(30);
CommonWorldGenOres.add(new int[] {Block.oreIron.blockID, 0}); CommonWorldGenOres.add(new int[] {Block.oreIron.blockID, 0});
CommonWorldGenOres.add(new int[] {Block.oreGold.blockID, 0}); CommonWorldGenOres.add(new int[] {Block.oreGold.blockID, 0});
@ -305,7 +300,9 @@ public class WarpDriveConfig
CommonWorldGenOres.add(new int[] {Block.oreLapis.blockID, 0}); CommonWorldGenOres.add(new int[] {Block.oreLapis.blockID, 0});
CommonWorldGenOres.add(new int[] {Block.oreRedstoneGlowing.blockID, 0}); CommonWorldGenOres.add(new int[] {Block.oreRedstoneGlowing.blockID, 0});
CommonWorldGenOres.add(new int[] {Block.oreRedstone.blockID, 0}); CommonWorldGenOres.add(new int[] {Block.oreRedstone.blockID, 0});
//
forceFieldBlocks = new ArrayList<Integer>();
SpaceHelmets = new HashSet<Integer>(); SpaceHelmets = new HashSet<Integer>();
Jetpacks = new HashSet<Integer>(); Jetpacks = new HashSet<Integer>();
MinerOres = new HashSet<Integer>(); MinerOres = new HashSet<Integer>();
@ -398,12 +395,17 @@ public class WarpDriveConfig
loadMetallurgy(); loadMetallurgy();
} }
isAdvancedRepulsionSystemsLoaded = Loader.isModLoaded("AdvancedRepulsionSystems");
if (isAdvancedRepulsionSystemsLoaded) {
loadAdvancedRepulsionSystems();
}
// //
MinerOres.add(Block.oreNetherQuartz.blockID); MinerOres.add(Block.oreNetherQuartz.blockID);
MinerOres.add(Block.obsidian.blockID); MinerOres.add(Block.obsidian.blockID);
MinerOres.add(Block.web.blockID); MinerOres.add(Block.web.blockID);
MinerOres.add(Block.fence.blockID); MinerOres.add(Block.fence.blockID);
//MinerOres.add(Block.torchWood.blockID); MinerOres.add(Block.torchWood.blockID);
MinerOres.add(Block.glowStone.blockID);
LoadOreDict(); LoadOreDict();
// Ignore WarpDrive blocks (which potentially will be duplicated by cheaters using ship scan/deploy) // Ignore WarpDrive blocks (which potentially will be duplicated by cheaters using ship scan/deploy)
scannerIgnoreBlocks.add(coreID); scannerIgnoreBlocks.add(coreID);
@ -583,61 +585,48 @@ public class WarpDriveConfig
} }
} }
private static void loadICBM() private static void loadICBM() {
{ try {
try
{
Class<?> z = Class.forName("icbm.core.ICBMCore"); Class<?> z = Class.forName("icbm.core.ICBMCore");
CommonWorldGenOres.add(new int[] {((Block)z.getField("blockSulfurOre").get(null)).blockID, 0}); CommonWorldGenOres.add(new int[] {((Block)z.getField("blockSulfurOre").get(null)).blockID, 0});
z = Class.forName("icbm.explosion.ICBMExplosion"); z = Class.forName("icbm.explosion.ICBMExplosion");
ICBM_Machine = ((Block)z.getField("blockMachine").get(null)).blockID; ICBM_Machine = ((Block)z.getField("blockMachine").get(null)).blockID;
ICBM_Missile = ((Item)z.getField("itemMissile").get(null)).itemID; ICBM_Missile = ((Item)z.getField("itemMissile").get(null)).itemID;
} } catch (Exception e) {
catch (Exception e)
{
WarpDrive.debugPrint("WarpDriveConfig Error loading ICBM classes"); WarpDrive.debugPrint("WarpDriveConfig Error loading ICBM classes");
e.printStackTrace(); e.printStackTrace();
isICBMLoaded = false; isICBMLoaded = false;
} }
} }
private static void loadMFFS() private static void loadMFFS() {
{ try {
try
{
Class<?> z = Class.forName("mffs.ModularForceFieldSystem"); Class<?> z = Class.forName("mffs.ModularForceFieldSystem");
MFFS_Field = ((Block)z.getField("blockForceField").get(null)).blockID; int blockId = ((Block)z.getField("blockForceField").get(null)).blockID;
} forceFieldBlocks.add(blockId);
catch (Exception e) } catch (Exception e) {
{
WarpDrive.debugPrint("WarpDriveConfig Error loading MFFS classes"); WarpDrive.debugPrint("WarpDriveConfig Error loading MFFS classes");
e.printStackTrace(); e.printStackTrace();
isICBMLoaded = false; isICBMLoaded = false;
} }
} }
private static void loadGS() private static void loadGS() {
{ try {
try
{
Class<?> z = Class.forName("gravisuite.GraviSuite"); Class<?> z = Class.forName("gravisuite.GraviSuite");
if (z.getField("ultimateSolarHelmet").get(null) != null) if (z.getField("ultimateSolarHelmet").get(null) != null)
SpaceHelmets.add(((Item)z.getField("ultimateSolarHelmet").get(null)).itemID); SpaceHelmets.add(((Item)z.getField("ultimateSolarHelmet").get(null)).itemID);
Jetpacks.add(z.getField("advJetpackID").getInt(null) + 256); Jetpacks.add(z.getField("advJetpackID").getInt(null) + 256);
Jetpacks.add(z.getField("graviChestPlateID").getInt(null) + 256); Jetpacks.add(z.getField("graviChestPlateID").getInt(null) + 256);
} } catch (Exception e) {
catch (Exception e)
{
WarpDrive.debugPrint("WarpDriveConfig Error loading GS classes"); WarpDrive.debugPrint("WarpDriveConfig Error loading GS classes");
e.printStackTrace(); e.printStackTrace();
isGraviSuiteLoaded = false; isGraviSuiteLoaded = false;
} }
} }
private static void loadUndergroundBiomes() private static void loadUndergroundBiomes() {
{ try {
try
{
Class<?> z = Class.forName("exterminatorJeff.undergroundBiomes.common.UndergroundBiomes"); Class<?> z = Class.forName("exterminatorJeff.undergroundBiomes.common.UndergroundBiomes");
UB_igneousStone = ((Block)z.getField("igneousStone").get(null)).blockID; UB_igneousStone = ((Block)z.getField("igneousStone").get(null)).blockID;
UB_igneousCobblestone = ((Block)z.getField("igneousCobblestone").get(null)).blockID; UB_igneousCobblestone = ((Block)z.getField("igneousCobblestone").get(null)).blockID;
@ -645,19 +634,15 @@ public class WarpDriveConfig
UB_metamorphicCobblestone = ((Block)z.getField("metamorphicCobblestone").get(null)).blockID; UB_metamorphicCobblestone = ((Block)z.getField("metamorphicCobblestone").get(null)).blockID;
UB_sedimentaryStone = ((Block)z.getField("sedimentaryStone").get(null)).blockID; UB_sedimentaryStone = ((Block)z.getField("sedimentaryStone").get(null)).blockID;
WarpDrive.debugPrint("WarpDriveConfig found UndergroundBiomes blocks " + UB_igneousStone + ", " + UB_igneousCobblestone + ", " + UB_metamorphicStone + ", " + UB_metamorphicCobblestone + ", " + UB_sedimentaryStone); WarpDrive.debugPrint("WarpDriveConfig found UndergroundBiomes blocks " + UB_igneousStone + ", " + UB_igneousCobblestone + ", " + UB_metamorphicStone + ", " + UB_metamorphicCobblestone + ", " + UB_sedimentaryStone);
} } catch (Exception e) {
catch (Exception e)
{
WarpDrive.debugPrint("WarpDriveConfig Error loading UndergroundBiomes classes"); WarpDrive.debugPrint("WarpDriveConfig Error loading UndergroundBiomes classes");
e.printStackTrace(); e.printStackTrace();
isUndergroundBiomesLoaded = false; isUndergroundBiomesLoaded = false;
} }
} }
private static void loadNetherOres() private static void loadNetherOres() {
{ try {
try
{
NetherOres_count = 21; // FIXME: extract it properly NetherOres_count = 21; // FIXME: extract it properly
/* Class<?> z = Class.forName("powercrystals.netherores.ores.Ores"); /* Class<?> z = Class.forName("powercrystals.netherores.ores.Ores");
NO_netherOresCount = z.getField("values").get(null).length; NO_netherOresCount = z.getField("values").get(null).length;
@ -705,6 +690,18 @@ public class WarpDriveConfig
} }
} }
private static void loadAdvancedRepulsionSystems() {
try {
Class<?> z = Class.forName("mods.immibis.ars.ARSMod");
int fieldBlockId = ((Block)z.getField("MFFSFieldblock").get(null)).blockID;
forceFieldBlocks.add(fieldBlockId);
} catch (Exception e) {
System.out.println("WarpDriveConfig Error loading AdvancedRepulsionSystems classes");
e.printStackTrace();
isAdvancedRepulsionSystemsLoaded = false;
}
}
public static int[] getDefaultSurfaceBlock(Random random, boolean corrupted, boolean isMoon) { public static int[] getDefaultSurfaceBlock(Random random, boolean corrupted, boolean isMoon) {
if (isMoon) { if (isMoon) {
if (isGregLoaded && (random.nextInt(100) == 1)) { if (isGregLoaded && (random.nextInt(100) == 1)) {

View file

@ -1,5 +1,6 @@
package cr0s.WarpDrive.machines; package cr0s.WarpDrive.machines;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import cr0s.WarpDrive.WarpDrive; import cr0s.WarpDrive.WarpDrive;
@ -10,12 +11,19 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BlockMiningLaser extends BlockContainer { public class BlockMiningLaser extends BlockContainer {
private Icon[] iconBuffer; private Icon[] iconBuffer;
private final static int ICON_TOP = 5;
public final static int ICON_IDLE = 0;
public final static int ICON_MININGLOWPOWER = 1;
public final static int ICON_MININGPOWERED = 2;
public final static int ICON_SCANNINGLOWPOWER = 3;
public final static int ICON_SCANNINGPOWERED = 4;
public BlockMiningLaser(int id, int texture, Material material) { public BlockMiningLaser(int id, int texture, Material material) {
super(id, material); super(id, material);
@ -28,19 +36,26 @@ public class BlockMiningLaser extends BlockContainer {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) { public void registerIcons(IconRegister par1IconRegister) {
iconBuffer = new Icon[2]; iconBuffer = new Icon[16];
// Solid textures // Solid textures
iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:particleBoosterTopBottom"); iconBuffer[ICON_TOP ] = par1IconRegister.registerIcon("warpdrive:particleBoosterTopBottom");
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:miningLaserSide0"); iconBuffer[ICON_IDLE ] = par1IconRegister.registerIcon("warpdrive:miningLaser_idle");
iconBuffer[ICON_MININGLOWPOWER ] = par1IconRegister.registerIcon("warpdrive:miningLaser_miningLowPower");
iconBuffer[ICON_MININGPOWERED ] = par1IconRegister.registerIcon("warpdrive:miningLaser_miningPowered");
iconBuffer[ICON_SCANNINGLOWPOWER] = par1IconRegister.registerIcon("warpdrive:miningLaser_scanningLowPower");
iconBuffer[ICON_SCANNINGPOWERED ] = par1IconRegister.registerIcon("warpdrive:miningLaser_scanningPowered");
} }
@Override @Override
public Icon getIcon(int side, int metadata) { public Icon getIcon(int side, int metadata) {
if (side == 0 || side == 1) { if (side == 0 || side == 1) {
return iconBuffer[0]; return iconBuffer[ICON_TOP];
}
if (metadata < iconBuffer.length) {
return iconBuffer[metadata];
} else {
return null;
} }
return iconBuffer[1];
} }
@Override @Override
@ -63,4 +78,23 @@ public class BlockMiningLaser extends BlockContainer {
public int idDropped(int par1, Random par2Random, int par3) { public int idDropped(int par1, Random par2Random, int par3) {
return this.blockID; return this.blockID;
} }
/**
* Called upon block activation (right click on the block.)
*/
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
return false;
}
TileEntityMiningLaser miningLaser = (TileEntityMiningLaser)par1World.getBlockTileEntity(par2, par3, par4);
if (miningLaser != null && (par5EntityPlayer.getHeldItem() == null)) {
par5EntityPlayer.addChatMessage(miningLaser.getStatus());
return true;
}
return false;
}
} }

View file

@ -30,7 +30,7 @@ public class BlockParticleBooster extends BlockContainer {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) { public void registerIcons(IconRegister par1IconRegister) {
iconBuffer = new Icon[12]; iconBuffer = new Icon[16];
iconBuffer[ 0] = par1IconRegister.registerIcon("warpdrive:particleBoosterSide0"); iconBuffer[ 0] = par1IconRegister.registerIcon("warpdrive:particleBoosterSide0");
iconBuffer[ 1] = par1IconRegister.registerIcon("warpdrive:particleBoosterSide1"); iconBuffer[ 1] = par1IconRegister.registerIcon("warpdrive:particleBoosterSide1");
iconBuffer[ 2] = par1IconRegister.registerIcon("warpdrive:particleBoosterSide2"); iconBuffer[ 2] = par1IconRegister.registerIcon("warpdrive:particleBoosterSide2");

View file

@ -20,7 +20,11 @@ public class BlockRadar extends BlockContainer
{ {
private Icon[] iconBuffer; private Icon[] iconBuffer;
private final int ICON_INACTIVE_SIDE = 0, ICON_BOTTOM = 1, ICON_TOP = 2, ICON_SIDE_ACTIVATED = 3, ICON_SIDE_ACTIVATED_SCAN = 4; private final int ICON_SIDE_INACTIVE = 0;
private final int ICON_BOTTOM = 1;
private final int ICON_TOP = 2;
private final int ICON_SIDE_ACTIVATED = 3;
private final int ICON_SIDE_ACTIVATED_SCAN = 4;
public BlockRadar(int id, int texture, Material material) { public BlockRadar(int id, int texture, Material material) {
super(id, material); super(id, material);
@ -33,8 +37,8 @@ public class BlockRadar extends BlockContainer
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister) { public void registerIcons(IconRegister par1IconRegister) {
iconBuffer = new Icon[5]; iconBuffer = new Icon[16];
iconBuffer[ICON_INACTIVE_SIDE] = par1IconRegister.registerIcon("warpdrive:radarSideInactive"); iconBuffer[ICON_SIDE_INACTIVE] = par1IconRegister.registerIcon("warpdrive:radarSideInactive");
iconBuffer[ICON_BOTTOM] = par1IconRegister.registerIcon("warpdrive:contBottom"); iconBuffer[ICON_BOTTOM] = par1IconRegister.registerIcon("warpdrive:contBottom");
iconBuffer[ICON_TOP] = par1IconRegister.registerIcon("warpdrive:contTop"); iconBuffer[ICON_TOP] = par1IconRegister.registerIcon("warpdrive:contTop");
iconBuffer[ICON_SIDE_ACTIVATED] = par1IconRegister.registerIcon("warpdrive:radarSideActive"); iconBuffer[ICON_SIDE_ACTIVATED] = par1IconRegister.registerIcon("warpdrive:radarSideActive");
@ -50,14 +54,14 @@ public class BlockRadar extends BlockContainer
} }
if (metadata == 0) {// Inactive state if (metadata == 0) {// Inactive state
return iconBuffer[ICON_INACTIVE_SIDE]; return iconBuffer[ICON_SIDE_INACTIVE];
} else if (metadata == 1) { // Attached state } else if (metadata == 1) { // Attached state
return iconBuffer[ICON_SIDE_ACTIVATED]; return iconBuffer[ICON_SIDE_ACTIVATED];
} else if (metadata == 2) { // Scanning state } else if (metadata == 2) { // Scanning state
return iconBuffer[ICON_SIDE_ACTIVATED_SCAN]; return iconBuffer[ICON_SIDE_ACTIVATED_SCAN];
} }
return iconBuffer[ICON_INACTIVE_SIDE]; return iconBuffer[ICON_SIDE_INACTIVE];
} }
@Override @Override

View file

@ -13,51 +13,4 @@ import cr0s.WarpDrive.WarpDrive;
public abstract class TileEntityAbstractLaser extends WarpChunkTE public abstract class TileEntityAbstractLaser extends WarpChunkTE
{ {
protected void sendLaserPacket(Vector3 source, Vector3 dest, float r, float g, float b, int age, int energy, int radius)
{
Side side = FMLCommonHandler.instance().getEffectiveSide();
if (side == Side.SERVER)
{
WarpDrive.debugPrint("laser:" + source + ":" + dest + ":" + r + ":" + g + ":" + b + ":" + age);
if (source == null || dest == null || worldObj == null)
{
return;
}
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
DataOutputStream outputStream = new DataOutputStream(bos);
try
{
// Write source vector
outputStream.writeDouble(source.x);
outputStream.writeDouble(source.y);
outputStream.writeDouble(source.z);
// Write target vector
outputStream.writeDouble(dest.x);
outputStream.writeDouble(dest.y);
outputStream.writeDouble(dest.z);
// Write r, g, b of laser
outputStream.writeFloat(r);
outputStream.writeFloat(g);
outputStream.writeFloat(b);
// Write age
outputStream.writeByte(age);
// Write energy value
outputStream.writeInt(0);
}
catch (Exception ex)
{
ex.printStackTrace();
}
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = "WarpDriveBeam";
packet.data = bos.toByteArray();
packet.length = bos.size();
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(source.intX(), source.intY(), source.intZ(), radius, worldObj.provider.dimensionId, packet);
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(dest.intX(), dest.intY(), dest.intZ(), radius, worldObj.provider.dimensionId, packet);
}
}
} }

View file

@ -12,8 +12,8 @@ import appeng.api.me.tiles.IGridMachine;
import appeng.api.me.tiles.ITileCable; import appeng.api.me.tiles.ITileCable;
import appeng.api.me.util.IGridInterface; import appeng.api.me.util.IGridInterface;
import appeng.api.me.util.IMEInventoryHandler; import appeng.api.me.util.IMEInventoryHandler;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockFluid;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -22,6 +22,7 @@ import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import cr0s.WarpDrive.Vector3; import cr0s.WarpDrive.Vector3;
import cr0s.WarpDrive.WarpDrive;
import cr0s.WarpDrive.WarpDriveConfig; import cr0s.WarpDrive.WarpDriveConfig;
public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser implements IGridMachine, ITileCable public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser implements IGridMachine, ITileCable
@ -195,12 +196,29 @@ public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser im
return false; return false;
} }
protected boolean canDig(int blockID) private boolean canDig(int blockID, int x, int y, int z) {// not used
{ // ignore air & fluids
if (Block.blocksList[blockID] != null) if (!WarpDriveConfig.isAirBlock(worldObj, blockID, x, y, z) && Block.blocksList[blockID] != null && !(Block.blocksList[blockID] instanceof BlockFluid)) {
return ((blockID == WarpDriveConfig.GT_Granite || blockID == WarpDriveConfig.GT_Ores || blockID == WarpDriveConfig.iridiumID || Block.blocksList[blockID].blockResistance <= Block.obsidian.blockResistance) && blockID != WarpDriveConfig.MFFS_Field && blockID != Block.bedrock.blockID); return false;
else }
return (blockID != WarpDriveConfig.MFFS_Field && blockID != Block.bedrock.blockID); // check blacklist
if (blockID == Block.bedrock.blockID) {
return false;
}
if (WarpDriveConfig.forceFieldBlocks.contains(blockID)) {
// isMining = false;
return false;
}
// check whitelist
// WarpDriveConfig.i.MinerOres.contains(blockID) then true ?
else if (blockID == WarpDriveConfig.GT_Granite || blockID == WarpDriveConfig.GT_Ores || blockID == WarpDriveConfig.iridiumID) {
return true;
}
// check default
else if ( (Block.blocksList[blockID] != null) && (Block.blocksList[blockID].blockResistance <= Block.obsidian.blockResistance) ) {
return true;
}
return false;
} }
//MINING FUNCTIONS //MINING FUNCTIONS
@ -211,7 +229,7 @@ public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser im
float r = getColorR(); float r = getColorR();
float g = getColorG(); float g = getColorG();
float b = getColorB(); float b = getColorB();
sendLaserPacket(minerVector, valuable.clone().translate(0.5), r, g, b, 2 * WarpDriveConfig.ML_MINE_DELAY, 0, 50); WarpDrive.sendLaserPacket(worldObj, minerVector, valuable.clone().translate(0.5D), r, g, b, 2 * WarpDriveConfig.ML_MINE_DELAY_TICKS, 0, 50);
//worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F); //worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F);
} }

View file

@ -132,7 +132,7 @@ public class TileEntityLaser extends WarpTE implements IPeripheral {
return; return;
} }
Vector3 beamVector = new Vector3(this).add(0.5); Vector3 beamVector = new Vector3(this).translate(0.5D);
System.out.println("beamVector: " + beamVector); System.out.println("beamVector: " + beamVector);
float yawz = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI); float yawz = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
float yawx = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI); float yawx = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI);
@ -155,7 +155,7 @@ public class TileEntityLaser extends WarpTE implements IPeripheral {
firstHit = worldObj.rayTraceBlocks_do_do(beamVector.toVec3(), reachPoint.toVec3(), false, false); firstHit = worldObj.rayTraceBlocks_do_do(beamVector.toVec3(), reachPoint.toVec3(), false, false);
if (firstHit != null) { if (firstHit != null) {
sendLaserPacket(beamVector, new Vector3(firstHit), r, g, b, 50, energy, 200); WarpDrive.sendLaserPacket(worldObj, beamVector, new Vector3(firstHit), r, g, b, 50, energy, 200);
} }
return; return;
} }
@ -246,7 +246,7 @@ public class TileEntityLaser extends WarpTE implements IPeripheral {
} }
} }
sendLaserPacket(beamVector, endPoint, r, g, b, 50, energy, beamLengthBlocks); WarpDrive.instance.sendLaserPacket(worldObj, beamVector, endPoint, r, g, b, 50, energy, beamLengthBlocks);
} }
public MovingObjectPosition raytraceEntities(Vector3 beamVec, Vector3 lookVec, boolean collisionFlag, double reachDistance) { public MovingObjectPosition raytraceEntities(Vector3 beamVec, Vector3 lookVec, boolean collisionFlag, double reachDistance) {
@ -379,72 +379,6 @@ public class TileEntityLaser extends WarpTE implements IPeripheral {
return null; return null;
} }
public void sendLaserPacket(Vector3 source, Vector3 dest, float r, float g, float b, int age, int energy, int radius) {
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
DataOutputStream outputStream = new DataOutputStream(bos);
try {
// Write source vector
outputStream.writeDouble(source.x);
outputStream.writeDouble(source.y);
outputStream.writeDouble(source.z);
// Write target vector
outputStream.writeDouble(dest.x);
outputStream.writeDouble(dest.y);
outputStream.writeDouble(dest.z);
// Write r, g, b of laser
outputStream.writeFloat(r);
outputStream.writeFloat(g);
outputStream.writeFloat(b);
// Write age
outputStream.writeByte(age);
// Write energy value
outputStream.writeInt(energy);
} catch (Exception e) {
e.printStackTrace();
}
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = "WarpDriveBeam";
packet.data = bos.toByteArray();
packet.length = bos.size();
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(source.intX(), source.intY(), source.intZ(), radius, worldObj.provider.dimensionId, packet);
WarpDrive.debugPrint("" + this + " Packet '" + packet.channel + "' sent around source");
ByteArrayOutputStream bos2 = new ByteArrayOutputStream(8);
DataOutputStream outputStream2 = new DataOutputStream(bos2);
try {
// Write source vector
outputStream2.writeDouble(source.x);
outputStream2.writeDouble(source.y);
outputStream2.writeDouble(source.z);
// Write target vector
outputStream2.writeDouble(dest.x);
outputStream2.writeDouble(dest.y);
outputStream2.writeDouble(dest.z);
// Write r, g, b of laser
outputStream2.writeFloat(r);
outputStream2.writeFloat(g);
outputStream2.writeFloat(b);
// Write age
outputStream2.writeByte(age);
// Write energy value
outputStream2.writeInt(energy);
} catch (Exception e) {
e.printStackTrace();
}
Packet250CustomPayload packet2 = new Packet250CustomPayload();
packet.channel = "WarpDriveBeam";
packet.data = bos.toByteArray();
packet.length = bos.size();
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(dest.intX(), dest.intY(), dest.intZ(), radius, worldObj.provider.dimensionId, packet);
WarpDrive.debugPrint("" + this + " Packet '" + packet.channel + "' sent around destination");
}
}
private void playSoundCorrespondsEnergy(int energy) { private void playSoundCorrespondsEnergy(int energy) {
if (energy <= 500000) { if (energy <= 500000) {
worldObj.playSoundEffect(xCoord + 0.5f, yCoord - 0.5f, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F); worldObj.playSoundEffect(xCoord + 0.5f, yCoord - 0.5f, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F);

View file

@ -110,7 +110,7 @@ public class TileEntityLaserReactorMonitor extends TileEntityAbstractLaser {
if(coolReactor(react)) if(coolReactor(react))
{ {
TileEntity te = (TileEntity)o; TileEntity te = (TileEntity)o;
sendLaserPacket(myPos,new Vector3(te.xCoord,te.yCoord,te.zCoord).translate(0.5),0f,0.8f,1f,20,0,20); WarpDrive.sendLaserPacket(worldObj, myPos, new Vector3(te.xCoord,te.yCoord,te.zCoord).translate(0.5D), 0f, 0.8f, 1f, 20, 0, 20);
} }
} }
} }

View file

@ -63,23 +63,21 @@ public class TileEntityLift extends WarpEnergyTE {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, mode, 2); // current mode worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, mode, 2); // current mode
// Launch a beam: search non-air blocks under lift // Launch a beam: search non-air blocks under lift
for (int ny = yCoord - 1; ny > 0; ny--) for (int ny = yCoord - 1; ny > 0; ny--) {
{ int blockId = worldObj.getBlockId(xCoord, ny, zCoord);
if (!worldObj.isAirBlock(xCoord, ny, zCoord)) // 63 & 68 = signs
{ if (blockId != 0 && blockId != 63 && blockId != 68 && !WarpDriveConfig.isAirBlock(worldObj, blockId, xCoord, ny, zCoord)) {
firstUncoveredY = ny; firstUncoveredY = ny;
break; break;
} }
} }
if (yCoord - firstUncoveredY > 0) if (yCoord - firstUncoveredY > 0) {
if (mode == 1) if (mode == 1) {
{ WarpDrive.instance.sendLaserPacket(worldObj, new Vector3(this).translate(0.5D), new Vector3(xCoord, firstUncoveredY, zCoord).translate(0.5D), 0f, 1f, 0f, 40, 0, 100);
sendLaserPacket(new Vector3(this).add(0.5), new Vector3(xCoord, firstUncoveredY, zCoord).add(0.5), 0f, 1f, 0f, 40, 0, 100); } else if (mode == 2) {
WarpDrive.instance.sendLaserPacket(worldObj, new Vector3(this).translate(0.5D), new Vector3(xCoord, firstUncoveredY, zCoord).translate(0.5D), 0f, 0f, 1f, 40, 0, 100);
} }
else if (mode == 2)
{
sendLaserPacket(new Vector3(this).add(0.5), new Vector3(xCoord, firstUncoveredY, zCoord).add(0.5), 0f, 0f, 1f, 40, 0, 100);
} }
liftEntity(); liftEntity();
@ -132,7 +130,7 @@ public class TileEntityLift extends WarpEnergyTE {
if (o != null && o instanceof EntityLivingBase) if (o != null && o instanceof EntityLivingBase)
{ {
((EntityLivingBase)o).setPositionAndUpdate(xCoord + 0.5f, yCoord + 1, zCoord + 0.5f); ((EntityLivingBase)o).setPositionAndUpdate(xCoord + 0.5f, yCoord + 1, zCoord + 0.5f);
sendLaserPacket(new Vector3(this).add(0.5), new Vector3(xCoord, firstUncoveredY, zCoord).add(0.5), 1, 1, 0, 40, 0, 100); WarpDrive.sendLaserPacket(worldObj, new Vector3(this).translate(0.5), new Vector3(xCoord, firstUncoveredY, zCoord).translate(0.5), 1F, 1F, 0F, 40, 0, 100);
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:hilaser", 4F, 1F); worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:hilaser", 4F, 1F);
consumeAllEnergy(); consumeAllEnergy();
return; return;
@ -152,7 +150,7 @@ public class TileEntityLift extends WarpEnergyTE {
if (o != null && o instanceof EntityLivingBase) if (o != null && o instanceof EntityLivingBase)
{ {
((EntityLivingBase)o).setPositionAndUpdate(xCoord + 0.5f, firstUncoveredY + 1, zCoord + 0.5f); ((EntityLivingBase)o).setPositionAndUpdate(xCoord + 0.5f, firstUncoveredY + 1, zCoord + 0.5f);
sendLaserPacket(new Vector3(this).add(0.5), new Vector3(xCoord, firstUncoveredY + 1, zCoord).add(0.5), 1, 1, 0, 40, 0, 100); WarpDrive.sendLaserPacket(worldObj, new Vector3(this).translate(0.5), new Vector3(xCoord, firstUncoveredY + 1, zCoord).translate(0.5), 1F, 1F, 0F, 40, 0, 100);
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:hilaser", 4F, 1F); worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:hilaser", 4F, 1F);
consumeAllEnergy(); consumeAllEnergy();
return; return;
@ -162,79 +160,6 @@ public class TileEntityLift extends WarpEnergyTE {
} }
} }
public void sendLaserPacket(Vector3 source, Vector3 dest, float r, float g, float b, int age, int energy, int radius)
{
Side side = FMLCommonHandler.instance().getEffectiveSide();
if (side == Side.SERVER)
{
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
DataOutputStream outputStream = new DataOutputStream(bos);
try
{
// Write source vector
outputStream.writeDouble(source.x);
outputStream.writeDouble(source.y);
outputStream.writeDouble(source.z);
// Write target vector
outputStream.writeDouble(dest.x);
outputStream.writeDouble(dest.y);
outputStream.writeDouble(dest.z);
// Write r, g, b of laser
outputStream.writeFloat(r);
outputStream.writeFloat(g);
outputStream.writeFloat(b);
// Write age
outputStream.writeByte(age);
// Write energy value
outputStream.writeInt(energy);
}
catch (Exception ex)
{
ex.printStackTrace();
}
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = "WarpDriveBeam";
packet.data = bos.toByteArray();
packet.length = bos.size();
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(source.intX(), source.intY(), source.intZ(), radius, worldObj.provider.dimensionId, packet);
ByteArrayOutputStream bos2 = new ByteArrayOutputStream(8);
DataOutputStream outputStream2 = new DataOutputStream(bos2);
try
{
// Write source vector
outputStream2.writeDouble(source.x);
outputStream2.writeDouble(source.y);
outputStream2.writeDouble(source.z);
// Write target vector
outputStream2.writeDouble(dest.x);
outputStream2.writeDouble(dest.y);
outputStream2.writeDouble(dest.z);
// Write r, g, b of laser
outputStream2.writeFloat(r);
outputStream2.writeFloat(g);
outputStream2.writeFloat(b);
// Write age
outputStream2.writeByte(age);
// Write energy value
outputStream2.writeInt(energy);
}
catch (Exception ex)
{
ex.printStackTrace();
}
Packet250CustomPayload packet2 = new Packet250CustomPayload();
packet.channel = "WarpDriveBeam";
packet.data = bos.toByteArray();
packet.length = bos.size();
MinecraftServer.getServer().getConfigurationManager().sendToAllNear(dest.intX(), dest.intY(), dest.intZ(), radius, worldObj.provider.dimensionId, packet);
}
}
@Override @Override
public void readFromNBT(NBTTagCompound tag) public void readFromNBT(NBTTagCompound tag)
{ {

File diff suppressed because it is too large Load diff

View file

@ -28,9 +28,9 @@ public class TileEntityParticleBooster extends WarpEnergyTE {
super.updateEntity(); super.updateEntity();
ticks++; ticks++;
if (ticks > 40) { if (ticks > 20) {
ticks = 0; ticks = 0;
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, Math.min(0, Math.max(10, (getEnergyStored() * 10) / WarpDriveConfig.PB_MAX_ENERGY_VALUE)), 2); worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, Math.max(0, Math.min(10, Math.round((getEnergyStored() * 10) / WarpDriveConfig.PB_MAX_ENERGY_VALUE))), 2);
} }
} }

View file

@ -3,6 +3,7 @@ package cr0s.WarpDrive.machines;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
@ -43,20 +44,19 @@ public class TileEntityRadar extends WarpEnergyTE implements IPeripheral {
} }
super.updateEntity(); super.updateEntity();
try try {
{
if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 2) { if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 2) {
if (cooldownTime++ > (20 * ((scanRadius / 1000) + 1))) { cooldownTime++;
//System.out.println("Scanning..."); if (cooldownTime > (20 * ((scanRadius / 1000) + 1))) {
WarpDrive.debugPrint("" + this + " Scanning over " + scanRadius + " radius...");
WarpDrive.instance.warpCores.removeDeadCores(); WarpDrive.instance.warpCores.removeDeadCores();
results = WarpDrive.instance.warpCores.searchWarpCoresInRadius(xCoord, yCoord, zCoord, scanRadius); results = WarpDrive.instance.warpCores.searchWarpCoresInRadius(xCoord, yCoord, zCoord, scanRadius);
WarpDrive.debugPrint("" + this + " Scan found " + results.size() + " results");
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 + 2); worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 + 2);
cooldownTime = 0; cooldownTime = 0;
} }
} }
} } catch (Exception e) {
catch (Exception e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -73,22 +73,18 @@ public class TileEntityRadar extends WarpEnergyTE implements IPeripheral {
// IPeripheral methods implementation // IPeripheral methods implementation
@Override @Override
public String getType() public String getType() {
{
return "radar"; return "radar";
} }
@Override @Override
public String[] getMethodNames() public String[] getMethodNames() {
{
return methodsArray; return methodsArray;
} }
@Override @Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
{ switch (method) {
switch (method)
{
case 0: // scanRay (toX, toY, toZ) case 0: // scanRay (toX, toY, toZ)
return new Object[] { -1 }; return new Object[] { -1 };
@ -96,13 +92,19 @@ public class TileEntityRadar extends WarpEnergyTE implements IPeripheral {
if (arguments.length != 1) { if (arguments.length != 1) {
return new Boolean[] { false }; return new Boolean[] { false };
} }
int radius = ((Double)arguments[0]).intValue(); int radius;
if (radius <= 0 || radius > 10000) try {
{ radius = ((Double)arguments[0]).intValue();
scanRadius = 0; } catch(Exception e) {
return new Boolean[] { false }; return new Boolean[] { false };
} }
if (radius == 0 || !consumeEnergy(radius * radius, false)) {
if (radius <= 0 || radius > 10000) {
scanRadius = 0;
results = null;
return new Boolean[] { false };
}
if (!consumeEnergy(Math.max(radius, 100) * Math.max(radius, 100), false)) {
results = null; results = null;
return new Boolean[] { false }; return new Boolean[] { false };
} }
@ -110,20 +112,25 @@ public class TileEntityRadar extends WarpEnergyTE implements IPeripheral {
// Begin searching // Begin searching
scanRadius = radius; scanRadius = radius;
cooldownTime = 0; cooldownTime = 0;
results = null;
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 2, 1 + 2); worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 2, 1 + 2);
return new Boolean[] { true }; return new Boolean[] { true };
case 2: // getResultsCount case 2: // getResultsCount
if (results != null) if (results != null) {
return new Integer[] { results.size() }; return new Integer[] { results.size() };
}
return new Integer[] { 0 }; return new Integer[] { 0 };
case 3: // getResult case 3: // getResult
if (arguments.length == 1 && (results != null)) if (arguments.length == 1 && (results != null)) {
{ int index;
int index = ((Double)arguments[0]).intValue(); try {
if (index > -1 && index < results.size()) index = ((Double)arguments[0]).intValue();
{ } catch(Exception e) {
return new Object[] { (String)"FAIL", 0, 0, 0 };
}
if (index >= 0 && index < results.size()) {
TileEntityReactor res = results.get(index); TileEntityReactor res = results.get(index);
if (res != null) if (res != null)
{ {
@ -146,12 +153,17 @@ public class TileEntityRadar extends WarpEnergyTE implements IPeripheral {
@Override @Override
public void attach(IComputerAccess computer) { public void attach(IComputerAccess computer) {
computer.mount("/radar", ComputerCraftAPI.createResourceMount(WarpDrive.class, "warpdrive", "lua/radar"));
computer.mount("/scan", ComputerCraftAPI.createResourceMount(WarpDrive.class, "warpdrive", "lua/radar/scan"));
computer.mount("/ping", ComputerCraftAPI.createResourceMount(WarpDrive.class, "warpdrive", "lua/radar/ping"));
if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 0) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 + 2); worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 1 + 2);
} }
}
@Override @Override
public void detach(IComputerAccess computer) { public void detach(IComputerAccess computer) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 + 2); // worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 1 + 2);
} }
@Override @Override

View file

@ -97,9 +97,9 @@ public class TileEntityShipScanner extends WarpEnergyTE implements IPeripheral {
if (state == 0) { // inactive if (state == 0) { // inactive
if (++laserTicks > 20) { if (++laserTicks > 20) {
sendLaserPacket(new Vector3(this).add(0.5), new Vector3( WarpDrive.sendLaserPacket(worldObj,
core.xCoord, core.yCoord, core.zCoord).add(0.5), 0f, new Vector3(this).translate(0.5D), new Vector3(core.xCoord, core.yCoord, core.zCoord).translate(0.5D),
1f, 0f, 40, 0, 100); 0f, 1f, 0f, 40, 0, 100);
laserTicks = 0; laserTicks = 0;
} }
} else if (state == 1 && !isDeploying) { // active: scanning } else if (state == 1 && !isDeploying) { // active: scanning
@ -145,7 +145,7 @@ public class TileEntityShipScanner extends WarpEnergyTE implements IPeripheral {
g = 0f; g = 0f;
} }
sendLaserPacket(new Vector3(this).add(0.5), new Vector3(x, core.maxY, randomZ).add(0.5), r, g, b, 15, 0, 100); WarpDrive.sendLaserPacket(worldObj, new Vector3(this).translate(0.5D), new Vector3(x, core.maxY, randomZ).translate(0.5D), r, g, b, 15, 0, 100);
} }
} }
@ -187,9 +187,10 @@ public class TileEntityShipScanner extends WarpEnergyTE implements IPeripheral {
if (worldObj.rand.nextInt(100) <= 10) { if (worldObj.rand.nextInt(100) <= 10) {
worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F); worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F);
sendLaserPacket(new Vector3(this).add(0.5), new Vector3( WarpDrive.sendLaserPacket(worldObj,
newX + block.x, newY + block.y, newZ + block.z).add(0.5), 0f, new Vector3(this).translate(0.5D),
1f, 0f, 15, 0, 100); new Vector3(newX + block.x, newY + block.y, newZ + block.z).translate(0.5D),
0f, 1f, 0f, 15, 0, 100);
} }
} }
@ -226,80 +227,6 @@ public class TileEntityShipScanner extends WarpEnergyTE implements IPeripheral {
return result; return result;
} }
public void sendLaserPacket(Vector3 source, Vector3 dest, float r, float g,
float b, int age, int energy, int radius) {
Side side = FMLCommonHandler.instance().getEffectiveSide();
if (side == Side.SERVER) {
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
DataOutputStream outputStream = new DataOutputStream(bos);
try {
// Write source vector
outputStream.writeDouble(source.x);
outputStream.writeDouble(source.y);
outputStream.writeDouble(source.z);
// Write target vector
outputStream.writeDouble(dest.x);
outputStream.writeDouble(dest.y);
outputStream.writeDouble(dest.z);
// Write r, g, b of laser
outputStream.writeFloat(r);
outputStream.writeFloat(g);
outputStream.writeFloat(b);
// Write age
outputStream.writeByte(age);
// Write energy value
outputStream.writeInt(energy);
} catch (Exception ex) {
ex.printStackTrace();
}
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = "WarpDriveBeam";
packet.data = bos.toByteArray();
packet.length = bos.size();
MinecraftServer
.getServer()
.getConfigurationManager()
.sendToAllNear(source.intX(), source.intY(), source.intZ(),
radius, worldObj.provider.dimensionId, packet);
ByteArrayOutputStream bos2 = new ByteArrayOutputStream(8);
DataOutputStream outputStream2 = new DataOutputStream(bos2);
try {
// Write source vector
outputStream2.writeDouble(source.x);
outputStream2.writeDouble(source.y);
outputStream2.writeDouble(source.z);
// Write target vector
outputStream2.writeDouble(dest.x);
outputStream2.writeDouble(dest.y);
outputStream2.writeDouble(dest.z);
// Write r, g, b of laser
outputStream2.writeFloat(r);
outputStream2.writeFloat(g);
outputStream2.writeFloat(b);
// Write age
outputStream2.writeByte(age);
// Write energy value
outputStream2.writeInt(energy);
} catch (Exception ex) {
ex.printStackTrace();
}
Packet250CustomPayload packet2 = new Packet250CustomPayload();
packet.channel = "WarpDriveBeam";
packet.data = bos.toByteArray();
packet.length = bos.size();
MinecraftServer
.getServer()
.getConfigurationManager()
.sendToAllNear(dest.intX(), dest.intY(), dest.intZ(),
radius, worldObj.provider.dimensionId, packet);
}
}
private void saveShipToSchematic(String fileName) { private void saveShipToSchematic(String fileName) {
NBTTagCompound schematic = new NBTTagCompound("Schematic"); NBTTagCompound schematic = new NBTTagCompound("Schematic");

View file

@ -12,12 +12,11 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
public abstract class WarpEnergyTE extends WarpTE implements IEnergyHandler, IEnergySink public abstract class WarpEnergyTE extends WarpTE implements IEnergyHandler, IEnergySink {
{
protected boolean addedToEnergyNet = false; protected boolean addedToEnergyNet = false;
protected int energyStored_internal = 0; protected int energyStored_internal = 0;
private final double INTERNAL_TO_EU = 1.0D; private static final double EU_PER_INTERNAL = 1.0D;
private final double INTERNAL_TO_RF = 437.5D / 1800.0D; private static final double RF_PER_INTERNAL = 1800.0D / 437.5D;
// WarpDrive methods // WarpDrive methods
public int getEnergyStored() { public int getEnergyStored() {
@ -92,20 +91,20 @@ public abstract class WarpEnergyTE extends WarpTE implements IEnergyHandler, IEn
// IndustrialCraft overrides // IndustrialCraft overrides
@Override @Override
public double demandedEnergyUnits() { public double demandedEnergyUnits() {
return Math.max(0.0D, getMaxEnergyStored() - energyStored_internal) * INTERNAL_TO_EU; return Math.max(0.0D, getMaxEnergyStored() - energyStored_internal) * EU_PER_INTERNAL;
} }
@Override @Override
public double injectEnergyUnits(ForgeDirection directionFrom, double amount) { public double injectEnergyUnits(ForgeDirection directionFrom, double amount) {
double leftover = 0; double leftover = 0;
energyStored_internal += Math.round(amount) / INTERNAL_TO_EU; energyStored_internal += Math.round(amount) / EU_PER_INTERNAL;
if (energyStored_internal > getMaxEnergyStored()) { if (energyStored_internal > getMaxEnergyStored()) {
leftover = (energyStored_internal - getMaxEnergyStored()); leftover = (energyStored_internal - getMaxEnergyStored());
energyStored_internal = getMaxEnergyStored(); energyStored_internal = getMaxEnergyStored();
} }
return leftover * INTERNAL_TO_EU; return leftover * EU_PER_INTERNAL;
} }
@Override @Override
@ -121,24 +120,25 @@ public abstract class WarpEnergyTE extends WarpTE implements IEnergyHandler, IEn
// ThermalExpansion overrides // ThermalExpansion overrides
@Override @Override
public int getEnergyStored(ForgeDirection from) { public int getEnergyStored(ForgeDirection from) {
return (int)(getEnergyStored() * INTERNAL_TO_RF); return (int)Math.round(getEnergyStored() * RF_PER_INTERNAL);
} }
@Override @Override
public int getMaxEnergyStored(ForgeDirection from) { public int getMaxEnergyStored(ForgeDirection from) {
return (int)(getMaxEnergyStored() * INTERNAL_TO_RF); return (int)Math.round(getMaxEnergyStored() * RF_PER_INTERNAL);
} }
@Override @Override
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
int maxStored = (int)(getMaxEnergyStored() * INTERNAL_TO_RF); int maxStored = getMaxEnergyStored(from);
if (maxStored == 0) { if (maxStored == 0) {
return 0; return 0;
} }
int energyStored = getEnergyStored(from);
int toAdd = Math.min(maxReceive, maxStored - (int)(getEnergyStored() * INTERNAL_TO_RF)); int toAdd = Math.min(maxReceive, maxStored - energyStored);
if (!simulate) { if (!simulate) {
energyStored_internal += toAdd / INTERNAL_TO_RF; energyStored_internal = (int)Math.min(getMaxEnergyStored(), energyStored_internal + toAdd / RF_PER_INTERNAL);
} }
return toAdd; return toAdd;