1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +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:
Joseph C. Sible 2017-09-24 01:18:20 -04:00
parent 19e4c03d3a
commit 80ec54eaf6
33 changed files with 101 additions and 109 deletions

View File

@ -141,10 +141,10 @@ public void drawStringTextPart( int x, int y, TextBuffer s, TextBuffer textColou
}
// Draw char
int index = (int)s.charAt( i );
int index = s.charAt( i );
if( index < 0 || index > 255 )
{
index = (int)'?';
index = '?';
}
drawChar( renderer, x + i * FONT_WIDTH, y, index, colour, p, greyScale );
}

View File

@ -175,10 +175,10 @@ protected void drawFullImage( int x, int y, int w, int h )
{
Tessellator tessellator = Tessellator.getInstance();
tessellator.getBuffer().begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX );
tessellator.getBuffer().pos( (double) ( x + 0 ), (double) ( y + h ), (double) this.zLevel ).tex( 0.0, 1.0 ).endVertex();
tessellator.getBuffer().pos( (double) ( x + w ), (double) ( y + h ), (double) this.zLevel ).tex( 1.0, 1.0 ).endVertex();
tessellator.getBuffer().pos( (double) ( x + w ), (double) ( y + 0 ), (double) this.zLevel ).tex( 1.0, 0.0 ).endVertex();
tessellator.getBuffer().pos( (double) ( x + 0 ), (double) ( y + 0 ), (double) this.zLevel ).tex( 0.0, 0.0 ).endVertex();
tessellator.getBuffer().pos( x + 0, y + h, this.zLevel ).tex( 0.0, 1.0 ).endVertex();
tessellator.getBuffer().pos( x + w, y + h, this.zLevel ).tex( 1.0, 1.0 ).endVertex();
tessellator.getBuffer().pos( x + w, y + 0, this.zLevel ).tex( 1.0, 0.0 ).endVertex();
tessellator.getBuffer().pos( x + 0, y + 0, this.zLevel ).tex( 0.0, 0.0 ).endVertex();
tessellator.draw();
}

View File

@ -82,11 +82,11 @@ private void renderMonitorAt( TileMonitor monitor, double posX, double posY, dou
GlStateManager.rotate( pitch, 1.0f, 0.0f, 0.0f );
GlStateManager.translate(
-0.5 + TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN,
((double)origin.getHeight() - 0.5) - (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN),
(origin.getHeight() - 0.5) - (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN),
0.5
);
double xSize = (double)origin.getWidth() - 2.0 * ( TileMonitor.RENDER_MARGIN + TileMonitor.RENDER_BORDER );
double ySize = (double)origin.getHeight() - 2.0 * ( TileMonitor.RENDER_MARGIN + TileMonitor.RENDER_BORDER );
double xSize = origin.getWidth() - 2.0 * ( TileMonitor.RENDER_MARGIN + TileMonitor.RENDER_BORDER );
double ySize = origin.getHeight() - 2.0 * ( TileMonitor.RENDER_MARGIN + TileMonitor.RENDER_BORDER );
// Get renderers
Minecraft mc = Minecraft.getMinecraft();
@ -126,8 +126,8 @@ private void renderMonitorAt( TileMonitor monitor, double posX, double posY, dou
GlStateManager.pushMatrix();
try
{
double xScale = xSize / (double) ( width * FixedWidthFontRenderer.FONT_WIDTH );
double yScale = ySize / (double) ( height * FixedWidthFontRenderer.FONT_HEIGHT );
double xScale = xSize / ( width * FixedWidthFontRenderer.FONT_WIDTH );
double yScale = ySize / ( height * FixedWidthFontRenderer.FONT_HEIGHT );
GlStateManager.scale( xScale, -yScale, 1.0 );
// Draw background
@ -140,7 +140,7 @@ private void renderMonitorAt( TileMonitor monitor, double posX, double posY, dou
{
double marginXSize = TileMonitor.RENDER_MARGIN / xScale;
double marginYSize = TileMonitor.RENDER_MARGIN / yScale;
double marginSquash = marginYSize / (double) FixedWidthFontRenderer.FONT_HEIGHT;
double marginSquash = marginYSize / FixedWidthFontRenderer.FONT_HEIGHT;
// Top and bottom margins
GlStateManager.pushMatrix();

View File

@ -310,10 +310,10 @@ private void renderLabel( BlockPos position, String label )
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder renderer = tessellator.getBuffer();
renderer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR );
renderer.pos( (double) ( -xOffset - 1 ), (double) ( -1 + yOffset ), 0.0D ).color( 0.0F, 0.0F, 0.0F, 0.25F ).endVertex();
renderer.pos( (double) ( -xOffset - 1 ), (double) ( 8 + yOffset ), 0.0D ).color( 0.0F, 0.0F, 0.0F, 0.25F ).endVertex();
renderer.pos( (double) ( xOffset + 1 ), (double) ( 8 + yOffset ), 0.0D ).color( 0.0F, 0.0F, 0.0F, 0.25F ).endVertex();
renderer.pos( (double) ( xOffset + 1 ), (double) ( -1 + yOffset ), 0.0D ).color( 0.0F, 0.0F, 0.0F, 0.25F ).endVertex();
renderer.pos( -xOffset - 1, -1 + yOffset, 0.0D ).color( 0.0F, 0.0F, 0.0F, 0.25F ).endVertex();
renderer.pos( -xOffset - 1, 8 + yOffset, 0.0D ).color( 0.0F, 0.0F, 0.0F, 0.25F ).endVertex();
renderer.pos( xOffset + 1, 8 + yOffset, 0.0D ).color( 0.0F, 0.0F, 0.0F, 0.25F ).endVertex();
renderer.pos( xOffset + 1, -1 + yOffset, 0.0D ).color( 0.0F, 0.0F, 0.0F, 0.25F ).endVertex();
tessellator.draw();
}
finally

View File

@ -45,8 +45,8 @@ public boolean contains( InetAddress address )
public AddressPredicate( String... filters )
{
List<Pattern> wildcards = this.wildcards = new ArrayList<Pattern>();
List<HostRange> ranges = this.ranges = new ArrayList<HostRange>();
List<Pattern> wildcards = this.wildcards = new ArrayList<>();
List<HostRange> ranges = this.ranges = new ArrayList<>();
for( String filter : filters )
{

View File

@ -52,8 +52,8 @@ public Alarm( double time, int day )
@Override
public int compareTo( @Nonnull Alarm o )
{
double t = (double)m_day * 24.0 + m_time;
double ot = (double)m_day * 24.0 + m_time;
double t = m_day * 24.0 + m_time;
double ot = m_day * 24.0 + m_time;
if( t < ot ) {
return -1;
} else if( t > ot ) {
@ -135,13 +135,13 @@ public void advance( double dt )
if( time > previousTime || day > previousDay )
{
double now = (double)m_day * 24.0 + m_time;
double now = m_day * 24.0 + m_time;
Iterator<Map.Entry<Integer, Alarm>> it = m_alarms.entrySet().iterator();
while( it.hasNext() )
{
Map.Entry<Integer, Alarm> entry = it.next();
Alarm alarm = entry.getValue();
double t = (double)alarm.m_day * 24.0 + alarm.m_time;
double t = alarm.m_day * 24.0 + alarm.m_time;
if( now >= t )
{
queueLuaEvent( "alarm", new Object[]{ entry.getKey() } );
@ -196,8 +196,8 @@ public String[] getMethodNames()
private float getTimeForCalendar(Calendar c)
{
float time = c.get(Calendar.HOUR_OF_DAY);
time += (float)c.get(Calendar.MINUTE) / 60.0f;
time += (float)c.get(Calendar.SECOND) / (60.0f * 60.0f);
time += c.get(Calendar.MINUTE) / 60.0f;
time += c.get(Calendar.SECOND) / (60.0f * 60.0f);
return time;
}
@ -296,7 +296,7 @@ public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull O
// clock
synchronized( m_timers )
{
return new Object[] { (double)m_clock * 0.05 };
return new Object[] { m_clock * 0.05 };
}
}
case 11:

View File

@ -193,7 +193,7 @@ public void run()
m_encoding = connection.getContentEncoding();
Joiner joiner = Joiner.on( ',' );
Map<String, String> headers = m_responseHeaders = new HashMap<String, String>();
Map<String, String> headers = m_responseHeaders = new HashMap<>();
for( Map.Entry<String, List<String>> header : connection.getHeaderFields().entrySet() )
{
headers.put( header.getKey(), joiner.join( header.getValue() ) );

View File

@ -452,7 +452,7 @@ public IWritableMount getRootMount()
private boolean initFileSystem()
{
// Create the file system
int id = assignID();
assignID();
try
{
m_fileSystem = new FileSystem( "hdd", getRootMount() );

View File

@ -9,7 +9,6 @@
import dan200.computercraft.api.filesystem.IMount;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
@ -22,31 +21,31 @@ public EmptyMount()
// IMount implementation
@Override
public boolean exists( @Nonnull String path ) throws IOException
public boolean exists( @Nonnull String path )
{
return path.isEmpty();
}
@Override
public boolean isDirectory( @Nonnull String path ) throws IOException
public boolean isDirectory( @Nonnull String path )
{
return path.isEmpty();
}
@Override
public void list( @Nonnull String path, @Nonnull List<String> contents ) throws IOException
public void list( @Nonnull String path, @Nonnull List<String> contents )
{
}
@Override
public long getSize( @Nonnull String path ) throws IOException
public long getSize( @Nonnull String path )
{
return 0;
}
@Nonnull
@Override
public InputStream openForRead( @Nonnull String path ) throws IOException
public InputStream openForRead( @Nonnull String path )
{
return null;
}

View File

@ -95,7 +95,7 @@ public FileMount( File rootPath, long capacity )
// IMount implementation
@Override
public boolean exists( @Nonnull String path ) throws IOException
public boolean exists( @Nonnull String path )
{
if( !created() )
{
@ -109,7 +109,7 @@ public boolean exists( @Nonnull String path ) throws IOException
}
@Override
public boolean isDirectory( @Nonnull String path ) throws IOException
public boolean isDirectory( @Nonnull String path )
{
if( !created() )
{
@ -339,7 +339,7 @@ else if( file.isDirectory() )
}
@Override
public long getRemainingSpace() throws IOException
public long getRemainingSpace()
{
return Math.max( m_capacity - m_usedSpace, 0 );
}

View File

@ -65,7 +65,7 @@ public long getFreeSpace()
}
}
public boolean isReadOnly( String path ) throws FileSystemException
public boolean isReadOnly( String path )
{
return (m_writableMount == null);
}
@ -347,7 +347,7 @@ public synchronized void mountWritable( String label, String location, IWritable
mount( new MountWrapper( label, location, mount ) );
}
private synchronized void mount( MountWrapper wrapper ) throws FileSystemException
private synchronized void mount( MountWrapper wrapper )
{
String location = wrapper.getLocation();
if( m_mounts.containsKey( location ) )

View File

@ -176,14 +176,14 @@ public JarMount( File jarFile, String subPath ) throws IOException
// IMount implementation
@Override
public boolean exists( @Nonnull String path ) throws IOException
public boolean exists( @Nonnull String path )
{
FileInZip file = m_root.getFile( path );
return file != null;
}
@Override
public boolean isDirectory( @Nonnull String path ) throws IOException
public boolean isDirectory( @Nonnull String path )
{
FileInZip file = m_root.getFile( path );
if( file != null )

View File

@ -159,7 +159,7 @@ public boolean isUsable( EntityPlayer player, boolean ignoreRange )
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;
}

View File

@ -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 String[] getMethodNames()
}
@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 )
{

View File

@ -19,7 +19,6 @@
import net.minecraft.util.NonNullList;
import javax.annotation.Nonnull;
import java.util.List;
public class TileComputer extends TileComputerBase
{

View File

@ -290,7 +290,7 @@ public void setLabel( String label )
@Override
public double getTimeOfDay()
{
return (double)((m_world.getWorldTime() + 6000) % 24000) / 1000.0;
return (m_world.getWorldTime() + 6000) % 24000 / 1000.0;
}
@Override

View File

@ -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 java.util.List;
public abstract class TilePeripheralBase extends TileGeneric
implements IPeripheralTile, IDirectionalTile, ITickable
implements IPeripheralTile, ITickable
{
// Statics

View File

@ -24,7 +24,6 @@
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 static net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY;
public class TileDiskDrive extends TilePeripheralBase
implements IInventory, ITickable
implements IInventory
{
// Statics
@ -615,13 +614,13 @@ private synchronized void ejectContents( boolean destroyed )
}
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 )

View File

@ -41,7 +41,7 @@ public World getWorld()
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

View File

@ -101,7 +101,7 @@ public Vec3d getPosition()
{
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 @@ private void searchNetwork( ICableVisitor visitor )
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" );
}

View File

@ -45,7 +45,7 @@ public World getWorld()
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

View File

@ -31,7 +31,7 @@ public double getRange()
{
if( m_advanced )
{
return (double)Integer.MAX_VALUE;
return Integer.MAX_VALUE;
}
else
{
@ -39,12 +39,12 @@ public double getRange()
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 )
{

View File

@ -290,7 +290,7 @@ private ITerminal getLocalTerminal()
public double getTextScale()
{
return (double)m_textScale * 0.5;
return m_textScale * 0.5;
}
private void rebuildTerminal()
@ -301,11 +301,11 @@ private void rebuildTerminal()
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 void monitorTouched( float xPos, float yPos, float zPos )
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 )
{

View File

@ -17,7 +17,6 @@
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 static net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY;
public class TilePrinter extends TilePeripheralBase
implements IInventory, ISidedInventory
implements ISidedInventory
{
// Statics
@ -583,9 +582,9 @@ private void ejectContents()
// 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;

View File

@ -170,7 +170,7 @@ private synchronized Object[] playSound( Object[] arguments, ILuaContext context
{
@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;

View File

@ -48,7 +48,7 @@
import static net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY;
public class TileTurtle extends TileComputerBase
implements ITurtleTile, IInventory, ITickable
implements ITurtleTile, IInventory
{
// Statics

View File

@ -936,11 +936,11 @@ public Vec3d getRenderOffset( float f )
}
}
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 float getToolRenderAngle( TurtleSide side, float f )
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 @@ private void updateAnimation()
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 );

View File

@ -85,9 +85,9 @@ public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
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() )
{

View File

@ -9,7 +9,6 @@
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 javax.annotation.Nonnull;
public class ItemTurtleNormal extends ItemTurtleBase implements IColouredItem
public class ItemTurtleNormal extends ItemTurtleBase
{
public ItemTurtleNormal( Block block )
{

View File

@ -32,7 +32,6 @@
public class TurtleModem implements ITurtleUpgrade
{
private static class Peripheral extends WirelessModemPeripheral
implements IPeripheral
{
private final ITurtleAccess m_turtle;
@ -55,9 +54,9 @@ public Vec3d getPosition()
{
BlockPos turtlePos = m_turtle.getPosition();
return new Vec3d(
(double)turtlePos.getX(),
(double)turtlePos.getY(),
(double)turtlePos.getZ()
turtlePos.getX(),
turtlePos.getY(),
turtlePos.getZ()
);
}

View File

@ -52,9 +52,9 @@ public static Colour fromHex(int 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,
};
}

View File

@ -38,7 +38,7 @@ public int getColour()
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);

View File

@ -125,9 +125,9 @@ public static void dropItemStack( @Nonnull ItemStack stack, World world, BlockPo
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
{