Code cleanup (mostly imports)

This commit is contained in:
LemADEC 2017-02-23 21:46:38 +01:00
parent e37a0a3afd
commit 4cbc277de1
213 changed files with 2022 additions and 1574 deletions

View file

@ -1,12 +1,16 @@
package cr0s.warpdrive;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.registry.EntityRegistry;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.entity.EntityParticleBunch;
import cr0s.warpdrive.render.EntityCamera;
import cr0s.warpdrive.world.EntitySphereGen;
import cr0s.warpdrive.world.EntityStarCore;
import java.lang.ref.WeakReference;
import java.util.UUID;
import java.util.WeakHashMap;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@ -15,16 +19,15 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.WorldSettings;
import cpw.mods.fml.common.registry.EntityRegistry;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.event.world.BlockEvent;
import java.lang.ref.WeakReference;
import java.util.UUID;
import java.util.WeakHashMap;
public abstract class CommonProxy {
public class CommonProxy {
private static final WeakHashMap<GameProfile, WeakReference<EntityPlayer>> fakePlayers = new WeakHashMap<>(100);
void registerEntities() {

View file

@ -0,0 +1,278 @@
package cr0s.warpdrive;
import cr0s.warpdrive.data.VectorI;
import net.minecraft.block.Block;
import net.minecraft.command.ICommandSender;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Common static methods
*/
public class Commons {
public static void addChatMessage(final ICommandSender sender, final String message) {
if (sender == null) {
WarpDrive.logger.error("Unable to send message to NULL sender: " + message);
return;
}
String[] lines = message.replace("§", "" + (char)167).replace("\\n", "\n").replaceAll("\u00A0", " ").split("\n");
for (String line : lines) {
sender.addChatMessage(new ChatComponentText(line));
}
// logger.info(message);
}
// add tooltip information with text formatting and line splitting
// will ensure it fits on minimum screen width
public static void addTooltip(List<String> list, String tooltip) {
final String charFormatting = "" + (char)167;
tooltip = tooltip.replace("§", charFormatting).replace("\\n", "\n").replace("|", "\n");
tooltip = tooltip.replace(charFormatting + "r", charFormatting + "7");
String[] split = tooltip.split("\n");
for (String line : split) {
String lineRemaining = line;
String formatNextLine = "";
while (!lineRemaining.isEmpty()) {
int indexToCut = formatNextLine.length();
int displayLength = 0;
int length = lineRemaining.length();
while (indexToCut < length && displayLength <= 38) {
if (lineRemaining.charAt(indexToCut) == (char)167 && indexToCut + 1 < length) {
indexToCut++;
} else {
displayLength++;
}
indexToCut++;
}
if (indexToCut < length) {
indexToCut = lineRemaining.substring(0, indexToCut).lastIndexOf(' ');
if (indexToCut == -1 || indexToCut == 0) {// no space available, show the whole line 'as is'
list.add(lineRemaining);
lineRemaining = "";
} else {// cut at last space
list.add(lineRemaining.substring(0, indexToCut).replaceAll("\u00A0", " "));
// compute remaining format
int index = formatNextLine.length();
while (index <= indexToCut) {
if (lineRemaining.charAt(index) == (char)167 && index + 1 < indexToCut) {
index++;
formatNextLine += ("" + (char)167) + lineRemaining.charAt(index);
}
index++;
}
// cut for next line, recovering current format
lineRemaining = formatNextLine + " " + lineRemaining.substring(indexToCut + 1);
}
} else {
list.add(lineRemaining.replaceAll("\u00A0", " "));
lineRemaining = "";
}
}
}
}
public static Field getField(Class<?> clazz, String deobfuscatedName, String obfuscatedName) {
Field fieldToReturn = null;
try {
fieldToReturn = clazz.getDeclaredField(deobfuscatedName);
} catch (Exception exception1) {
try {
fieldToReturn = clazz.getDeclaredField(obfuscatedName);
} catch (Exception exception2) {
exception2.printStackTrace();
String map = "";
for(Field fieldDeclared : clazz.getDeclaredFields()) {
if (!map.isEmpty()) {
map += ", ";
}
map += fieldDeclared.getName();
}
WarpDrive.logger.error(String.format("Unable to find %1$s field in %2$s class. Available fields are: %3$s",
deobfuscatedName, clazz.toString(), map));
}
}
if (fieldToReturn != null) {
fieldToReturn.setAccessible(true);
}
return fieldToReturn;
}
public static String format(final long value) {
// alternate: BigDecimal.valueOf(value).setScale(0, RoundingMode.HALF_EVEN).toPlainString(),
return String.format("%,d", Math.round(value));
}
public static ItemStack copyWithSize(ItemStack itemStack, int newSize) {
ItemStack ret = itemStack.copy();
ret.stackSize = newSize;
return ret;
}
public static Collection<IInventory> getConnectedInventories(TileEntity tileEntityConnection) {
Collection<IInventory> result = new ArrayList<>(6);
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tileEntity = tileEntityConnection.getWorldObj().getTileEntity(
tileEntityConnection.xCoord + side.offsetX, tileEntityConnection.yCoord + side.offsetY, tileEntityConnection.zCoord + side.offsetZ);
if (tileEntity != null && (tileEntity instanceof IInventory)) {
result.add((IInventory) tileEntity);
if (tileEntity instanceof TileEntityChest) {
TileEntityChest tileEntityChest = (TileEntityChest) tileEntity;
tileEntityChest.checkForAdjacentChests();
if (tileEntityChest.adjacentChestXNeg != null) {
result.add(tileEntityChest.adjacentChestXNeg);
} else if (tileEntityChest.adjacentChestXPos != null) {
result.add(tileEntityChest.adjacentChestXPos);
} else if (tileEntityChest.adjacentChestZNeg != null) {
result.add(tileEntityChest.adjacentChestZNeg);
} else if (tileEntityChest.adjacentChestZPos != null) {
result.add(tileEntityChest.adjacentChestZPos);
}
}
}
}
return result;
}
// searching methods
public static final ForgeDirection[] UP_DIRECTIONS = { ForgeDirection.UP, ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST };
public static final ForgeDirection[] HORIZONTAL_DIRECTIONS = { ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST };
public static Set<VectorI> getConnectedBlocks(World world, final VectorI start, final ForgeDirection[] directions, final Set<Block> whitelist, final int maxRange, final VectorI... ignore) {
return getConnectedBlocks(world, Collections.singletonList(start), directions, whitelist, maxRange, ignore);
}
public static Set<VectorI> getConnectedBlocks(World world, final Collection<VectorI> start, final ForgeDirection[] directions, final Set<Block> whitelist, final int maxRange, final VectorI... ignore) {
Set<VectorI> toIgnore = new HashSet<>();
if (ignore != null) {
toIgnore.addAll(Arrays.asList(ignore));
}
Set<VectorI> toIterate = new HashSet<>();
toIterate.addAll(start);
Set<VectorI> toIterateNext;
Set<VectorI> iterated = new HashSet<>();
int range = 0;
while(!toIterate.isEmpty() && range < maxRange) {
toIterateNext = new HashSet<>();
for (VectorI current : toIterate) {
if (whitelist.contains(current.getBlock_noChunkLoading(world))) {
iterated.add(current);
}
for(ForgeDirection direction : directions) {
VectorI next = current.clone(direction);
if (!iterated.contains(next) && !toIgnore.contains(next) && !toIterate.contains(next) && !toIterateNext.contains(next)) {
if (whitelist.contains(next.getBlock_noChunkLoading(world))) {
toIterateNext.add(next);
}
}
}
}
toIterate = toIterateNext;
range++;
}
return iterated;
}
// data manipulation methods
public static int toInt(double d) {
return (int) Math.round(d);
}
public static int toInt(Object object) {
return Commons.toInt(toDouble(object));
}
public static double toDouble(Object object) {
assert(!(object instanceof Object[]));
return Double.parseDouble(object.toString());
}
public static float toFloat(Object object) {
assert(!(object instanceof Object[]));
return Float.parseFloat(object.toString());
}
public static boolean toBool(Object object) {
if (object == null) {
return false;
}
assert(!(object instanceof Object[]));
if (object instanceof Boolean) {
return ((Boolean) object);
}
String string = object.toString();
return string.equals("true") || string.equals("1.0") || string.equals("1") || string.equals("y") || string.equals("yes");
}
public static int clamp(final int min, final int max, final int value) {
return Math.min(max, Math.max(value, min));
}
public static float clamp(final float min, final float max, final float value) {
return Math.min(max, Math.max(value, min));
}
public static double clamp(final double min, final double max, final double value) {
return Math.min(max, Math.max(value, min));
}
// configurable interpolation
public static double interpolate(final double[] xValues, final double[] yValues, final double xInput) {
if (WarpDrive.isDev) {
assert(xValues.length == yValues.length);
assert(xValues.length > 1);
}
// clamp to minimum
if (xInput < xValues[0]) {
return yValues[0];
}
for(int index = 0; index < xValues.length - 1; index++) {
if (xInput < xValues[index + 1]) {
return interpolate(xValues[index], yValues[index], xValues[index + 1], yValues[index + 1], xInput);
}
}
// clamp to maximum
return yValues[yValues.length - 1];
}
private static double interpolate(final double xMin, final double yMin, final double xMax, final double yMax, final double x) {
return yMin + (x - xMin) * (yMax - yMin) / (xMax - xMin);
}
}

View file

@ -2,6 +2,7 @@ package cr0s.warpdrive;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -1,6 +1,8 @@
package cr0s.warpdrive;
import cr0s.warpdrive.config.Dictionary;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;

View file

@ -1,9 +1,9 @@
package cr0s.warpdrive;
import java.util.Stack;
import cr0s.warpdrive.config.WarpDriveConfig;
import java.util.Stack;
public class LocalProfiler {
private static class StackElement {
public long start;

View file

@ -1,65 +1,43 @@
package cr0s.warpdrive;
import java.lang.reflect.Field;
import java.util.List;
import java.util.UUID;
import com.mojang.authlib.GameProfile;
import cr0s.warpdrive.block.*;
import cr0s.warpdrive.block.atomic.*;
import cr0s.warpdrive.block.detection.*;
import cr0s.warpdrive.block.forcefield.*;
import cr0s.warpdrive.block.hull.BlockHullStairs;
import cr0s.warpdrive.config.RecipeParticleShapedOre;
import cr0s.warpdrive.config.RecipeTuningDriver;
import cr0s.warpdrive.damage.*;
import cr0s.warpdrive.item.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.client.Minecraft;
import net.minecraft.command.ICommandSender;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemDye;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.LoadingCallback;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.ForgeChunkManager.Type;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.oredict.RecipeSorter;
import org.apache.logging.log4j.Logger;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cr0s.warpdrive.block.BlockAirGenerator;
import cr0s.warpdrive.block.BlockChunkLoader;
import cr0s.warpdrive.block.BlockLaser;
import cr0s.warpdrive.block.BlockLaserMedium;
import cr0s.warpdrive.block.ItemBlockAbstractBase;
import cr0s.warpdrive.block.TileEntityAbstractChunkLoading;
import cr0s.warpdrive.block.TileEntityAirGenerator;
import cr0s.warpdrive.block.TileEntityChunkLoader;
import cr0s.warpdrive.block.TileEntityLaser;
import cr0s.warpdrive.block.TileEntityLaserMedium;
import cr0s.warpdrive.block.atomic.BlockAcceleratorControlPoint;
import cr0s.warpdrive.block.atomic.BlockChiller;
import cr0s.warpdrive.block.atomic.BlockElectromagnetGlass;
import cr0s.warpdrive.block.atomic.BlockElectromagnetPlain;
import cr0s.warpdrive.block.atomic.BlockParticlesCollider;
import cr0s.warpdrive.block.atomic.BlockParticlesInjector;
import cr0s.warpdrive.block.atomic.BlockVoidShellGlass;
import cr0s.warpdrive.block.atomic.BlockVoidShellPlain;
import cr0s.warpdrive.block.atomic.TileEntityAcceleratorControlPoint;
import cr0s.warpdrive.block.atomic.TileEntityParticlesInjector;
import cr0s.warpdrive.block.building.BlockShipScanner;
import cr0s.warpdrive.block.building.TileEntityShipScanner;
import cr0s.warpdrive.block.collection.BlockLaserTreeFarm;
import cr0s.warpdrive.block.collection.BlockMiningLaser;
import cr0s.warpdrive.block.collection.TileEntityLaserTreeFarm;
import cr0s.warpdrive.block.collection.TileEntityMiningLaser;
import cr0s.warpdrive.block.detection.BlockCamera;
import cr0s.warpdrive.block.detection.BlockCloakingCoil;
import cr0s.warpdrive.block.detection.BlockCloakingCore;
import cr0s.warpdrive.block.detection.BlockMonitor;
import cr0s.warpdrive.block.detection.BlockRadar;
import cr0s.warpdrive.block.detection.BlockSiren;
import cr0s.warpdrive.block.detection.BlockWarpIsolation;
import cr0s.warpdrive.block.detection.TileEntityCamera;
import cr0s.warpdrive.block.detection.TileEntityCloakingCore;
import cr0s.warpdrive.block.detection.TileEntityMonitor;
import cr0s.warpdrive.block.detection.TileEntityRadar;
import cr0s.warpdrive.block.detection.TileEntitySiren;
import cr0s.warpdrive.block.energy.BlockEnanReactorCore;
import cr0s.warpdrive.block.energy.BlockEnanReactorLaser;
import cr0s.warpdrive.block.energy.BlockEnergyBank;
@ -68,8 +46,17 @@ import cr0s.warpdrive.block.energy.TileEntityEnanReactorCore;
import cr0s.warpdrive.block.energy.TileEntityEnanReactorLaser;
import cr0s.warpdrive.block.energy.TileEntityEnergyBank;
import cr0s.warpdrive.block.energy.TileEntityIC2reactorLaserMonitor;
import cr0s.warpdrive.block.forcefield.BlockForceField;
import cr0s.warpdrive.block.forcefield.BlockForceFieldProjector;
import cr0s.warpdrive.block.forcefield.BlockForceFieldRelay;
import cr0s.warpdrive.block.forcefield.ItemBlockForceFieldProjector;
import cr0s.warpdrive.block.forcefield.ItemBlockForceFieldRelay;
import cr0s.warpdrive.block.forcefield.TileEntityForceField;
import cr0s.warpdrive.block.forcefield.TileEntityForceFieldProjector;
import cr0s.warpdrive.block.forcefield.TileEntityForceFieldRelay;
import cr0s.warpdrive.block.hull.BlockHullGlass;
import cr0s.warpdrive.block.hull.BlockHullPlain;
import cr0s.warpdrive.block.hull.BlockHullStairs;
import cr0s.warpdrive.block.hull.ItemBlockHull;
import cr0s.warpdrive.block.movement.BlockLift;
import cr0s.warpdrive.block.movement.BlockShipController;
@ -96,8 +83,17 @@ import cr0s.warpdrive.command.CommandGenerate;
import cr0s.warpdrive.command.CommandInvisible;
import cr0s.warpdrive.command.CommandJumpgates;
import cr0s.warpdrive.command.CommandSpace;
import cr0s.warpdrive.config.RecipeParticleShapedOre;
import cr0s.warpdrive.config.RecipeTuningDriver;
import cr0s.warpdrive.config.Recipes;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.damage.DamageAsphyxia;
import cr0s.warpdrive.damage.DamageCold;
import cr0s.warpdrive.damage.DamageIrradiation;
import cr0s.warpdrive.damage.DamageLaser;
import cr0s.warpdrive.damage.DamageShock;
import cr0s.warpdrive.damage.DamageTeleportation;
import cr0s.warpdrive.damage.DamageWarm;
import cr0s.warpdrive.data.CamerasRegistry;
import cr0s.warpdrive.data.CloakManager;
import cr0s.warpdrive.data.JumpgatesRegistry;
@ -105,16 +101,71 @@ import cr0s.warpdrive.data.StarMapRegistry;
import cr0s.warpdrive.event.ClientHandler;
import cr0s.warpdrive.event.LivingHandler;
import cr0s.warpdrive.event.WorldHandler;
import cr0s.warpdrive.item.ItemAirCanisterFull;
import cr0s.warpdrive.item.ItemComponent;
import cr0s.warpdrive.item.ItemCrystalToken;
import cr0s.warpdrive.item.ItemElectromagneticCell;
import cr0s.warpdrive.item.ItemForceFieldShape;
import cr0s.warpdrive.item.ItemForceFieldUpgrade;
import cr0s.warpdrive.item.ItemIC2reactorLaserFocus;
import cr0s.warpdrive.item.ItemTuningDriver;
import cr0s.warpdrive.item.ItemTuningFork;
import cr0s.warpdrive.item.ItemUpgrade;
import cr0s.warpdrive.item.ItemWarpArmor;
import cr0s.warpdrive.network.PacketHandler;
import cr0s.warpdrive.render.ClientCameraHandler;
import cr0s.warpdrive.render.RenderBlockForceField;
import cr0s.warpdrive.render.RenderBlockStandard;
import cr0s.warpdrive.render.RenderOverlayCamera;
import cr0s.warpdrive.world.BiomeSpace;
import cr0s.warpdrive.world.HyperSpaceWorldProvider;
import cr0s.warpdrive.world.HyperSpaceWorldGenerator;
import cr0s.warpdrive.world.SpaceWorldProvider;
import cr0s.warpdrive.world.HyperSpaceWorldProvider;
import cr0s.warpdrive.world.SpaceWorldGenerator;
import cr0s.warpdrive.world.SpaceWorldProvider;
import org.apache.logging.log4j.Logger;
import java.lang.reflect.Field;
import java.util.List;
import java.util.UUID;
import com.mojang.authlib.GameProfile;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.client.Minecraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemDye;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.biome.BiomeGenBase;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.LoadingCallback;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.ForgeChunkManager.Type;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.oredict.RecipeSorter;
@Mod(modid = WarpDrive.MODID, name = "WarpDrive", version = WarpDrive.VERSION, dependencies = "after:IC2;" + " after:CoFHCore;" + " after:ComputerCraft;"
+ " after:OpenComputer;" + " after:CCTurtle;" + " after:gregtech;" + " after:AppliedEnergistics;" + " after:EnderIO;")
@ -248,7 +299,7 @@ public class WarpDrive implements LoadingCallback {
WarpDriveConfig.onFMLInitialization();
// open access to Block.blockHardness
fieldBlockHardness = WarpDrive.getField(Block.class, "blockHardness", "field_149782_v");
fieldBlockHardness = Commons.getField(Block.class, "blockHardness", "field_149782_v");
// CORE CONTROLLER
blockShipController = new BlockShipController();
@ -690,19 +741,6 @@ public class WarpDrive implements LoadingCallback {
}
}
public static void addChatMessage(final ICommandSender sender, final String message) {
if (sender == null) {
logger.error("Unable to send message to NULL sender: " + message);
return;
}
String[] lines = message.replace("§", "" + (char)167).replace("\\n", "\n").replaceAll("\u00A0", " ").split("\n");
for (String line : lines) {
sender.addChatMessage(new ChatComponentText(line));
}
// logger.info(message);
}
@Mod.EventHandler
public void onFMLMissingMappings(FMLMissingMappingsEvent event) {
for (FMLMissingMappingsEvent.MissingMapping mapping: event.get()) {
@ -904,87 +942,4 @@ public class WarpDrive implements LoadingCallback {
}
}
// add tooltip information with text formatting and line splitting
// will ensure it fits on minimum screen width
public static void addTooltip(List<String> list, String tooltip) {
final String charFormatting = "" + (char)167;
tooltip = tooltip.replace("§", charFormatting).replace("\\n", "\n").replace("|", "\n");
tooltip = tooltip.replace(charFormatting + "r", charFormatting + "7");
String[] split = tooltip.split("\n");
for (String line : split) {
String lineRemaining = line;
String formatNextLine = "";
while (!lineRemaining.isEmpty()) {
int indexToCut = formatNextLine.length();
int displayLength = 0;
int length = lineRemaining.length();
while (indexToCut < length && displayLength <= 38) {
if (lineRemaining.charAt(indexToCut) == (char)167 && indexToCut + 1 < length) {
indexToCut++;
} else {
displayLength++;
}
indexToCut++;
}
if (indexToCut < length) {
indexToCut = lineRemaining.substring(0, indexToCut).lastIndexOf(' ');
if (indexToCut == -1 || indexToCut == 0) {// no space available, show the whole line 'as is'
list.add(lineRemaining);
lineRemaining = "";
} else {// cut at last space
list.add(lineRemaining.substring(0, indexToCut).replaceAll("\u00A0", " "));
// compute remaining format
int index = formatNextLine.length();
while (index <= indexToCut) {
if (lineRemaining.charAt(index) == (char)167 && index + 1 < indexToCut) {
index++;
formatNextLine += ("" + (char)167) + lineRemaining.charAt(index);
}
index++;
}
// cut for next line, recovering current format
lineRemaining = formatNextLine + " " + lineRemaining.substring(indexToCut + 1);
}
} else {
list.add(lineRemaining.replaceAll("\u00A0", " "));
lineRemaining = "";
}
}
}
}
public static Field getField(Class<?> clazz, String deobfuscatedName, String obfuscatedName) {
Field fieldToReturn = null;
try {
fieldToReturn = clazz.getDeclaredField(deobfuscatedName);
} catch (Exception exception1) {
try {
fieldToReturn = clazz.getDeclaredField(obfuscatedName);
} catch (Exception exception2) {
exception2.printStackTrace();
String map = "";
for(Field fieldDeclared : clazz.getDeclaredFields()) {
if (!map.isEmpty()) {
map += ", ";
}
map += fieldDeclared.getName();
}
WarpDrive.logger.error(String.format("Unable to find %1$s field in %2$s class. Available fields are: %3$s",
deobfuscatedName, clazz.toString(), map));
}
}
if (fieldToReturn != null) {
fieldToReturn.setAccessible(true);
}
return fieldToReturn;
}
public static String format(final long value) {
// alternate: BigDecimal.valueOf(value).setScale(0, RoundingMode.HALF_EVEN).toPlainString(),
return String.format("%,d", Math.round(value));
}
}

View file

@ -1,12 +1,14 @@
package cr0s.warpdrive;
import cpw.mods.fml.common.Optional;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.Optional;
@Optional.InterfaceList({
@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheralProvider", modid = "ComputerCraft")
})

View file

@ -5,9 +5,9 @@ import net.minecraft.item.ItemStack;
@Deprecated // we should use fluid storage instead here
public interface IAirCanister {
// Return true if that itemStack is Air compatible (i.e. may or already contains air)
public boolean canContainAir(ItemStack itemStack);
boolean canContainAir(ItemStack itemStack);
public boolean containsAir(ItemStack itemStack);
public ItemStack emptyDrop(ItemStack itemStack);
public ItemStack fullDrop(ItemStack itemStack);
boolean containsAir(ItemStack itemStack);
ItemStack emptyDrop(ItemStack itemStack);
ItemStack fullDrop(ItemStack itemStack);
}

View file

@ -2,5 +2,5 @@ package cr0s.warpdrive.api;
public interface IBlockUpdateDetector
{
public void updatedNeighbours();
void updatedNeighbours();
}

View file

@ -4,9 +4,9 @@ import net.minecraft.entity.Entity;
public interface IBreathingHelmet {
public boolean canBreath(Entity player);
boolean canBreath(Entity player);
public boolean removeAir(Entity player);
boolean removeAir(Entity player);
public int ticksPerCanDamage();
int ticksPerCanDamage();
}

View file

@ -1,6 +1,7 @@
package cr0s.warpdrive.api;
import cr0s.warpdrive.data.Vector3;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;

View file

@ -3,7 +3,6 @@ package cr0s.warpdrive.api;
import cr0s.warpdrive.data.ForceFieldSetup;
import cr0s.warpdrive.data.VectorI;
import java.util.Collection;
import java.util.Map;
public interface IForceFieldShape {

View file

@ -1,11 +1,12 @@
package cr0s.warpdrive.api;
import cr0s.warpdrive.data.VectorI;
import net.minecraft.block.Block;
import net.minecraft.util.AxisAlignedBB;
import java.util.UUID;
import net.minecraft.block.Block;
import net.minecraft.util.AxisAlignedBB;
public interface IStarMapRegistryTileEntity {
// get the registry type

View file

@ -1,13 +1,14 @@
package cr0s.warpdrive.api;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.EnumRarity;
import net.minecraft.util.StatCollector;
import cr0s.warpdrive.Commons;
import java.util.Locale;
import static cr0s.warpdrive.config.WarpDriveConfig.clamp;
import net.minecraft.item.EnumRarity;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Particle {
protected final String registryName;
@ -27,17 +28,17 @@ public class Particle {
}
public Particle setColorIndex(final int colorIndex) {
this.colorIndex = clamp(0, 4, colorIndex);
this.colorIndex = Commons.clamp(0, 4, colorIndex);
return this;
}
public Particle setColor(final int colorIndex) {
this.color = clamp(0x000000, 0xFFFFFF, color);
this.color = Commons.clamp(0x000000, 0xFFFFFF, color);
return this;
}
public Particle setColor(final int red, final int green, final int blue) {
this.color = (clamp(0, 255, red) << 16) + (clamp(0, 255, green) << 8) + clamp(0, 255, blue);
this.color = (Commons.clamp(0, 255, red) << 16) + (Commons.clamp(0, 255, green) << 8) + Commons.clamp(0, 255, blue);
return this;
}

View file

@ -3,15 +3,17 @@ package cr0s.warpdrive.api;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import net.minecraft.item.EnumRarity;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.item.EnumRarity;
import net.minecraftforge.common.MinecraftForge;
import java.util.Map;
public class ParticleRegistry {
private static BiMap<String, Particle> particles = HashBiMap.create();

View file

@ -1,10 +1,11 @@
package cr0s.warpdrive.api;
import cpw.mods.fml.common.FMLLog;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nonnull;
import cpw.mods.fml.common.FMLLog;
public class ParticleStack {
private final Particle particle;

View file

@ -1,10 +1,12 @@
package cr0s.warpdrive.block;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBlockBase;
import cr0s.warpdrive.api.IBlockUpdateDetector;
import cr0s.warpdrive.config.WarpDriveConfig;
import defense.api.IEMPBlock;
import defense.api.IExplosion;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@ -17,8 +19,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBlockUpdateDetector;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.ForgeDirection;
@Optional.InterfaceList({

View file

@ -1,5 +1,9 @@
package cr0s.warpdrive.block;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.api.IAirCanister;
import cr0s.warpdrive.config.WarpDriveConfig;
import java.util.Random;
import net.minecraft.block.material.Material;
@ -12,9 +16,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IAirCanister;
import cr0s.warpdrive.config.WarpDriveConfig;
public class BlockAirGenerator extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -91,7 +92,7 @@ public class BlockAirGenerator extends BlockAbstractContainer {
TileEntityAirGenerator airGenerator = (TileEntityAirGenerator)tileEntity;
ItemStack heldItemStack = entityPlayer.getHeldItem();
if (heldItemStack == null) {
WarpDrive.addChatMessage(entityPlayer, airGenerator.getStatus());
Commons.addChatMessage(entityPlayer, airGenerator.getStatus());
return true;
} else {
Item heldItem = heldItemStack.getItem();

View file

@ -1,5 +1,7 @@
package cr0s.warpdrive.block;
import cr0s.warpdrive.Commons;
import java.util.Random;
import net.minecraft.block.material.Material;
@ -9,7 +11,6 @@ import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
public class BlockLaser extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -68,7 +69,7 @@ public class BlockLaser extends BlockAbstractContainer {
if (entityPlayer.getHeldItem() == null) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityLaser) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityLaser)tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityLaser)tileEntity).getStatus());
return true;
}
}

View file

@ -1,5 +1,7 @@
package cr0s.warpdrive.block;
import cr0s.warpdrive.Commons;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@ -7,7 +9,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
public class BlockLaserMedium extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -67,7 +68,7 @@ public class BlockLaserMedium extends BlockAbstractContainer {
if (entityPlayer.getHeldItem() == null) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityLaserMedium) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityLaserMedium) tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityLaserMedium) tileEntity).getStatus());
return true;
}
}

View file

@ -1,9 +1,10 @@
package cr0s.warpdrive.block;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.api.IBlockBase;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
@ -14,7 +15,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockAbstractBase extends ItemBlock {
@ -74,14 +76,14 @@ public class ItemBlockAbstractBase extends ItemBlock {
String tooltipName1 = getUnlocalizedName(itemStack) + ".tooltip";
if (StatCollector.canTranslate(tooltipName1)) {
WarpDrive.addTooltip(list, StatCollector.translateToLocalFormatted(tooltipName1));
Commons.addTooltip(list, StatCollector.translateToLocalFormatted(tooltipName1));
}
String tooltipName2 = getUnlocalizedName() + ".tooltip";
if ((!tooltipName1.equals(tooltipName2)) && StatCollector.canTranslate(tooltipName2)) {
WarpDrive.addTooltip(list, StatCollector.translateToLocalFormatted(tooltipName2));
Commons.addTooltip(list, StatCollector.translateToLocalFormatted(tooltipName2));
}
WarpDrive.addTooltip(list, StatCollector.translateToLocalFormatted(getStatus(itemStack.getTagCompound(), itemStack.getItemDamage())));
Commons.addTooltip(list, StatCollector.translateToLocalFormatted(getStatus(itemStack.getTagCompound(), itemStack.getItemDamage())));
}
}

View file

@ -1,10 +1,20 @@
package cr0s.warpdrive.block;
import cr0s.warpdrive.CommonProxy;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBlockUpdateDetector;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.VectorI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import net.minecraft.block.Block;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
@ -12,22 +22,8 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
public abstract class TileEntityAbstractBase extends TileEntity implements IBlockUpdateDetector {
private boolean isFirstTick = true;
@ -49,10 +45,6 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc
public void updatedNeighbours() {
}
protected boolean isOnPlanet() {
return worldObj.provider.dimensionId == 0;
}
protected void updateMetadata(int metadata) {
if (getBlockMetadata() != metadata) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, metadata, 2);
@ -69,47 +61,14 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc
// Inventory management methods
public static ItemStack copyWithSize(ItemStack itemStack, int newSize) {
ItemStack ret = itemStack.copy();
ret.stackSize = newSize;
return ret;
}
public static Collection<IInventory> getConnectedInventories(TileEntity tileEntityConnection) {
Collection<IInventory> result = new ArrayList<>(6);
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tileEntity = tileEntityConnection.getWorldObj().getTileEntity(
tileEntityConnection.xCoord + side.offsetX, tileEntityConnection.yCoord + side.offsetY, tileEntityConnection.zCoord + side.offsetZ);
if (tileEntity != null && (tileEntity instanceof IInventory)) {
result.add((IInventory) tileEntity);
if (tileEntity instanceof TileEntityChest) {
TileEntityChest tileEntityChest = (TileEntityChest) tileEntity;
tileEntityChest.checkForAdjacentChests();
if (tileEntityChest.adjacentChestXNeg != null) {
result.add(tileEntityChest.adjacentChestXNeg);
} else if (tileEntityChest.adjacentChestXPos != null) {
result.add(tileEntityChest.adjacentChestXPos);
} else if (tileEntityChest.adjacentChestZNeg != null) {
result.add(tileEntityChest.adjacentChestZNeg);
} else if (tileEntityChest.adjacentChestZPos != null) {
result.add(tileEntityChest.adjacentChestZPos);
}
}
}
}
return result;
}
protected boolean addToConnectedInventories(final ItemStack itemStack) {
List<ItemStack> itemStacks = new ArrayList<>(1);
itemStacks.add(itemStack);
return addToInventories(itemStacks, getConnectedInventories(this));
return addToInventories(itemStacks, Commons.getConnectedInventories(this));
}
protected boolean addToConnectedInventories(final List<ItemStack> itemStacks) {
return addToInventories(itemStacks, getConnectedInventories(this));
return addToInventories(itemStacks, Commons.getConnectedInventories(this));
}
protected boolean addToInventories(final List<ItemStack> itemStacks, final Collection<IInventory> inventories) {
@ -138,7 +97,7 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc
int transfer;
while (qtyLeft > 0) {
transfer = Math.min(qtyLeft, itemStackLeft.getMaxStackSize());
ItemStack itemStackDrop = copyWithSize(itemStackLeft, transfer);
ItemStack itemStackDrop = Commons.copyWithSize(itemStackLeft, transfer);
EntityItem entityItem = new EntityItem(worldObj, xCoord + 0.5D, yCoord + 1.0D, zCoord + 0.5D, itemStackDrop);
worldObj.spawnEntityInWorld(entityItem);
qtyLeft -= transfer;
@ -189,7 +148,7 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc
}
transfer = Math.min(qtyLeft, itemStackSource.getMaxStackSize());
ItemStack dest = copyWithSize(itemStackSource, transfer);
ItemStack dest = Commons.copyWithSize(itemStackSource, transfer);
inventory.setInventorySlotContents(i, dest);
qtyLeft -= transfer;
@ -203,96 +162,6 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc
}
// searching methods
public static final ForgeDirection[] UP_DIRECTIONS = { ForgeDirection.UP, ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST };
public static final ForgeDirection[] HORIZONTAL_DIRECTIONS = { ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST };
public static Set<VectorI> getConnectedBlocks(World world, final VectorI start, final ForgeDirection[] directions, final Set<Block> whitelist, final int maxRange, final VectorI... ignore) {
return getConnectedBlocks(world, Collections.singletonList(start), directions, whitelist, maxRange, ignore);
}
public static Set<VectorI> getConnectedBlocks(World world, final Collection<VectorI> start, final ForgeDirection[] directions, final Set<Block> whitelist, final int maxRange, final VectorI... ignore) {
Set<VectorI> toIgnore = new HashSet<>();
if (ignore != null) {
toIgnore.addAll(Arrays.asList(ignore));
}
Set<VectorI> toIterate = new HashSet<>();
toIterate.addAll(start);
Set<VectorI> toIterateNext;
Set<VectorI> iterated = new HashSet<>();
int range = 0;
while(!toIterate.isEmpty() && range < maxRange) {
toIterateNext = new HashSet<>();
for (VectorI current : toIterate) {
if (whitelist.contains(current.getBlock_noChunkLoading(world))) {
iterated.add(current);
}
for(ForgeDirection direction : directions) {
VectorI next = current.clone(direction);
if (!iterated.contains(next) && !toIgnore.contains(next) && !toIterate.contains(next) && !toIterateNext.contains(next)) {
if (whitelist.contains(next.getBlock_noChunkLoading(world))) {
toIterateNext.add(next);
}
}
}
}
toIterate = toIterateNext;
range++;
}
return iterated;
}
// data manipulation methods
protected static int toInt(double d) {
return (int) Math.round(d);
}
protected static int toInt(Object object) {
return toInt(toDouble(object));
}
protected static double toDouble(Object object) {
assert(!(object instanceof Object[]));
return Double.parseDouble(object.toString());
}
protected static float toFloat(Object object) {
assert(!(object instanceof Object[]));
return Float.parseFloat(object.toString());
}
protected static boolean toBool(Object object) {
if (object == null) {
return false;
}
assert(!(object instanceof Object[]));
if (object instanceof Boolean) {
return ((Boolean) object);
}
String string = object.toString();
return string.equals("true") || string.equals("1.0") || string.equals("1") || string.equals("y") || string.equals("yes");
}
public static int clamp(final int min, final int max, final int value) {
return Math.min(max, Math.max(value, min));
}
public static float clamp(final float min, final float max, final float value) {
return Math.min(max, Math.max(value, min));
}
public static double clamp(final double min, final double max, final double value) {
return Math.min(max, Math.max(value, min));
}
// area protection
protected boolean isBlockBreakCanceled(final UUID uuidPlayer, World world, final int eventX, final int eventY, final int eventZ) {
return CommonProxy.isBlockBreakCanceled(uuidPlayer, xCoord, yCoord, zCoord, world, eventX, eventY, eventZ);

View file

@ -1,16 +1,16 @@
package cr0s.warpdrive.block;
import com.google.common.collect.ImmutableSet;
import cr0s.warpdrive.WarpDrive;
import java.util.ArrayList;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import com.google.common.collect.ImmutableSet;
import cr0s.warpdrive.WarpDrive;
public abstract class TileEntityAbstractChunkLoading extends TileEntityAbstractEnergy
{
private final ArrayList<Ticket> ticketList = new ArrayList<>();

View file

@ -1,25 +1,28 @@
package cr0s.warpdrive.block;
import cofh.api.energy.IEnergyHandler;
import cofh.api.energy.IEnergyReceiver;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import cofh.api.energy.IEnergyHandler;
import cofh.api.energy.IEnergyReceiver;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.config.WarpDriveConfig;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
@Optional.InterfaceList({
@Optional.Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHCore"),
@ -81,7 +84,7 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa
}
public int energy_getEnergyStored() {
return clamp(0, energy_getMaxStorage(), energyStored_internal);
return Commons.clamp(0, energy_getMaxStorage(), energyStored_internal);
}
// Methods to override
@ -150,8 +153,8 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractInterfa
return "";
}
return StatCollector.translateToLocalFormatted("warpdrive.energy.statusLine",
WarpDrive.format((long) convertInternalToEU_floor(energy_getEnergyStored())),
WarpDrive.format((long) convertInternalToEU_floor(energy_getMaxStorage())) );
Commons.format((long) convertInternalToEU_floor(energy_getEnergyStored())),
Commons.format((long) convertInternalToEU_floor(energy_getMaxStorage())) );
}
@Override

View file

@ -1,8 +1,11 @@
package cr0s.warpdrive.block;
import java.net.URL;
import java.util.*;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import li.cil.oc.api.FileSystem;
import li.cil.oc.api.Network;
import li.cil.oc.api.machine.Arguments;
@ -14,14 +17,17 @@ import li.cil.oc.api.network.ManagedEnvironment;
import li.cil.oc.api.network.Message;
import li.cil.oc.api.network.Node;
import li.cil.oc.api.network.Visibility;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
// OpenComputer API: https://github.com/MightyPirates/OpenComputers/tree/master-MC1.7.10/src/main/java/li/cil/oc/api

View file

@ -1,18 +1,19 @@
package cr0s.warpdrive.block;
import cr0s.warpdrive.config.WarpDriveConfig;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import java.util.LinkedList;
import java.util.List;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.config.WarpDriveConfig;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.ForgeDirection;
// Abstract class to manage laser mediums
public abstract class TileEntityAbstractLaser extends TileEntityAbstractInterfaced {

View file

@ -1,9 +1,6 @@
package cr0s.warpdrive.block;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
import dan200.computercraft.api.lua.ILuaContext;
@ -12,6 +9,12 @@ import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityAirGenerator extends TileEntityAbstractEnergy {
private int cooldownTicks = 0;
private boolean isEnabled = true;
@ -126,7 +129,7 @@ public class TileEntityAirGenerator extends TileEntityAbstractEnergy {
public Object[] enable(Object[] arguments) {
if (arguments.length == 1) {
isEnabled = toBool(arguments[0]);
isEnabled = Commons.toBool(arguments[0]);
}
return new Object[] { isEnabled };
}

View file

@ -1,15 +1,17 @@
package cr0s.warpdrive.block;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.UpgradeType;
import cr0s.warpdrive.item.ItemUpgrade;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.chunk.Chunk;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.UpgradeType;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading {
@ -93,10 +95,10 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading {
return;
}
}
negDX = - clamp(0, WarpDriveConfig.CL_MAX_DISTANCE, negDX);
posDX = clamp(0, WarpDriveConfig.CL_MAX_DISTANCE, posDX);
negDZ = - clamp(0, WarpDriveConfig.CL_MAX_DISTANCE, negDZ);
posDZ = clamp(0, WarpDriveConfig.CL_MAX_DISTANCE, posDZ);
negDX = - Commons.clamp(0, WarpDriveConfig.CL_MAX_DISTANCE, negDX);
posDX = Commons.clamp(0, WarpDriveConfig.CL_MAX_DISTANCE, posDX);
negDZ = - Commons.clamp(0, WarpDriveConfig.CL_MAX_DISTANCE, negDZ);
posDZ = Commons.clamp(0, WarpDriveConfig.CL_MAX_DISTANCE, posDZ);
minChunk = new ChunkCoordIntPair(myChunk.chunkXPos+negDX,myChunk.chunkZPos+negDZ);
maxChunk = new ChunkCoordIntPair(myChunk.chunkXPos+posDX,myChunk.chunkZPos+posDZ);
area = (posDX - negDX + 1) * (posDZ - negDZ + 1);
@ -136,7 +138,7 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading {
switch (methodName) {
case "radius":
if (arguments.length == 1) {
int dist = toInt(arguments[0]);
int dist = Commons.toInt(arguments[0]);
negDX = dist;
negDZ = dist;
posDX = dist;
@ -147,16 +149,16 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading {
return new Object[]{false};
case "bounds":
if (arguments.length == 4) {
negDX = toInt(arguments[0]);
posDX = toInt(arguments[1]);
negDZ = toInt(arguments[2]);
posDZ = toInt(arguments[3]);
negDX = Commons.toInt(arguments[0]);
posDX = Commons.toInt(arguments[1]);
negDZ = Commons.toInt(arguments[2]);
posDZ = Commons.toInt(arguments[3]);
changedDistance();
}
return new Object[]{negDX, posDX, negDZ, posDZ};
case "active":
if (arguments.length == 1)
shouldLoad = toBool(arguments[0]);
shouldLoad = Commons.toBool(arguments[0]);
return new Object[]{shouldChunkLoad()};
case "upgrades":
return new Object[] { getUpgradesAsString() };

View file

@ -1,14 +1,28 @@
package cr0s.warpdrive.block;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBeamFrequency;
import cr0s.warpdrive.api.IDamageReceiver;
import cr0s.warpdrive.api.IVideoChannel;
import cr0s.warpdrive.block.weapon.BlockLaserCamera;
import cr0s.warpdrive.block.weapon.TileEntityLaserCamera;
import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.data.VectorI;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;
import cr0s.warpdrive.api.IVideoChannel;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
@ -21,19 +35,8 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.util.Vec3;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBeamFrequency;
import cr0s.warpdrive.api.IDamageReceiver;
import cr0s.warpdrive.block.weapon.BlockLaserCamera;
import cr0s.warpdrive.block.weapon.TileEntityLaserCamera;
import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.data.VectorI;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFrequency {
@ -146,7 +149,7 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
private void emitBeam(int beamEnergy) {
int energy = beamEnergy;
int beamLengthBlocks = clamp(0, WarpDriveConfig.LASER_CANNON_RANGE_MAX, energy / 200);
int beamLengthBlocks = Commons.clamp(0, WarpDriveConfig.LASER_CANNON_RANGE_MAX, energy / 200);
if (energy == 0 || beamFrequency > 65000 || beamFrequency <= 0) {
if (WarpDriveConfig.LOGGING_WEAPON) {
@ -272,7 +275,7 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
// apply effects
mopEntity.entityHit.setFire(WarpDriveConfig.LASER_CANNON_ENTITY_HIT_SET_ON_FIRE_SECONDS);
if (entity != null) {
float damage = (float)clamp(0.0D, WarpDriveConfig.LASER_CANNON_ENTITY_HIT_MAX_DAMAGE,
float damage = (float) Commons.clamp(0.0D, WarpDriveConfig.LASER_CANNON_ENTITY_HIT_MAX_DAMAGE,
WarpDriveConfig.LASER_CANNON_ENTITY_HIT_BASE_DAMAGE + energy / WarpDriveConfig.LASER_CANNON_ENTITY_HIT_ENERGY_PER_DAMAGE);
entity.attackEntityFrom(DamageSource.inFire, damage);
} else {
@ -280,7 +283,7 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
}
if (energy > WarpDriveConfig.LASER_CANNON_ENTITY_HIT_EXPLOSION_ENERGY_THRESHOLD) {
float strength = (float)clamp(0.0D, WarpDriveConfig.LASER_CANNON_ENTITY_HIT_EXPLOSION_MAX_STRENGTH,
float strength = (float) Commons.clamp(0.0D, WarpDriveConfig.LASER_CANNON_ENTITY_HIT_EXPLOSION_MAX_STRENGTH,
WarpDriveConfig.LASER_CANNON_ENTITY_HIT_EXPLOSION_BASE_STRENGTH + energy / WarpDriveConfig.LASER_CANNON_ENTITY_HIT_EXPLOSION_ENERGY_PER_STRENGTH);
worldObj.newExplosion(null, mopEntity.entityHit.posX, mopEntity.entityHit.posY, mopEntity.entityHit.posZ, strength, true, true);
}
@ -345,7 +348,7 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
// explode on unbreakable blocks
if (hardness < 0.0F) {
float strength = (float)clamp(0.0D, WarpDriveConfig.LASER_CANNON_BLOCK_HIT_EXPLOSION_MAX_STRENGTH,
float strength = (float) Commons.clamp(0.0D, WarpDriveConfig.LASER_CANNON_BLOCK_HIT_EXPLOSION_MAX_STRENGTH,
WarpDriveConfig.LASER_CANNON_BLOCK_HIT_EXPLOSION_BASE_STRENGTH + energy / WarpDriveConfig.LASER_CANNON_BLOCK_HIT_EXPLOSION_ENERGY_PER_STRENGTH);
if (WarpDriveConfig.LOGGING_WEAPON) {
WarpDrive.logger.info("Explosion triggered with strength " + strength);
@ -356,9 +359,9 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
}
// Compute parameters
int energyCost = clamp(WarpDriveConfig.LASER_CANNON_BLOCK_HIT_ENERGY_MIN, WarpDriveConfig.LASER_CANNON_BLOCK_HIT_ENERGY_MAX,
int energyCost = Commons.clamp(WarpDriveConfig.LASER_CANNON_BLOCK_HIT_ENERGY_MIN, WarpDriveConfig.LASER_CANNON_BLOCK_HIT_ENERGY_MAX,
Math.round(hardness * WarpDriveConfig.LASER_CANNON_BLOCK_HIT_ENERGY_PER_BLOCK_HARDNESS));
double absorptionChance = clamp(0.0D, WarpDriveConfig.LASER_CANNON_BLOCK_HIT_ABSORPTION_MAX,
double absorptionChance = Commons.clamp(0.0D, WarpDriveConfig.LASER_CANNON_BLOCK_HIT_ABSORPTION_MAX,
hardness * WarpDriveConfig.LASER_CANNON_BLOCK_HIT_ABSORPTION_PER_BLOCK_HARDNESS);
do {
@ -411,7 +414,7 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
}
if (hardness >= WarpDriveConfig.LASER_CANNON_BLOCK_HIT_EXPLOSION_HARDNESS_THRESHOLD) {
float strength = (float)clamp(0.0D, WarpDriveConfig.LASER_CANNON_BLOCK_HIT_EXPLOSION_MAX_STRENGTH,
float strength = (float) Commons.clamp(0.0D, WarpDriveConfig.LASER_CANNON_BLOCK_HIT_EXPLOSION_MAX_STRENGTH,
WarpDriveConfig.LASER_CANNON_BLOCK_HIT_EXPLOSION_BASE_STRENGTH + energy / WarpDriveConfig.LASER_CANNON_BLOCK_HIT_EXPLOSION_ENERGY_PER_STRENGTH);
if (WarpDriveConfig.LOGGING_WEAPON) {
WarpDrive.logger.info("Explosion triggered with strength " + strength);
@ -599,13 +602,13 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
try {
float newYaw, newPitch;
if (arguments.length == 2) {
newYaw = toFloat(arguments[0]);
newPitch = toFloat(arguments[1]);
newYaw = Commons.toFloat(arguments[0]);
newPitch = Commons.toFloat(arguments[1]);
initiateBeamEmission(newYaw, newPitch);
} else if (arguments.length == 3) {
float deltaX = -toFloat(arguments[0]);
float deltaY = -toFloat(arguments[1]);
float deltaZ = toFloat(arguments[2]);
float deltaX = -Commons.toFloat(arguments[0]);
float deltaY = -Commons.toFloat(arguments[1]);
float deltaZ = Commons.toFloat(arguments[2]);
double horizontalDistance = MathHelper.sqrt_double(deltaX * deltaX + deltaZ * deltaZ);
//noinspection SuspiciousNameCombination
newYaw = (float) (Math.atan2(deltaX, deltaZ) * 180.0D / Math.PI);
@ -655,7 +658,7 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
case "beamFrequency":
if (arguments.length == 1) {
setBeamFrequency(toInt(arguments[0]));
setBeamFrequency(Commons.toInt(arguments[0]));
}
return new Integer[]{ beamFrequency };

View file

@ -1,9 +1,11 @@
package cr0s.warpdrive.block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import cr0s.warpdrive.config.WarpDriveConfig;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityLaserMedium extends TileEntityAbstractEnergy {
private int ticks = 0;

View file

@ -3,6 +3,7 @@ package cr0s.warpdrive.block.atomic;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBlockBase;
import cr0s.warpdrive.config.WarpDriveConfig;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EnumCreatureType;

View file

@ -1,8 +1,7 @@
package cr0s.warpdrive.block.atomic;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.Commons;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@ -10,6 +9,9 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockAcceleratorControlPoint extends BlockAbstractAccelerator implements ITileEntityProvider {
@SideOnly(Side.CLIENT)
@ -46,7 +48,7 @@ public class BlockAcceleratorControlPoint extends BlockAbstractAccelerator imple
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityAcceleratorControlPoint) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityAcceleratorControlPoint)tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityAcceleratorControlPoint)tileEntity).getStatus());
return true;
}
}

View file

@ -1,10 +1,11 @@
package cr0s.warpdrive.block.atomic;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.network.PacketHandler;
import java.util.Random;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@ -13,7 +14,8 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockChiller extends BlockAbstractAccelerator {

View file

@ -1,12 +1,13 @@
package cr0s.warpdrive.block.atomic;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockParticlesInjector extends BlockAcceleratorControlPoint {
@SideOnly(Side.CLIENT)

View file

@ -1,22 +1,24 @@
package cr0s.warpdrive.block.atomic;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IControlChannel;
import cr0s.warpdrive.block.TileEntityAbstractInterfaced;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.common.Optional;
public class TileEntityAcceleratorControlPoint extends TileEntityAbstractInterfaced implements IControlChannel {
// persistent properties
@ -24,9 +26,7 @@ public class TileEntityAcceleratorControlPoint extends TileEntityAbstractInterfa
private int controlChannel = -1;
// computed properties
private final static int PACKET_SEND_INTERVAL_TICKS = 60 * 20;
private static final int UPDATE_INTERVAL_TICKS = 20;
private int packetSendTicks = 10;
private int updateTicks;
public TileEntityAcceleratorControlPoint() {
@ -58,12 +58,6 @@ public class TileEntityAcceleratorControlPoint extends TileEntityAbstractInterfa
updateTicks = UPDATE_INTERVAL_TICKS;
updateMetadata((controlChannel == -1) ? 0 : 1);
}
packetSendTicks--;
if (packetSendTicks <= 0) {
packetSendTicks = PACKET_SEND_INTERVAL_TICKS;
PacketHandler.sendVideoChannelPacket(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, controlChannel);
}
}
@Override
@ -85,7 +79,6 @@ public class TileEntityAcceleratorControlPoint extends TileEntityAbstractInterfa
WarpDrive.logger.info(this + " Accelerator control point controlChannel channel set to " + controlChannel);
}
// force update through main thread since CC runs on server as 'client'
packetSendTicks = 0;
markDirty();
}
}
@ -160,7 +153,7 @@ public class TileEntityAcceleratorControlPoint extends TileEntityAbstractInterfa
if (arguments.length == 1) {
boolean enable;
try {
enable = toBool(arguments[0]);
enable = Commons.toBool(arguments[0]);
} catch (Exception exception) {
throw new Exception("Function expects a boolean value");
}
@ -187,7 +180,7 @@ public class TileEntityAcceleratorControlPoint extends TileEntityAbstractInterfa
case "controlChannel":
if (arguments.length == 1) {
setControlChannel(toInt(arguments[0]));
setControlChannel(Commons.toInt(arguments[0]));
}
return new Integer[] { controlChannel };

View file

@ -2,6 +2,7 @@ package cr0s.warpdrive.block.building;
import java.util.Random;
import cr0s.warpdrive.Commons;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@ -9,7 +10,6 @@ import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
public class BlockShipScanner extends BlockAbstractContainer {
@ -67,7 +67,7 @@ public class BlockShipScanner extends BlockAbstractContainer {
if (entityPlayer.getHeldItem() == null) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityShipScanner) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityShipScanner)tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityShipScanner)tileEntity).getStatus());
return true;
}
}

View file

@ -1,5 +1,23 @@
package cr0s.warpdrive.block.building;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.block.movement.TileEntityShipCore;
import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.JumpBlock;
import cr0s.warpdrive.data.JumpShip;
import cr0s.warpdrive.data.Transformation;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.item.ItemCrystalToken;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -9,11 +27,6 @@ import java.util.Date;
import java.util.List;
import java.util.UUID;
import cr0s.warpdrive.data.JumpShip;
import cr0s.warpdrive.item.ItemCrystalToken;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@ -28,20 +41,10 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.MathHelper;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.block.movement.TileEntityShipCore;
import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.JumpBlock;
import cr0s.warpdrive.data.Transformation;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
public class TileEntityShipScanner extends TileEntityAbstractEnergy {
private boolean isActive = false;
@ -170,7 +173,7 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
if (tileEntity instanceof TileEntityShipCore) {
((TileEntityShipCore)tileEntity).summonOwnerOnDeploy(playerName);
if (entityPlayerMP != null) {
WarpDrive.addChatMessage(entityPlayerMP, "§6" + "Welcome aboard captain. Use the computer to get moving...");
Commons.addChatMessage(entityPlayerMP, "§6" + "Welcome aboard captain. Use the computer to get moving...");
}
}
@ -240,7 +243,7 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
// Warn owner if deployment done but wait next tick for teleportation
if (currentDeployIndex >= blocksToDeployCount) {
if (entityPlayerMP != null) {
WarpDrive.addChatMessage(entityPlayerMP, "Ship complete. Teleporting captain to the main deck");
Commons.addChatMessage(entityPlayerMP, "Ship complete. Teleporting captain to the main deck");
}
}
}
@ -782,10 +785,10 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
private Object[] deploy(Object[] arguments) {
if (arguments.length == 5) {
String fileName = (String) arguments[0];
int x = toInt(arguments[1]);
int y = toInt(arguments[2]);
int z = toInt(arguments[3]);
byte rotationSteps = (byte) toInt(arguments[4]);
int x = Commons.toInt(arguments[1]);
int y = Commons.toInt(arguments[2]);
int z = Commons.toInt(arguments[3]);
byte rotationSteps = (byte) Commons.toInt(arguments[4]);
if (!new File(WarpDriveConfig.G_SCHEMALOCATION + "/" + fileName + ".schematic").exists()) {
return new Object[] { 0, "Specified schematic file was not found!" };
@ -866,7 +869,7 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
}
if (entityPlayers.size() > 1) {
for (EntityPlayer entityPlayer : entityPlayers) {
WarpDrive.addChatMessage(entityPlayer, "§c" + "Too many players detected: please stand in the beam one at a time.");
Commons.addChatMessage(entityPlayer, "§c" + "Too many players detected: please stand in the beam one at a time.");
cooldownPlayerDetection = 3 * SS_SEARCH_INTERVAL_TICKS;
}
warmupPlayerId = null;
@ -886,7 +889,7 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
}
}
if (itemStack == null || slotIndex >= entityPlayer.inventory.getSizeInventory()) {
WarpDrive.addChatMessage(entityPlayer, "Please come back once you've a Crystal token.");
Commons.addChatMessage(entityPlayer, "Please come back once you've a Crystal token.");
cooldownPlayerDetection = 3 * SS_SEARCH_INTERVAL_TICKS;
return;
}
@ -896,11 +899,11 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
warmupPlayerId = entityPlayer.getUniqueID();
warmupPlayer = SS_SEARCH_WARMUP_INTERVALS + 1;
warmupSchematicName = ItemCrystalToken.getSchematicName(itemStack);
WarpDrive.addChatMessage(entityPlayer, "§6" + String.format("Token '%1$s' detected!", warmupSchematicName, SS_SEARCH_WARMUP_INTERVALS));
Commons.addChatMessage(entityPlayer, "§6" + String.format("Token '%1$s' detected!", warmupSchematicName, SS_SEARCH_WARMUP_INTERVALS));
}
warmupPlayer--;
if (warmupPlayer > 0) {
WarpDrive.addChatMessage(entityPlayer, String.format("Stand by for ship materialization in %2$d...", warmupSchematicName, warmupPlayer));
Commons.addChatMessage(entityPlayer, String.format("Stand by for ship materialization in %2$d...", warmupSchematicName, warmupPlayer));
return;
}
// warmup done
@ -912,11 +915,11 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy {
deployShip(ItemCrystalToken.getSchematicName(itemStack), targetX - xCoord, targetY - yCoord, targetZ - zCoord, rotationSteps, true, reason);
if (!isActive) {
// failed
WarpDrive.addChatMessage(entityPlayer, "§c" + reason.toString());
Commons.addChatMessage(entityPlayer, "§c" + reason.toString());
cooldownPlayerDetection = 5 * SS_SEARCH_INTERVAL_TICKS;
return;
}
WarpDrive.addChatMessage(entityPlayer, "§6" + reason.toString());
Commons.addChatMessage(entityPlayer, "§6" + reason.toString());
// success => remove token
if (!entityPlayer.capabilities.isCreativeMode) {

View file

@ -1,5 +1,8 @@
package cr0s.warpdrive.block.collection;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.BlockAbstractContainer;
import java.util.Random;
import net.minecraft.block.material.Material;
@ -10,8 +13,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
public class BlockLaserTreeFarm extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -97,7 +98,7 @@ public class BlockLaserTreeFarm extends BlockAbstractContainer {
if (entityPlayer.getHeldItem() == null) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityLaserTreeFarm) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityLaserTreeFarm)tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityLaserTreeFarm)tileEntity).getStatus());
return true;
}
}

View file

@ -1,5 +1,8 @@
package cr0s.warpdrive.block.collection;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.BlockAbstractContainer;
import java.util.Random;
import net.minecraft.block.material.Material;
@ -10,8 +13,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
public class BlockMiningLaser extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -93,7 +94,7 @@ public class BlockMiningLaser extends BlockAbstractContainer {
if (entityPlayer.getHeldItem() == null) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityMiningLaser) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityMiningLaser)tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityMiningLaser)tileEntity).getStatus());
return true;
}
}

View file

@ -1,5 +1,11 @@
package cr0s.warpdrive.block.collection;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractLaser;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.data.VectorI;
import java.util.ArrayList;
import java.util.List;
@ -8,22 +14,18 @@ import net.minecraft.block.BlockLiquid;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractLaser;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.data.VectorI;
public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser {
// machine type
protected ForgeDirection laserOutputSide = ForgeDirection.NORTH;
protected ForgeDirection laserOutputSide = ForgeDirection.NORTH;
// machine state
protected boolean enableSilktouch = false;
protected boolean enableSilktouch = false;
// pre-computation
protected Vector3 laserOutput = null;
protected Vector3 laserOutput = null;
public TileEntityAbstractMiner() {
super();

View file

@ -1,21 +1,6 @@
package cr0s.warpdrive.block.collection;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import cpw.mods.fml.common.Optional;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.config.WarpDriveConfig;
@ -24,6 +9,24 @@ import cr0s.warpdrive.data.VectorI;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
private boolean breakLeaves = false;
@ -327,7 +330,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
VectorI soil = soils.get(soilIndex);
Block block = worldObj.getBlock(soil.x, soil.y, soil.z);
soilIndex++;
Collection<IInventory> inventories = getConnectedInventories(this);
Collection<IInventory> inventories = Commons.getConnectedInventories(this);
if (inventories == null || inventories.isEmpty()) {
currentState = STATE_WARMUP;
delayTargetTicks = TREE_FARM_WARMUP_DELAY_TICKS;
@ -523,7 +526,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
if (breakLeaves) {
whitelist.addAll(Dictionary.BLOCKS_LEAVES);
}
logPositions = getConnectedBlocks(worldObj, logPositions, UP_DIRECTIONS, whitelist, WarpDriveConfig.TREE_FARM_MAX_LOG_DISTANCE + laserMediumCount * WarpDriveConfig.TREE_FARM_MAX_LOG_DISTANCE_PER_MEDIUM);
logPositions = Commons.getConnectedBlocks(worldObj, logPositions, Commons.UP_DIRECTIONS, whitelist, WarpDriveConfig.TREE_FARM_MAX_LOG_DISTANCE + laserMediumCount * WarpDriveConfig.TREE_FARM_MAX_LOG_DISTANCE_PER_MEDIUM);
}
if (WarpDriveConfig.LOGGING_COLLECTION) {
WarpDrive.logger.info("Found " + logPositions.size() + " valuables");
@ -548,12 +551,12 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
if (radiusX == 0) {
radiusX = 1;
}
radiusX = clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, radiusX);
radiusX = Commons.clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, radiusX);
radiusZ = tag.getInteger("radiusZ");
if (radiusZ == 0) {
radiusZ = 1;
}
radiusZ = clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, radiusZ);
radiusZ = Commons.clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, radiusZ);
breakLeaves = tag.getBoolean("breakLeaves");
tapTrees = tag.getBoolean("tapTrees");
@ -636,12 +639,12 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
private Object[] radius(Object[] arguments) {
try {
if (arguments.length == 1) {
radiusX = clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, toInt(arguments[0]));
radiusX = Commons.clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, Commons.toInt(arguments[0]));
radiusZ = radiusX;
markDirty();
} else if (arguments.length == 2) {
radiusX = clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, toInt(arguments[0]));
radiusZ = clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, toInt(arguments[1]));
radiusX = Commons.clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, Commons.toInt(arguments[0]));
radiusZ = Commons.clamp(1, WarpDriveConfig.TREE_FARM_totalMaxRadius, Commons.toInt(arguments[1]));
markDirty();
}
} catch(NumberFormatException exception) {
@ -654,7 +657,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
private Object[] breakLeaves(Object[] arguments) {
if (arguments.length == 1) {
try {
breakLeaves = toBool(arguments[0]);
breakLeaves = Commons.toBool(arguments[0]);
markDirty();
} catch (Exception exception) {
return new Object[] { breakLeaves };
@ -666,7 +669,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
private Object[] silktouch(Object[] arguments) {
if (arguments.length == 1) {
try {
enableSilktouch = toBool(arguments[0]);
enableSilktouch = Commons.toBool(arguments[0]);
markDirty();
} catch (Exception exception) {
return new Object[] { enableSilktouch };
@ -678,7 +681,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
private Object[] tapTrees(Object[] arguments) {
if (arguments.length == 1) {
try {
tapTrees = toBool(arguments[0]);
tapTrees = Commons.toBool(arguments[0]);
markDirty();
} catch (Exception exception) {
return new Object[] { tapTrees };

View file

@ -1,17 +1,6 @@
package cr0s.warpdrive.block.collection;
import java.util.ArrayList;
import java.util.Arrays;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidRegistry;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.config.WarpDriveConfig;
@ -20,6 +9,20 @@ import cr0s.warpdrive.data.VectorI;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import java.util.ArrayList;
import java.util.Arrays;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidRegistry;
public class TileEntityMiningLaser extends TileEntityAbstractMiner {
private final boolean canSilktouch = (WarpDriveConfig.MINING_LASER_SILKTOUCH_DEUTERIUM_L <= 0 || FluidRegistry.isFluidRegistered("deuterium"));
@ -84,7 +87,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
return;
}
boolean isOnEarth = isOnPlanet();
boolean isOnPlanet = WarpDrive.starMap.isPlanet(worldObj);
delayTicks--;
if (currentState == STATE_WARMUP) {
@ -99,7 +102,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
} else if (currentState == STATE_SCANNING) {
if (delayTicks == WarpDriveConfig.MINING_LASER_SCAN_DELAY_TICKS - 1) {
// check power level
enoughPower = consumeEnergyFromLaserMediums(isOnEarth ? WarpDriveConfig.MINING_LASER_PLANET_ENERGY_PER_LAYER : WarpDriveConfig.MINING_LASER_SPACE_ENERGY_PER_LAYER, true);
enoughPower = consumeEnergyFromLaserMediums(isOnPlanet ? WarpDriveConfig.MINING_LASER_PLANET_ENERGY_PER_LAYER : WarpDriveConfig.MINING_LASER_SPACE_ENERGY_PER_LAYER, true);
if (!enoughPower) {
updateMetadata(BlockMiningLaser.ICON_SCANNING_LOW_POWER);
delayTicks = WarpDriveConfig.MINING_LASER_WARMUP_DELAY_TICKS;
@ -128,7 +131,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
}
// consume power
enoughPower = consumeEnergyFromLaserMediums(isOnEarth ? WarpDriveConfig.MINING_LASER_PLANET_ENERGY_PER_LAYER : WarpDriveConfig.MINING_LASER_SPACE_ENERGY_PER_LAYER, false);
enoughPower = consumeEnergyFromLaserMediums(isOnPlanet ? WarpDriveConfig.MINING_LASER_PLANET_ENERGY_PER_LAYER : WarpDriveConfig.MINING_LASER_SPACE_ENERGY_PER_LAYER, false);
if (!enoughPower) {
updateMetadata(BlockMiningLaser.ICON_SCANNING_LOW_POWER);
delayTicks = WarpDriveConfig.MINING_LASER_WARMUP_DELAY_TICKS;
@ -182,7 +185,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
}
// consume power
int requiredPower = isOnEarth ? WarpDriveConfig.MINING_LASER_PLANET_ENERGY_PER_BLOCK : WarpDriveConfig.MINING_LASER_SPACE_ENERGY_PER_BLOCK;
int requiredPower = isOnPlanet ? WarpDriveConfig.MINING_LASER_PLANET_ENERGY_PER_BLOCK : WarpDriveConfig.MINING_LASER_SPACE_ENERGY_PER_BLOCK;
if (!mineAllBlocks) {
requiredPower *= WarpDriveConfig.MINING_LASER_ORESONLY_ENERGY_FACTOR;
}
@ -442,7 +445,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
private Object[] onlyOres(Object[] arguments) {
if (arguments.length == 1) {
try {
mineAllBlocks = ! toBool(arguments[0]);
mineAllBlocks = ! Commons.toBool(arguments[0]);
markDirty();
if (WarpDriveConfig.LOGGING_LUA) {
WarpDrive.logger.info(this + " onlyOres set to " + !mineAllBlocks);
@ -457,7 +460,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
private Object[] offset(Object[] arguments) {
if (arguments.length == 1) {
try {
layerOffset = Math.min(256, Math.abs(toInt(arguments[0])));
layerOffset = Math.min(256, Math.abs(Commons.toInt(arguments[0])));
markDirty();
if (WarpDriveConfig.LOGGING_LUA) {
WarpDrive.logger.info(this + " offset set to " + layerOffset);
@ -472,7 +475,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
private Object[] silktouch(Object[] arguments) {
if (arguments.length == 1) {
try {
enableSilktouch = toBool(arguments[0]);
enableSilktouch = Commons.toBool(arguments[0]);
markDirty();
if (WarpDriveConfig.LOGGING_LUA) {
WarpDrive.logger.info(this + " silktouch set to " + enableSilktouch);

View file

@ -1,5 +1,8 @@
package cr0s.warpdrive.block.detection;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.BlockAbstractContainer;
import java.util.Random;
import net.minecraft.block.material.Material;
@ -9,8 +12,6 @@ import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
public class BlockCamera extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -63,7 +64,7 @@ public class BlockCamera extends BlockAbstractContainer {
if (entityPlayer.getHeldItem() == null) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityCamera) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityCamera)tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityCamera)tileEntity).getStatus());
return true;
}
}

View file

@ -1,5 +1,7 @@
package cr0s.warpdrive.block.detection;
import cr0s.warpdrive.WarpDrive;
import java.util.Random;
import net.minecraft.block.Block;
@ -7,8 +9,8 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import cr0s.warpdrive.WarpDrive;
public class BlockCloakingCoil extends Block {
private IIcon[] iconBuffer;

View file

@ -1,5 +1,8 @@
package cr0s.warpdrive.block.detection;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.BlockAbstractContainer;
import java.util.Random;
import net.minecraft.block.Block;
@ -13,8 +16,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
public class BlockCloakingCore extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -82,12 +83,12 @@ public class BlockCloakingCore extends BlockAbstractContainer {
if (tileEntity instanceof TileEntityCloakingCore) {
TileEntityCloakingCore cloakingCore = (TileEntityCloakingCore)tileEntity;
if (entityPlayer.getHeldItem() == null) {
WarpDrive.addChatMessage(entityPlayer, cloakingCore.getStatus());
Commons.addChatMessage(entityPlayer, cloakingCore.getStatus());
// + " isInvalid? " + te.isInvalid() + " Valid? " + te.isValid + " Cloaking? " + te.isCloaking + " Enabled? " + te.isEnabled
return true;
} else if (entityPlayer.getHeldItem().getItem() == Item.getItemFromBlock(Blocks.redstone_torch)) {
cloakingCore.isEnabled = !cloakingCore.isEnabled;
WarpDrive.addChatMessage(entityPlayer, cloakingCore.getStatus());
Commons.addChatMessage(entityPlayer, cloakingCore.getStatus());
return true;
// } else if (xxx) {// TODO if player has advanced tool
// WarpDrive.addChatMessage(entityPlayer, cloakingCore.getStatus() + "\n" + cloakingCore.getEnergyStatus());

View file

@ -1,5 +1,11 @@
package cr0s.warpdrive.block.detection;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
import cr0s.warpdrive.data.CameraRegistryItem;
import cr0s.warpdrive.render.ClientCameraHandler;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@ -9,11 +15,6 @@ import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
import cr0s.warpdrive.data.CameraRegistryItem;
import cr0s.warpdrive.render.ClientCameraHandler;
public class BlockMonitor extends BlockAbstractContainer {
private IIcon iconFront;
private IIcon iconSide;
@ -55,10 +56,10 @@ public class BlockMonitor extends BlockAbstractContainer {
int videoChannel = ((TileEntityMonitor)tileEntity).getVideoChannel();
CameraRegistryItem camera = WarpDrive.cameras.getCameraByVideoChannel(world, videoChannel);
if (camera == null || entityPlayer.isSneaking()) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityMonitor)tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityMonitor)tileEntity).getStatus());
return true;
} else {
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.monitor.viewingCamera",
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.monitor.viewingCamera",
videoChannel,
camera.position.chunkPosX,
camera.position.chunkPosY,

View file

@ -1,5 +1,8 @@
package cr0s.warpdrive.block.detection;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.BlockAbstractContainer;
import java.util.Random;
import net.minecraft.block.material.Material;
@ -11,8 +14,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
public class BlockRadar extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -105,7 +106,7 @@ public class BlockRadar extends BlockAbstractContainer {
if (entityPlayer.getHeldItem() == null) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityRadar) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityRadar)tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityRadar)tileEntity).getStatus());
return true;
}
}

View file

@ -1,9 +1,10 @@
package cr0s.warpdrive.block.detection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@ -13,7 +14,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockSiren extends BlockAbstractContainer {

View file

@ -1,5 +1,7 @@
package cr0s.warpdrive.block.detection;
import cr0s.warpdrive.WarpDrive;
import java.util.Random;
import net.minecraft.block.Block;
@ -7,7 +9,6 @@ import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import cr0s.warpdrive.WarpDrive;
public class BlockWarpIsolation extends Block {
private IIcon[] iconBuffer;

View file

@ -1,15 +1,6 @@
package cr0s.warpdrive.block.detection;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.StatCollector;
import net.minecraft.world.ChunkPosition;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IVideoChannel;
import cr0s.warpdrive.block.TileEntityAbstractInterfaced;
@ -19,6 +10,18 @@ import cr0s.warpdrive.data.EnumCameraType;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.StatCollector;
import net.minecraft.world.ChunkPosition;
import cpw.mods.fml.common.Optional;
public class TileEntityCamera extends TileEntityAbstractInterfaced implements IVideoChannel {
private int videoChannel = -1;
@ -175,7 +178,7 @@ public class TileEntityCamera extends TileEntityAbstractInterfaced implements IV
if (methodName.equals("videoChannel")) {
if (arguments.length == 1) {
setVideoChannel(toInt(arguments[0]));
setVideoChannel(Commons.toInt(arguments[0]));
}
return new Integer[] { videoChannel };
}

View file

@ -1,16 +1,6 @@
package cr0s.warpdrive.block.detection;
import java.util.Arrays;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.WarpDriveConfig;
@ -19,6 +9,19 @@ import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import java.util.Arrays;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityCloakingCore extends TileEntityAbstractEnergy {
public boolean isEnabled = false;
@ -420,7 +423,7 @@ public class TileEntityCloakingCore extends TileEntityAbstractEnergy {
switch (methodName) {
case "tier":
if (arguments.length == 1) {
if (toInt(arguments[0]) == 2) {
if (Commons.toInt(arguments[0]) == 2) {
tier = 2;
} else {
tier = 1;
@ -434,7 +437,7 @@ public class TileEntityCloakingCore extends TileEntityAbstractEnergy {
case "enable":
if (arguments.length == 1) {
isEnabled = toBool(arguments[0]);
isEnabled = Commons.toBool(arguments[0]);
markDirty();
}
return new Object[] { isEnabled };

View file

@ -1,14 +1,6 @@
package cr0s.warpdrive.block.detection;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IVideoChannel;
import cr0s.warpdrive.block.TileEntityAbstractInterfaced;
@ -17,6 +9,17 @@ import cr0s.warpdrive.data.CameraRegistryItem;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.common.Optional;
public class TileEntityMonitor extends TileEntityAbstractInterfaced implements IVideoChannel {
private int videoChannel = -1;
@ -134,7 +137,7 @@ public class TileEntityMonitor extends TileEntityAbstractInterfaced implements I
if (methodName.equals("videoChannel")) {
if (arguments.length == 1) {
setVideoChannel(toInt(arguments[0]));
setVideoChannel(Commons.toInt(arguments[0]));
}
return new Integer[] { videoChannel };
}

View file

@ -1,14 +1,6 @@
package cr0s.warpdrive.block.detection;
import java.util.ArrayList;
import java.util.Arrays;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.WarpDriveConfig;
@ -16,6 +8,17 @@ import cr0s.warpdrive.data.StarMapRegistryItem;
import cr0s.warpdrive.data.VectorI;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import java.util.ArrayList;
import java.util.Arrays;
import net.minecraft.nbt.NBTTagCompound;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityRadar extends TileEntityAbstractEnergy {
private ArrayList<StarMapRegistryItem> results;
@ -137,11 +140,11 @@ public class TileEntityRadar extends TileEntityAbstractEnergy {
if (arguments.length == 1 && getBlockMetadata() != 2) {
int newRadius;
try {
newRadius = toInt(arguments[0]);
newRadius = Commons.toInt(arguments[0]);
} catch(Exception exception) {
return new Integer[] { radius };
}
radius = clamp(0, 10000, newRadius);
radius = Commons.clamp(0, 10000, newRadius);
}
return new Integer[] { radius };
}
@ -149,7 +152,7 @@ public class TileEntityRadar extends TileEntityAbstractEnergy {
private Object[] getEnergyRequired(Object[] arguments) {
try {
if (arguments.length == 1) {
return new Object[] { calculateEnergyRequired(toInt(arguments[0])) };
return new Object[] { calculateEnergyRequired(Commons.toInt(arguments[0])) };
}
} catch (Exception exception) {
return new Integer[] { -1 };
@ -160,7 +163,7 @@ public class TileEntityRadar extends TileEntityAbstractEnergy {
private Object[] getScanDuration(Object[] arguments) {
try {
if (arguments.length == 1) {
return new Object[] { 0.050D * calculateScanDuration(toInt(arguments[0])) };
return new Object[] { 0.050D * calculateScanDuration(Commons.toInt(arguments[0])) };
}
} catch (Exception exception) {
return new Integer[] { -1 };
@ -199,7 +202,7 @@ public class TileEntityRadar extends TileEntityAbstractEnergy {
if (arguments.length == 1 && (results != null)) {
int index;
try {
index = toInt(arguments[0]);
index = Commons.toInt(arguments[0]);
} catch(Exception exception) {
return new Object[] { false, COMPUTER_ERROR_TAG, null, 0, 0, 0 };
}

View file

@ -1,12 +1,14 @@
package cr0s.warpdrive.block.detection;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractBase;
import cr0s.warpdrive.client.SirenSound;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.warpdrive.client.SirenSound;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractBase;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
public class TileEntitySiren extends TileEntityAbstractBase {
public enum SirenState {

View file

@ -1,6 +1,7 @@
package cr0s.warpdrive.block.energy;
import cr0s.warpdrive.block.BlockAbstractContainer;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;

View file

@ -1,6 +1,7 @@
package cr0s.warpdrive.block.energy;
import cr0s.warpdrive.block.BlockAbstractContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;

View file

@ -1,11 +1,14 @@
package cr0s.warpdrive.block.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.api.IWarpTool;
import cr0s.warpdrive.block.BlockAbstractContainer;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.EnumComponentType;
import cr0s.warpdrive.item.ItemComponent;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@ -20,10 +23,9 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockEnergyBank extends BlockAbstractContainer {
@SideOnly(Side.CLIENT)
@ -130,18 +132,18 @@ public class BlockEnergyBank extends BlockAbstractContainer {
ItemStack itemStack = new ItemStack(Item.getItemFromBlock(this), 1, world.getBlockMetadata(x, y, z));
switch (tileEntityEnergyBank.getMode(facing)) {
case TileEntityEnergyBank.MODE_INPUT:
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.guide.prefix",
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.guide.prefix",
StatCollector.translateToLocalFormatted(itemStack.getUnlocalizedName() + ".name"))
+ StatCollector.translateToLocalFormatted("warpdrive.energy.side.changedToInput", facing.name()));
return true;
case TileEntityEnergyBank.MODE_OUTPUT:
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.guide.prefix",
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.guide.prefix",
StatCollector.translateToLocalFormatted(itemStack.getUnlocalizedName() + ".name"))
+ StatCollector.translateToLocalFormatted("warpdrive.energy.side.changedToOutput", facing.name()));
return true;
case TileEntityEnergyBank.MODE_DISABLED:
default:
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.guide.prefix",
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.guide.prefix",
StatCollector.translateToLocalFormatted(itemStack.getUnlocalizedName() + ".name"))
+ StatCollector.translateToLocalFormatted("warpdrive.energy.side.changedToDisabled", facing.name()));
return true;
@ -164,7 +166,7 @@ public class BlockEnergyBank extends BlockAbstractContainer {
if (enumComponentType == null) {
// no more upgrades to dismount
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.noUpgradeToDismount"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.noUpgradeToDismount"));
return true;
}
@ -178,25 +180,25 @@ public class BlockEnergyBank extends BlockAbstractContainer {
tileEntityEnergyBank.dismountUpgrade(enumComponentType);
// upgrade dismounted
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.dismounted", enumComponentType.name()));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.dismounted", enumComponentType.name()));
return false;
}
} else if (itemStackHeld == null) {// no sneaking and no item in hand => show status
WarpDrive.addChatMessage(entityPlayer, tileEntityEnergyBank.getStatus());
Commons.addChatMessage(entityPlayer, tileEntityEnergyBank.getStatus());
return true;
} else if (enumComponentType != null) {// no sneaking and an upgrade in hand => mounting an upgrade
// validate type
if (tileEntityEnergyBank.getUpgradeMaxCount(enumComponentType) <= 0) {
// invalid upgrade type
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.invalidUpgrade"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.invalidUpgrade"));
return true;
}
if (!tileEntityEnergyBank.canUpgrade(enumComponentType)) {
// too many upgrades
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.tooManyUpgrades",
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.tooManyUpgrades",
tileEntityEnergyBank.getUpgradeMaxCount(enumComponentType)));
return true;
}
@ -205,7 +207,7 @@ public class BlockEnergyBank extends BlockAbstractContainer {
// validate quantity
if (itemStackHeld.stackSize < 1) {
// not enough upgrade items
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.notEnoughUpgrades"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.notEnoughUpgrades"));
return true;
}
@ -216,7 +218,7 @@ public class BlockEnergyBank extends BlockAbstractContainer {
// mount the new upgrade item
tileEntityEnergyBank.mountUpgrade(enumComponentType);
// upgrade mounted
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.mounted", enumComponentType.name()));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.mounted", enumComponentType.name()));
}
return false;

View file

@ -1,5 +1,8 @@
package cr0s.warpdrive.block.energy;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.BlockAbstractContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@ -7,8 +10,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
public class BlockIC2reactorLaserMonitor extends BlockAbstractContainer {
static IIcon[] icons;
@ -68,7 +69,7 @@ public class BlockIC2reactorLaserMonitor extends BlockAbstractContainer {
if (entityPlayer.getHeldItem() == null) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityIC2reactorLaserMonitor) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityIC2reactorLaserMonitor) tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityIC2reactorLaserMonitor) tileEntity).getStatus());
return true;
}
}

View file

@ -1,21 +1,24 @@
package cr0s.warpdrive.block.energy;
import java.util.Arrays;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.WarpDriveConfig;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import java.util.Arrays;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy {
private int containedEnergy = 0;
@ -311,7 +314,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy {
if (arguments.length == 1) {
boolean activate;
try {
activate = toBool(arguments[0]);
activate = Commons.toBool(arguments[0]);
} catch (Exception exception) {
throw new Exception("Function expects a boolean value");
}
@ -341,7 +344,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy {
boolean doRelease;
if (arguments.length > 0) {
try {
doRelease = toBool(arguments[0]);
doRelease = Commons.toBool(arguments[0]);
} catch (Exception exception) {
throw new Exception("Function expects a boolean value");
}
@ -362,7 +365,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy {
private Object[] releaseRate(Object[] arguments) throws Exception {
int rate;
try {
rate = toInt(arguments[0]);
rate = Commons.toInt(arguments[0]);
} catch (Exception exception) {
throw new Exception("Function expects an integer value");
}
@ -388,7 +391,7 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy {
private Object[] releaseAbove(Object[] arguments) throws Exception {
int above;
try {
above = toInt(arguments[0]);
above = Commons.toInt(arguments[0]);
} catch (Exception exception) {
throw new Exception("Function expects an integer value");
}

View file

@ -1,12 +1,6 @@
package cr0s.warpdrive.block.energy;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import cpw.mods.fml.common.Optional;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractLaser;
import cr0s.warpdrive.config.WarpDriveConfig;
@ -14,6 +8,15 @@ import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityEnanReactorLaser extends TileEntityAbstractLaser {
Vector3 myVec;
@ -175,7 +178,7 @@ public class TileEntityEnanReactorLaser extends TileEntityAbstractLaser {
case "stabilize":
if (arguments.length >= 1) {
stabilize(toInt(arguments[0]));
stabilize(Commons.toInt(arguments[0]));
}
break;

View file

@ -1,14 +1,17 @@
package cr0s.warpdrive.block.energy;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.EnumComponentType;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.util.ForgeDirection;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.WarpDriveConfig;
public class TileEntityEnergyBank extends TileEntityAbstractEnergy {
@ -46,7 +49,7 @@ public class TileEntityEnergyBank extends TileEntityAbstractEnergy {
}
private double getEfficiency() {
int upgradeCount = clamp(0, getUpgradeMaxCount(EnumComponentType.SUPERCONDUCTOR), getUpgradeCount(EnumComponentType.SUPERCONDUCTOR));
int upgradeCount = Commons.clamp(0, getUpgradeMaxCount(EnumComponentType.SUPERCONDUCTOR), getUpgradeCount(EnumComponentType.SUPERCONDUCTOR));
return WarpDriveConfig.ENERGY_BANK_EFFICIENCY_PER_UPGRADE[upgradeCount];
}

View file

@ -1,5 +1,11 @@
package cr0s.warpdrive.block.energy;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.item.ItemIC2reactorLaserFocus;
import cr0s.warpdrive.network.PacketHandler;
import ic2.api.reactor.IReactor;
import ic2.api.reactor.IReactorChamber;
@ -14,14 +20,9 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.item.ItemIC2reactorLaserFocus;
import cr0s.warpdrive.network.PacketHandler;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
private int ticks = WarpDriveConfig.IC2_REACTOR_COOLING_INTERVAL_TICKS;

View file

@ -2,6 +2,7 @@ package cr0s.warpdrive.block.forcefield;
import cr0s.warpdrive.block.BlockAbstractContainer;
import cr0s.warpdrive.config.WarpDriveConfig;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

View file

@ -1,16 +1,18 @@
package cr0s.warpdrive.block.forcefield;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IDamageReceiver;
import cr0s.warpdrive.block.hull.BlockHullGlass;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.ForceFieldSetup;
import cr0s.warpdrive.data.EnumPermissionNode;
import cr0s.warpdrive.data.ForceFieldSetup;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.data.VectorI;
import cr0s.warpdrive.render.RenderBlockForceField;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockGlass;
import net.minecraft.block.material.Material;
@ -31,10 +33,10 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.List;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockForceField extends BlockAbstractForceField implements IDamageReceiver {
@SideOnly(Side.CLIENT)

View file

@ -1,12 +1,13 @@
package cr0s.warpdrive.block.forcefield;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.data.EnumForceFieldShape;
import cr0s.warpdrive.data.EnumForceFieldUpgrade;
import cr0s.warpdrive.item.ItemForceFieldShape;
import cr0s.warpdrive.item.ItemForceFieldUpgrade;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@ -20,9 +21,10 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockForceFieldProjector extends BlockAbstractForceField {
@SideOnly(Side.CLIENT)
@ -78,6 +80,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
}
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(Item item, CreativeTabs creativeTab, List list) {
for (int i = 0; i < 2; ++i) {
list.add(new ItemStack(item, 1, i));
@ -132,7 +135,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
if (enumForceFieldUpgrade == EnumForceFieldUpgrade.NONE) {
// no more upgrades to dismount
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.noUpgradeToDismount"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.noUpgradeToDismount"));
return true;
}
@ -146,7 +149,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
tileEntityForceFieldProjector.dismountUpgrade(enumForceFieldUpgrade);
// upgrade dismounted
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.dismounted", enumForceFieldUpgrade.name()));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.dismounted", enumForceFieldUpgrade.name()));
return false;
} else {// default to dismount shape
@ -162,21 +165,21 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
tileEntityForceFieldProjector.setShape(EnumForceFieldShape.NONE);
// shape dismounted
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.shapeDismounted"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.shapeDismounted"));
} else {
// wrong side
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.wrongShapeSide"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.wrongShapeSide"));
return true;
}
} else {
// no shape to dismount
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.noShapeToDismount"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.noShapeToDismount"));
return true;
}
}
} else if (itemStackHeld == null) {// no sneaking and no item in hand => show status
WarpDrive.addChatMessage(entityPlayer, tileEntityForceFieldProjector.getStatus());
Commons.addChatMessage(entityPlayer, tileEntityForceFieldProjector.getStatus());
return true;
} else if (itemStackHeld.getItem() instanceof ItemForceFieldShape) {// no sneaking and shape in hand => mounting a shape
@ -185,7 +188,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
// validate quantity
if (itemStackHeld.stackSize < (tileEntityForceFieldProjector.isDoubleSided ? 2 : 1)) {
// not enough shape items
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted(
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted(
tileEntityForceFieldProjector.isDoubleSided ?
"warpdrive.upgrade.result.notEnoughShapes.double" : "warpdrive.upgrade.result.notEnoughShapes.single"));
return true;
@ -206,11 +209,11 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
// mount the new shape item(s)
tileEntityForceFieldProjector.setShape(EnumForceFieldShape.get(itemStackHeld.getItemDamage()));
// shape mounted
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.shapeMounted"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.shapeMounted"));
} else {
// wrong side
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.wrongShapeSide"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.wrongShapeSide"));
return true;
}
@ -218,12 +221,12 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
// validate type
if (tileEntityForceFieldProjector.getUpgradeMaxCount(enumForceFieldUpgrade) <= 0) {
// invalid upgrade type
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.invalidProjectorUpgrade"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.invalidProjectorUpgrade"));
return true;
}
if (!tileEntityForceFieldProjector.canUpgrade(enumForceFieldUpgrade)) {
// too many upgrades
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.tooManyUpgrades",
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.tooManyUpgrades",
tileEntityForceFieldProjector.getUpgradeMaxCount(enumForceFieldUpgrade)));
return true;
}
@ -232,7 +235,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
// validate quantity
if (itemStackHeld.stackSize < 1) {
// not enough upgrade items
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.notEnoughUpgrades"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.notEnoughUpgrades"));
return true;
}
@ -243,7 +246,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField {
// mount the new upgrade item
tileEntityForceFieldProjector.mountUpgrade(enumForceFieldUpgrade);
// upgrade mounted
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.mounted", enumForceFieldUpgrade));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.mounted", enumForceFieldUpgrade));
}
return false;

View file

@ -1,10 +1,9 @@
package cr0s.warpdrive.block.forcefield;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.data.EnumForceFieldUpgrade;
import cr0s.warpdrive.item.ItemForceFieldUpgrade;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityItem;
@ -16,6 +15,9 @@ import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockForceFieldRelay extends BlockAbstractForceField {
@SideOnly(Side.CLIENT)
private IIcon[] icons;
@ -97,23 +99,23 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
tileEntityForceFieldRelay.setUpgrade(EnumForceFieldUpgrade.NONE);
// upgrade dismounted
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.dismounted", enumForceFieldUpgrade.name()));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.dismounted", enumForceFieldUpgrade.name()));
} else {
// no more upgrades to dismount
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.noUpgradeToDismount"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.noUpgradeToDismount"));
return true;
}
} else if (itemStackHeld == null) {// no sneaking and no item in hand to show status
WarpDrive.addChatMessage(entityPlayer, tileEntityForceFieldRelay.getStatus());
Commons.addChatMessage(entityPlayer, tileEntityForceFieldRelay.getStatus());
return true;
} else if (itemStackHeld.getItem() instanceof ItemForceFieldUpgrade) {
// validate type
if (EnumForceFieldUpgrade.get(itemStackHeld.getItemDamage()).maxCountOnRelay <= 0) {
// invalid upgrade type
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.invalidRelayUpgrade"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.invalidRelayUpgrade"));
return true;
}
@ -121,7 +123,7 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
// validate quantity
if (itemStackHeld.stackSize < 1) {
// not enough upgrade items
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.notEnoughUpgrades"));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.notEnoughUpgrades"));
return true;
}
@ -141,7 +143,7 @@ public class BlockForceFieldRelay extends BlockAbstractForceField {
EnumForceFieldUpgrade enumForceFieldUpgrade = EnumForceFieldUpgrade.get(itemStackHeld.getItemDamage());
tileEntityForceFieldRelay.setUpgrade(enumForceFieldUpgrade);
// upgrade mounted
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.mounted", enumForceFieldUpgrade.name()));
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.mounted", enumForceFieldUpgrade.name()));
}
return false;

