Code cleanup

This commit is contained in:
Unknown 2019-07-01 10:29:51 +02:00 committed by unknown
parent 48a6736a57
commit f5b313f6a3
9 changed files with 20 additions and 13 deletions

View file

@ -5,6 +5,8 @@ import cr0s.warpdrive.event.EMPReceiver;
import cr0s.warpdrive.event.ItemHandler; import cr0s.warpdrive.event.ItemHandler;
import cr0s.warpdrive.event.LivingHandler; import cr0s.warpdrive.event.LivingHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.UUID; import java.util.UUID;
import java.util.WeakHashMap; import java.util.WeakHashMap;
@ -28,7 +30,8 @@ public class CommonProxy {
private static final WeakHashMap<GameProfile, WeakReference<EntityPlayer>> fakePlayers = new WeakHashMap<>(100); 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; assert world.getMinecraftServer() != null;
for (final EntityPlayerMP entityPlayerMP : world.getMinecraftServer().getPlayerList().getPlayers()) { for (final EntityPlayerMP entityPlayerMP : world.getMinecraftServer().getPlayerList().getPlayers()) {
if (entityPlayerMP.getUniqueID() == uuidPlayer) { if (entityPlayerMP.getUniqueID() == uuidPlayer) {
@ -59,7 +62,7 @@ public class CommonProxy {
} }
public static boolean isBlockBreakCanceled(final UUID uuidPlayer, final BlockPos blockPosSource, 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)) { if (world.isRemote || !(world instanceof WorldServer)) {
return false; return false;
} }
@ -84,7 +87,7 @@ public class CommonProxy {
} }
public static boolean isBlockPlaceCanceled(final UUID uuidPlayer, final BlockPos blockPosSource, 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)) { if (world.isRemote || !(world instanceof WorldServer)) {
return false; return false;
} }

View file

@ -678,6 +678,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
return state(); return state();
} }
@Nonnull
private Object[] scan() { private Object[] scan() {
// Already scanning? // Already scanning?
if (enumShipScannerState != EnumShipScannerState.IDLE) { if (enumShipScannerState != EnumShipScannerState.IDLE) {
@ -692,6 +693,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
return new Object[] { success, 3, Commons.removeFormatting( reason.getUnformattedText() ) }; return new Object[] { success, 3, Commons.removeFormatting( reason.getUnformattedText() ) };
} }
@Nonnull
private Object[] filename() { private Object[] filename() {
if (enumShipScannerState != EnumShipScannerState.IDLE && !schematicFileName.isEmpty()) { if (enumShipScannerState != EnumShipScannerState.IDLE && !schematicFileName.isEmpty()) {
if (enumShipScannerState == EnumShipScannerState.DEPLOYING) { if (enumShipScannerState == EnumShipScannerState.DEPLOYING) {
@ -704,6 +706,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
return new Object[] { true, schematicFileName }; return new Object[] { true, schematicFileName };
} }
@Nonnull
private Object[] deploy(final Object[] arguments) { private Object[] deploy(final Object[] arguments) {
if (arguments == null || arguments.length != 5) { if (arguments == null || arguments.length != 5) {
return new Object[] { false, "Invalid arguments count, you need <.schematic file name>, <offsetX>, <offsetY>, <offsetZ>, <rotationSteps>!" }; 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() ) }; return new Object[] { isSuccess, Commons.removeFormatting( reason.getUnformattedText() ) };
} }
@Nonnull
private Object[] state() { private Object[] state() {
switch (enumShipScannerState) { switch (enumShipScannerState) {
default: default:

View file

@ -159,7 +159,7 @@ public class TileEntityShipCore extends TileEntityAbstractShipController impleme
if (ticksCooldown > 0) { if (ticksCooldown > 0) {
ticksCooldown--; ticksCooldown--;
// report coo down time when a command is requested // report cool down time when a command is requested
if ( isEnabled if ( isEnabled
&& isCommandConfirmed && isCommandConfirmed
&& enumShipCommand.isMovement() ) { && enumShipCommand.isMovement() ) {

View file

@ -41,7 +41,6 @@ public class CommandRender extends AbstractCommand {
if (args.length > 0) { if (args.length > 0) {
Commons.addChatMessage(commandSender, new TextComponentString(getUsage(commandSender))); Commons.addChatMessage(commandSender, new TextComponentString(getUsage(commandSender)));
return; return;
} }
final EntityPlayerMP entityPlayer = commandSender instanceof EntityPlayerMP ? (EntityPlayerMP) commandSender : null; final EntityPlayerMP entityPlayer = commandSender instanceof EntityPlayerMP ? (EntityPlayerMP) commandSender : null;

View file

@ -155,6 +155,7 @@ public class ClassTransformer implements net.minecraft.launchwrapper.IClassTrans
sizeClass.put(shortName, size + bytes.length); sizeClass.put(shortName, size + bytes.length);
} }
@Nonnull
public static String getClientValidation() { public static String getClientValidation() {
final StringBuilder result = new StringBuilder().append(new Date().toString()); final StringBuilder result = new StringBuilder().append(new Date().toString());
for (final String key : countClass.keySet()) { for (final String key : countClass.keySet()) {

View file

@ -9,7 +9,6 @@ import cr0s.warpdrive.data.Vector3;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.DataSerializers;

View file

@ -241,7 +241,7 @@ public class RenderCommons {
renderer renderer
.pos( Float.intBitsToFloat(vData[size * i ]), .pos( Float.intBitsToFloat(vData[size * i ]),
Float.intBitsToFloat(vData[size * i + 1]), Float.intBitsToFloat(vData[size * i + 1]),
Float.intBitsToFloat(vData[size * i + 2])) Float.intBitsToFloat(vData[size * i + 2]) )
.color(255, 255, 255, 255) .color(255, 255, 255, 255)
.tex(Float.intBitsToFloat(vData[size * i + uv]), Float.intBitsToFloat(vData[size * i + uv + 1])) .tex(Float.intBitsToFloat(vData[size * i + uv]), Float.intBitsToFloat(vData[size * i + uv + 1]))
.lightmap(l1, l2) .lightmap(l1, l2)

View file

@ -8,6 +8,7 @@ import cr0s.warpdrive.data.CelestialObject.RenderData;
import cr0s.warpdrive.data.StarMapRegistry; import cr0s.warpdrive.data.StarMapRegistry;
import cr0s.warpdrive.data.Vector3; import cr0s.warpdrive.data.Vector3;
import javax.annotation.Nonnull;
import java.awt.Color; import java.awt.Color;
import java.util.Random; import java.util.Random;
@ -489,7 +490,7 @@ public class RenderSpaceSky extends IRenderHandler {
// colorization loosely inspired from Hertzsprung-Russell diagram // colorization loosely inspired from Hertzsprung-Russell diagram
// (we're using it for non-star objects too, so yeah...) // (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 double colorType = rand.nextDouble();
final float hue; final float hue;
final float saturation; final float saturation;