mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-08 17:33:01 +00:00
Remove unnecessary code
- Remove unnecessary casts - Use the diamond operator where possible - Remove "throws" declarations that aren't actually thrown - Remove unused local variables - Remove unused imports - Remove redundant superinterfaces
This commit is contained in:
@@ -159,7 +159,7 @@ public abstract class TileGeneric extends TileEntity
|
||||
double range = getInteractRange( player );
|
||||
BlockPos pos = getPos();
|
||||
return player.getEntityWorld() == getWorld() &&
|
||||
player.getDistanceSq( (double)pos.getX() + 0.5, (double)pos.getY() + 0.5, (double)pos.getZ() + 0.5 ) <= ( range * range );
|
||||
player.getDistanceSq( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ) <= ( range * range );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package dan200.computercraft.shared.computer.blocks;
|
||||
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
@@ -50,7 +49,7 @@ public class ComputerPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments ) throws LuaException
|
||||
public Object[] callMethod( @Nonnull IComputerAccess computer, @Nonnull ILuaContext context, int method, @Nonnull Object[] arguments )
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
|
||||
@@ -19,7 +19,6 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class TileComputer extends TileComputerBase
|
||||
{
|
||||
|
||||
@@ -290,7 +290,7 @@ public class ServerComputer extends ServerTerminal
|
||||
@Override
|
||||
public double getTimeOfDay()
|
||||
{
|
||||
return (double)((m_world.getWorldTime() + 6000) % 24000) / 1000.0;
|
||||
return (m_world.getWorldTime() + 6000) % 24000 / 1000.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package dan200.computercraft.shared.peripheral.common;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.common.IDirectionalTile;
|
||||
import dan200.computercraft.shared.common.TileGeneric;
|
||||
import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -20,7 +19,7 @@ import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class TilePeripheralBase extends TileGeneric
|
||||
implements IPeripheralTile, IDirectionalTile, ITickable
|
||||
implements IPeripheralTile, ITickable
|
||||
{
|
||||
// Statics
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
@@ -44,7 +43,7 @@ import java.util.Set;
|
||||
import static net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY;
|
||||
|
||||
public class TileDiskDrive extends TilePeripheralBase
|
||||
implements IInventory, ITickable
|
||||
implements IInventory
|
||||
{
|
||||
// Statics
|
||||
|
||||
@@ -615,13 +614,13 @@ public class TileDiskDrive extends TilePeripheralBase
|
||||
}
|
||||
|
||||
BlockPos pos = getPos();
|
||||
double x = (double)pos.getX() + 0.5 + ((double)xOff * 0.5);
|
||||
double y = (double)pos.getY() + 0.75;
|
||||
double z = (double)pos.getZ() + 0.5 + ((double)zOff * 0.5);
|
||||
double x = pos.getX() + 0.5 + (xOff * 0.5);
|
||||
double y = pos.getY() + 0.75;
|
||||
double z = pos.getZ() + 0.5 + (zOff * 0.5);
|
||||
EntityItem entityitem = new EntityItem( getWorld(), x, y, z, disks );
|
||||
entityitem.motionX = (double)xOff * 0.15;
|
||||
entityitem.motionX = xOff * 0.15;
|
||||
entityitem.motionY = 0.0;
|
||||
entityitem.motionZ = (double)zOff * 0.15;
|
||||
entityitem.motionZ = zOff * 0.15;
|
||||
|
||||
getWorld().spawnEntity(entityitem);
|
||||
if( !destroyed )
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TileAdvancedModem extends TileModemBase
|
||||
public Vec3d getPosition()
|
||||
{
|
||||
BlockPos pos = m_entity.getPos().offset( m_entity.getDirection() );
|
||||
return new Vec3d( (double)pos.getX(), (double)pos.getY(), (double)pos.getZ() );
|
||||
return new Vec3d( pos.getX(), pos.getY(), pos.getZ() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -101,7 +101,7 @@ public class TileCable extends TileModemBase
|
||||
{
|
||||
EnumFacing direction = m_entity.getDirection();
|
||||
BlockPos pos = m_entity.getPos().offset( direction );
|
||||
return new Vec3d( (double)pos.getX() + 0.5, (double)pos.getY() + 0.5, (double)pos.getZ() + 0.5 );
|
||||
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -1032,12 +1032,12 @@ public class TileCable extends TileModemBase
|
||||
Queue<SearchLoc> queue = new LinkedList<>();
|
||||
enqueue( queue, getWorld(), getPos(), 1 );
|
||||
|
||||
int visited = 0;
|
||||
//int visited = 0;
|
||||
while( queue.peek() != null )
|
||||
{
|
||||
SearchLoc loc = queue.remove();
|
||||
visitBlock( queue, loc, searchID, visitor );
|
||||
visited++;
|
||||
//visited++;
|
||||
}
|
||||
//System.out.println( "Visited "+visited+" common" );
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class TileWirelessModem extends TileModemBase
|
||||
public Vec3d getPosition()
|
||||
{
|
||||
BlockPos pos = m_entity.getPos().offset( m_entity.getDirection() );
|
||||
return new Vec3d( (double)pos.getX(), (double)pos.getY(), (double)pos.getZ() );
|
||||
return new Vec3d( pos.getX(), pos.getY(), pos.getZ() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,7 +31,7 @@ public abstract class WirelessModemPeripheral extends ModemPeripheral
|
||||
{
|
||||
if( m_advanced )
|
||||
{
|
||||
return (double)Integer.MAX_VALUE;
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -39,12 +39,12 @@ public abstract class WirelessModemPeripheral extends ModemPeripheral
|
||||
if( world != null )
|
||||
{
|
||||
Vec3d position = getPosition();
|
||||
double minRange = (double) ComputerCraft.modem_range;
|
||||
double maxRange = (double) ComputerCraft.modem_highAltitudeRange;
|
||||
double minRange = ComputerCraft.modem_range;
|
||||
double maxRange = ComputerCraft.modem_highAltitudeRange;
|
||||
if( world.isRaining() && world.isThundering() )
|
||||
{
|
||||
minRange = (double) ComputerCraft.modem_rangeDuringStorm;
|
||||
maxRange = (double) ComputerCraft.modem_highAltitudeRangeDuringStorm;
|
||||
minRange = ComputerCraft.modem_rangeDuringStorm;
|
||||
maxRange = ComputerCraft.modem_highAltitudeRangeDuringStorm;
|
||||
}
|
||||
if( position.y > 96.0 && maxRange > minRange )
|
||||
{
|
||||
|
||||
@@ -290,7 +290,7 @@ public class TileMonitor extends TilePeripheralBase
|
||||
|
||||
public double getTextScale()
|
||||
{
|
||||
return (double)m_textScale * 0.5;
|
||||
return m_textScale * 0.5;
|
||||
}
|
||||
|
||||
private void rebuildTerminal()
|
||||
@@ -301,11 +301,11 @@ public class TileMonitor extends TilePeripheralBase
|
||||
|
||||
double textScale = getTextScale();
|
||||
int termWidth = (int)Math.max(
|
||||
Math.round( ((double)m_width - 2.0 * ( TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN )) / (textScale * 6.0 * TileMonitor.RENDER_PIXEL_SCALE) ),
|
||||
Math.round( (m_width - 2.0 * ( TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN )) / (textScale * 6.0 * TileMonitor.RENDER_PIXEL_SCALE) ),
|
||||
1.0
|
||||
);
|
||||
int termHeight = (int)Math.max(
|
||||
Math.round( ((double)m_height - 2.0 * ( TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN )) / (textScale * 9.0 * TileMonitor.RENDER_PIXEL_SCALE) ),
|
||||
Math.round( (m_height - 2.0 * ( TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN )) / (textScale * 9.0 * TileMonitor.RENDER_PIXEL_SCALE) ),
|
||||
1.0
|
||||
);
|
||||
((ServerTerminal)getLocalTerminal()).resize( termWidth, termHeight );
|
||||
@@ -709,11 +709,11 @@ public class TileMonitor extends TilePeripheralBase
|
||||
return;
|
||||
}
|
||||
|
||||
double xCharWidth = ((double)m_width - ((RENDER_BORDER + RENDER_MARGIN) * 2.0)) / ((double)originTerminal.getWidth());
|
||||
double yCharHeight = ((double)m_height - ((RENDER_BORDER + RENDER_MARGIN) * 2.0)) / ((double)originTerminal.getHeight());
|
||||
double xCharWidth = (m_width - ((RENDER_BORDER + RENDER_MARGIN) * 2.0)) / (originTerminal.getWidth());
|
||||
double yCharHeight = (m_height - ((RENDER_BORDER + RENDER_MARGIN) * 2.0)) / (originTerminal.getHeight());
|
||||
|
||||
int xCharPos = (int)Math.min((double)originTerminal.getWidth(), Math.max(((pair.x - RENDER_BORDER - RENDER_MARGIN) / xCharWidth) + 1.0, 1.0));
|
||||
int yCharPos = (int)Math.min((double)originTerminal.getHeight(), Math.max(((pair.y - RENDER_BORDER - RENDER_MARGIN) / yCharHeight) + 1.0, 1.0));
|
||||
int xCharPos = (int)Math.min(originTerminal.getWidth(), Math.max(((pair.x - RENDER_BORDER - RENDER_MARGIN) / xCharWidth) + 1.0, 1.0));
|
||||
int yCharPos = (int)Math.min(originTerminal.getHeight(), Math.max(((pair.y - RENDER_BORDER - RENDER_MARGIN) / yCharHeight) + 1.0, 1.0));
|
||||
|
||||
for( int y=0; y<m_height; ++y )
|
||||
{
|
||||
|
||||
@@ -17,7 +17,6 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -42,7 +41,7 @@ import javax.annotation.Nullable;
|
||||
import static net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY;
|
||||
|
||||
public class TilePrinter extends TilePeripheralBase
|
||||
implements IInventory, ISidedInventory
|
||||
implements ISidedInventory
|
||||
{
|
||||
// Statics
|
||||
|
||||
@@ -583,9 +582,9 @@ public class TilePrinter extends TilePeripheralBase
|
||||
|
||||
// Spawn the item in the world
|
||||
BlockPos pos = getPos();
|
||||
double x = (double)pos.getX() + 0.5;
|
||||
double y = (double)pos.getY() + 0.75;
|
||||
double z = (double)pos.getZ() + 0.5;
|
||||
double x = pos.getX() + 0.5;
|
||||
double y = pos.getY() + 0.75;
|
||||
double z = pos.getZ() + 0.5;
|
||||
EntityItem entityitem = new EntityItem( getWorld(), x, y, z, stack );
|
||||
entityitem.motionX = getWorld().rand.nextFloat() * 0.2 - 0.1;
|
||||
entityitem.motionY = getWorld().rand.nextFloat() * 0.2 - 0.1;
|
||||
|
||||
@@ -170,7 +170,7 @@ public class SpeakerPeripheral implements IPeripheral {
|
||||
{
|
||||
@Nullable
|
||||
@Override
|
||||
public Object[] execute() throws LuaException
|
||||
public Object[] execute()
|
||||
{
|
||||
world.playSound( null, pos, SoundEvent.REGISTRY.getObject( resource ), SoundCategory.RECORDS, Math.min( vol, 3f ), soundPitch );
|
||||
return null;
|
||||
|
||||
@@ -48,7 +48,7 @@ import java.util.List;
|
||||
import static net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY;
|
||||
|
||||
public class TileTurtle extends TileComputerBase
|
||||
implements ITurtleTile, IInventory, ITickable
|
||||
implements ITurtleTile, IInventory
|
||||
{
|
||||
// Statics
|
||||
|
||||
|
||||
@@ -936,11 +936,11 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
}
|
||||
|
||||
double distance = -1.0 + (double)getAnimationFraction( f );
|
||||
double distance = -1.0 + getAnimationFraction( f );
|
||||
return new Vec3d(
|
||||
distance * (double)dir.getFrontOffsetX(),
|
||||
distance * (double)dir.getFrontOffsetY(),
|
||||
distance * (double)dir.getFrontOffsetZ()
|
||||
distance * dir.getFrontOffsetX(),
|
||||
distance * dir.getFrontOffsetY(),
|
||||
distance * dir.getFrontOffsetZ()
|
||||
);
|
||||
}
|
||||
default:
|
||||
@@ -955,7 +955,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
if( (side == TurtleSide.Left && m_animation == TurtleAnimation.SwingLeftTool) ||
|
||||
(side == TurtleSide.Right && m_animation == TurtleAnimation.SwingRightTool) )
|
||||
{
|
||||
return 45.0f * (float)Math.sin( (double) getAnimationFraction( f ) * Math.PI );
|
||||
return 45.0f * (float)Math.sin( getAnimationFraction( f ) * Math.PI );
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
@@ -1126,39 +1126,39 @@ public class TurtleBrain implements ITurtleAccess
|
||||
float push = Math.max( pushFrac + 0.0125f, 0.0f );
|
||||
if (moveDir.getFrontOffsetX() < 0)
|
||||
{
|
||||
minX += (double)((float)moveDir.getFrontOffsetX() * push);
|
||||
minX += moveDir.getFrontOffsetX() * push;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxX -= (double)((float)moveDir.getFrontOffsetX() * push);
|
||||
maxX -= moveDir.getFrontOffsetX() * push;
|
||||
}
|
||||
|
||||
if (moveDir.getFrontOffsetY() < 0)
|
||||
{
|
||||
minY += (double)((float)moveDir.getFrontOffsetY() * push);
|
||||
minY += moveDir.getFrontOffsetY() * push;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxY -= (double)((float)moveDir.getFrontOffsetY() * push);
|
||||
maxY -= moveDir.getFrontOffsetY() * push;
|
||||
}
|
||||
|
||||
if (moveDir.getFrontOffsetZ() < 0)
|
||||
{
|
||||
minZ += (double)((float)moveDir.getFrontOffsetZ() * push);
|
||||
minZ += moveDir.getFrontOffsetZ() * push;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxZ -= (double)((float)moveDir.getFrontOffsetZ() * push);
|
||||
maxZ -= moveDir.getFrontOffsetZ() * push;
|
||||
}
|
||||
|
||||
AxisAlignedBB aabb = new AxisAlignedBB( minX, minY, minZ, maxX, maxY, maxZ );
|
||||
List<Entity> list = world.getEntitiesWithinAABBExcludingEntity( null, aabb );
|
||||
if( !list.isEmpty() )
|
||||
{
|
||||
double pushStep = 1.0f / (float) ANIM_DURATION;
|
||||
double pushStepX = (double) moveDir.getFrontOffsetX() * pushStep;
|
||||
double pushStepY = (double) moveDir.getFrontOffsetY() * pushStep;
|
||||
double pushStepZ = (double) moveDir.getFrontOffsetZ() * pushStep;
|
||||
double pushStep = 1.0f / ANIM_DURATION;
|
||||
double pushStepX = moveDir.getFrontOffsetX() * pushStep;
|
||||
double pushStepY = moveDir.getFrontOffsetY() * pushStep;
|
||||
double pushStepZ = moveDir.getFrontOffsetZ() * pushStep;
|
||||
for (Entity entity : list)
|
||||
{
|
||||
entity.move( MoverType.PISTON, pushStepX, pushStepY, pushStepZ );
|
||||
|
||||
@@ -85,9 +85,9 @@ public class TurtleMoveCommand implements ITurtleCommand
|
||||
if( entityBB != null )
|
||||
{
|
||||
AxisAlignedBB pushedBB = entityBB.offset(
|
||||
(double) direction.getFrontOffsetX(),
|
||||
(double) direction.getFrontOffsetY(),
|
||||
(double) direction.getFrontOffsetZ()
|
||||
direction.getFrontOffsetX(),
|
||||
direction.getFrontOffsetY(),
|
||||
direction.getFrontOffsetZ()
|
||||
);
|
||||
if( !oldWorld.getCollisionBoxes( null, pushedBB ).isEmpty() )
|
||||
{
|
||||
|
||||
@@ -9,7 +9,6 @@ package dan200.computercraft.shared.turtle.items;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.shared.common.IColouredItem;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.util.ColourUtils;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -20,7 +19,7 @@ import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemTurtleNormal extends ItemTurtleBase implements IColouredItem
|
||||
public class ItemTurtleNormal extends ItemTurtleBase
|
||||
{
|
||||
public ItemTurtleNormal( Block block )
|
||||
{
|
||||
|
||||
@@ -32,7 +32,6 @@ import javax.vecmath.Matrix4f;
|
||||
public class TurtleModem implements ITurtleUpgrade
|
||||
{
|
||||
private static class Peripheral extends WirelessModemPeripheral
|
||||
implements IPeripheral
|
||||
{
|
||||
private final ITurtleAccess m_turtle;
|
||||
|
||||
@@ -55,9 +54,9 @@ public class TurtleModem implements ITurtleUpgrade
|
||||
{
|
||||
BlockPos turtlePos = m_turtle.getPosition();
|
||||
return new Vec3d(
|
||||
(double)turtlePos.getX(),
|
||||
(double)turtlePos.getY(),
|
||||
(double)turtlePos.getZ()
|
||||
turtlePos.getX(),
|
||||
turtlePos.getY(),
|
||||
turtlePos.getZ()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,9 +52,9 @@ public enum Colour
|
||||
{
|
||||
m_hex = hex;
|
||||
m_rgb = new float[] {
|
||||
(float)((hex >> 16) & 0xFF) / 255.0f,
|
||||
(float)((hex >> 8 ) & 0xFF) / 255.0f,
|
||||
(float)((hex ) & 0xFF) / 255.0f,
|
||||
((hex >> 16) & 0xFF) / 255.0f,
|
||||
((hex >> 8 ) & 0xFF) / 255.0f,
|
||||
((hex ) & 0xFF) / 255.0f,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ColourTracker
|
||||
int avgB = totalB / count;
|
||||
|
||||
float avgTotal = (float) total / (float) count;
|
||||
float avgMax = (float) Math.max( avgR, Math.max( avgG, avgB ) );
|
||||
float avgMax = Math.max( avgR, Math.max( avgG, avgB ) );
|
||||
avgR = (int) (avgR * avgTotal / avgMax);
|
||||
avgG = (int) (avgG * avgTotal / avgMax);
|
||||
avgB = (int) (avgB * avgTotal / avgMax);
|
||||
|
||||
@@ -125,9 +125,9 @@ public class WorldUtil
|
||||
double zDir;
|
||||
if( direction != null )
|
||||
{
|
||||
xDir = (double)direction.getFrontOffsetX();
|
||||
yDir = (double)direction.getFrontOffsetY();
|
||||
zDir = (double)direction.getFrontOffsetZ();
|
||||
xDir = direction.getFrontOffsetX();
|
||||
yDir = direction.getFrontOffsetY();
|
||||
zDir = direction.getFrontOffsetZ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user