View file

@ -1,6 +1,7 @@
package cr0s.warpdrive.block.forcefield;
import cr0s.warpdrive.block.ItemBlockAbstractBase;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;

View file

@ -1,6 +1,7 @@
package cr0s.warpdrive.block.forcefield;
import cr0s.warpdrive.block.ItemBlockAbstractBase;
import net.minecraft.block.Block;
public class ItemBlockForceFieldRelay extends ItemBlockAbstractBase {

View file

@ -1,6 +1,6 @@
package cr0s.warpdrive.block.forcefield;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBeamFrequency;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
@ -12,6 +12,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
@ -19,6 +20,8 @@ import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.common.Optional;
public class TileEntityAbstractForceField extends TileEntityAbstractEnergy implements IBeamFrequency {
// persistent properties
protected byte tier = -1;
@ -166,7 +169,7 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple
if (arguments.length == 1) {
boolean enable;
try {
enable = toBool(arguments[0]);
enable = Commons.toBool(arguments[0]);
} catch (Exception exception) {
throw new Exception("Function expects a boolean value");
}
@ -188,7 +191,7 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple
case "beamFrequency":
if (arguments.length == 1) {
setBeamFrequency(toInt(arguments[0]));
setBeamFrequency(Commons.toInt(arguments[0]));
}
return new Integer[]{ beamFrequency };
}

View file

@ -7,6 +7,7 @@ import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.ForceFieldSetup;
import cr0s.warpdrive.data.VectorI;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;

View file

@ -1,18 +1,32 @@
package cr0s.warpdrive.block.forcefield;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IBeamFrequency;
import cr0s.warpdrive.api.IForceFieldShape;
import cr0s.warpdrive.config.*;
import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.data.*;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.EnumForceFieldShape;
import cr0s.warpdrive.data.EnumForceFieldUpgrade;
import cr0s.warpdrive.data.ForceFieldSetup;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.data.VectorI;
import cr0s.warpdrive.network.PacketHandler;
import cpw.mods.fml.common.Optional;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.BlockStaticLiquid;
@ -29,14 +43,13 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
public class TileEntityForceFieldProjector extends TileEntityAbstractForceField {
private static final int PROJECTOR_MAX_ENERGY_STORED = 30000;
private static final int PROJECTOR_COOLDOWN_TICKS = 300;
@ -233,7 +246,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
continue;
}
WarpDrive.addChatMessage((EntityPlayer) entity, msg);
Commons.addChatMessage((EntityPlayer) entity, msg);
}
}
}
@ -723,7 +736,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
}
private void setMin(final float x, final float y, final float z) {
v3Min = new Vector3(clamp(-1.0D, 0.0D, x), clamp(-1.0D, 0.0D, y), clamp(-1.0D, 0.0D, z));
v3Min = new Vector3(Commons.clamp(-1.0D, 0.0D, x), Commons.clamp(-1.0D, 0.0D, y), Commons.clamp(-1.0D, 0.0D, z));
}
public Vector3 getMax() {
@ -731,7 +744,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
}
private void setMax(final float x, final float y, final float z) {
v3Max = new Vector3(clamp(0.0D, 1.0D, x), clamp(0.0D, 1.0D, y), clamp(0.0D, 1.0D, z));
v3Max = new Vector3(Commons.clamp(0.0D, 1.0D, x), Commons.clamp(0.0D, 1.0D, y), Commons.clamp(0.0D, 1.0D, z));
}
public float getRotationYaw() {
@ -782,8 +795,8 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
float oldYaw = this.rotationYaw;
float oldPitch = this.rotationPitch;
float oldRoll = this.rotationRoll;
this.rotationYaw = clamp( -45.0F, +45.0F, rotationYaw);
this.rotationPitch = clamp( -45.0F, +45.0F, rotationPitch);
this.rotationYaw = Commons.clamp( -45.0F, +45.0F, rotationYaw);
this.rotationPitch = Commons.clamp( -45.0F, +45.0F, rotationPitch);
this.rotationRoll = (rotationRoll + 720.0F) % 360.0F - 180.0F;
if (oldYaw != this.rotationYaw || oldPitch != this.rotationPitch || oldRoll != this.rotationRoll) {
isDirty.set(true);
@ -818,7 +831,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
}
private void setTranslation(final float x, final float y, final float z) {
v3Translation = new Vector3(clamp(-1.0D, 1.0D, x), clamp(-1.0D, 1.0D, y), clamp(-1.0D, 1.0D, z));
v3Translation = new Vector3(Commons.clamp(-1.0D, 1.0D, x), Commons.clamp(-1.0D, 1.0D, y), Commons.clamp(-1.0D, 1.0D, z));
}
@Override
@ -1071,31 +1084,31 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
switch (methodName) {
case "min":
if (arguments.length == 1) {
setMin(toFloat(arguments[0]), toFloat(arguments[0]), toFloat(arguments[0]));
setMin(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[0]), Commons.toFloat(arguments[0]));
} else if (arguments.length == 2) {
setMin(toFloat(arguments[0]), toFloat(arguments[1]), toFloat(arguments[0]));
setMin(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[1]), Commons.toFloat(arguments[0]));
} else if (arguments.length == 3) {
setMin(toFloat(arguments[0]), toFloat(arguments[1]), toFloat(arguments[2]));
setMin(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[1]), Commons.toFloat(arguments[2]));
}
return new Double[] { v3Min.x, v3Min.y, v3Min.z };
case "max":
if (arguments.length == 1) {
setMax(toFloat(arguments[0]), toFloat(arguments[0]), toFloat(arguments[0]));
setMax(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[0]), Commons.toFloat(arguments[0]));
} else if (arguments.length == 2) {
setMax(toFloat(arguments[0]), toFloat(arguments[1]), toFloat(arguments[0]));
setMax(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[1]), Commons.toFloat(arguments[0]));
} else if (arguments.length == 3) {
setMax(toFloat(arguments[0]), toFloat(arguments[1]), toFloat(arguments[2]));
setMax(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[1]), Commons.toFloat(arguments[2]));
}
return new Double[] { v3Max.x, v3Max.y, v3Max.z };
case "rotation":
if (arguments.length == 1) {
setRotation(toFloat(arguments[0]), rotationPitch, rotationRoll);
setRotation(Commons.toFloat(arguments[0]), rotationPitch, rotationRoll);
} else if (arguments.length == 2) {
setRotation(toFloat(arguments[0]), toFloat(arguments[1]), rotationRoll);
setRotation(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[1]), rotationRoll);
} else if (arguments.length == 3) {
setRotation(toFloat(arguments[0]), toFloat(arguments[1]), toFloat(arguments[2]));
setRotation(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[1]), Commons.toFloat(arguments[2]));
}
return new Float[] { rotationYaw, rotationPitch, rotationRoll };
@ -1104,11 +1117,11 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
case "translation":
if (arguments.length == 1) {
setTranslation(toFloat(arguments[0]), toFloat(arguments[0]), toFloat(arguments[0]));
setTranslation(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[0]), Commons.toFloat(arguments[0]));
} else if (arguments.length == 2) {
setTranslation(toFloat(arguments[0]), toFloat(arguments[1]), toFloat(arguments[0]));
setTranslation(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[1]), Commons.toFloat(arguments[0]));
} else if (arguments.length == 3) {
setTranslation(toFloat(arguments[0]), toFloat(arguments[1]), toFloat(arguments[2]));
setTranslation(Commons.toFloat(arguments[0]), Commons.toFloat(arguments[1]), Commons.toFloat(arguments[2]));
}
return new Double[] { v3Translation.x, v3Translation.y, v3Translation.z };
}

