1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-26 07:03:22 +00:00

A wee bit of a cleanup of the API

- Move some method over to defaulted methods
 - Use Objects rather than Preconditions
This commit is contained in:
SquidDev 2018-12-17 21:33:49 +00:00
parent 3537f49ced
commit 741ee447ca
38 changed files with 184 additions and 260 deletions

View File

@ -5,9 +5,7 @@ indent_style = space
indent_size = 4 indent_size = 4
end_of_line = lf end_of_line = lf
charset = utf-8 charset = utf-8
# Sadly too many files have whitespace errors, so we leave this as is for trim_trailing_whitespace = true
# now and just make sure we don't introduce any more.
# trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
[*.md] [*.md]

View File

@ -268,7 +268,9 @@ public static void registerMediaProvider( @Nonnull IMediaProvider handler )
* *
* @param handler The turtle permission provider to register. * @param handler The turtle permission provider to register.
* @see dan200.computercraft.api.permissions.ITurtlePermissionProvider * @see dan200.computercraft.api.permissions.ITurtlePermissionProvider
* @deprecated Prefer using {@link dan200.computercraft.api.turtle.event.TurtleBlockEvent} or the standard Forge events.
*/ */
@Deprecated
public static void registerPermissionProvider( @Nonnull ITurtlePermissionProvider handler ) public static void registerPermissionProvider( @Nonnull ITurtlePermissionProvider handler )
{ {
findCC(); findCC();

View File

@ -90,7 +90,7 @@ public interface IMount
* @throws IOException If the file does not exist, or could not be opened. * @throws IOException If the file does not exist, or could not be opened.
*/ */
@Nonnull @Nonnull
@SuppressWarnings("deprecation") @SuppressWarnings( "deprecation" )
default ReadableByteChannel openChannelForRead( @Nonnull String path ) throws IOException default ReadableByteChannel openChannelForRead( @Nonnull String path ) throws IOException
{ {
return Channels.newChannel( openForRead( path ) ); return Channels.newChannel( openForRead( path ) );

View File

@ -67,7 +67,7 @@ public interface IWritableMount extends IMount
* @throws IOException If the file could not be opened for writing. * @throws IOException If the file could not be opened for writing.
*/ */
@Nonnull @Nonnull
@SuppressWarnings("deprecation") @SuppressWarnings( "deprecation" )
default WritableByteChannel openChannelForWrite( @Nonnull String path ) throws IOException default WritableByteChannel openChannelForWrite( @Nonnull String path ) throws IOException
{ {
return Channels.newChannel( openForWrite( path ) ); return Channels.newChannel( openForWrite( path ) );
@ -94,7 +94,7 @@ default WritableByteChannel openChannelForWrite( @Nonnull String path ) throws I
* @throws IOException If the file could not be opened for writing. * @throws IOException If the file could not be opened for writing.
*/ */
@Nonnull @Nonnull
@SuppressWarnings("deprecation") @SuppressWarnings( "deprecation" )
default WritableByteChannel openChannelForAppend( @Nonnull String path ) throws IOException default WritableByteChannel openChannelForAppend( @Nonnull String path ) throws IOException
{ {
return Channels.newChannel( openForAppend( path ) ); return Channels.newChannel( openForAppend( path ) );

View File

@ -4,7 +4,7 @@
* For help using the API, and posting your mods, visit the forums at computercraft.info. * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
@API( owner="ComputerCraft", provides="ComputerCraft|API|FileSystem", apiVersion="${version}" ) @API( owner = "ComputerCraft", provides = "ComputerCraft|API|FileSystem", apiVersion = "${version}" )
package dan200.computercraft.api.filesystem; package dan200.computercraft.api.filesystem;
import net.minecraftforge.fml.common.API; import net.minecraftforge.fml.common.API;

View File

@ -31,17 +31,23 @@ public interface ILuaAPI extends ILuaObject
* *
* One should only interact with the file system. * One should only interact with the file system.
*/ */
default void startup() { } default void startup()
{
}
/** /**
* Called every time the computer is ticked. This can be used to process various. * Called every time the computer is ticked. This can be used to process various.
*/ */
default void update() { } default void update()
{
}
/** /**
* Called when the computer is turned off or unloaded. * Called when the computer is turned off or unloaded.
* *
* This should reset the state of the object, disposing any remaining file handles, or other resources. * This should reset the state of the object, disposing any remaining file handles, or other resources.
*/ */
default void shutdown() { } default void shutdown()
{
}
} }

View File

@ -14,7 +14,7 @@
public class LuaException extends Exception public class LuaException extends Exception
{ {
private static final long serialVersionUID = -6136063076818512651L; private static final long serialVersionUID = -6136063076818512651L;
private final int m_level; private final int level;
public LuaException() public LuaException()
{ {
@ -29,7 +29,7 @@ public LuaException( @Nullable String message )
public LuaException( @Nullable String message, int level ) public LuaException( @Nullable String message, int level )
{ {
super( message ); super( message );
m_level = level; this.level = level;
} }
/** /**
@ -40,6 +40,6 @@ public LuaException( @Nullable String message, int level )
*/ */
public int getLevel() public int getLevel()
{ {
return m_level; return level;
} }
} }

View File

@ -4,7 +4,7 @@
* For help using the API, and posting your mods, visit the forums at computercraft.info. * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
@API( owner="ComputerCraft", provides="ComputerCraft|API|Lua", apiVersion="${version}" ) @API( owner = "ComputerCraft", provides = "ComputerCraft|API|Lua", apiVersion = "${version}" )
package dan200.computercraft.api.lua; package dan200.computercraft.api.lua;
import net.minecraftforge.fml.common.API; import net.minecraftforge.fml.common.API;

View File

@ -23,7 +23,7 @@ public interface IMedia
/** /**
* Get a string representing the label of this item. Will be called via {@code disk.getLabel()} in lua. * Get a string representing the label of this item. Will be called via {@code disk.getLabel()} in lua.
* *
* @param stack The itemstack to inspect. * @param stack The {@link ItemStack} to inspect.
* @return The label. ie: "Dan's Programs". * @return The label. ie: "Dan's Programs".
*/ */
@Nullable @Nullable
@ -32,36 +32,45 @@ public interface IMedia
/** /**
* Set a string representing the label of this item. Will be called vi {@code disk.setLabel()} in lua. * Set a string representing the label of this item. Will be called vi {@code disk.setLabel()} in lua.
* *
* @param stack The itemstack to modify. * @param stack The {@link ItemStack} to modify.
* @param label The string to set the label to. * @param label The string to set the label to.
* @return true if the label was updated, false if the label may not be modified. * @return true if the label was updated, false if the label may not be modified.
*/ */
boolean setLabel( @Nonnull ItemStack stack, @Nullable String label ); default boolean setLabel( @Nonnull ItemStack stack, @Nullable String label )
{
return false;
}
/** /**
* If this disk represents an item with audio (like a record), get the readable name of the audio track. ie: * If this disk represents an item with audio (like a record), get the readable name of the audio track. ie:
* "Jonathon Coulton - Still Alive" * "Jonathon Coulton - Still Alive"
* *
* @param stack The itemstack to inspect. * @param stack The {@link ItemStack} to modify.
* @return The name, or null if this item does not represent an item with audio. * @return The name, or null if this item does not represent an item with audio.
*/ */
@Nullable @Nullable
String getAudioTitle( @Nonnull ItemStack stack ); default String getAudioTitle( @Nonnull ItemStack stack )
{
return null;
}
/** /**
* If this disk represents an item with audio (like a record), get the resource name of the audio track to play. * If this disk represents an item with audio (like a record), get the resource name of the audio track to play.
* *
* @param stack The itemstack to inspect. * @param stack The {@link ItemStack} to modify.
* @return The name, or null if this item does not represent an item with audio. * @return The name, or null if this item does not represent an item with audio.
*/ */
@Nullable @Nullable
SoundEvent getAudio( @Nonnull ItemStack stack ); default SoundEvent getAudio( @Nonnull ItemStack stack )
{
return null;
}
/** /**
* If this disk represents an item with data (like a floppy disk), get a mount representing it's contents. This will * If this disk represents an item with data (like a floppy disk), get a mount representing it's contents. This will
* be mounted onto the filesystem of the computer while the media is in the disk drive. * be mounted onto the filesystem of the computer while the media is in the disk drive.
* *
* @param stack The itemstack to inspect. * @param stack The {@link ItemStack} to modify.
* @param world The world in which the item and disk drive reside. * @param world The world in which the item and disk drive reside.
* @return The mount, or null if this item does not represent an item with data. If the mount returned also * @return The mount, or null if this item does not represent an item with data. If the mount returned also
* implements {@link dan200.computercraft.api.filesystem.IWritableMount}, it will mounted using mountWritable() * implements {@link dan200.computercraft.api.filesystem.IWritableMount}, it will mounted using mountWritable()
@ -71,5 +80,8 @@ public interface IMedia
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String) * @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
*/ */
@Nullable @Nullable
IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world ); default IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{
return null;
}
} }

View File

@ -4,7 +4,7 @@
* For help using the API, and posting your mods, visit the forums at computercraft.info. * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
@API( owner="ComputerCraft", provides="ComputerCraft|API|Media", apiVersion="${version}" ) @API( owner = "ComputerCraft", provides = "ComputerCraft|API|Media", apiVersion = "${version}" )
package dan200.computercraft.api.media; package dan200.computercraft.api.media;
import net.minecraftforge.fml.common.API; import net.minecraftforge.fml.common.API;

View File

@ -5,10 +5,9 @@
*/ */
package dan200.computercraft.api.network; package dan200.computercraft.api.network;
import com.google.common.base.Preconditions;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Objects;
/** /**
* Represents a packet which may be sent across a {@link IPacketNetwork}. * Represents a packet which may be sent across a {@link IPacketNetwork}.
@ -21,11 +20,11 @@
*/ */
public class Packet public class Packet
{ {
private final int m_channel; private final int channel;
private final int m_replyChannel; private final int replyChannel;
private final Object m_payload; private final Object payload;
private final IPacketSender m_sender; private final IPacketSender sender;
/** /**
* Create a new packet, ready for transmitting across the network. * Create a new packet, ready for transmitting across the network.
@ -39,12 +38,12 @@ public class Packet
*/ */
public Packet( int channel, int replyChannel, @Nullable Object payload, @Nonnull IPacketSender sender ) public Packet( int channel, int replyChannel, @Nullable Object payload, @Nonnull IPacketSender sender )
{ {
Preconditions.checkNotNull( sender, "sender cannot be null" ); Objects.requireNonNull( sender, "sender cannot be null" );
m_channel = channel; this.channel = channel;
m_replyChannel = replyChannel; this.replyChannel = replyChannel;
m_payload = payload; this.payload = payload;
m_sender = sender; this.sender = sender;
} }
/** /**
@ -55,7 +54,7 @@ public Packet( int channel, int replyChannel, @Nullable Object payload, @Nonnull
*/ */
public int getChannel() public int getChannel()
{ {
return m_channel; return channel;
} }
/** /**
@ -65,7 +64,7 @@ public int getChannel()
*/ */
public int getReplyChannel() public int getReplyChannel()
{ {
return m_replyChannel; return replyChannel;
} }
/** /**
@ -77,7 +76,7 @@ public int getReplyChannel()
@Nullable @Nullable
public Object getPayload() public Object getPayload()
{ {
return m_payload; return payload;
} }
/** /**
@ -88,7 +87,7 @@ public Object getPayload()
@Nonnull @Nonnull
public IPacketSender getSender() public IPacketSender getSender()
{ {
return m_sender; return sender;
} }
@Override @Override
@ -99,20 +98,20 @@ public boolean equals( Object o )
Packet packet = (Packet) o; Packet packet = (Packet) o;
if( m_channel != packet.m_channel ) return false; if( channel != packet.channel ) return false;
if( m_replyChannel != packet.m_replyChannel ) return false; if( replyChannel != packet.replyChannel ) return false;
if( m_payload != null ? !m_payload.equals( packet.m_payload ) : packet.m_payload != null ) return false; if( !Objects.equals( payload, packet.payload ) ) return false;
return m_sender.equals( packet.m_sender ); return sender.equals( packet.sender );
} }
@Override @Override
public int hashCode() public int hashCode()
{ {
int result; int result;
result = m_channel; result = channel;
result = 31 * result + m_replyChannel; result = 31 * result + replyChannel;
result = 31 * result + (m_payload != null ? m_payload.hashCode() : 0); result = 31 * result + (payload != null ? payload.hashCode() : 0);
result = 31 * result + m_sender.hashCode(); result = 31 * result + sender.hashCode();
return result; return result;
} }
} }

View File

@ -4,7 +4,7 @@
* For help using the API, and posting your mods, visit the forums at computercraft.info. * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
@API( owner="ComputerCraft", provides="ComputerCraft|API|Network", apiVersion="${version}" ) @API( owner = "ComputerCraft", provides = "ComputerCraft|API|Network", apiVersion = "${version}" )
package dan200.computercraft.api.network; package dan200.computercraft.api.network;
import net.minecraftforge.fml.common.API; import net.minecraftforge.fml.common.API;

View File

@ -4,7 +4,7 @@
* For help using the API, and posting your mods, visit the forums at computercraft.info. * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
@API( owner="ComputerCraft", provides="ComputerCraft|API|Network|Wired", apiVersion="${version}" ) @API( owner = "ComputerCraft", provides = "ComputerCraft|API|Network|Wired", apiVersion = "${version}" )
package dan200.computercraft.api.network.wired; package dan200.computercraft.api.network.wired;
import net.minecraftforge.fml.common.API; import net.minecraftforge.fml.common.API;

View File

@ -4,7 +4,7 @@
* For help using the API, and posting your mods, visit the forums at computercraft.info. * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
@API( owner="ComputerCraft", provides="ComputerCraft|API", apiVersion="${version}" ) @API( owner = "ComputerCraft", provides = "ComputerCraft|API", apiVersion = "${version}" )
package dan200.computercraft.api; package dan200.computercraft.api;
import net.minecraftforge.fml.common.API; import net.minecraftforge.fml.common.API;

View File

@ -4,7 +4,7 @@
* For help using the API, and posting your mods, visit the forums at computercraft.info. * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
@API( owner="ComputerCraft", provides="ComputerCraft|API|Peripheral", apiVersion="${version}" ) @API( owner = "ComputerCraft", provides = "ComputerCraft|API|Peripheral", apiVersion = "${version}" )
package dan200.computercraft.api.peripheral; package dan200.computercraft.api.peripheral;
import net.minecraftforge.fml.common.API; import net.minecraftforge.fml.common.API;

View File

@ -4,7 +4,7 @@
* For help using the API, and posting your mods, visit the forums at computercraft.info. * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
@API( owner="ComputerCraft", provides="ComputerCraft|API|Permissions", apiVersion="${version}" ) @API( owner = "ComputerCraft", provides = "ComputerCraft|API|Permissions", apiVersion = "${version}" )
package dan200.computercraft.api.permissions; package dan200.computercraft.api.permissions;
import net.minecraftforge.fml.common.API; import net.minecraftforge.fml.common.API;

View File

@ -4,7 +4,7 @@
* For help using the API, and posting your mods, visit the forums at computercraft.info. * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
@API( owner="ComputerCraft", provides="ComputerCraft|API|Redstone", apiVersion="${version}" ) @API( owner = "ComputerCraft", provides = "ComputerCraft|API|Redstone", apiVersion = "${version}" )
package dan200.computercraft.api.redstone; package dan200.computercraft.api.redstone;
import net.minecraftforge.fml.common.API; import net.minecraftforge.fml.common.API;

View File

@ -25,7 +25,6 @@
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.vecmath.Matrix4f; import javax.vecmath.Matrix4f;
/** /**
* The primary interface for defining an update for Turtles. A turtle update * The primary interface for defining an update for Turtles. A turtle update
* can either be a new tool, or a new peripheral. * can either be a new tool, or a new peripheral.
@ -98,7 +97,10 @@ public interface ITurtleUpgrade
* and this method is not expected to be called. * and this method is not expected to be called.
*/ */
@Nullable @Nullable
IPeripheral createPeripheral( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side ); default IPeripheral createPeripheral( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side )
{
return null;
}
/** /**
* Will only be called for Tool turtle. Called when turtle.dig() or turtle.attack() is called * Will only be called for Tool turtle. Called when turtle.dig() or turtle.attack() is called
@ -119,7 +121,10 @@ public interface ITurtleUpgrade
* to be called. * to be called.
*/ */
@Nonnull @Nonnull
TurtleCommandResult useTool( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side, @Nonnull TurtleVerb verb, @Nonnull EnumFacing direction ); default TurtleCommandResult useTool( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side, @Nonnull TurtleVerb verb, @Nonnull EnumFacing direction )
{
return TurtleCommandResult.failure();
}
/** /**
* Called to obtain the model to be used when rendering a turtle peripheral. * Called to obtain the model to be used when rendering a turtle peripheral.
@ -133,8 +138,8 @@ public interface ITurtleUpgrade
* @return The model that you wish to be used to render your upgrade, and a transformation to apply to it. Returning * @return The model that you wish to be used to render your upgrade, and a transformation to apply to it. Returning
* a transformation of {@code null} has the same effect as the identify matrix. * a transformation of {@code null} has the same effect as the identify matrix.
*/ */
@SideOnly(Side.CLIENT)
@Nonnull @Nonnull
@SideOnly( Side.CLIENT )
Pair<IBakedModel, Matrix4f> getModel( @Nullable ITurtleAccess turtle, @Nonnull TurtleSide side ); Pair<IBakedModel, Matrix4f> getModel( @Nullable ITurtleAccess turtle, @Nonnull TurtleSide side );
/** /**

View File

@ -19,8 +19,8 @@
*/ */
public final class TurtleCommandResult public final class TurtleCommandResult
{ {
private static final TurtleCommandResult s_success = new TurtleCommandResult( true, null, null ); private static final TurtleCommandResult EMPTY_SUCCESS = new TurtleCommandResult( true, null, null );
private static final TurtleCommandResult s_emptyFailure = new TurtleCommandResult( false, null, null ); private static final TurtleCommandResult EMPTY_FAILURE = new TurtleCommandResult( false, null, null );
/** /**
* Create a successful command result with no result. * Create a successful command result with no result.
@ -30,7 +30,7 @@ public final class TurtleCommandResult
@Nonnull @Nonnull
public static TurtleCommandResult success() public static TurtleCommandResult success()
{ {
return success( null ); return EMPTY_SUCCESS;
} }
/** /**
@ -42,14 +42,8 @@ public static TurtleCommandResult success()
@Nonnull @Nonnull
public static TurtleCommandResult success( @Nullable Object[] results ) public static TurtleCommandResult success( @Nullable Object[] results )
{ {
if( results == null || results.length == 0 ) if( results == null || results.length == 0 ) return EMPTY_SUCCESS;
{ return new TurtleCommandResult( true, null, results );
return s_success;
}
else
{
return new TurtleCommandResult( true, null, results );
}
} }
/** /**
@ -60,7 +54,7 @@ public static TurtleCommandResult success( @Nullable Object[] results )
@Nonnull @Nonnull
public static TurtleCommandResult failure() public static TurtleCommandResult failure()
{ {
return failure( null ); return EMPTY_FAILURE;
} }
/** /**
@ -72,25 +66,19 @@ public static TurtleCommandResult failure()
@Nonnull @Nonnull
public static TurtleCommandResult failure( @Nullable String errorMessage ) public static TurtleCommandResult failure( @Nullable String errorMessage )
{ {
if( errorMessage == null ) if( errorMessage == null ) return EMPTY_FAILURE;
{ return new TurtleCommandResult( false, errorMessage, null );
return s_emptyFailure;
}
else
{
return new TurtleCommandResult( false, errorMessage, null );
}
} }
private final boolean m_success; private final boolean success;
private final String m_errorMessage; private final String errorMessage;
private final Object[] m_results; private final Object[] results;
private TurtleCommandResult( boolean success, String errorMessage, Object[] results ) private TurtleCommandResult( boolean success, String errorMessage, Object[] results )
{ {
m_success = success; this.success = success;
m_errorMessage = errorMessage; this.errorMessage = errorMessage;
m_results = results; this.results = results;
} }
/** /**
@ -100,7 +88,7 @@ private TurtleCommandResult( boolean success, String errorMessage, Object[] resu
*/ */
public boolean isSuccess() public boolean isSuccess()
{ {
return m_success; return success;
} }
/** /**
@ -111,7 +99,7 @@ public boolean isSuccess()
@Nullable @Nullable
public String getErrorMessage() public String getErrorMessage()
{ {
return m_errorMessage; return errorMessage;
} }
/** /**
@ -122,6 +110,6 @@ public String getErrorMessage()
@Nullable @Nullable
public Object[] getResults() public Object[] getResults()
{ {
return m_results; return results;
} }
} }

View File

@ -30,7 +30,7 @@ public enum TurtleUpgradeType
* your upgrade to also provide methods. For example, a pickaxe could provide methods * your upgrade to also provide methods. For example, a pickaxe could provide methods
* determining whether it can break the given block or not. * determining whether it can break the given block or not.
*/ */
Both,; Both;
public boolean isTool() public boolean isTool()
{ {

View File

@ -1,12 +1,12 @@
package dan200.computercraft.api.turtle.event; package dan200.computercraft.api.turtle.event;
import com.google.common.base.Preconditions;
import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.TurtleCommandResult; import dan200.computercraft.api.turtle.TurtleCommandResult;
import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Cancelable;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Objects;
/** /**
* An event fired when a turtle is performing a known action. * An event fired when a turtle is performing a known action.
@ -21,7 +21,7 @@ public TurtleActionEvent( @Nonnull ITurtleAccess turtle, @Nonnull TurtleAction a
{ {
super( turtle ); super( turtle );
Preconditions.checkNotNull( action, "action cannot be null" ); Objects.requireNonNull( action, "action cannot be null" );
this.action = action; this.action = action;
} }

View File

@ -6,7 +6,6 @@
package dan200.computercraft.api.turtle.event; package dan200.computercraft.api.turtle.event;
import com.google.common.base.Preconditions;
import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.ITurtleUpgrade;
import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.api.turtle.TurtleSide;
@ -17,6 +16,7 @@
import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.event.entity.player.AttackEntityEvent;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.Objects;
/** /**
* Fired when a turtle attempts to attack an entity. * Fired when a turtle attempts to attack an entity.
@ -37,9 +37,9 @@ public class TurtleAttackEvent extends TurtlePlayerEvent
public TurtleAttackEvent( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull Entity target, @Nonnull ITurtleUpgrade upgrade, @Nonnull TurtleSide side ) public TurtleAttackEvent( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull Entity target, @Nonnull ITurtleUpgrade upgrade, @Nonnull TurtleSide side )
{ {
super( turtle, TurtleAction.ATTACK, player ); super( turtle, TurtleAction.ATTACK, player );
Preconditions.checkNotNull( target, "target cannot be null" ); Objects.requireNonNull( target, "target cannot be null" );
Preconditions.checkNotNull( upgrade, "upgrade cannot be null" ); Objects.requireNonNull( upgrade, "upgrade cannot be null" );
Preconditions.checkNotNull( side, "side cannot be null" ); Objects.requireNonNull( side, "side cannot be null" );
this.target = target; this.target = target;
this.upgrade = upgrade; this.upgrade = upgrade;
this.side = side; this.side = side;

View File

@ -6,7 +6,6 @@
package dan200.computercraft.api.turtle.event; package dan200.computercraft.api.turtle.event;
import com.google.common.base.Preconditions;
import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleAccess;
@ -24,6 +23,7 @@
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* A general event for when a turtle interacts with a block or region. * A general event for when a turtle interacts with a block or region.
@ -47,8 +47,8 @@ protected TurtleBlockEvent( @Nonnull ITurtleAccess turtle, @Nonnull TurtleAction
{ {
super( turtle, action, player ); super( turtle, action, player );
Preconditions.checkNotNull( world, "world cannot be null" ); Objects.requireNonNull( world, "world cannot be null" );
Preconditions.checkNotNull( pos, "pos cannot be null" ); Objects.requireNonNull( pos, "pos cannot be null" );
this.world = world; this.world = world;
this.pos = pos; this.pos = pos;
} }
@ -95,9 +95,9 @@ public Dig( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull
{ {
super( turtle, TurtleAction.DIG, player, world, pos ); super( turtle, TurtleAction.DIG, player, world, pos );
Preconditions.checkNotNull( block, "block cannot be null" ); Objects.requireNonNull( block, "block cannot be null" );
Preconditions.checkNotNull( upgrade, "upgrade cannot be null" ); Objects.requireNonNull( upgrade, "upgrade cannot be null" );
Preconditions.checkNotNull( side, "side cannot be null" ); Objects.requireNonNull( side, "side cannot be null" );
this.block = block; this.block = block;
this.upgrade = upgrade; this.upgrade = upgrade;
this.side = side; this.side = side;
@ -165,7 +165,7 @@ public Place( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnul
{ {
super( turtle, TurtleAction.PLACE, player, world, pos ); super( turtle, TurtleAction.PLACE, player, world, pos );
Preconditions.checkNotNull( stack, "stack cannot be null" ); Objects.requireNonNull( stack, "stack cannot be null" );
this.stack = stack; this.stack = stack;
} }
@ -198,8 +198,8 @@ public Inspect( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonn
{ {
super( turtle, TurtleAction.INSPECT, player, world, pos ); super( turtle, TurtleAction.INSPECT, player, world, pos );
Preconditions.checkNotNull( state, "state cannot be null" ); Objects.requireNonNull( state, "state cannot be null" );
Preconditions.checkNotNull( data, "data cannot be null" ); Objects.requireNonNull( data, "data cannot be null" );
this.data = data; this.data = data;
this.state = state; this.state = state;
} }
@ -234,7 +234,7 @@ public Map<String, Object> getData()
*/ */
public void addData( @Nonnull Map<String, ?> newData ) public void addData( @Nonnull Map<String, ?> newData )
{ {
Preconditions.checkNotNull( newData, "newData cannot be null" ); Objects.requireNonNull( newData, "newData cannot be null" );
data.putAll( newData ); data.putAll( newData );
} }
} }

View File

@ -6,11 +6,11 @@
package dan200.computercraft.api.turtle.event; package dan200.computercraft.api.turtle.event;
import com.google.common.base.Preconditions;
import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleAccess;
import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.Event;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.Objects;
/** /**
* A base class for all events concerning a turtle. This will only ever constructed and fired on the server side, * A base class for all events concerning a turtle. This will only ever constructed and fired on the server side,
@ -26,7 +26,7 @@ public abstract class TurtleEvent extends Event
protected TurtleEvent( @Nonnull ITurtleAccess turtle ) protected TurtleEvent( @Nonnull ITurtleAccess turtle )
{ {
Preconditions.checkNotNull( turtle, "turtle cannot be null" ); Objects.requireNonNull( turtle, "turtle cannot be null" );
this.turtle = turtle; this.turtle = turtle;
} }

View File

@ -1,6 +1,5 @@
package dan200.computercraft.api.turtle.event; package dan200.computercraft.api.turtle.event;
import com.google.common.base.Preconditions;
import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleAccess;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -11,6 +10,7 @@
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Objects;
/** /**
* Fired when a turtle attempts to interact with an inventory. * Fired when a turtle attempts to interact with an inventory.
@ -65,7 +65,7 @@ public Drop( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull
{ {
super( turtle, TurtleAction.DROP, player, world, pos, handler ); super( turtle, TurtleAction.DROP, player, world, pos, handler );
Preconditions.checkNotNull( stack, "stack cannot be null" ); Objects.requireNonNull( stack, "stack cannot be null" );
this.stack = stack; this.stack = stack;
} }

View File

@ -6,11 +6,11 @@
package dan200.computercraft.api.turtle.event; package dan200.computercraft.api.turtle.event;
import com.google.common.base.Preconditions;
import dan200.computercraft.api.turtle.ITurtleAccess; import dan200.computercraft.api.turtle.ITurtleAccess;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.Objects;
/** /**
* An action done by a turtle which is normally done by a player. * An action done by a turtle which is normally done by a player.
@ -25,7 +25,7 @@ protected TurtlePlayerEvent( @Nonnull ITurtleAccess turtle, @Nonnull TurtleActio
{ {
super( turtle, action ); super( turtle, action );
Preconditions.checkNotNull( player, "player cannot be null" ); Objects.requireNonNull( player, "player cannot be null" );
this.player = player; this.player = player;
} }

View File

@ -4,7 +4,7 @@
* For help using the API, and posting your mods, visit the forums at computercraft.info. * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
@API(owner = "ComputerCraft", provides = "ComputerCraft|API|Turtle|Event", apiVersion = "${version}") @API( owner = "ComputerCraft", provides = "ComputerCraft|API|Turtle|Event", apiVersion = "${version}" )
package dan200.computercraft.api.turtle.event; package dan200.computercraft.api.turtle.event;
import net.minecraftforge.fml.common.API; import net.minecraftforge.fml.common.API;

View File

@ -4,7 +4,7 @@
* For help using the API, and posting your mods, visit the forums at computercraft.info. * For help using the API, and posting your mods, visit the forums at computercraft.info.
*/ */
@API( owner="ComputerCraft", provides="ComputerCraft|API|Turtle", apiVersion="${version}" ) @API( owner = "ComputerCraft", provides = "ComputerCraft|API|Turtle", apiVersion = "${version}" )
package dan200.computercraft.api.turtle; package dan200.computercraft.api.turtle;
import net.minecraftforge.fml.common.API; import net.minecraftforge.fml.common.API;

View File

@ -87,18 +87,6 @@ public boolean setLabel( @Nonnull ItemStack stack, String label )
return true; return true;
} }
@Override
public String getAudioTitle( @Nonnull ItemStack stack )
{
return null;
}
@Override
public SoundEvent getAudio( @Nonnull ItemStack stack )
{
return null;
}
@Override @Override
public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world ) public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{ {

View File

@ -11,22 +11,12 @@
public class DefaultMediaProvider implements IMediaProvider public class DefaultMediaProvider implements IMediaProvider
{ {
public DefaultMediaProvider()
{
}
@Override @Override
public IMedia getMedia( @Nonnull ItemStack stack ) public IMedia getMedia( @Nonnull ItemStack stack )
{ {
Item item = stack.getItem(); Item item = stack.getItem();
if( item instanceof IMedia ) if( item instanceof IMedia ) return (IMedia) item;
{ if( item instanceof ItemRecord ) return RecordMedia.INSTANCE;
return (IMedia)item;
}
else if( item instanceof ItemRecord )
{
return new RecordMedia();
}
return null; return null;
} }
} }

View File

@ -18,7 +18,6 @@
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -34,16 +33,16 @@ public ItemDiskLegacy()
setMaxStackSize( 1 ); setMaxStackSize( 1 );
setHasSubtypes( true ); setHasSubtypes( true );
setTranslationKey( "computercraft:disk" ); setTranslationKey( "computercraft:disk" );
setCreativeTab( ComputerCraft.mainCreativeTab ); setCreativeTab( ComputerCraft.mainCreativeTab );
} }
@Override @Override
public void getSubItems( @Nonnull CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list ) public void getSubItems( @Nonnull CreativeTabs tabs, @Nonnull NonNullList<ItemStack> list )
{ {
if( !isInCreativeTab( tabs ) ) return; if( !isInCreativeTab( tabs ) ) return;
for( int colour=0; colour<16; ++colour ) for( int colour = 0; colour < 16; ++colour )
{ {
ItemStack stack = createFromIDAndColour( -1, null, Colour.values()[ colour ].getHex() ); ItemStack stack = createFromIDAndColour( -1, null, Colour.values()[colour].getHex() );
if( stack.getItem() == this ) if( stack.getItem() == this )
{ {
list.add( stack ); list.add( stack );
@ -69,9 +68,12 @@ public int getDiskID( @Nonnull ItemStack stack )
protected void setDiskID( @Nonnull ItemStack stack, int id ) protected void setDiskID( @Nonnull ItemStack stack, int id )
{ {
if( id > 0 ) { if( id > 0 )
{
stack.setItemDamage( id ); stack.setItemDamage( id );
} else { }
else
{
stack.setItemDamage( 0 ); stack.setItemDamage( 0 );
} }
} }
@ -115,18 +117,6 @@ public boolean setLabel( @Nonnull ItemStack stack, String label )
return true; return true;
} }
@Override
public String getAudioTitle( @Nonnull ItemStack stack )
{
return null;
}
@Override
public SoundEvent getAudio( @Nonnull ItemStack stack )
{
return null;
}
@Override @Override
public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world ) public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{ {

View File

@ -18,7 +18,6 @@
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -66,24 +65,6 @@ public String getLabel( @Nonnull ItemStack stack )
return getTitle( stack ); return getTitle( stack );
} }
@Override
public boolean setLabel( @Nonnull ItemStack stack, String label )
{
return false;
}
@Override
public String getAudioTitle( @Nonnull ItemStack stack )
{
return null;
}
@Override
public SoundEvent getAudio( @Nonnull ItemStack stack )
{
return null;
}
@Override @Override
public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world ) public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{ {
@ -126,7 +107,7 @@ public static ItemStack create( String subPath, int colourIndex )
{ {
nbt.setString( "title", "untitled" ); nbt.setString( "title", "untitled" );
} }
nbt.setInteger( "colour", Colour.values()[ colourIndex ].getHex() ); nbt.setInteger( "colour", Colour.values()[colourIndex].getHex() );
ItemStack result = new ItemStack( ComputerCraft.Items.treasureDisk, 1, 0 ); ItemStack result = new ItemStack( ComputerCraft.Items.treasureDisk, 1, 0 );
result.setTagCompound( nbt ); result.setTagCompound( nbt );

View File

@ -7,19 +7,21 @@
package dan200.computercraft.shared.media.items; package dan200.computercraft.shared.media.items;
import dan200.computercraft.ComputerCraft; import dan200.computercraft.ComputerCraft;
import dan200.computercraft.api.filesystem.IMount;
import dan200.computercraft.api.media.IMedia; import dan200.computercraft.api.media.IMedia;
import net.minecraft.item.ItemRecord; import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvent;
import net.minecraft.world.World;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
// An implementation of IMedia for ItemRecord's /**
* An implementation of IMedia for ItemRecord's
*/
public class RecordMedia implements IMedia public class RecordMedia implements IMedia
{ {
public RecordMedia() public static final RecordMedia INSTANCE = new RecordMedia();
private RecordMedia()
{ {
} }
@ -29,12 +31,6 @@ public String getLabel( @Nonnull ItemStack stack )
return getAudioTitle( stack ); return getAudioTitle( stack );
} }
@Override
public boolean setLabel( @Nonnull ItemStack stack, String label )
{
return false;
}
@Override @Override
public String getAudioTitle( @Nonnull ItemStack stack ) public String getAudioTitle( @Nonnull ItemStack stack )
{ {
@ -44,13 +40,7 @@ public String getAudioTitle( @Nonnull ItemStack stack )
@Override @Override
public SoundEvent getAudio( @Nonnull ItemStack stack ) public SoundEvent getAudio( @Nonnull ItemStack stack )
{ {
ItemRecord itemRecord = (ItemRecord)stack.getItem(); ItemRecord itemRecord = (ItemRecord) stack.getItem();
return itemRecord.sound; return itemRecord.sound;
} }
@Override
public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{
return null;
}
} }

View File

@ -28,7 +28,10 @@
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*; import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@ -396,18 +399,6 @@ public boolean setLabel( @Nonnull ItemStack stack, String label )
return true; return true;
} }
@Override
public String getAudioTitle( @Nonnull ItemStack stack )
{
return null;
}
@Override
public SoundEvent getAudio( @Nonnull ItemStack stack )
{
return null;
}
@Override @Override
public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world ) public IMount createDataMount( @Nonnull ItemStack stack, @Nonnull World world )
{ {
@ -457,7 +448,7 @@ private void setSessionID( @Nonnull ItemStack stack, int sessionID )
stack.getTagCompound().setInteger( "sessionID", sessionID ); stack.getTagCompound().setInteger( "sessionID", sessionID );
} }
@SideOnly(Side.CLIENT) @SideOnly( Side.CLIENT )
public ComputerState getState( @Nonnull ItemStack stack ) public ComputerState getState( @Nonnull ItemStack stack )
{ {
ClientComputer computer = getClientComputer( stack ); ClientComputer computer = getClientComputer( stack );
@ -468,7 +459,7 @@ public ComputerState getState( @Nonnull ItemStack stack )
return ComputerState.Off; return ComputerState.Off;
} }
@SideOnly(Side.CLIENT) @SideOnly( Side.CLIENT )
public int getLightState( @Nonnull ItemStack stack ) public int getLightState( @Nonnull ItemStack stack )
{ {
ClientComputer computer = getClientComputer( stack ); ClientComputer computer = getClientComputer( stack );

View File

@ -7,14 +7,16 @@
package dan200.computercraft.shared.turtle.upgrades; package dan200.computercraft.shared.turtle.upgrades;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.turtle.*; import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
import dan200.computercraft.api.turtle.TurtleSide;
import dan200.computercraft.api.turtle.TurtleUpgradeType;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ModelManager; import net.minecraft.client.renderer.block.model.ModelManager;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -82,13 +84,6 @@ public IPeripheral createPeripheral( @Nonnull ITurtleAccess turtle, @Nonnull Tur
return new CraftingTablePeripheral( turtle ); return new CraftingTablePeripheral( turtle );
} }
@Nonnull
@Override
public TurtleCommandResult useTool( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side, @Nonnull TurtleVerb verb, @Nonnull EnumFacing dir )
{
return TurtleCommandResult.failure();
}
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
private void loadModelLocations() private void loadModelLocations()
{ {

View File

@ -8,7 +8,10 @@
package dan200.computercraft.shared.turtle.upgrades; package dan200.computercraft.shared.turtle.upgrades;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.turtle.*; import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
import dan200.computercraft.api.turtle.TurtleSide;
import dan200.computercraft.api.turtle.TurtleUpgradeType;
import dan200.computercraft.shared.peripheral.PeripheralType; import dan200.computercraft.shared.peripheral.PeripheralType;
import dan200.computercraft.shared.peripheral.common.PeripheralItemFactory; import dan200.computercraft.shared.peripheral.common.PeripheralItemFactory;
import dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral; import dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral;
@ -17,13 +20,13 @@
import net.minecraft.client.renderer.block.model.ModelManager; import net.minecraft.client.renderer.block.model.ModelManager;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.vecmath.Matrix4f; import javax.vecmath.Matrix4f;
@ -34,7 +37,7 @@ private static class Peripheral extends SpeakerPeripheral
// Members // Members
ITurtleAccess m_turtle; ITurtleAccess m_turtle;
public Peripheral(ITurtleAccess turtle) public Peripheral( ITurtleAccess turtle )
{ {
super(); super();
m_turtle = turtle; m_turtle = turtle;
@ -59,9 +62,9 @@ public BlockPos getPos()
} }
@Override @Override
public boolean equals(IPeripheral other) public boolean equals( IPeripheral other )
{ {
if (other instanceof Peripheral) if( other instanceof Peripheral )
{ {
Peripheral otherPeripheral = (Peripheral) other; Peripheral otherPeripheral = (Peripheral) other;
return otherPeripheral.m_turtle == m_turtle; return otherPeripheral.m_turtle == m_turtle;
@ -124,14 +127,7 @@ public ItemStack getCraftingItem()
@Override @Override
public IPeripheral createPeripheral( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side ) public IPeripheral createPeripheral( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side )
{ {
return new TurtleSpeaker.Peripheral(turtle); return new TurtleSpeaker.Peripheral( turtle );
}
@Nonnull
@Override
public TurtleCommandResult useTool( @Nonnull ITurtleAccess turtleAccess, @Nonnull TurtleSide turtleSide, @Nonnull TurtleVerb verb, @Nonnull EnumFacing direction )
{
return TurtleCommandResult.failure();
} }
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
@ -166,7 +162,7 @@ public Pair<IBakedModel, Matrix4f> getModel( ITurtleAccess turtle, @Nonnull Turt
public void update( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide turtleSide ) public void update( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide turtleSide )
{ {
IPeripheral turtlePeripheral = turtle.getPeripheral( turtleSide ); IPeripheral turtlePeripheral = turtle.getPeripheral( turtleSide );
if ( turtlePeripheral instanceof Peripheral ) if( turtlePeripheral instanceof Peripheral )
{ {
Peripheral peripheral = (Peripheral) turtlePeripheral; Peripheral peripheral = (Peripheral) turtlePeripheral;
peripheral.update(); peripheral.update();

View File

@ -7,7 +7,6 @@
package dan200.computercraft.shared.turtle.upgrades; package dan200.computercraft.shared.turtle.upgrades;
import dan200.computercraft.ComputerCraft; import dan200.computercraft.ComputerCraft;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.turtle.*; import dan200.computercraft.api.turtle.*;
import dan200.computercraft.api.turtle.event.TurtleAttackEvent; import dan200.computercraft.api.turtle.event.TurtleAttackEvent;
import dan200.computercraft.api.turtle.event.TurtleBlockEvent; import dan200.computercraft.api.turtle.event.TurtleBlockEvent;
@ -94,12 +93,6 @@ public ItemStack getCraftingItem()
return m_item.copy(); return m_item.copy();
} }
@Override
public IPeripheral createPeripheral( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide side )
{
return null;
}
@Nonnull @Nonnull
@Override @Override
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )