Code cleanup
This commit is contained in:
parent
48a6736a57
commit
f5b313f6a3
9 changed files with 20 additions and 13 deletions
|
@ -5,6 +5,8 @@ import cr0s.warpdrive.event.EMPReceiver;
|
|||
import cr0s.warpdrive.event.ItemHandler;
|
||||
import cr0s.warpdrive.event.LivingHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
|
@ -28,7 +30,8 @@ public class CommonProxy {
|
|||
|
||||
private static final WeakHashMap<GameProfile, WeakReference<EntityPlayer>> fakePlayers = new WeakHashMap<>(100);
|
||||
|
||||
private static EntityPlayerMP getPlayer(final WorldServer world, final UUID uuidPlayer) {
|
||||
@Nullable
|
||||
private static EntityPlayerMP getPlayer(@Nonnull final WorldServer world, final UUID uuidPlayer) {
|
||||
assert world.getMinecraftServer() != null;
|
||||
for (final EntityPlayerMP entityPlayerMP : world.getMinecraftServer().getPlayerList().getPlayers()) {
|
||||
if (entityPlayerMP.getUniqueID() == uuidPlayer) {
|
||||
|
@ -59,7 +62,7 @@ public class CommonProxy {
|
|||
}
|
||||
|
||||
public static boolean isBlockBreakCanceled(final UUID uuidPlayer, final BlockPos blockPosSource,
|
||||
final World world, final BlockPos blockPosEvent) {
|
||||
@Nonnull final World world, final BlockPos blockPosEvent) {
|
||||
if (world.isRemote || !(world instanceof WorldServer)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -84,7 +87,7 @@ public class CommonProxy {
|
|||
}
|
||||
|
||||
public static boolean isBlockPlaceCanceled(final UUID uuidPlayer, final BlockPos blockPosSource,
|
||||
final World world, final BlockPos blockPosEvent, final IBlockState blockState) {
|
||||
@Nonnull final World world, final BlockPos blockPosEvent, final IBlockState blockState) {
|
||||
if (world.isRemote || !(world instanceof WorldServer)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
|
|||
private int laserTicks = 0;
|
||||
private int scanTicks = 0;
|
||||
private int deployTicks = 0;
|
||||
|
||||
|
||||
private int searchTicks = 0;
|
||||
|
||||
private String playerName = "";
|
||||
|
@ -421,7 +421,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
|
|||
|
||||
// Returns true on success and reason string
|
||||
private boolean deployShip(final String fileName, final int offsetX, final int offsetY, final int offsetZ,
|
||||
final byte rotationSteps, final boolean isForced, final WarpDriveText reason) {
|
||||
final byte rotationSteps, final boolean isForced, final WarpDriveText reason) {
|
||||
targetX = pos.getX() + offsetX;
|
||||
targetY = pos.getY() + offsetY;
|
||||
targetZ = pos.getZ() + offsetZ;
|
||||
|
@ -678,6 +678,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
|
|||
return state();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private Object[] scan() {
|
||||
// Already scanning?
|
||||
if (enumShipScannerState != EnumShipScannerState.IDLE) {
|
||||
|
@ -692,6 +693,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
|
|||
return new Object[] { success, 3, Commons.removeFormatting( reason.getUnformattedText() ) };
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private Object[] filename() {
|
||||
if (enumShipScannerState != EnumShipScannerState.IDLE && !schematicFileName.isEmpty()) {
|
||||
if (enumShipScannerState == EnumShipScannerState.DEPLOYING) {
|
||||
|
@ -704,6 +706,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
|
|||
return new Object[] { true, schematicFileName };
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private Object[] deploy(final Object[] arguments) {
|
||||
if (arguments == null || arguments.length != 5) {
|
||||
return new Object[] { false, "Invalid arguments count, you need <.schematic file name>, <offsetX>, <offsetY>, <offsetZ>, <rotationSteps>!" };
|
||||
|
@ -743,6 +746,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
|
|||
return new Object[] { isSuccess, Commons.removeFormatting( reason.getUnformattedText() ) };
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private Object[] state() {
|
||||
switch (enumShipScannerState) {
|
||||
default:
|
||||
|
|
|
@ -159,7 +159,7 @@ public class TileEntityShipCore extends TileEntityAbstractShipController impleme
|
|||
if (ticksCooldown > 0) {
|
||||
ticksCooldown--;
|
||||
|
||||
// report coo down time when a command is requested
|
||||
// report cool down time when a command is requested
|
||||
if ( isEnabled
|
||||
&& isCommandConfirmed
|
||||
&& enumShipCommand.isMovement() ) {
|
||||
|
|
|
@ -41,7 +41,6 @@ public class CommandRender extends AbstractCommand {
|
|||
if (args.length > 0) {
|
||||
Commons.addChatMessage(commandSender, new TextComponentString(getUsage(commandSender)));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final EntityPlayerMP entityPlayer = commandSender instanceof EntityPlayerMP ? (EntityPlayerMP) commandSender : null;
|
||||
|
|
|
@ -821,13 +821,13 @@ public class WarpDriveConfig {
|
|||
TOOLTIP_ADD_ORE_DICTIONARY_NAME = EnumTooltipCondition.valueOf(config.get("tooltip", "add_ore_dictionary_name", TOOLTIP_ADD_ORE_DICTIONARY_NAME.name(),
|
||||
String.format(commentTooltip, "ore dictionary names")).getString());
|
||||
TOOLTIP_ADD_ARMOR_POINTS = EnumTooltipCondition.valueOf(config.get("tooltip", "add_armor_points", TOOLTIP_ADD_ARMOR_POINTS.name(),
|
||||
String.format(commentTooltip, "armor points")).getString());
|
||||
String.format(commentTooltip, "armor points")).getString());
|
||||
TOOLTIP_ADD_BURN_TIME = EnumTooltipCondition.valueOf(config.get("tooltip", "add_burn_time", TOOLTIP_ADD_BURN_TIME.name(),
|
||||
String.format(commentTooltip, "burn time")).getString());
|
||||
TOOLTIP_ADD_DURABILITY = EnumTooltipCondition.valueOf(config.get("tooltip", "add_durability", TOOLTIP_ADD_DURABILITY.name(),
|
||||
String.format(commentTooltip, "durability")).getString());
|
||||
TOOLTIP_ADD_ENCHANTABILITY = EnumTooltipCondition.valueOf(config.get("tooltip", "add_enchantability", TOOLTIP_ADD_ENCHANTABILITY.name(),
|
||||
String.format(commentTooltip, "armor & tool enchantability")).getString());
|
||||
String.format(commentTooltip, "armor & tool enchantability")).getString());
|
||||
TOOLTIP_ADD_ENTITY_ID = EnumTooltipCondition.valueOf(config.get("tooltip", "add_entity_id", TOOLTIP_ADD_ENTITY_ID.name(),
|
||||
String.format(commentTooltip, "entity id")).getString());
|
||||
TOOLTIP_ADD_FLAMMABILITY = EnumTooltipCondition.valueOf(config.get("tooltip", "add_flammability", TOOLTIP_ADD_FLAMMABILITY.name(),
|
||||
|
|
|
@ -155,6 +155,7 @@ public class ClassTransformer implements net.minecraft.launchwrapper.IClassTrans
|
|||
sizeClass.put(shortName, size + bytes.length);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String getClientValidation() {
|
||||
final StringBuilder result = new StringBuilder().append(new Date().toString());
|
||||
for (final String key : countClass.keySet()) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import cr0s.warpdrive.data.Vector3;
|
|||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.datasync.DataParameter;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
|
|
|
@ -240,8 +240,8 @@ public class RenderCommons {
|
|||
for (int i = 0; i < 4; ++i) {
|
||||
renderer
|
||||
.pos( Float.intBitsToFloat(vData[size * i ]),
|
||||
Float.intBitsToFloat(vData[size * i + 1]),
|
||||
Float.intBitsToFloat(vData[size * i + 2]))
|
||||
Float.intBitsToFloat(vData[size * i + 1]),
|
||||
Float.intBitsToFloat(vData[size * i + 2]) )
|
||||
.color(255, 255, 255, 255)
|
||||
.tex(Float.intBitsToFloat(vData[size * i + uv]), Float.intBitsToFloat(vData[size * i + uv + 1]))
|
||||
.lightmap(l1, l2)
|
||||
|
|
|
@ -8,6 +8,7 @@ import cr0s.warpdrive.data.CelestialObject.RenderData;
|
|||
import cr0s.warpdrive.data.StarMapRegistry;
|
||||
import cr0s.warpdrive.data.Vector3;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.Color;
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -489,7 +490,7 @@ public class RenderSpaceSky extends IRenderHandler {
|
|||
|
||||
// colorization loosely inspired from Hertzsprung-Russell diagram
|
||||
// (we're using it for non-star objects too, so yeah...)
|
||||
private static int getStarColorRGB(final Random rand) {
|
||||
private static int getStarColorRGB(@Nonnull final Random rand) {
|
||||
final double colorType = rand.nextDouble();
|
||||
final float hue;
|
||||
final float saturation;
|
||||
|
|
Loading…
Reference in a new issue