View file

@ -4,6 +4,7 @@ import cr0s.warpdrive.api.IForceFieldUpgrade;
import cr0s.warpdrive.api.IForceFieldUpgradeEffector;
import cr0s.warpdrive.data.EnumForceFieldUpgrade;
import cr0s.warpdrive.data.ForceFieldSetup;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;

View file

@ -1,6 +1,10 @@
package cr0s.warpdrive.block.hull;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IDamageReceiver;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Vector3;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockGlass;
@ -8,10 +12,8 @@ import net.minecraft.block.material.Material;
import net.minecraft.util.DamageSource;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IDamageReceiver;
import cr0s.warpdrive.config.WarpDriveConfig;
public class BlockHullGlass extends BlockColored implements IDamageReceiver {
final byte tier;

View file

@ -1,10 +1,12 @@
package cr0s.warpdrive.block.hull;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IDamageReceiver;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Vector3;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.warpdrive.data.Vector3;
import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
@ -16,9 +18,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IDamageReceiver;
import cr0s.warpdrive.config.WarpDriveConfig;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockHullPlain extends Block implements IDamageReceiver {
@SideOnly(Side.CLIENT)

View file

@ -4,6 +4,7 @@ import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IDamageReceiver;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Vector3;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.block.BlockStairs;

View file

@ -1,7 +1,5 @@
package cr0s.warpdrive.block.hull;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.item.EnumRarity;
@ -10,6 +8,9 @@ import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemBlockHull extends ItemBlock {
public ItemBlockHull(Block block) {

View file

@ -1,5 +1,8 @@
package cr0s.warpdrive.block.movement;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.BlockAbstractContainer;
import java.util.Random;
import net.minecraft.block.material.Material;
@ -10,8 +13,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
public class BlockLift extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -93,7 +94,7 @@ public class BlockLift extends BlockAbstractContainer {
if (entityPlayer.getHeldItem() == null) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityLift) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityLift)tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityLift)tileEntity).getStatus());
return true;
}
}

View file

@ -1,5 +1,8 @@
package cr0s.warpdrive.block.movement;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.BlockAbstractContainer;
import java.util.Random;
import net.minecraft.block.material.Material;
@ -10,10 +13,9 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
public class BlockShipController extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -106,9 +108,9 @@ public class BlockShipController extends BlockAbstractContainer {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityShipController) {
if (entityPlayer.isSneaking()) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityShipController)tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityShipController)tileEntity).getStatus());
} else {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityShipController)tileEntity).attachPlayer(entityPlayer));
Commons.addChatMessage(entityPlayer, ((TileEntityShipController)tileEntity).attachPlayer(entityPlayer));
}
return true;
}

View file

@ -1,10 +1,13 @@
package cr0s.warpdrive.block.movement;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.BlockAbstractContainer;
import cr0s.warpdrive.data.EnumComponentType;
import cr0s.warpdrive.item.ItemComponent;
import java.util.ArrayList;
import java.util.Random;
import cr0s.warpdrive.data.EnumComponentType;
import cr0s.warpdrive.item.ItemComponent;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.item.EntityTNTPrimed;
@ -14,8 +17,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
public class BlockShipCore extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -132,7 +133,7 @@ public class BlockShipCore extends BlockAbstractContainer {
if (entityPlayer.getHeldItem() == null) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityShipCore) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityShipCore)tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityShipCore)tileEntity).getStatus());
return true;
}
}

View file

@ -1,7 +1,8 @@
package cr0s.warpdrive.block.movement;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.BlockAbstractContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
@ -54,7 +55,7 @@ public class BlockTransporter extends BlockAbstractContainer {
if (entityPlayer.getHeldItem() == null) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityTransporter) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityTransporter)tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityTransporter)tileEntity).getStatus());
return true;
}
}

View file

@ -1,23 +1,26 @@
package cr0s.warpdrive.block.movement;
import java.util.List;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityLift extends TileEntityAbstractEnergy {
private static final int MODE_REDSTONE = -1;
@ -169,13 +172,13 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
if (tag.hasKey("mode")) {
mode = clamp(-1, 2, tag.getByte("mode"));
mode = Commons.clamp(-1, 2, tag.getByte("mode"));
}
if (tag.hasKey("computerEnabled")) {
computerEnabled = tag.getBoolean("computerEnabled");
}
if (tag.hasKey("computerMode")) {
computerMode = clamp(-1, 2, tag.getByte("computerMode"));
computerMode = Commons.clamp(-1, 2, tag.getByte("computerMode"));
}
}
@ -254,7 +257,7 @@ public class TileEntityLift extends TileEntityAbstractEnergy {
} else if (methodName.equals("active")) {
if (arguments.length == 1) {
computerEnabled = toBool(arguments[0]);
computerEnabled = Commons.toBool(arguments[0]);
}
return new Object[] { !computerEnabled && isEnabled };
}

View file

@ -1,17 +1,6 @@
package cr0s.warpdrive.block.movement;
import java.util.ArrayList;
import java.util.Arrays;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractInterfaced;
import cr0s.warpdrive.block.movement.TileEntityShipCore.EnumShipCoreMode;
@ -19,11 +8,21 @@ import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.VectorI;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import java.util.ArrayList;
import java.util.Arrays;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.common.Optional;
/**
* Protocol block tile entity
* @author Cr0s
*/
public class TileEntityShipController extends TileEntityAbstractInterfaced {
// Variables
private int distance = 0;
@ -595,9 +594,9 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced {
try {
if (arguments.length == 3) {
int argInt0, argInt1, argInt2;
argInt0 = clamp(0, WarpDriveConfig.SHIP_MAX_SIDE_SIZE, Math.abs(toInt(arguments[0])));
argInt1 = clamp(0, WarpDriveConfig.SHIP_MAX_SIDE_SIZE, Math.abs(toInt(arguments[1])));
argInt2 = clamp(0, WarpDriveConfig.SHIP_MAX_SIDE_SIZE, Math.abs(toInt(arguments[2])));
argInt0 = Commons.clamp(0, WarpDriveConfig.SHIP_MAX_SIDE_SIZE, Math.abs(Commons.toInt(arguments[0])));
argInt1 = Commons.clamp(0, WarpDriveConfig.SHIP_MAX_SIDE_SIZE, Math.abs(Commons.toInt(arguments[1])));
argInt2 = Commons.clamp(0, WarpDriveConfig.SHIP_MAX_SIDE_SIZE, Math.abs(Commons.toInt(arguments[2])));
if (WarpDriveConfig.LOGGING_LUA) {
WarpDrive.logger.info(this + " Positive dimensions set to front " + argInt0 + ", right " + argInt1 + ", up " + argInt2);
}
@ -616,9 +615,9 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced {
try {
if (arguments.length == 3) {
int argInt0, argInt1, argInt2;
argInt0 = clamp(0, WarpDriveConfig.SHIP_MAX_SIDE_SIZE, Math.abs(toInt(arguments[0])));
argInt1 = clamp(0, WarpDriveConfig.SHIP_MAX_SIDE_SIZE, Math.abs(toInt(arguments[1])));
argInt2 = clamp(0, WarpDriveConfig.SHIP_MAX_SIDE_SIZE, Math.abs(toInt(arguments[2])));
argInt0 = Commons.clamp(0, WarpDriveConfig.SHIP_MAX_SIDE_SIZE, Math.abs(Commons.toInt(arguments[0])));
argInt1 = Commons.clamp(0, WarpDriveConfig.SHIP_MAX_SIDE_SIZE, Math.abs(Commons.toInt(arguments[1])));
argInt2 = Commons.clamp(0, WarpDriveConfig.SHIP_MAX_SIDE_SIZE, Math.abs(Commons.toInt(arguments[2])));
if (WarpDriveConfig.LOGGING_LUA) {
WarpDrive.logger.info(this + " Negative dimensions set to back " + argInt0 + ", left " + argInt1 + ", down " + argInt2);
}
@ -636,7 +635,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced {
private Object[] mode(Object[] arguments) {
try {
if (arguments.length == 1) {
setMode(toInt(arguments[0]));
setMode(Commons.toInt(arguments[0]));
}
} catch (Exception exception) {
return new Integer[] { mode.getCode() };
@ -648,7 +647,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced {
private Object[] distance(Object[] arguments) {
try {
if (arguments.length == 1) {
setDistance(toInt(arguments[0]));
setDistance(Commons.toInt(arguments[0]));
}
} catch (Exception exception) {
return new Integer[] { getDistance() };
@ -660,7 +659,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced {
private Object[] direction(Object[] arguments) {
try {
if (arguments.length == 1) {
setDirection(toInt(arguments[0]));
setDirection(Commons.toInt(arguments[0]));
}
} catch (Exception exception) {
return new Integer[] { getDirection() };
@ -672,7 +671,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced {
private Object[] movement(Object[] arguments) {
try {
if (arguments.length == 3) {
setMovement(toInt(arguments[0]), toInt(arguments[1]), toInt(arguments[2]));
setMovement(Commons.toInt(arguments[0]), Commons.toInt(arguments[1]), Commons.toInt(arguments[2]));
}
} catch (Exception exception) {
return new Integer[] { moveFront, moveUp, moveRight };
@ -684,7 +683,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced {
private Object[] rotationSteps(Object[] arguments) {
try {
if (arguments.length == 1) {
setRotationSteps((byte)toInt(arguments[0]));
setRotationSteps((byte) Commons.toInt(arguments[0]));
}
} catch (Exception exception) {
return new Integer[] { (int) rotationSteps };
@ -712,7 +711,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced {
}
int playerIndex;
try {
playerIndex = toInt(arguments[0]);
playerIndex = Commons.toInt(arguments[0]);
} catch (Exception exception) {
return new Object[] { false };
}
@ -727,7 +726,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced {
private Object[] getEnergyRequired(Object[] arguments) {
try {
if (arguments.length == 1 && core != null) {
return new Object[] { core.calculateRequiredEnergy(getMode(), core.shipMass, toInt(arguments[0])) };
return new Object[] { core.calculateRequiredEnergy(getMode(), core.shipMass, Commons.toInt(arguments[0])) };
}
} catch (Exception exception) {
return new Integer[] { -1 };

View file

@ -1,10 +1,20 @@
package cr0s.warpdrive.block.movement;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IStarMapRegistryTileEntity;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Jumpgate;
import cr0s.warpdrive.data.StarMapRegistryItem.EnumStarMapEntryType;
import cr0s.warpdrive.data.VectorI;
import cr0s.warpdrive.event.JumpSequencer;
import cr0s.warpdrive.world.SpaceTeleporter;
import java.util.List;
import java.util.UUID;
import cr0s.warpdrive.api.IStarMapRegistryTileEntity;
import cr0s.warpdrive.data.StarMapRegistryItem.EnumStarMapEntryType;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@ -25,20 +35,10 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.StatCollector;
import net.minecraft.util.Vec3;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.util.ForgeDirection;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.Jumpgate;
import cr0s.warpdrive.data.VectorI;
import cr0s.warpdrive.event.JumpSequencer;
import cr0s.warpdrive.world.SpaceTeleporter;
/**
* @author Cr0s
*/
public class TileEntityShipCore extends TileEntityAbstractEnergy implements IStarMapRegistryTileEntity {
public int dx, dz;
@ -355,7 +355,7 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy implements ISta
continue;
}
WarpDrive.addChatMessage((EntityPlayer) object, "[" + (!shipName.isEmpty() ? shipName : "ShipCore") + "] " + msg);
Commons.addChatMessage((EntityPlayer) object, "[" + (!shipName.isEmpty() ? shipName : "ShipCore") + "] " + msg);
}
}
@ -448,7 +448,7 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy implements ISta
EntityPlayerMP entityPlayerMP = MinecraftServer.getServer().getConfigurationManager().func_152612_a(playerName);
StringBuilder reason = new StringBuilder();
if (!validateShipSpatialParameters(reason)) {
WarpDrive.addChatMessage(entityPlayerMP, "[" + (!shipName.isEmpty() ? shipName : "ShipCore") + "] §c" + reason.toString());
Commons.addChatMessage(entityPlayerMP, "[" + (!shipName.isEmpty() ? shipName : "ShipCore") + "] §c" + reason.toString());
return;
}
@ -482,7 +482,7 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy implements ISta
}
if (WarpDriveConfig.SHIP_SUMMON_MAX_RANGE >= 0 && distance > WarpDriveConfig.SHIP_SUMMON_MAX_RANGE) {
messageToAllPlayersOnShip("§c" + String.format("%1$s is too far away to be summoned (max. is %2$d m)", entityPlayer.getDisplayName(), WarpDriveConfig.SHIP_SUMMON_MAX_RANGE));
WarpDrive.addChatMessage(entityPlayer, "§c" + String.format("You are to far away to be summoned aboard '%1$s' (max. is %2$d m)", shipName, WarpDriveConfig.SHIP_SUMMON_MAX_RANGE));
Commons.addChatMessage(entityPlayer, "§c" + String.format("You are to far away to be summoned aboard '%1$s' (max. is %2$d m)", shipName, WarpDriveConfig.SHIP_SUMMON_MAX_RANGE));
return;
}
@ -605,7 +605,9 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy implements ISta
}
updateShipMassAndVolume();
if (!isUnlimited && shipMass > WarpDriveConfig.SHIP_VOLUME_MAX_ON_PLANET_SURFACE && isOnPlanet()) {
if ( !isUnlimited
&& shipMass > WarpDriveConfig.SHIP_VOLUME_MAX_ON_PLANET_SURFACE
&& WarpDrive.starMap.isPlanet(worldObj) ) {
reason.append("Ship is too big for a planet (max is " + WarpDriveConfig.SHIP_VOLUME_MAX_ON_PLANET_SURFACE + " blocks)");
return false;
}

View file

@ -1,27 +1,29 @@
package cr0s.warpdrive.block.movement;
import java.util.ArrayList;
import java.util.List;
import cr0s.warpdrive.item.ItemUpgrade;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import cpw.mods.fml.common.Optional;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import cr0s.warpdrive.damage.DamageTeleportation;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.UpgradeType;
import cr0s.warpdrive.data.Vector3;
import cr0s.warpdrive.item.ItemUpgrade;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.StatCollector;
import cpw.mods.fml.common.Optional;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityTransporter extends TileEntityAbstractEnergy {
private double scanRange = 2;
@ -208,9 +210,9 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy {
try {
if (arguments.length >= 3) {
unlock();
vec.x = toDouble(arguments[0]);
vec.y = toDouble(arguments[1]);
vec.z = toDouble(arguments[2]);
vec.x = Commons.toDouble(arguments[0]);
vec.y = Commons.toDouble(arguments[1]);
vec.z = Commons.toDouble(arguments[2]);
} else if (arguments.length == 1) {
unlock();
if (WarpDriveConfig.TRANSPORTER_USE_RELATIVE_COORDS) {
@ -277,7 +279,7 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy {
private double powerBoost(Object[] arguments) {
try {
if (arguments.length >= 1) {
powerBoost = clamp(1, WarpDriveConfig.TRANSPORTER_MAX_BOOST_MUL, toDouble(arguments[0]));
powerBoost = Commons.clamp(1, WarpDriveConfig.TRANSPORTER_MAX_BOOST_MUL, Commons.toDouble(arguments[0]));
}
} catch (NumberFormatException e) {
powerBoost = 1;
@ -398,7 +400,7 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy {
private double beaconScan(Vector3 s, Vector3 d) {
s = absoluteVector(s);
d = absoluteVector(d);
return beaconScan(toInt(s.x), toInt(s.y), toInt(s.z)) + beaconScan(toInt(d.x), toInt(d.y), toInt(d.z));
return beaconScan(Commons.toInt(s.x), Commons.toInt(s.y), Commons.toInt(s.z)) + beaconScan(Commons.toInt(d.x), Commons.toInt(d.y), Commons.toInt(d.z));
}
private Vector3 absoluteVector(Vector3 a) {
@ -419,7 +421,7 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy {
private static double calculatePower(Vector3 s, Vector3 d) {
double dist = s.distanceTo(d);
return clamp(0, 1, Math.pow(Math.E, -dist / 300));
return Commons.clamp(0, 1, Math.pow(Math.E, -dist / 300));
}
private static double min(double... ds) {
@ -433,7 +435,7 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy {
if (isLocked) {
int rangeUgrades = getUpgradeCount(ItemUpgrade.getItemStack(UpgradeType.Range));
double upgradeBoost = Math.pow(1.2, rangeUgrades);
return clamp(0, 1, baseLockStrength * lockStrengthMul * Math.pow(2, powerBoost - 1) * upgradeBoost * (1 + beaconEffect));
return Commons.clamp(0, 1, baseLockStrength * lockStrengthMul * Math.pow(2, powerBoost - 1) * upgradeBoost * (1 + beaconEffect));
}
return -1;
}

View file

@ -1,5 +1,9 @@
package cr0s.warpdrive.block.passive;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.render.RenderBlockStandard;
import java.util.Random;
import net.minecraft.block.Block;
@ -11,9 +15,6 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.render.RenderBlockStandard;
public class BlockAir extends Block {
private final boolean TRANSPARENT_AIR = true;

View file

@ -1,8 +1,10 @@
package cr0s.warpdrive.block.passive;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.data.EnumDecorativeType;
import java.util.List;
import cr0s.warpdrive.data.EnumDecorativeType;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@ -10,7 +12,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cr0s.warpdrive.WarpDrive;
public class BlockDecorative extends Block {
private static IIcon[] icons;

View file

@ -1,5 +1,7 @@
package cr0s.warpdrive.block.passive;
import cr0s.warpdrive.WarpDrive;
import java.util.Random;
import net.minecraft.block.Block;
@ -10,8 +12,6 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
public class BlockGas extends Block {
private IIcon[] iconBuffer;

View file

@ -1,12 +1,13 @@
package cr0s.warpdrive.block.passive;
import cr0s.warpdrive.WarpDrive;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import cr0s.warpdrive.WarpDrive;
public class BlockHighlyAdvancedMachine extends Block {
public BlockHighlyAdvancedMachine() {

View file

@ -1,12 +1,13 @@
package cr0s.warpdrive.block.passive;
import cr0s.warpdrive.WarpDrive;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import cr0s.warpdrive.WarpDrive;
public class BlockIridium extends Block {
public BlockIridium() {

View file

@ -1,6 +1,7 @@
package cr0s.warpdrive.block.passive;
import cr0s.warpdrive.WarpDrive;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;

View file

@ -1,8 +1,9 @@
package cr0s.warpdrive.block.passive;
import cr0s.warpdrive.data.EnumDecorativeType;
import java.util.List;
import cr0s.warpdrive.data.EnumDecorativeType;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

View file

@ -1,5 +1,10 @@
package cr0s.warpdrive.block.weapon;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
import cr0s.warpdrive.render.ClientCameraHandler;
import java.util.Random;
import net.minecraft.block.material.Material;
@ -10,9 +15,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
import cr0s.warpdrive.render.ClientCameraHandler;
public class BlockLaserCamera extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -64,9 +66,9 @@ public class BlockLaserCamera extends BlockAbstractContainer {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!ClientCameraHandler.isOverlayEnabled) {
if (tileEntity instanceof TileEntityLaserCamera) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityLaserCamera) tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityLaserCamera) tileEntity).getStatus());
} else {
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.guide.prefix",
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.guide.prefix",
getLocalizedName()) + StatCollector.translateToLocalFormatted("warpdrive.error.badTileEntity"));
WarpDrive.logger.error("Block " + this + " with invalid tile entity " + tileEntity);
}

View file

@ -1,5 +1,9 @@
package cr0s.warpdrive.block.weapon;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
import java.util.Random;
import net.minecraft.block.material.Material;
@ -10,8 +14,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
public class BlockWeaponController extends BlockAbstractContainer {
private IIcon[] iconBuffer;
@ -65,9 +67,9 @@ public class BlockWeaponController extends BlockAbstractContainer {
if (entityPlayer.getHeldItem() == null) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityWeaponController) {
WarpDrive.addChatMessage(entityPlayer, ((TileEntityWeaponController) tileEntity).getStatus());
Commons.addChatMessage(entityPlayer, ((TileEntityWeaponController) tileEntity).getStatus());
} else {
WarpDrive.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.guide.prefix",
Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.guide.prefix",
getLocalizedName()) + StatCollector.translateToLocalFormatted("warpdrive.error.badTileEntity"));
WarpDrive.logger.error("Block " + this + " with invalid tile entity " + tileEntity);
}

View file

@ -1,15 +1,6 @@
package cr0s.warpdrive.block.weapon;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.StatCollector;
import net.minecraft.world.ChunkPosition;
import cpw.mods.fml.common.Optional;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.api.IVideoChannel;
import cr0s.warpdrive.block.TileEntityLaser;
@ -19,6 +10,18 @@ import cr0s.warpdrive.data.EnumCameraType;
import cr0s.warpdrive.network.PacketHandler;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.StatCollector;
import net.minecraft.world.ChunkPosition;
import cpw.mods.fml.common.Optional;
public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChannel {
private int videoChannel = -1;
@ -169,7 +172,7 @@ public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChan
if (methodName.equals("videoChannel")) {
if (arguments.length == 1) {
setVideoChannel(toInt(arguments[0]));
setVideoChannel(Commons.toInt(arguments[0]));
}
return new Integer[] { videoChannel };
}

View file

@ -1,10 +1,10 @@
package cr0s.warpdrive.block.weapon;
import cr0s.warpdrive.block.TileEntityAbstractInterfaced;
import java.util.Arrays;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import cr0s.warpdrive.block.TileEntityAbstractInterfaced;
public class TileEntityWeaponController extends TileEntityAbstractInterfaced {

View file

@ -1,10 +1,11 @@
package cr0s.warpdrive.client;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cr0s.warpdrive.CommonProxy;
import cr0s.warpdrive.entity.EntityParticleBunch;
import cr0s.warpdrive.render.RenderEntityParticleBunch;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class ClientProxy extends CommonProxy {
@Override

View file

@ -1,12 +1,13 @@
package cr0s.warpdrive.client;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.MovingSound;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class SirenSound extends MovingSound {
ResourceLocation resource;

View file

@ -1,19 +1,18 @@
package cr0s.warpdrive.command;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
import net.minecraft.block.Block;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import cpw.mods.fml.common.FMLCommonHandler;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
/*
* /wdebug <dimension> <coordinates> <blockId> <Metadata> <actions>
*/
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraftforge.common.DimensionManager;
public class CommandDebug extends CommandBase
{
@ -85,7 +84,7 @@ public class CommandDebug extends CommandBase
catch (Exception exception)
{
exception.printStackTrace();
WarpDrive.addChatMessage(player, getCommandUsage(icommandsender));
Commons.addChatMessage(player, getCommandUsage(icommandsender));
return;
}
@ -156,7 +155,7 @@ public class CommandDebug extends CommandBase
}
else
{
WarpDrive.addChatMessage(player, getCommandUsage(icommandsender));
Commons.addChatMessage(player, getCommandUsage(icommandsender));
}
}

View file

@ -1,21 +1,24 @@
package cr0s.warpdrive.command;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import java.util.*;
import java.util.Map.Entry;
/*
* /wentity <radius> <filter> <kill?>
*/
public class CommandEntity extends CommandBase {
private static final List<String> entitiesNoRemoval = Arrays.asList(
"item.EntityItemFrame_"
@ -45,7 +48,7 @@ public class CommandEntity extends CommandBase {
@Override
public void processCommand(ICommandSender icommandsender, String[] params) {
if (params.length > 3) {
WarpDrive.addChatMessage(icommandsender, getCommandUsage(icommandsender));
Commons.addChatMessage(icommandsender, getCommandUsage(icommandsender));
return;
}
@ -72,7 +75,7 @@ public class CommandEntity extends CommandBase {
}
} catch (Exception exception) {
exception.printStackTrace();
WarpDrive.addChatMessage(icommandsender, getCommandUsage(icommandsender));
Commons.addChatMessage(icommandsender, getCommandUsage(icommandsender));
return;
}
@ -86,14 +89,14 @@ public class CommandEntity extends CommandBase {
} else if (radius <= 0) {
world = DimensionManager.getWorld(0);
} else {
WarpDrive.addChatMessage(icommandsender, getCommandUsage(icommandsender));
Commons.addChatMessage(icommandsender, getCommandUsage(icommandsender));
return;
}
entities = new ArrayList<>();
entities.addAll(world.loadedEntityList);
} else {
if (!(icommandsender instanceof EntityPlayerMP)) {
WarpDrive.addChatMessage(icommandsender, getCommandUsage(icommandsender));
Commons.addChatMessage(icommandsender, getCommandUsage(icommandsender));
return;
}
EntityPlayerMP entityPlayer = (EntityPlayerMP) icommandsender;
@ -127,7 +130,7 @@ public class CommandEntity extends CommandBase {
counts.put(name, counts.get(name) + 1);
}
if (!filter.isEmpty()) {
WarpDrive.addChatMessage(icommandsender, "§cFound " + object);
Commons.addChatMessage(icommandsender, "§cFound " + object);
}
// remove entity
if (kill && !((Entity) object).invulnerable) {
@ -144,14 +147,14 @@ public class CommandEntity extends CommandBase {
}
}
if (count == 0) {
WarpDrive.addChatMessage(icommandsender, "§cNo matching entities found within " + radius + " blocks");
Commons.addChatMessage(icommandsender, "§cNo matching entities found within " + radius + " blocks");
return;
}
WarpDrive.addChatMessage(icommandsender, "§6" + count + " matching entities within " + radius + " blocks:");
Commons.addChatMessage(icommandsender, "§6" + count + " matching entities within " + radius + " blocks:");
if (counts.size() < 10) {
for (Entry<String, Integer> entry : counts.entrySet()) {
WarpDrive.addChatMessage(icommandsender, "§f" + entry.getValue() + "§8x§d" + entry.getKey());
Commons.addChatMessage(icommandsender, "§f" + entry.getValue() + "§8x§d" + entry.getKey());
}
} else {
String message = "";
@ -161,7 +164,7 @@ public class CommandEntity extends CommandBase {
}
message += "§f" + entry.getValue() + "§8x§d" + entry.getKey();
}
WarpDrive.addChatMessage(icommandsender, message);
Commons.addChatMessage(icommandsender, message);
}
}
}

View file

@ -1,24 +1,21 @@
package cr0s.warpdrive.command;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.structures.AbstractStructure;
import cr0s.warpdrive.config.structures.StructureManager;
import cr0s.warpdrive.world.JumpgateGenerator;
import cr0s.warpdrive.world.SpaceWorldGenerator;
import cr0s.warpdrive.world.WorldGenSmallShip;
import cr0s.warpdrive.world.WorldGenStation;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.structures.AbstractStructure;
import cr0s.warpdrive.config.structures.StructureManager;
import cr0s.warpdrive.world.JumpgateGenerator;
import cr0s.warpdrive.world.WorldGenSmallShip;
import cr0s.warpdrive.world.WorldGenStation;
/*
* /generate <structure>
* Possible structures:
* moon, ship, asteroid, astfield, gascloud, star
*/
import cpw.mods.fml.common.FMLCommonHandler;
public class CommandGenerate extends CommandBase {
@Override
@ -42,7 +39,7 @@ public class CommandGenerate extends CommandBase {
ChunkCoordinates coordinates = commandSender.getPlayerCoordinates();
if (world == null || coordinates == null) {
WarpDrive.addChatMessage(commandSender, "* generate: unknown world or coordinates, probably an invalid command sender in action here.");
Commons.addChatMessage(commandSender, "* generate: unknown world or coordinates, probably an invalid command sender in action here.");
return;
}
int x = coordinates.posX;
@ -50,7 +47,7 @@ public class CommandGenerate extends CommandBase {
int z = coordinates.posZ;
if (params.length <= 0 || params.length == 3 || params.length > 5) {
WarpDrive.addChatMessage(commandSender, getCommandUsage(commandSender));
Commons.addChatMessage(commandSender, getCommandUsage(commandSender));
return;
}
@ -64,7 +61,7 @@ public class CommandGenerate extends CommandBase {
// Reject command, if player is not in space
if (!WarpDrive.starMap.isInSpace(world) && (!"ship".equals(structure))) {
WarpDrive.addChatMessage(commandSender, "* generate: this structure is only allowed in space!");
Commons.addChatMessage(commandSender, "* generate: this structure is only allowed in space!");
return;
}
@ -97,7 +94,7 @@ public class CommandGenerate extends CommandBase {
break;
case "jumpgate":
if (params.length != 2) {
WarpDrive.addChatMessage(commandSender, "Missing jumpgate name");
Commons.addChatMessage(commandSender, "Missing jumpgate name");
} else {
WarpDrive.logger.info("/generate: creating jumpgate at " + x + ", " + y + ", " + z);
@ -109,7 +106,7 @@ public class CommandGenerate extends CommandBase {
}
break;
default:
WarpDrive.addChatMessage(commandSender, getCommandUsage(commandSender));
Commons.addChatMessage(commandSender, getCommandUsage(commandSender));
break;
}
}
@ -130,7 +127,7 @@ public class CommandGenerate extends CommandBase {
private void generateStructure(ICommandSender commandSender, final String group, final String name, World world, final int x, final int y, final int z) {
AbstractStructure structure = StructureManager.getStructure(world.rand, group, name);
if (structure == null) {
WarpDrive.addChatMessage(commandSender, "Invalid " + group + " '" + name + "', try one of the followings:\n" + StructureManager.getStructureNames(group));
Commons.addChatMessage(commandSender, "Invalid " + group + " '" + name + "', try one of the followings:\n" + StructureManager.getStructureNames(group));
} else {
WarpDrive.logger.info("/generate: Generating " + group + ":" + structure.getName() + " at " + x + " " + y + " " + z);
structure.generate(world, world.rand, x, y, z);

Some files were not shown because too many files have changed in this diff Show more