add the code!

This commit is contained in:
LordMZTE 2022-10-31 19:14:21 +01:00
parent 48a1998551
commit f4a938ab3d
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
247 changed files with 12595 additions and 3 deletions

4
.gitignore vendored
View file

@ -1,3 +1,7 @@
.project
.classpath
bin
.settings
.gradle
.idea
build

View file

@ -17,17 +17,36 @@ buildscript {
apply plugin: 'forge'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceSets {
api {}
}
version = "1.0"
group= "modgroup"
archivesBaseName = "modid"
group = "universalelectricity"
archivesBaseName = "electricexpansion"
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "run"
}
dependencies {
repositories {
maven { url = "https://maven.tilera.xyz" }
maven {
name 'central'
url 'https://maven.thorfusion.com/artifactory/central/'
}
}
dependencies {
compile "codechicken:NotEnoughItems:1.7.10-1.0.5.120:dev"
compile "codechicken:CodeChickenCore:1.7.10-1.0.7.48:dev"
compile "codechicken:CodeChickenLib:1.7.10-1.1.3.141:dev"
compile "universalelectricity:basiccomponents:1.0.2-dirty:deobf"
}
processResources

0
gradlew vendored Normal file → Executable file
View file

View file

@ -0,0 +1,315 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api;
import dan200.computercraft.api.filesystem.IMount;
import dan200.computercraft.api.filesystem.IWritableMount;
import dan200.computercraft.api.media.IMediaProvider;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import dan200.computercraft.api.permissions.ITurtlePermissionProvider;
import dan200.computercraft.api.redstone.IBundledRedstoneProvider;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
import net.minecraft.world.World;
import java.lang.reflect.Method;
/**
* The static entry point to the ComputerCraft API.
* Members in this class must be called after mod_ComputerCraft has been initialised,
* but may be called before it is fully loaded.
*/
public final class ComputerCraftAPI
{
public static boolean isInstalled()
{
findCC();
return computerCraft != null;
}
public static String getInstalledVersion()
{
findCC();
if( computerCraft_getVersion != null )
{
try {
return (String)computerCraft_getVersion.invoke( null );
} catch (Exception e) {
// It failed
}
}
return "";
}
public static String getAPIVersion()
{
return "1.75";
}
/**
* Creates a numbered directory in a subfolder of the save directory for a given world, and returns that number.<br>
* Use in conjuction with createSaveDirMount() to create a unique place for your peripherals or media items to store files.<br>
* @param world The world for which the save dir should be created. This should be the serverside world object.
* @param parentSubPath The folder path within the save directory where the new directory should be created. eg: "computercraft/disk"
* @return The numerical value of the name of the new folder, or -1 if the folder could not be created for some reason.<br>
* eg: if createUniqueNumberedSaveDir( world, "computer/disk" ) was called returns 42, then "computer/disk/42" is now available for writing.
* @see #createSaveDirMount(World, String, long)
*/
public static int createUniqueNumberedSaveDir( World world, String parentSubPath )
{
findCC();
if( computerCraft_createUniqueNumberedSaveDir != null )
{
try {
return (Integer)computerCraft_createUniqueNumberedSaveDir.invoke( null, world, parentSubPath );
} catch (Exception e) {
// It failed
}
}
return -1;
}
/**
* Creates a file system mount that maps to a subfolder of the save directory for a given world, and returns it.<br>
* Use in conjuction with IComputerAccess.mount() or IComputerAccess.mountWritable() to mount a folder from the
* users save directory onto a computers file system.<br>
* @param world The world for which the save dir can be found. This should be the serverside world object.
* @param subPath The folder path within the save directory that the mount should map to. eg: "computer/disk/42".<br>
* Use createUniqueNumberedSaveDir() to create a new numbered folder to use.
* @param capacity The ammount of data that can be stored in the directory before it fills up, in bytes.
* @return The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable()
* to mount this on a Computers' file system.
* @see #createUniqueNumberedSaveDir(World, String)
* @see dan200.computercraft.api.peripheral.IComputerAccess#mount(String, dan200.computercraft.api.filesystem.IMount)
* @see dan200.computercraft.api.peripheral.IComputerAccess#mountWritable(String, dan200.computercraft.api.filesystem.IWritableMount)
* @see dan200.computercraft.api.filesystem.IMount
* @see IWritableMount
*/
public static IWritableMount createSaveDirMount( World world, String subPath, long capacity )
{
findCC();
if( computerCraft_createSaveDirMount != null )
{
try {
return (IWritableMount)computerCraft_createSaveDirMount.invoke( null, world, subPath, capacity );
} catch (Exception e){
// It failed
}
}
return null;
}
/**
* Creates a file system mount to a resource folder, and returns it.<br>
* Use in conjuction with IComputerAccess.mount() or IComputerAccess.mountWritable() to mount a resource folder onto a computers file system.<br>
* The files in this mount will be a combination of files in the specified mod jar, and resource packs that contain resources with the same domain and path.<br>
* @param modClass A class in whose jar to look first for the resources to mount. Using your main mod class is recommended. eg: MyMod.class
* @param domain The domain under which to look for resources. eg: "mymod"
* @param subPath The domain under which to look for resources. eg: "mymod/lua/myfiles"
* @return The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable()
* to mount this on a Computers' file system.
* @see dan200.computercraft.api.peripheral.IComputerAccess#mount(String, dan200.computercraft.api.filesystem.IMount)
* @see dan200.computercraft.api.peripheral.IComputerAccess#mountWritable(String, IWritableMount)
* @see dan200.computercraft.api.filesystem.IMount
*/
public static IMount createResourceMount( Class modClass, String domain, String subPath )
{
findCC();
if( computerCraft_createResourceMount != null )
{
try {
return (IMount)computerCraft_createResourceMount.invoke( null, modClass, domain, subPath );
} catch (Exception e){
// It failed
}
}
return null;
}
/**
* Registers a peripheral handler to convert blocks into IPeripheral implementations.
* @see dan200.computercraft.api.peripheral.IPeripheral
* @see dan200.computercraft.api.peripheral.IPeripheralProvider
*/
public static void registerPeripheralProvider( IPeripheralProvider handler )
{
findCC();
if ( computerCraft_registerPeripheralProvider != null)
{
try {
computerCraft_registerPeripheralProvider.invoke( null, handler );
} catch (Exception e){
// It failed
}
}
}
/**
* Registers a new turtle turtle for use in ComputerCraft. After calling this,
* users should be able to craft Turtles with your new turtle. It is recommended to call
* this during the load() method of your mod.
* @see dan200.computercraft.api.turtle.ITurtleUpgrade
*/
public static void registerTurtleUpgrade( ITurtleUpgrade upgrade )
{
if( upgrade != null )
{
findCC();
if( computerCraft_registerTurtleUpgrade != null )
{
try {
computerCraft_registerTurtleUpgrade.invoke( null, upgrade );
} catch( Exception e ) {
// It failed
}
}
}
}
/**
* Registers a bundled redstone handler to provide bundled redstone output for blocks
* @see dan200.computercraft.api.redstone.IBundledRedstoneProvider
*/
public static void registerBundledRedstoneProvider( IBundledRedstoneProvider handler )
{
findCC();
if( computerCraft_registerBundledRedstoneProvider != null )
{
try {
computerCraft_registerBundledRedstoneProvider.invoke( null, handler );
} catch (Exception e) {
// It failed
}
}
}
/**
* If there is a Computer or Turtle at a certain position in the world, get it's bundled redstone output.
* @see dan200.computercraft.api.redstone.IBundledRedstoneProvider
* @return If there is a block capable of emitting bundled redstone at the location, it's signal (0-65535) will be returned.
* If there is no block capable of emitting bundled redstone at the location, -1 will be returned.
*/
public static int getBundledRedstoneOutput( World world, int x, int y, int z, int side )
{
findCC();
if( computerCraft_getDefaultBundledRedstoneOutput != null )
{
try {
return (Integer)computerCraft_getDefaultBundledRedstoneOutput.invoke( null, world, x, y, z, side );
} catch (Exception e){
// It failed
}
}
return -1;
}
/**
* Registers a media handler to provide IMedia implementations for Items
* @see dan200.computercraft.api.media.IMediaProvider
*/
public static void registerMediaProvider( IMediaProvider handler )
{
findCC();
if( computerCraft_registerMediaProvider != null )
{
try {
computerCraft_registerMediaProvider.invoke( null, handler );
} catch (Exception e){
// It failed
}
}
}
/**
* Registers a permission handler to restrict where turtles can move or build
* @see dan200.computercraft.api.permissions.ITurtlePermissionProvider
*/
public static void registerPermissionProvider( ITurtlePermissionProvider handler )
{
findCC();
if( computerCraft_registerPermissionProvider != null )
{
try {
computerCraft_registerPermissionProvider.invoke( null, handler );
} catch (Exception e) {
// It failed
}
}
}
// The functions below here are private, and are used to interface with the non-API ComputerCraft classes.
// Reflection is used here so you can develop your mod without decompiling ComputerCraft and including
// it in your solution, and so your mod won't crash if ComputerCraft is installed.
private static void findCC()
{
if( !ccSearched ) {
try {
computerCraft = Class.forName( "dan200.computercraft.ComputerCraft" );
computerCraft_getVersion = findCCMethod( "getVersion", new Class[]{
} );
computerCraft_createUniqueNumberedSaveDir = findCCMethod( "createUniqueNumberedSaveDir", new Class[]{
World.class, String.class
} );
computerCraft_createSaveDirMount = findCCMethod( "createSaveDirMount", new Class[] {
World.class, String.class, Long.TYPE
} );
computerCraft_createResourceMount = findCCMethod( "createResourceMount", new Class[] {
Class.class, String.class, String.class
} );
computerCraft_registerPeripheralProvider = findCCMethod( "registerPeripheralProvider", new Class[] {
IPeripheralProvider.class
} );
computerCraft_registerTurtleUpgrade = findCCMethod( "registerTurtleUpgrade", new Class[] {
ITurtleUpgrade.class
} );
computerCraft_registerBundledRedstoneProvider = findCCMethod( "registerBundledRedstoneProvider", new Class[] {
IBundledRedstoneProvider.class
} );
computerCraft_getDefaultBundledRedstoneOutput = findCCMethod( "getDefaultBundledRedstoneOutput", new Class[] {
World.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE
} );
computerCraft_registerMediaProvider = findCCMethod( "registerMediaProvider", new Class[] {
IMediaProvider.class
} );
computerCraft_registerPermissionProvider = findCCMethod( "registerPermissionProvider", new Class[] {
ITurtlePermissionProvider.class
} );
} catch( Exception e ) {
System.out.println( "ComputerCraftAPI: ComputerCraft not found." );
} finally {
ccSearched = true;
}
}
}
private static Method findCCMethod( String name, Class[] args )
{
try {
if( computerCraft != null )
{
return computerCraft.getMethod( name, args );
}
return null;
} catch( NoSuchMethodException e ) {
System.out.println( "ComputerCraftAPI: ComputerCraft method " + name + " not found." );
return null;
}
}
private static boolean ccSearched = false;
private static Class computerCraft = null;
private static Method computerCraft_getVersion = null;
private static Method computerCraft_createUniqueNumberedSaveDir = null;
private static Method computerCraft_createSaveDirMount = null;
private static Method computerCraft_createResourceMount = null;
private static Method computerCraft_registerPeripheralProvider = null;
private static Method computerCraft_registerTurtleUpgrade = null;
private static Method computerCraft_registerBundledRedstoneProvider = null;
private static Method computerCraft_getDefaultBundledRedstoneOutput = null;
private static Method computerCraft_registerMediaProvider = null;
private static Method computerCraft_registerPermissionProvider = null;
}

View file

@ -0,0 +1,57 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.filesystem;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
* Represents a read only part of a virtual filesystem that can be mounted onto a computercraft using IComputerAccess.mount().
* Ready made implementations of this interface can be created using ComputerCraftAPI.createSaveDirMount() or ComputerCraftAPI.createResourceMount(), or you're free to implement it yourselves!
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
* @see dan200.computercraft.api.peripheral.IComputerAccess#mount(String, IMount)
* @see IWritableMount
*/
public interface IMount
{
/**
* Returns whether a file with a given path exists or not.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
* @return true if the file exists, false otherwise
*/
public boolean exists( String path ) throws IOException;
/**
* Returns whether a file with a given path is a directory or not.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
* @return true if the file exists and is a directory, false otherwise
*/
public boolean isDirectory( String path ) throws IOException;
/**
* Returns the file names of all the files in a directory.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprograms"
* @param contents A list of strings. Add all the file names to this list
*/
public void list( String path, List<String> contents ) throws IOException;
/**
* Returns the size of a file with a given path, in bytes
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
* @return the size of the file, in bytes
*/
public long getSize( String path ) throws IOException;
/**
* Opens a file with a given path, and returns an inputstream representing it's contents.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
* @return a stream representing the contents of the file
*/
public InputStream openForRead( String path ) throws IOException;
}

View file

@ -0,0 +1,52 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.filesystem;
import java.io.IOException;
import java.io.OutputStream;
/**
* Represents a part of a virtual filesystem that can be mounted onto a computercraft using IComputerAccess.mount() or IComputerAccess.mountWritable(), that can also be written to.
* Ready made implementations of this interface can be created using ComputerCraftAPI.createSaveDirMount(), or you're free to implement it yourselves!
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.peripheral.IComputerAccess#mountWritable(String, dan200.computercraft.api.filesystem.IMount)
* @see dan200.computercraft.api.filesystem.IMount
*/
public interface IWritableMount extends IMount
{
/**
* Creates a directory at a given path inside the virtual file system.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/mynewprograms"
*/
public void makeDirectory( String path ) throws IOException;
/**
* Deletes a directory at a given path inside the virtual file system.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myoldprograms"
*/
public void delete( String path ) throws IOException;
/**
* Opens a file with a given path, and returns an outputstream for writing to it.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
* @return a stream for writing to
*/
public OutputStream openForWrite( String path ) throws IOException;
/**
* Opens a file with a given path, and returns an outputstream for appending to it.
* @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
* @return a stream for writing to
*/
public OutputStream openForAppend( String path ) throws IOException;
/**
* Get the ammount of free space on the mount, in bytes. You should decrease this value as the user writes to the mount, and write operations should fail once it reaches zero.
* @return The ammount of free space, in bytes.
*/
public long getRemainingSpace() throws IOException;
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|FileSystem", apiVersion="1.75" )
package dan200.computercraft.api.filesystem;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,58 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.lua;
/**
* An interface passed to peripherals and ILuaObjects' by computers or turtles, providing methods
* that allow the peripheral call to wait for events before returning, just like in lua.
* This is very useful if you need to signal work to be performed on the main thread, and don't want to return
* until the work has been completed.
*/
public interface ILuaContext
{
/**
* Wait for an event to occur on the computercraft, suspending the thread until it arises. This method is exactly equivalent to os.pullEvent() in lua.
* @param filter A specific event to wait for, or null to wait for any event
* @return An object array containing the name of the event that occurred, and any event parameters
* @throws Exception If the user presses CTRL+T to terminate the current program while pullEvent() is waiting for an event, a "Terminated" exception will be thrown here.
* Do not attempt to common this exception, unless you wish to prevent termination, which is not recommended.
* @throws InterruptedException If the user shuts down or reboots the computercraft while pullEvent() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
*/
public Object[] pullEvent( String filter ) throws LuaException, InterruptedException;
/**
* The same as pullEvent(), except "terminated" events are ignored. Only use this if you want to prevent program termination, which is not recommended. This method is exactly equivalent to os.pullEventRaw() in lua.
* @param filter A specific event to wait for, or null to wait for any event
* @return An object array containing the name of the event that occurred, and any event parameters
* @throws InterruptedException If the user shuts down or reboots the computercraft while pullEventRaw() is waiting for an event, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
* @see #pullEvent(String)
*/
public Object[] pullEventRaw( String filter ) throws InterruptedException;
/**
* Yield the current coroutine with some arguments until it is resumed. This method is exactly equivalent to coroutine.yield() in lua. Use pullEvent() if you wish to wait for events.
* @param arguments An object array containing the arguments to pass to coroutine.yield()
* @return An object array containing the return values from coroutine.yield()
* @throws InterruptedException If the user shuts down or reboots the computercraft the coroutine is suspended, InterruptedException will be thrown. This exception must not be caught or intercepted, or the computercraft will leak memory and end up in a broken state.
* @see #pullEvent(String)
*/
public Object[] yield( Object[] arguments ) throws InterruptedException;
/**
* TODO: Document me
* @param task
* @return
*/
public Object[] executeMainThreadTask( ILuaTask task ) throws LuaException, InterruptedException;
/**
* TODO: Document me
* @param task
* @return
*/
public long issueMainThreadTask( ILuaTask task ) throws LuaException;
}

View file

@ -0,0 +1,26 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.lua;
/**
* An interface for representing custom objects returned by IPeripheral.callMethod() calls.
* Return objects implementing this interface to expose objects with methods to lua.
*/
public interface ILuaObject
{
/**
* Get the names of the methods that this object implements. This works the same as IPeripheral.getMethodNames(). See that method for detailed documentation.
* @see dan200.computercraft.api.peripheral.IPeripheral#getMethodNames()
*/
public String[] getMethodNames();
/**
* Called when a user calls one of the methods that this object implements. This works the same as IPeripheral.callMethod(). See that method for detailed documentation.
* @see dan200.computercraft.api.peripheral.IPeripheral#callMethod(dan200.computercraft.api.peripheral.IComputerAccess, ILuaContext, int, Object[])
*/
public Object[] callMethod( ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException;
}

View file

@ -0,0 +1,12 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.lua;
public interface ILuaTask
{
public Object[] execute() throws LuaException;
}

View file

@ -0,0 +1,36 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.lua;
/**
* An exception representing an error in Lua, like that raised by the error() function
*/
public class LuaException extends Exception
{
private final int m_level;
public LuaException()
{
this( "error", 1 );
}
public LuaException( String message )
{
this( message, 1 );
}
public LuaException( String message, int level )
{
super( message );
m_level = level;
}
public int getLevel()
{
return m_level;
}
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Lua", apiVersion="1.75" )
package dan200.computercraft.api.lua;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,59 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.media;
import dan200.computercraft.api.filesystem.IMount;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* Represents an item that can be placed in a disk drive and used by a Computer.
* Implement this interface on your Item class to allow it to be used in the drive.
*/
public interface IMedia
{
/**
* Get a string representing the label of this item. Will be called vi disk.getLabel() in lua.
* @param stack The itemstack to inspect
* @return The label. ie: "Dan's Programs"
*/
public String getLabel( ItemStack stack );
/**
* Set a string representing the label of this item. Will be called vi disk.setLabel() in lua.
* @param stack The itemstack to modify.
* @param label The string to set the label to.
* @return true if the label was updated, false if the label may not be modified.
*/
public boolean setLabel( ItemStack stack, String label );
/**
* If this disk represents an item with audio (like a record), get the readable name of the audio track. ie: "Jonathon Coulton - Still Alive"
* @param stack The itemstack to inspect.
* @return The name, or null if this item does not represent an item with audio.
*/
public String getAudioTitle( ItemStack stack );
/**
* 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.
* @return The name, or null if this item does not represent an item with audio.
*/
public String getAudioRecordName( ItemStack stack );
/**
* 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 computercraft while the media is in the disk drive.
* @param stack The itemstack to inspect.
* @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 IMount returned also implements IWritableMount, it will mounted using mountWritable()
* @see dan200.computercraft.api.filesystem.IMount
* @see dan200.computercraft.api.filesystem.IWritableMount
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String, long)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
*/
public IMount createDataMount( ItemStack stack, World world );
}

View file

@ -0,0 +1,23 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.media;
import net.minecraft.item.ItemStack;
/**
* This interface is used to provide IMedia implementations for ItemStack
* @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(IMediaProvider)
*/
public interface IMediaProvider
{
/**
* Produce an IMedia implementation from an ItemStack.
* @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(IMediaProvider)
* @return an IMedia implementation, or null if the item is not something you wish to handle
*/
public IMedia getMedia( ItemStack stack );
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Media", apiVersion="1.75" )
package dan200.computercraft.api.media;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API", apiVersion="1.75" )
package dan200.computercraft.api;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,102 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
import dan200.computercraft.api.filesystem.IMount;
import dan200.computercraft.api.filesystem.IWritableMount;
/**
* The interface passed to peripherals by computers or turtles, providing methods
* that they can call. This should not be implemented by your classes. Do not interact
* with computers except via this interface.
*/
public interface IComputerAccess
{
/**
* Mount a mount onto the computers' file system in a read only mode.<br>
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
* @param mount The mount object to mount on the computercraft. These can be obtained by calling ComputerCraftAPI.createSaveDirMount(), ComputerCraftAPI.createResourceMount() or by creating your own objects that implement the IMount interface.
* @return The location on the computercraft's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
* @see #mountWritable(String, dan200.computercraft.api.filesystem.IWritableMount)
* @see #unmount(String)
* @see dan200.computercraft.api.filesystem.IMount
*/
public String mount( String desiredLocation, IMount mount );
/**
* TODO: Document me
*/
public String mount( String desiredLocation, IMount mount, String driveName );
/**
* Mount a mount onto the computers' file system in a writable mode.<br>
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
* @param mount The mount object to mount on the computercraft. These can be obtained by calling ComputerCraftAPI.createSaveDirMount() or by creating your own objects that implement the IWritableMount interface.
* @return The location on the computercraft's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
* @see #mount(String, IMount)
* @see #unmount(String)
* @see IMount
*/
public String mountWritable( String desiredLocation, IWritableMount mount );
/**
* TODO: Document me
*/
public String mountWritable( String desiredLocation, IWritableMount mount, String driveName );
/**
* Unmounts a directory previously mounted onto the computers file system by mount() or mountWritable().<br>
* When a directory is unmounted, it will disappear from the computers file system, and the user will no longer be able to
* access it. All directories mounted by a mount or mountWritable are automatically unmounted when the peripheral
* is attached if they have not been explicitly unmounted.
* @param location The desired location in the computers file system of the directory to unmount.
* This must be the location of a directory previously mounted by mount() or mountWritable(), as
* indicated by their return value.
* @see #mount(String, IMount)
* @see #mountWritable(String, IWritableMount)
*/
public void unmount( String location );
/**
* Returns the numerical ID of this computercraft.<br>
* This is the same number obtained by calling os.getComputerID() or running the "id" program from lua,
* and is guarunteed unique. This number will be positive.
* @return The identifier.
*/
public int getID();
/**
* Causes an event to be raised on this computercraft, which the computercraft can respond to by calling
* os.pullEvent(). This can be used to notify the computercraft when things happen in the world or to
* this peripheral.
* @param event A string identifying the type of event that has occurred, this will be
* returned as the first value from os.pullEvent(). It is recommended that you
* you choose a name that is unique, and recognisable as originating from your
* peripheral. eg: If your peripheral type is "button", a suitable event would be
* "button_pressed".
* @param arguments In addition to a name, you may pass an array of extra arguments to the event, that will
* be supplied as extra return values to os.pullEvent(). Objects in the array will be converted
* to lua data types in the same fashion as the return values of IPeripheral.callMethod().<br>
* You may supply null to indicate that no arguments are to be supplied.
* @see dan200.computercraft.api.peripheral.IPeripheral#callMethod
*/
public void queueEvent( String event, Object[] arguments );
/**
* Get a string, unique to the computercraft, by which the computercraft refers to this peripheral.
* For directly attached peripherals this will be "left","right","front","back",etc, but
* for peripherals attached remotely it will be different. It is good practice to supply
* this string when raising events to the computercraft, so that the computercraft knows from
* which peripheral the event came.
* @return A string unique to the computercraft, but not globally.
*/
public String getAttachmentName();
}

View file

@ -0,0 +1,100 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
/**
* The interface that defines a peripheral. This should be implemented by the
* TileEntity of any common that you wish to be interacted with by
* computercraft or turtle.
*/
public interface IPeripheral
{
/**
* Should return a string that uniquely identifies this type of peripheral.
* This can be queried from lua by calling peripheral.getType()
* @return A string identifying the type of peripheral.
*/
public String getType();
/**
* Should return an array of strings that identify the methods that this
* peripheral exposes to Lua. This will be called once before each attachment,
* and should not change when called multiple times.
* @return An array of strings representing method names.
* @see #callMethod
*/
public String[] getMethodNames();
/**
* This is called when a lua program on an attached computercraft calls peripheral.call() with
* one of the methods exposed by getMethodNames().<br>
* <br>
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
* when interacting with minecraft objects.
* @param computer The interface to the computercraft that is making the call. Remember that multiple
* computers can be attached to a peripheral at once.
* @param context The context of the currently running lua thread. This can be used to wait for events
* or otherwise yield.
* @param method An integer identifying which of the methods from getMethodNames() the computercraft
* wishes to call. The integer indicates the index into the getMethodNames() table
* that corresponds to the string passed into peripheral.call()
* @param arguments An array of objects, representing the arguments passed into peripheral.call().<br>
* Lua values of type "string" will be represented by Object type String.<br>
* Lua values of type "number" will be represented by Object type Double.<br>
* Lua values of type "boolean" will be represented by Object type Boolean.<br>
* Lua values of any other type will be represented by a null object.<br>
* This array will be empty if no arguments are passed.
* @return An array of objects, representing values you wish to return to the lua program.<br>
* Integers, Doubles, Floats, Strings, Booleans and null be converted to their corresponding lua type.<br>
* All other types will be converted to nil.<br>
* You may return null to indicate no values should be returned.
* @throws Exception If you throw any exception from this function, a lua error will be raised with the
* same message as your exception. Use this to throw appropriate errors if the wrong
* arguments are supplied to your method.
* @see #getMethodNames
*/
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException;
/**
* Is called when canAttachToSide has returned true, and a computercraft is attaching to the peripheral.
* This will occur when a peripheral is placed next to an active computercraft, when a computercraft is turned on next to a peripheral,
* or when a turtle travels into a square next to a peripheral.
* Between calls to attach() and detach(), the attached computercraft can make method calls on the peripheral using peripheral.call().
* This method can be used to keep track of which computers are attached to the peripheral, or to take action when attachment
* occurs.<br>
* <br>
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
* when interacting with minecraft objects.
* @param computer The interface to the computercraft that is being attached. Remember that multiple
* computers can be attached to a peripheral at once.
* @see #detach
*/
public void attach( IComputerAccess computer );
/**
* Is called when a computercraft is detaching from the peripheral.
* This will occur when a computercraft shuts down, when the peripheral is removed while attached to computers,
* or when a turtle moves away from a square attached to a peripheral.
* This method can be used to keep track of which computers are attached to the peripheral, or to take action when detachment
* occurs.<br>
* <br>
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
* when interacting with minecraft objects.
* @param computer The interface to the computercraft that is being detached. Remember that multiple
* computers can be attached to a peripheral at once.
* @see #detach
*/
public void detach( IComputerAccess computer );
/**
* TODO: Document me
*/
public boolean equals( IPeripheral other );
}

View file

@ -0,0 +1,23 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.peripheral;
import net.minecraft.world.World;
/**
* This interface is used to create peripheral implementations for blocks
* @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
*/
public interface IPeripheralProvider
{
/**
* Produce an peripheral implementation from a block location.
* @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
* @return a peripheral, or null if there is not a peripheral here you'd like to handle.
*/
public IPeripheral getPeripheral( World world, int x, int y, int z, int side );
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Peripheral", apiVersion="1.75" )
package dan200.computercraft.api.peripheral;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,19 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.permissions;
import net.minecraft.world.World;
/**
* This interface is used to restrict where turtles can move or build
* @see dan200.computercraft.api.ComputerCraftAPI#registerPermissionProvider(ITurtlePermissionProvider)
*/
public interface ITurtlePermissionProvider
{
public boolean isBlockEnterable( World world, int x, int y, int z );
public boolean isBlockEditable( World world, int x, int y, int z );
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Permissions", apiVersion="1.75" )
package dan200.computercraft.api.permissions;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,23 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.redstone;
import net.minecraft.world.World;
/**
* This interface is used to provide bundled redstone output for blocks
* @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider)
*/
public interface IBundledRedstoneProvider
{
/**
* Produce an bundled redstone output from a block location.
* @see dan200.computercraft.api.ComputerCraftAPI#registerBundledRedstoneProvider(IBundledRedstoneProvider)
* @return a number in the range 0-65535 to indicate this block is providing output, or -1 if you do not wish to handle this block
*/
public int getBundledRedstoneOutput( World world, int x, int y, int z, int side );
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Redstone", apiVersion="1.75" )
package dan200.computercraft.api.redstone;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,168 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
/**
* The interface passed to turtle by turtles, providing methods that they can call.
* This should not be implemented by your classes. Do not interact with turtles except via this interface and ITurtleUpgrade.
*/
public interface ITurtleAccess
{
/**
* Returns the world in which the turtle resides.
* @return the world in which the turtle resides.
*/
public World getWorld();
/**
* Returns a vector containing the integer co-ordinates at which the turtle resides.
* @return a vector containing the integer co-ordinates at which the turtle resides.
*/
public ChunkCoordinates getPosition();
/**
* TODO: Document me
*/
public boolean teleportTo( World world, int x, int y, int z );
/**
* Returns a vector containing the floating point co-ordinates at which the turtle is rendered.
* This will shift when the turtle is moving.
* @param f The subframe fraction
* @return a vector containing the floating point co-ordinates at which the turtle resides.
*/
public Vec3 getVisualPosition( float f );
/**
* TODO: Document me
*/
public float getVisualYaw( float f );
/**
* Returns the world direction the turtle is currently facing.
* @return the world direction the turtle is currently facing.
*/
public int getDirection();
/**
* TODO: Document me
*/
public void setDirection( int dir );
/**
* TODO: Document me
*/
public int getSelectedSlot();
/**
* TODO: Document me
*/
public void setSelectedSlot( int slot );
/**
* Sets the colour of the turtle, as if the player had dyed it with a dye item.
* @param dyeColour 0-15 to dye the turtle one of the 16 standard minecraft colours, or -1 to remove the dye from the turtle.
*/
public void setDyeColour( int dyeColour );
/**
* Gets the colour the turtle has been dyed.
* @return 0-15 if the turtle has been dyed one of the 16 standard minecraft colours, -1 if the turtle is clean.
*/
public int getDyeColour();
/**
* TODO: Document me
*/
public IInventory getInventory();
/**
* TODO: Document me
*/
public boolean isFuelNeeded();
/**
* TODO: Document me
*/
public int getFuelLevel();
/**
* TODO: Document me
*/
public void setFuelLevel( int fuel );
/**
* TODO: Document me
*/
public int getFuelLimit();
/**
* Removes some fuel from the turtles fuel supply. Negative numbers can be passed in to INCREASE the fuel level of the turtle.
* @return Whether the turtle was able to consume the ammount of fuel specified. Will return false if you supply a number
* greater than the current fuel level of the turtle.
*/
public boolean consumeFuel( int fuel );
/**
* TODO: Document me
*/
public void addFuel( int fuel );
/**
* Adds a custom command to the turtles command queue. Unlike peripheral methods, these custom commands will be executed
* on the main thread, so are guaranteed to be able to access Minecraft objects safely, and will be queued up
* with the turtles standard movement and tool commands. An issued command will return an unique integer, which will
* be supplied as a parameter to a "turtle_response" event issued to the turtle after the command has completed. Look at the
* lua source code for "rom/apis/turtle" for how to build a lua wrapper around this functionality.
* @param command an object which will execute the custom command when its point in the queue is reached
* @return the objects the command returned when executed. you should probably return these to the player
* unchanged if called from a peripheral method.
* @see ITurtleCommand
*/
public Object[] executeCommand( ILuaContext context, ITurtleCommand command ) throws LuaException, InterruptedException;
/**
* TODO: Document me
*/
public void playAnimation( TurtleAnimation animation );
/**
* Returns the turtle on the specified side of the turtle, if there is one.
* @return the turtle on the specified side of the turtle, if there is one.
*/
public ITurtleUpgrade getUpgrade( TurtleSide side );
/**
* TODO: Document me
*/
public void setUpgrade( TurtleSide side, ITurtleUpgrade upgrade );
/**
* Returns the peripheral created by the upgrade on the specified side of the turtle, if there is one.
* @return the peripheral created by the upgrade on the specified side of the turtle, if there is one.
*/
public IPeripheral getPeripheral( TurtleSide side );
/**
* TODO: Document me
*/
public NBTTagCompound getUpgradeNBTData( TurtleSide side );
/**
* TODO: Document me
*/
public void updateUpgradeNBTData( TurtleSide side );
}

View file

@ -0,0 +1,25 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
/**
* An interface for objects executing custom turtle commands, used with ITurtleAccess.issueCommand
* @see ITurtleAccess#executeCommand(dan200.computercraft.api.lua.ILuaContext,ITurtleCommand)
*/
public interface ITurtleCommand
{
/**
* Will be called by the turtle on the main thread when it is time to execute the custom command.
* The handler should either perform the work of the command, and return success, or return
* failure with an error message to indicate the command cannot be executed at this time.
* @param turtle access to the turtle for whom the command was issued
* @return TurtleCommandResult.success() or TurtleCommandResult.failure( errorMessage )
* @see ITurtleAccess#executeCommand(dan200.computercraft.api.lua.ILuaContext,ITurtleCommand)
* @see dan200.computercraft.api.turtle.TurtleCommandResult
*/
public TurtleCommandResult execute( ITurtleAccess turtle );
}

View file

@ -0,0 +1,94 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
/**
* The primary interface for defining an turtle for Turtles. A turtle turtle
* can either be a new tool, or a new peripheral.
* @see dan200.computercraft.api.ComputerCraftAPI#registerTurtleUpgrade( dan200.computercraft.api.turtle.ITurtleUpgrade )
*/
public interface ITurtleUpgrade
{
/**
* Gets a unique numerical identifier representing this type of turtle turtle.
* Like Minecraft common and item IDs, you should strive to make this number unique
* among all turtle turtle that have been released for ComputerCraft.
* The ID must be in the range 64 to 255, as the ID is stored as an 8-bit value,
* and 0-64 is reserved for future use by ComputerCraft. The turtle will
* fail registration if an already used ID is specified.
* @see dan200.computercraft.api.ComputerCraftAPI#registerTurtleUpgrade( dan200.computercraft.api.turtle.ITurtleUpgrade )
*/
public int getUpgradeID();
/**
* Return a String to describe this type of turtle in turtle item names.
* Examples of built-in adjectives are "Wireless", "Mining" and "Crafty".
*/
public String getUnlocalisedAdjective();
/**
* Return whether this turtle adds a tool or a peripheral to the turtle.
* Currently, turtle crafting is restricted to one tool & one peripheral per turtle.
* @see TurtleUpgradeType for the differences between the two.
*/
public TurtleUpgradeType getType();
/**
* Return an item stack representing the type of item that a turtle must be crafted
* with to create a turtle which holds this turtle.
* Currently, turtle crafting is restricted to one tool & one peripheral per turtle.
*/
public ItemStack getCraftingItem();
/**
* Will only be called for Peripheral turtle. Creates a peripheral for a turtle
* being placed using this turtle. The peripheral created will be stored
* for the lifetime of the turtle, will have update() called once-per-tick, and will be
* attach'd detach'd and have methods called in the same manner as a Computer peripheral.
*
* @param turtle Access to the turtle that the peripheral is being created for.
* @param side Which side of the turtle (left or right) that the turtle resides on.
* @return The newly created peripheral. You may return null if this turtle is a Tool
* and this method is not expected to be called.
*/
public IPeripheral createPeripheral( ITurtleAccess turtle, TurtleSide side );
/**
* Will only be called for Tool turtle. Called when turtle.dig() or turtle.attack() is called
* by the turtle, and the tool is required to do some work.
* @param turtle Access to the turtle that the tool resides on.
* @param side Which side of the turtle (left or right) the tool resides on.
* @param verb Which action (dig or attack) the turtle is being called on to perform.
* @param direction Which world direction the action should be performed in, relative to the turtles
* position. This will either be up, down, or the direction the turtle is facing, depending on
* whether dig, digUp or digDown was called.
* @return Whether the turtle was able to perform the action, and hence whether the turtle.dig()
* or turtle.attack() lua method should return true. If true is returned, the tool will perform
* a swinging animation. You may return null if this turtle is a Peripheral
* and this method is not expected to be called.
*/
public TurtleCommandResult useTool( ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, int direction );
/**
* Called to obtain the IIcon to be used when rendering a turtle peripheral. Needs to be a "common"
* type IIcon for now, as there is no way to determine which texture sheet an IIcon is from by the
* IIcon itself.
* @param turtle Access to the turtle that the peripheral resides on.
* @param side Which side of the turtle (left or right) the peripheral resides on.
* @return The IIcon that you wish to be used to render your turtle peripheral.
*/
public IIcon getIcon( ITurtleAccess turtle, TurtleSide side );
/**
* TODO: Document me
*/
public void update( ITurtleAccess turtle, TurtleSide side );
}

View file

@ -0,0 +1,22 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
public enum TurtleAnimation
{
None,
MoveForward,
MoveBack,
MoveUp,
MoveDown,
TurnLeft,
TurnRight,
SwingLeftTool,
SwingRightTool,
Wait,
ShortWait,
}

View file

@ -0,0 +1,73 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
public final class TurtleCommandResult
{
private static final TurtleCommandResult s_success = new TurtleCommandResult( true, null, null );
private static final TurtleCommandResult s_emptyFailure = new TurtleCommandResult( false, null, null );
public static TurtleCommandResult success()
{
return success( null );
}
public static TurtleCommandResult success( Object[] results )
{
if( results == null || results.length == 0 )
{
return s_success;
}
else
{
return new TurtleCommandResult( true, null, results );
}
}
public static TurtleCommandResult failure()
{
return failure( null );
}
public static TurtleCommandResult failure( String errorMessage )
{
if( errorMessage == null )
{
return s_emptyFailure;
}
else
{
return new TurtleCommandResult( false, errorMessage, null );
}
}
private final boolean m_success;
private final String m_errorMessage;
private final Object[] m_results;
private TurtleCommandResult( boolean success, String errorMessage, Object[] results )
{
m_success = success;
m_errorMessage = errorMessage;
m_results = results;
}
public boolean isSuccess()
{
return m_success;
}
public String getErrorMessage()
{
return m_errorMessage;
}
public Object[] getResults()
{
return m_results;
}
}

View file

@ -0,0 +1,23 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
/**
* An enum representing the two sides of the turtle that a turtle turtle might reside.
*/
public enum TurtleSide
{
/**
* The turtles left side (where the pickaxe usually is on a Wireless Mining Turtle)
*/
Left,
/**
* The turtles right side (where the modem usually is on a Wireless Mining Turtle)
*/
Right,
}

View file

@ -0,0 +1,27 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
/**
* An enum representing the two different types of turtle that an ITurtleUpgrade
* implementation can add to a turtle.
* @see ITurtleUpgrade
*/
public enum TurtleUpgradeType
{
/**
* A tool is rendered as an item on the side of the turtle, and responds to the turtle.dig()
* and turtle.attack() methods (Such as pickaxe or sword on Mining and Melee turtles).
*/
Tool,
/**
* A peripheral adds a special peripheral which is attached to the side of the turtle,
* and can be interacted with the peripheral API (Such as the modem on Wireless Turtles).
*/
Peripheral,
}

View file

@ -0,0 +1,26 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
package dan200.computercraft.api.turtle;
/**
* An enum representing the two different actions that an ITurtleUpgrade of type
* Tool may be called on to perform by a turtle.
* @see ITurtleUpgrade
* @see ITurtleUpgrade#useTool
*/
public enum TurtleVerb
{
/**
* The turtle called turtle.dig(), turtle.digUp() or turtle.digDown()
*/
Dig,
/**
* The turtle called turtle.attack(), turtle.attackUp() or turtle.attackDown()
*/
Attack,
}

View file

@ -0,0 +1,10 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2015. This API may be redistributed unmodified and in full only.
* For help using the API, and posting your mods, visit the forums at computercraft.info.
*/
@API( owner="ComputerCraft", provides="ComputerCraft|API|Turtle", apiVersion="1.75" )
package dan200.computercraft.api.turtle;
import cpw.mods.fml.common.API;

View file

@ -0,0 +1,31 @@
package electricexpansion.api;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import universalelectricity.core.item.ItemElectric;
public class ElectricExpansionItems {
public static Block blockRawWire;
public static Block blockInsulatedWire;
public static Block blockWireBlock;
public static Block blockSwitchWire;
public static Block blockSwitchWireBlock;
public static Block blockLogisticsWire;
public static Block blockRedstonePaintedWire;
public static Block blockAdvBatteryBox;
public static Block blockMultimeter;
public static Block blockWireMill;
public static Block blockTransformer;
public static Block blockDistribution;
public static Block blockLead;
public static Block blockSilverOre;
public static Block blockInsulationMachine;
public static Block blockRedstoneNetworkCore;
public static Item itemParts;
public static Item itemUpgrade;
public static ItemElectric itemEliteBat;
public static ItemElectric itemAdvBat;
public static ItemElectric itemUltimateBat;
public static Item itemMultimeter;
public static Item itemFuse;
}

View file

@ -0,0 +1,23 @@
package electricexpansion.api;
public enum EnumWireMaterial {
COPPER("Copper", 0.0125f, 3, 200),
TIN("Tin", 0.01f, 2, 30),
SILVER("Silver", 0.005f, 1, 300),
ALUMINUM("Aluminum", 0.025f, 8, 15),
SUPERCONDUCTOR("Superconductor", 0.0f, 5, Integer.MAX_VALUE),
UNKNOWN("Unknown", 0.4f, 2, 60);
public final String name;
public final float resistance;
public final int electrocutionDamage;
public final int maxAmps;
private EnumWireMaterial(final String name, final float resistance,
final int electrocutionDamage, final int maxAmps) {
this.name = name;
this.resistance = resistance;
this.electrocutionDamage = electrocutionDamage;
this.maxAmps = maxAmps;
}
}

View file

@ -0,0 +1,10 @@
package electricexpansion.api;
public enum EnumWireType {
UNINSULATED,
INSULATED,
SWITCH,
BLOCK_INSULATED,
BLOCK_SWITCH,
LOGISTICS;
}

View file

@ -0,0 +1,9 @@
package electricexpansion.api;
import universalelectricity.core.block.IConductor;
public interface IAdvancedConductor extends IConductor {
EnumWireMaterial getWireMaterial(final int p0);
EnumWireType getWireType(final int p0);
}

View file

@ -0,0 +1,17 @@
package electricexpansion.api;
import net.minecraft.item.ItemStack;
public interface IItemFuse {
double getMaxVolts(final ItemStack p0);
ItemStack onFuseTrip(final ItemStack p0);
boolean isValidFuse(final ItemStack p0);
boolean canReset(final ItemStack p0);
ItemStack onReset(final ItemStack p0);
String getUnlocalizedName(final ItemStack p0);
}

View file

@ -0,0 +1,8 @@
package electricexpansion.api;
import universalelectricity.core.block.INetworkProvider;
public interface IRedstoneNetAccessor extends INetworkProvider
{
int getRsSignalFromBlock();
}

View file

@ -0,0 +1,16 @@
package electricexpansion.api;
import net.minecraft.entity.player.EntityPlayer;
import universalelectricity.core.block.IElectricityStorage;
public interface IWirelessPowerMachine extends IElectricityStorage {
byte getFrequency();
void setFrequency(final byte p0);
String getType();
void removeJoules(final double p0);
void setPlayer(final EntityPlayer p0);
}

View file

@ -0,0 +1,60 @@
package electricexpansion.api;
import cpw.mods.fml.common.Loader;
import electricexpansion.common.misc.InsulationRecipes;
import electricexpansion.common.misc.WireMillRecipes;
import net.minecraft.item.ItemStack;
public class Recipes {
public boolean addInsulationRecipe(final ItemStack input, final int output,
final int ticks) {
if (Loader.isModLoaded("ElectricExpansion")) {
try {
InsulationRecipes.INSTANCE.addProcessing(input, output, ticks);
return true;
} catch (final Exception e) {
return false;
}
}
return false;
}
public boolean addInsulationRecipe(final String input, final int output,
final int ticks) {
if (Loader.isModLoaded("ElectricExpansion")) {
try {
InsulationRecipes.INSTANCE.addProcessing(input, output, ticks);
return true;
} catch (final Exception e) {
return false;
}
}
return false;
}
public boolean addDrawingRecipe(final ItemStack input, final ItemStack output,
final int ticks) {
if (Loader.isModLoaded("ElectricExpansion")) {
try {
WireMillRecipes.INSTANCE.addProcessing(input, output, ticks);
return true;
} catch (final Exception e) {
return false;
}
}
return false;
}
public boolean addDrawingRecipe(final String input, final ItemStack output,
final int ticks) {
if (Loader.isModLoaded("ElectricExpansion")) {
try {
WireMillRecipes.INSTANCE.addProcessing(input, output, ticks);
return true;
} catch (final Exception e) {
return false;
}
}
return false;
}
}

View file

@ -0,0 +1,95 @@
package electricexpansion.client;
import net.minecraft.tileentity.TileEntity;
import electricexpansion.client.gui.GuiFuseBox;
import electricexpansion.common.tile.TileEntityFuseBox;
import electricexpansion.client.gui.GuiInsulationMachine;
import electricexpansion.client.gui.GuiQuantumBatteryBox;
import electricexpansion.client.gui.GuiLogisticsWire;
import electricexpansion.client.gui.GuiWireMill;
import electricexpansion.client.gui.GuiAdvancedBatteryBox;
import net.minecraft.world.World;
import net.minecraft.entity.player.EntityPlayer;
import electricexpansion.common.tile.TileEntityAdvancedBatteryBox;
import electricexpansion.client.render.RenderMultimeter;
import electricexpansion.common.tile.TileEntityMultimeter;
import electricexpansion.client.render.RenderTransformer;
import electricexpansion.common.tile.TileEntityTransformer;
import electricexpansion.common.tile.TileEntityRedstoneNetworkCore;
import electricexpansion.common.tile.TileEntityInsulatingMachine;
import electricexpansion.common.tile.TileEntityQuantumBatteryBox;
import electricexpansion.common.cables.TileEntitySwitchWireBlock;
import cpw.mods.fml.common.registry.GameRegistry;
import electricexpansion.common.cables.TileEntityWireBlock;
import electricexpansion.common.cables.TileEntityRedstonePaintedWire;
import electricexpansion.common.cables.TileEntityLogisticsWire;
import electricexpansion.common.cables.TileEntitySwitchWire;
import electricexpansion.common.cables.TileEntityInsulatedWire;
import electricexpansion.client.render.RenderRawWire;
import electricexpansion.common.cables.TileEntityRawWire;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import cpw.mods.fml.client.registry.ClientRegistry;
import electricexpansion.client.render.RenderWireMill;
import electricexpansion.common.tile.TileEntityWireMill;
import electricexpansion.client.render.RenderInsulatedWire;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import electricexpansion.client.render.RenderHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.CommonProxy;
@SideOnly(Side.CLIENT)
public class ClientProxy extends CommonProxy
{
public static int RENDER_ID;
@Override
public void init() {
ClientProxy.RENDER_ID = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler((ISimpleBlockRenderingHandler)new RenderHandler());
final RenderInsulatedWire insulatedWireRenderer = new RenderInsulatedWire();
ClientRegistry.registerTileEntity(TileEntityWireMill.class, "TileEntityWireMill", (TileEntitySpecialRenderer)new RenderWireMill());
ClientRegistry.registerTileEntity(TileEntityRawWire.class, "TileEntityRawWire", (TileEntitySpecialRenderer)new RenderRawWire());
ClientRegistry.registerTileEntity(TileEntityInsulatedWire.class, "TileEntityInsulatedWire", (TileEntitySpecialRenderer)insulatedWireRenderer);
ClientRegistry.registerTileEntity(TileEntitySwitchWire.class, "TileEntitySwitchWire", (TileEntitySpecialRenderer)insulatedWireRenderer);
ClientRegistry.registerTileEntity(TileEntityLogisticsWire.class, "TileEntityLogisticsWire", (TileEntitySpecialRenderer)insulatedWireRenderer);
ClientRegistry.registerTileEntity(TileEntityRedstonePaintedWire.class, "TileEntityRedstonePaintedWire", (TileEntitySpecialRenderer)insulatedWireRenderer);
GameRegistry.registerTileEntity(TileEntityWireBlock.class, "TileEntityWireBlock");
GameRegistry.registerTileEntity(TileEntitySwitchWireBlock.class, "TileEntitySwitchWireBlock");
GameRegistry.registerTileEntity(TileEntityQuantumBatteryBox.class, "TileEntityDistribution");
GameRegistry.registerTileEntity(TileEntityInsulatingMachine.class, "TileEntityInsulatingMachine");
GameRegistry.registerTileEntity(TileEntityRedstoneNetworkCore.class, "TileEntityRedstoneNetworkCore");
ClientRegistry.registerTileEntity(TileEntityTransformer.class, "TileEntityTransformer", (TileEntitySpecialRenderer)new RenderTransformer());
ClientRegistry.registerTileEntity(TileEntityMultimeter.class, "TileEntityMultimeter", (TileEntitySpecialRenderer)new RenderMultimeter());
GameRegistry.registerTileEntity(TileEntityAdvancedBatteryBox.class, "TileEntityAdvBox");
}
@Override
public Object getClientGuiElement(final int ID, final EntityPlayer player, final World world, final int x, final int y, final int z) {
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null) {
switch (ID) {
case 0: {
return new GuiAdvancedBatteryBox(player.inventory, (TileEntityAdvancedBatteryBox)tileEntity);
}
case 2: {
return new GuiWireMill(player.inventory, (TileEntityWireMill)tileEntity);
}
case 3: {
return new GuiLogisticsWire((TileEntityLogisticsWire)tileEntity);
}
case 4: {
return new GuiQuantumBatteryBox(player.inventory, (TileEntityQuantumBatteryBox)tileEntity);
}
case 5: {
return new GuiInsulationMachine(player.inventory, (TileEntityInsulatingMachine)tileEntity);
}
case 6: {
return new GuiFuseBox(player.inventory, (TileEntityFuseBox)tileEntity);
}
}
}
return null;
}
}

View file

@ -0,0 +1,79 @@
package electricexpansion.client.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.containers.ContainerAdvBatteryBox;
import electricexpansion.common.tile.TileEntityAdvancedBatteryBox;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.electricity.ElectricityDisplay;
import universalelectricity.prefab.TranslationHelper;
@SideOnly(Side.CLIENT)
public class GuiAdvancedBatteryBox extends GuiContainer {
private TileEntityAdvancedBatteryBox tileEntity;
private int containerWidth;
private int containerHeight;
public GuiAdvancedBatteryBox(final InventoryPlayer par1InventoryPlayer,
final TileEntityAdvancedBatteryBox AdvBatteryBox) {
super((Container) new ContainerAdvBatteryBox(par1InventoryPlayer,
AdvBatteryBox));
this.tileEntity = AdvBatteryBox;
}
@Override
protected void drawGuiContainerForegroundLayer(final int par1,
final int par2) {
this.fontRendererObj.drawString(
TranslationHelper.getLocal(this.tileEntity.getInventoryName()), 22, 6,
4210752);
final String displayJoules = ElectricityDisplay.getDisplayShort(
this.tileEntity.getJoules(), ElectricityDisplay.ElectricUnit.JOULES);
String displayMaxJoules = ElectricityDisplay.getDisplayShort(
this.tileEntity.getMaxJoules(), ElectricityDisplay.ElectricUnit.JOULES);
final String displayInputVoltage = ElectricityDisplay.getDisplayShort(
this.tileEntity.getInputVoltage(),
ElectricityDisplay.ElectricUnit.VOLTAGE);
final String displayOutputVoltage = ElectricityDisplay.getDisplayShort(
this.tileEntity.getVoltage(), ElectricityDisplay.ElectricUnit.VOLTAGE);
if (this.tileEntity.isDisabled()) {
displayMaxJoules = "Disabled";
}
this.fontRendererObj.drawString(displayJoules + " of",
73 - displayJoules.length(), 25, 4210752);
this.fontRendererObj.drawString(displayMaxJoules, 70, 35, 4210752);
this.fontRendererObj.drawString("Voltage: " + displayOutputVoltage, 65, 55,
4210752);
this.fontRendererObj.drawString("Input: " + displayInputVoltage, 65, 65,
4210752);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("container.inventory"), 8,
this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(final float par1,
final int par2,
final int par3) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
this.mc.renderEngine.bindTexture(getTexture());
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0,
this.xSize, this.ySize);
final int scale = (int) (this.tileEntity.getJoules() /
this.tileEntity.getMaxJoules() * 72.0);
this.drawTexturedModalRect(this.containerWidth + 64,
this.containerHeight + 46, 176, 0, scale, 20);
}
public static ResourceLocation getTexture() {
return new ResourceLocation("electricexpansion",
"textures/gui/GuiBatBox.png");
}
}

View file

@ -0,0 +1,67 @@
package electricexpansion.client.gui;
import electricexpansion.api.IItemFuse;
import electricexpansion.common.containers.ContainerFuseBox;
import electricexpansion.common.tile.TileEntityFuseBox;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.electricity.ElectricityDisplay;
import universalelectricity.prefab.TranslationHelper;
public class GuiFuseBox extends GuiContainer {
public final TileEntityFuseBox tileEntity;
private int containerWidth;
private int containerHeight;
public GuiFuseBox(final InventoryPlayer par1InventoryPlayer,
final TileEntityFuseBox tileEntity) {
super((Container) new ContainerFuseBox(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity;
}
@Override
protected void drawGuiContainerBackgroundLayer(final float var1,
final int var2,
final int var3) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
this.mc.renderEngine.bindTexture(getTexture());
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0,
this.xSize, this.ySize);
}
@Override
protected void drawGuiContainerForegroundLayer(final int par1,
final int par2) {
this.fontRendererObj.drawString(
TranslationHelper.getLocal(this.tileEntity.getInventoryName()), 8, 6,
4210752);
final String displayVoltage = ElectricityDisplay.getDisplayShort(
this.tileEntity.getVoltage(), ElectricityDisplay.ElectricUnit.VOLTAGE);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("container.voltage") + ": " +
displayVoltage,
65, 55, 4210752);
if (this.tileEntity.getStackInSlot(0) != null) {
final ItemStack fuseStack = this.tileEntity.getStackInSlot(0);
final IItemFuse fuse = (IItemFuse) fuseStack.getItem();
this.fontRendererObj.drawString(
this.tileEntity.getStackInSlot(0).getUnlocalizedName(), 30, 18,
4210752);
this.fontRendererObj.drawString(
TranslationHelper.getLocal(fuse.getUnlocalizedName(fuseStack)), 30,
18, 4210752);
}
}
public static ResourceLocation getTexture() {
return new ResourceLocation("electricexpansion",
"textures/gui/GuiFuseBox.png");
}
}

View file

@ -0,0 +1,88 @@
package electricexpansion.client.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.containers.ContainerInsulationMachine;
import electricexpansion.common.tile.TileEntityInsulatingMachine;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.electricity.ElectricityDisplay;
@SideOnly(Side.CLIENT)
public class GuiInsulationMachine extends GuiContainer {
private TileEntityInsulatingMachine tileEntity;
private int containerWidth;
private int containerHeight;
public GuiInsulationMachine(final InventoryPlayer par1InventoryPlayer,
final TileEntityInsulatingMachine tileEntity) {
super((Container) new ContainerInsulationMachine(par1InventoryPlayer,
tileEntity));
this.tileEntity = tileEntity;
}
@Override
protected void drawGuiContainerForegroundLayer(final int par1,
final int par2) {
this.fontRendererObj.drawString("Insulation Refiner", 60, 6, 4210752);
String displayText = "";
if (this.tileEntity.isDisabled()) {
displayText = "Disabled!";
} else if (this.tileEntity.getProcessTimeLeft() > 0) {
displayText = "Working";
} else {
displayText = "Idle";
}
this.fontRendererObj.drawString("Status: " + displayText, 82, 45, 4210752);
this.fontRendererObj.drawString(
"Voltage: " + ElectricityDisplay.getDisplayShort(
this.tileEntity.getVoltage(),
ElectricityDisplay.ElectricUnit.VOLTAGE),
82, 56, 4210752);
final StringBuilder append = new StringBuilder().append("Require: ");
this.fontRendererObj.drawString(
append
.append(ElectricityDisplay.getDisplayShort(
500.0 * 20.0, ElectricityDisplay.ElectricUnit.WATT))
.toString(),
82, 68, 4210752);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("container.inventory"), 8,
this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(final float par1,
final int par2,
final int par3) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
this.mc.renderEngine.bindTexture(getTexture());
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0,
this.xSize, this.ySize);
if (this.tileEntity.getProcessTimeLeft() >= 0) {
final int scale = (int) (this.tileEntity.getProcessTimeLeft() /
(double) this.tileEntity.getProcessingTime() * 23.0);
this.drawTexturedModalRect(this.containerWidth + 77,
this.containerHeight + 27, 176, 0, 23 - scale,
13);
}
if (this.tileEntity.getJoules() >= 0.0) {
final int scale = (int) (this.tileEntity.getJoules() /
this.tileEntity.getMaxJoules() * 50.0);
this.drawTexturedModalRect(this.containerWidth + 35,
this.containerHeight + 20, 176, 13, 4,
50 - scale);
}
}
public static ResourceLocation getTexture() {
return new ResourceLocation("electricexpansion",
"textures/gui/GuiEEMachine.png");
}
}

View file

@ -0,0 +1,110 @@
package electricexpansion.client.gui;
import electricexpansion.common.ElectricExpansion;
import electricexpansion.common.cables.TileEntityLogisticsWire;
import electricexpansion.common.helpers.PacketLogisticsWireButton;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
public class GuiLogisticsWire extends GuiScreen {
private TileEntityLogisticsWire tileEntity;
public final int xSizeOfTexture = 176;
public final int ySizeOfTexture = 88;
public GuiLogisticsWire(final TileEntityLogisticsWire LogisticsWire) {
this.tileEntity = LogisticsWire;
}
@Override
public void drawScreen(final int x, final int y, final float f) {
this.drawDefaultBackground();
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
this.mc.renderEngine.bindTexture(getTexture());
final int field_73880_f = this.width;
this.getClass();
final int posX = (field_73880_f - 176) / 2;
final int field_73881_g = this.height;
this.getClass();
final int posY = (field_73881_g - 88) / 2;
final int n = posX;
final int n2 = posY;
final int n3 = 0;
final int n4 = 0;
this.getClass();
final int n5 = 176;
this.getClass();
this.drawTexturedModalRect(n, n2, n3, n4, n5, 88);
final String s = "Logistics Wire";
final int n6 = posX;
this.getClass();
this.fontRendererObj.drawString(s, n6 + 176 / 2 - 35, posY + 4, 4210752);
super.drawScreen(x, y, f);
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
// TODO: WTF
// PacketDispatcher.sendPacketToServer(PacketManager.getPacket("ElecEx",
// this.tileEntity, 7, false));
}
@Override
public void actionPerformed(final GuiButton button) {
boolean status = false;
switch (button.id) {
case 0:
this.tileEntity.buttonStatus0 = !this.tileEntity.buttonStatus0;
status = this.tileEntity.buttonStatus0;
break;
case 1:
this.tileEntity.buttonStatus1 = !this.tileEntity.buttonStatus1;
status = this.tileEntity.buttonStatus1;
break;
case 2:
this.tileEntity.buttonStatus2 = !this.tileEntity.buttonStatus2;
status = this.tileEntity.buttonStatus2;
break;
}
ElectricExpansion.channel.sendToServer(new PacketLogisticsWireButton(
new Vector3(this.tileEntity), button.id, status));
}
@Override
public void updateScreen() {
super.updateScreen();
this.buttonList.clear();
final int field_73880_f = this.width;
this.getClass();
final int posX = (field_73880_f - 176) / 2;
final int field_73881_g = this.height;
this.getClass();
final int posY = (field_73881_g - 88) / 2;
this.buttonList.add(new GuiSwitchButton(0, posX + 13, posY + 15, 150, 16,
"Output to World",
this.tileEntity.buttonStatus0));
this.buttonList.add(new GuiSwitchButton(1, posX + 13, posY + 38, 150, 16,
"Output to RS Network",
this.tileEntity.buttonStatus1));
this.buttonList.add(new GuiSwitchButton(2, posX + 13, posY + 61, 150, 16,
"Unused",
this.tileEntity.buttonStatus2));
if (!this.mc.thePlayer.isEntityAlive() ||
((Entity) this.mc.thePlayer).isDead) {
this.mc.thePlayer.closeScreen();
}
}
public static ResourceLocation getTexture() {
return new ResourceLocation("electricexpansion",
"textures/gui/GuiLogistics.png");
}
}

View file

@ -0,0 +1,134 @@
package electricexpansion.client.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.ElectricExpansion;
import electricexpansion.common.containers.ContainerDistribution;
import electricexpansion.common.helpers.PacketUpdateQuantumBatteryBoxFrequency;
import electricexpansion.common.tile.TileEntityQuantumBatteryBox;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.electricity.ElectricityDisplay;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.TranslationHelper;
@SideOnly(Side.CLIENT)
public class GuiQuantumBatteryBox extends GuiContainer {
private TileEntityQuantumBatteryBox tileEntity;
private GuiTextField textFieldFrequency;
private int containerWidth;
private int containerHeight;
private byte frequency;
public GuiQuantumBatteryBox(final InventoryPlayer par1InventoryPlayer,
final TileEntityQuantumBatteryBox tileEntity) {
super(
(Container) new ContainerDistribution(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity;
}
@Override
public void initGui() {
super.initGui();
final int var1 = (this.width - this.xSize) / 2;
final int var2 = (this.height - this.ySize) / 2;
(this.textFieldFrequency = new GuiTextField(this.fontRendererObj, 6, 45, 49, 13))
.setMaxStringLength(3);
this.textFieldFrequency.setText(this.tileEntity.getFrequency() + "");
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, var1 + 6, var2 + 60, 50, 20, "Set"));
}
@Override
protected void drawGuiContainerForegroundLayer(final int par1,
final int par2) {
this.textFieldFrequency.drawTextBox();
final String displayJoules = ElectricityDisplay.getDisplayShort(
this.tileEntity.getJoulesForDisplay(new Object[0]),
ElectricityDisplay.ElectricUnit.JOULES);
this.fontRendererObj.drawString(
TranslationHelper.getLocal(this.tileEntity.getInventoryName()), 42, 6,
4210752);
this.fontRendererObj.drawString("Current Frequency: " +
this.tileEntity.getFrequency(),
10, 20, 4210752);
this.fontRendererObj.drawString("Current Storage: " + displayJoules, 10, 30,
4210752);
if (this.tileEntity.getOwningPlayer() != null) {
this.fontRendererObj.drawString(
"Player: " + this.tileEntity.getOwningPlayer(), 65, 66, 4210752);
} else {
this.fontRendererObj.drawString("I have no owner. BUG!", 62, 66, 4210752);
}
}
@Override
protected void drawGuiContainerBackgroundLayer(final float par1,
final int par2,
final int par3) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
this.mc.renderEngine.bindTexture(getTexture());
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0,
this.xSize, this.ySize);
if (this.tileEntity.getJoulesForDisplay(new Object[0]) > 0.0) {
final int scale = (int) (this.tileEntity.getJoulesForDisplay(new Object[0]) /
this.tileEntity.getMaxJoules() * 72.0);
this.drawTexturedModalRect(this.containerWidth + 70,
this.containerHeight + 51, 0, 166, scale, 5);
}
}
@Override
protected void mouseClicked(final int par1, final int par2, final int par3) {
super.mouseClicked(par1, par2, par3);
this.textFieldFrequency.mouseClicked(par1 - this.containerWidth,
par2 - this.containerHeight, par3);
}
@Override
protected void keyTyped(final char par1, final int par2) {
super.keyTyped(par1, par2);
if (par2 == 28) {
ElectricExpansion.channel.sendToServer(
new PacketUpdateQuantumBatteryBoxFrequency(
new Vector3(this.tileEntity), this.frequency));
}
this.textFieldFrequency.textboxKeyTyped(par1, par2);
try {
final byte newFrequency = (byte) Math.max(Byte.parseByte(this.textFieldFrequency.getText()), 0);
this.frequency = newFrequency;
} catch (final Exception ex) {
}
}
@Override
public void actionPerformed(final GuiButton button) {
switch (button.id) {
case 0:
ElectricExpansion.channel.sendToServer(
new PacketUpdateQuantumBatteryBoxFrequency(
new Vector3(this.tileEntity), this.frequency));
break;
}
}
@Override
public void updateScreen() {
if (!this.textFieldFrequency.isFocused()) {
this.textFieldFrequency.setText(this.tileEntity.getFrequency() + "");
}
}
public static ResourceLocation getTexture() {
return new ResourceLocation("electricexpansion",
"textures/gui/GuiLogistics.png");
}
}

View file

@ -0,0 +1,76 @@
package electricexpansion.client.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiSwitchButton extends GuiButton {
private boolean isActive;
public GuiSwitchButton(final int par1, final int par2, final int par3,
final String par4Str, final boolean initState) {
this(par1, par2, par3, 200, 16, par4Str, initState);
}
public GuiSwitchButton(final int par1, final int par2, final int par3,
final int par4, final int par5, final String par6Str,
final boolean initState) {
super(par1, par2, par3, par4, par5, par6Str);
this.width = 200;
this.height = 16;
this.enabled = true;
// TODO: WTF
// this.drawButton = true;
this.id = par1;
this.xPosition = par2;
this.yPosition = par3;
this.width = par4;
this.height = par5;
this.displayString = par6Str;
this.isActive = initState;
}
@Override
public void drawButton(final Minecraft par1Minecraft, final int xpos,
final int ypos) {
final FontRenderer fontrenderer = par1Minecraft.fontRenderer;
par1Minecraft.renderEngine.bindTexture(new ResourceLocation(
"electricexpansion", "textures/gui/SwitchButton.png"));
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
// TODO: WTF
// field_82253_i
this.field_146123_n = (xpos >= this.xPosition && ypos >= this.yPosition &&
xpos < this.xPosition + this.width &&
ypos < this.yPosition + this.height);
int var5 = 0;
if (this.isActive) {
var5 = 16;
}
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, var5,
this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition,
200 - this.width / 2, var5, this.width / 2,
this.height);
this.mouseDragged(par1Minecraft, xpos, ypos);
this.drawCenteredString(fontrenderer, this.displayString,
this.xPosition + this.width / 2,
this.yPosition + (this.height - 8) / 2,
this.isActive ? 25600 : 16711680);
}
@Override
public boolean mousePressed(final Minecraft par1Minecraft, final int par2,
final int par3) {
if (this.getHoverState(this.field_146123_n) == 2) {
this.isActive = !this.isActive;
}
return this.enabled /* && this.drawButton */ && par2 >= this.xPosition &&
par3 >= this.yPosition && par2 < this.xPosition + this.width &&
par3 < this.yPosition + this.height;
}
}

View file

@ -0,0 +1,89 @@
package electricexpansion.client.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.containers.ContainerWireMill;
import electricexpansion.common.tile.TileEntityWireMill;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.electricity.ElectricityDisplay;
@SideOnly(Side.CLIENT)
public class GuiWireMill extends GuiContainer {
private TileEntityWireMill tileEntity;
private int containerWidth;
private int containerHeight;
public GuiWireMill(final InventoryPlayer par1InventoryPlayer,
final TileEntityWireMill tileEntity) {
super((Container) new ContainerWireMill(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity;
}
@Override
protected void drawGuiContainerForegroundLayer(final int par1,
final int par2) {
this.fontRendererObj.drawString("Wire Mill", 60, 6, 4210752);
String displayText = "";
if (this.tileEntity.isDisabled()) {
displayText = "Disabled!";
} else if (this.tileEntity.getDrawingTimeLeft() > 0) {
displayText = "Working";
} else {
displayText = "Idle";
}
this.fontRendererObj.drawString("Status: " + displayText, 82, 45, 4210752);
this.fontRendererObj.drawString(
"Voltage: " + ElectricityDisplay.getDisplayShort(
this.tileEntity.getVoltage(),
ElectricityDisplay.ElectricUnit.VOLTAGE),
82, 56, 4210752);
final FontRenderer fontRendererObj = this.fontRendererObj;
final StringBuilder append = new StringBuilder().append("Require: ");
fontRendererObj.drawString(
append
.append(ElectricityDisplay.getDisplayShort(
500.0 * 20.0, ElectricityDisplay.ElectricUnit.WATT))
.toString(),
82, 68, 4210752);
this.fontRendererObj.drawString(
StatCollector.translateToLocal("container.inventory"), 8,
this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(final float par1,
final int par2,
final int par3) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
this.mc.renderEngine.bindTexture(getTexture());
this.containerWidth = (this.width - this.xSize) / 2;
this.containerHeight = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(this.containerWidth, this.containerHeight, 0, 0,
this.xSize, this.ySize);
if (this.tileEntity.getDrawingTimeLeft() > 0) {
final int scale = (int) (this.tileEntity.getDrawingTimeLeft() /
(double) this.tileEntity.getDrawingTime() * 23.0);
this.drawTexturedModalRect(this.containerWidth + 77,
this.containerHeight + 27, 176, 0, 23 - scale,
13);
}
if (this.tileEntity.getJoules() >= 0.0) {
final int scale = (int) (this.tileEntity.getJoules() /
this.tileEntity.getMaxJoules() * 50.0);
this.drawTexturedModalRect(this.containerWidth + 35,
this.containerHeight + 20, 176, 13, 4,
50 - scale);
}
}
public static ResourceLocation getTexture() {
return new ResourceLocation("electricexpansion",
"textures/gui/GuiEEMachine.png");
}
}

View file

@ -0,0 +1,106 @@
package electricexpansion.client.model;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
@SideOnly(Side.CLIENT)
public class ModelInsulatedWire extends ModelBase {
ModelRenderer Middle;
ModelRenderer Right;
ModelRenderer Left;
ModelRenderer Back;
ModelRenderer Front;
ModelRenderer Top;
ModelRenderer Bottom;
public ModelInsulatedWire() {
super.textureWidth = 64;
super.textureHeight = 32;
(this.Middle = new ModelRenderer((ModelBase) this, 0, 0))
.addBox(0.0f, 0.0f, 0.0f, 4, 4, 4);
this.Middle.setRotationPoint(-2.0f, 14.0f, -2.0f);
this.Middle.setTextureSize(super.textureWidth, super.textureHeight);
this.Middle.mirror = true;
this.setRotation(this.Middle, 0.0f, 0.0f, 0.0f);
(this.Right = new ModelRenderer((ModelBase) this, 22, 0))
.addBox(0.0f, 0.0f, 0.0f, 6, 4, 4);
this.Right.setRotationPoint(2.0f, 14.0f, -2.0f);
this.Right.setTextureSize(super.textureWidth, super.textureHeight);
this.Right.mirror = true;
this.setRotation(this.Right, 0.0f, 0.0f, 0.0f);
(this.Left = new ModelRenderer((ModelBase) this, 44, 0))
.addBox(0.0f, 0.0f, 0.0f, 6, 4, 4);
this.Left.setRotationPoint(-8.0f, 14.0f, -2.0f);
this.Left.setTextureSize(super.textureWidth, super.textureHeight);
this.Left.mirror = true;
this.setRotation(this.Left, 0.0f, 0.0f, 0.0f);
(this.Back = new ModelRenderer((ModelBase) this, 0, 10))
.addBox(0.0f, 0.0f, 0.0f, 4, 4, 6);
this.Back.setRotationPoint(-2.0f, 14.0f, 2.0f);
this.Back.setTextureSize(super.textureWidth, super.textureHeight);
this.Back.mirror = true;
this.setRotation(this.Back, 0.0f, 0.0f, 0.0f);
(this.Front = new ModelRenderer((ModelBase) this, 0, 22))
.addBox(0.0f, 0.0f, 0.0f, 4, 4, 6);
this.Front.setRotationPoint(-2.0f, 14.0f, -8.0f);
this.Front.setTextureSize(super.textureWidth, super.textureHeight);
this.Front.mirror = true;
this.setRotation(this.Front, 0.0f, 0.0f, 0.0f);
(this.Top = new ModelRenderer((ModelBase) this, 22, 22))
.addBox(0.0f, 0.0f, 0.0f, 4, 6, 4);
this.Top.setRotationPoint(-2.0f, 8.0f, -2.0f);
this.Top.setTextureSize(super.textureWidth, super.textureHeight);
this.Top.mirror = true;
this.setRotation(this.Top, 0.0f, 0.0f, 0.0f);
(this.Bottom = new ModelRenderer((ModelBase) this, 22, 10))
.addBox(0.0f, 0.0f, 0.0f, 4, 6, 4);
this.Bottom.setRotationPoint(-2.0f, 18.0f, -2.0f);
this.Bottom.setTextureSize(super.textureWidth, super.textureHeight);
this.Bottom.mirror = true;
this.setRotation(this.Bottom, 0.0f, 0.0f, 0.0f);
}
public void renderMiddle() {
this.Middle.render(0.0625f);
}
public void renderBottom() {
this.Bottom.render(0.0625f);
}
public void renderTop() {
this.Top.render(0.0625f);
}
public void renderLeft() {
this.Left.render(0.0625f);
}
public void renderRight() {
this.Right.render(0.0625f);
}
public void renderBack() {
this.Back.render(0.0625f);
}
public void renderFront() {
this.Front.render(0.0625f);
}
private void setRotation(final ModelRenderer model, final float x,
final float y, final float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(final float f, final float f1, final float f2,
final float f3, final float f4, final float f5,
final Entity entity) {
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
}

View file

@ -0,0 +1,99 @@
package electricexpansion.client.model;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
@SideOnly(Side.CLIENT)
public class ModelRawWire extends ModelBase {
ModelRenderer Middle;
ModelRenderer Right;
ModelRenderer Back;
ModelRenderer Left;
ModelRenderer Front;
ModelRenderer Bottom;
ModelRenderer Top;
public ModelRawWire() {
super.textureWidth = 64;
super.textureHeight = 32;
(this.Middle = new ModelRenderer((ModelBase) this, 0, 0))
.addBox(0.0f, 0.0f, 0.0f, 2, 2, 2);
this.Middle.setRotationPoint(-1.0f, 15.0f, -1.0f);
this.Middle.setTextureSize(64, 32);
this.Middle.mirror = true;
this.setRotation(this.Middle, 0.0f, 0.0f, 0.0f);
(this.Right = new ModelRenderer((ModelBase) this, 22, 0))
.addBox(0.0f, 0.0f, 0.0f, 7, 2, 2);
this.Right.setRotationPoint(1.0f, 15.0f, -1.0f);
this.Right.setTextureSize(64, 32);
this.Right.mirror = true;
this.setRotation(this.Right, 0.0f, 0.0f, 0.0f);
(this.Back = new ModelRenderer((ModelBase) this, 0, 10))
.addBox(0.0f, 0.0f, 0.0f, 2, 2, 7);
this.Back.setRotationPoint(-1.0f, 15.0f, 1.0f);
this.Back.setTextureSize(64, 32);
this.Back.mirror = true;
this.setRotation(this.Back, 0.0f, 0.0f, 0.0f);
(this.Left = new ModelRenderer((ModelBase) this, 44, 0))
.addBox(0.0f, 0.0f, 0.0f, 7, 2, 2);
this.Left.setRotationPoint(-8.0f, 15.0f, -1.0f);
this.Left.setTextureSize(64, 32);
this.Left.mirror = true;
this.setRotation(this.Left, 0.0f, 0.0f, 0.0f);
(this.Front = new ModelRenderer((ModelBase) this, 0, 22))
.addBox(0.0f, 0.0f, 0.0f, 2, 2, 7);
this.Front.setRotationPoint(-1.0f, 15.0f, -8.0f);
this.Front.setTextureSize(64, 32);
this.Front.mirror = true;
this.setRotation(this.Front, 0.0f, 0.0f, 0.0f);
(this.Bottom = new ModelRenderer((ModelBase) this, 22, 10))
.addBox(0.0f, 0.0f, 0.0f, 2, 7, 2);
this.Bottom.setRotationPoint(-1.0f, 17.0f, -1.0f);
this.Bottom.setTextureSize(64, 32);
this.Bottom.mirror = true;
this.setRotation(this.Bottom, 0.0f, 0.0f, 0.0f);
(this.Top = new ModelRenderer((ModelBase) this, 22, 22))
.addBox(0.0f, 0.0f, 0.0f, 2, 7, 2);
this.Top.setRotationPoint(-1.0f, 8.0f, -1.0f);
this.Top.setTextureSize(64, 32);
this.Top.mirror = true;
this.setRotation(this.Top, 0.0f, 0.0f, 0.0f);
}
public void renderMiddle() {
this.Middle.render(0.0625f);
}
public void renderBottom() {
this.Bottom.render(0.0625f);
}
public void renderTop() {
this.Top.render(0.0625f);
}
public void renderLeft() {
this.Left.render(0.0625f);
}
public void renderRight() {
this.Right.render(0.0625f);
}
public void renderBack() {
this.Back.render(0.0625f);
}
public void renderFront() {
this.Front.render(0.0625f);
}
private void setRotation(final ModelRenderer model, final float x,
final float y, final float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -0,0 +1,148 @@
package electricexpansion.client.model;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
@SideOnly(Side.CLIENT)
public class ModelTransformer extends ModelBase {
ModelRenderer a;
ModelRenderer b;
ModelRenderer c;
ModelRenderer d;
ModelRenderer out2;
ModelRenderer out1;
ModelRenderer out3;
ModelRenderer out4;
ModelRenderer i;
ModelRenderer j;
ModelRenderer in1;
ModelRenderer in2;
ModelRenderer in3;
ModelRenderer in4;
public ModelTransformer() {
super.textureWidth = 70;
super.textureHeight = 45;
(this.a = new ModelRenderer((ModelBase) this, 0, 0))
.addBox(-8.0f, 0.0f, -8.0f, 16, 2, 16);
this.a.setRotationPoint(0.0f, 22.0f, 0.0f);
this.a.setTextureSize(70, 45);
this.a.mirror = true;
this.setRotation(this.a, 0.0f, 0.0f, 0.0f);
(this.b = new ModelRenderer((ModelBase) this, 0, 19))
.addBox(0.0f, 0.0f, -2.0f, 3, 11, 4);
this.b.setRotationPoint(5.0f, 11.0f, 0.0f);
this.b.setTextureSize(70, 45);
this.b.mirror = true;
this.setRotation(this.b, 0.0f, 0.0f, 0.0f);
(this.c = new ModelRenderer((ModelBase) this, 0, 19))
.addBox(0.0f, 0.0f, -2.0f, 3, 11, 4);
this.c.setRotationPoint(-8.0f, 11.0f, 0.0f);
this.c.setTextureSize(70, 45);
this.c.mirror = true;
this.setRotation(this.c, 0.0f, 0.0f, 0.0f);
(this.d = new ModelRenderer((ModelBase) this, 15, 19))
.addBox(0.0f, 0.0f, -2.0f, 16, 1, 4);
this.d.setRotationPoint(-8.0f, 10.0f, 0.0f);
this.d.setTextureSize(70, 45);
this.d.mirror = true;
this.setRotation(this.d, 0.0f, 0.0f, 0.0f);
(this.out2 = new ModelRenderer((ModelBase) this, 0, 35))
.addBox(0.0f, 0.0f, -3.0f, 5, 0, 6);
this.out2.setRotationPoint(-9.0f, 16.0f, 0.0f);
this.out2.setTextureSize(70, 45);
this.out2.mirror = true;
this.setRotation(this.out2, 0.0f, 0.0f, 0.0f);
(this.out1 = new ModelRenderer((ModelBase) this, 0, 35))
.addBox(0.0f, 0.0f, -3.0f, 5, 0, 6);
this.out1.setRotationPoint(-9.0f, 15.0f, 0.0f);
this.out1.setTextureSize(70, 45);
this.out1.mirror = true;
this.setRotation(this.out1, 0.0f, 0.0f, 0.0f);
(this.out3 = new ModelRenderer((ModelBase) this, 0, 35))
.addBox(0.0f, 0.0f, -3.0f, 5, 0, 6);
this.out3.setRotationPoint(-9.0f, 17.0f, 0.0f);
this.out3.setTextureSize(70, 45);
this.out3.mirror = true;
this.setRotation(this.out3, 0.0f, 0.0f, 0.0f);
(this.out4 = new ModelRenderer((ModelBase) this, 0, 35))
.addBox(0.0f, 0.0f, -3.0f, 5, 0, 6);
this.out4.setRotationPoint(-9.0f, 18.0f, 0.0f);
this.out4.setTextureSize(70, 45);
this.out4.mirror = true;
this.setRotation(this.out4, 0.0f, 0.0f, 0.0f);
(this.i = new ModelRenderer((ModelBase) this, 34, 35))
.addBox(0.0f, 0.0f, -1.0f, 2, 5, 2);
this.i.setRotationPoint(-10.0f, 14.0f, 0.0f);
this.i.setTextureSize(70, 45);
this.i.mirror = true;
this.setRotation(this.i, 0.0f, 0.0f, 0.0f);
(this.j = new ModelRenderer((ModelBase) this, 24, 35))
.addBox(0.0f, 0.0f, -1.0f, 2, 5, 2);
this.j.setRotationPoint(8.0f, 14.0f, 0.0f);
this.j.setTextureSize(70, 45);
this.j.mirror = true;
this.setRotation(this.j, 0.0f, 0.0f, 0.0f);
(this.in1 = new ModelRenderer((ModelBase) this, 0, 35))
.addBox(0.0f, 0.0f, -3.0f, 5, 0, 6);
this.in1.setRotationPoint(4.0f, 15.0f, 0.0f);
this.in1.setTextureSize(70, 45);
this.in1.mirror = true;
this.setRotation(this.in1, 0.0f, 0.0f, 0.0f);
(this.in2 = new ModelRenderer((ModelBase) this, 0, 35))
.addBox(0.0f, 0.0f, -3.0f, 5, 0, 6);
this.in2.setRotationPoint(4.0f, 16.0f, 0.0f);
this.in2.setTextureSize(70, 45);
this.in2.mirror = true;
this.setRotation(this.in2, 0.0f, 0.0f, 0.0f);
(this.in3 = new ModelRenderer((ModelBase) this, 0, 35))
.addBox(0.0f, 0.0f, -3.0f, 5, 0, 6);
this.in3.setRotationPoint(4.0f, 17.0f, 0.0f);
this.in3.setTextureSize(70, 45);
this.in3.mirror = true;
this.setRotation(this.in3, 0.0f, 0.0f, 0.0f);
(this.in4 = new ModelRenderer((ModelBase) this, 0, 35))
.addBox(0.0f, 0.0f, -3.0f, 5, 0, 6);
this.in4.setRotationPoint(4.0f, 18.0f, 0.0f);
this.in4.setTextureSize(70, 45);
this.in4.mirror = true;
this.setRotation(this.in4, 0.0f, 0.0f, 0.0f);
}
public void render(final Entity entity, final float f, final float f1,
final float f2, final float f3, final float f4,
final float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
this.a.render(f5);
this.b.render(f5);
this.c.render(f5);
this.d.render(f5);
this.out2.render(f5);
this.out1.render(f5);
this.out3.render(f5);
this.out4.render(f5);
this.i.render(f5);
this.j.render(f5);
this.in1.render(f5);
this.in2.render(f5);
this.in3.render(f5);
this.in4.render(f5);
}
private void setRotation(final ModelRenderer model, final float x,
final float y, final float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(final float f, final float f1, final float f2,
final float f3, final float f4, final float f5,
final Entity entity) {
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
}

View file

@ -0,0 +1,148 @@
package electricexpansion.client.model;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
@SideOnly(Side.CLIENT)
public class ModelWireMill extends ModelBase {
ModelRenderer base;
ModelRenderer plug;
ModelRenderer part1;
ModelRenderer part2;
ModelRenderer part3;
ModelRenderer part4;
ModelRenderer support;
ModelRenderer support2;
ModelRenderer container;
ModelRenderer support3;
ModelRenderer support4;
ModelRenderer gear1rot;
ModelRenderer gear2rot;
ModelRenderer output;
public ModelWireMill() {
super.textureWidth = 128;
super.textureHeight = 128;
(this.base = new ModelRenderer((ModelBase) this, 0, 0))
.addBox(0.0f, 0.0f, 0.0f, 16, 1, 16);
this.base.setRotationPoint(-8.0f, 23.0f, -8.0f);
this.base.setTextureSize(128, 128);
this.base.mirror = true;
this.setRotation(this.base, 0.0f, 0.0f, 0.0f);
(this.plug = new ModelRenderer((ModelBase) this, 0, 19))
.addBox(0.0f, 0.0f, 0.0f, 5, 12, 12);
this.plug.setRotationPoint(-7.0f, 11.0f, -4.0f);
this.plug.setTextureSize(128, 128);
this.plug.mirror = true;
this.setRotation(this.plug, 0.0f, 0.0f, 0.0f);
(this.part1 = new ModelRenderer((ModelBase) this, 0, 20))
.addBox(0.0f, -1.0f, 0.0f, 1, 2, 1);
this.part1.setRotationPoint(-8.0f, 14.0f, 0.0f);
this.part1.setTextureSize(128, 128);
this.part1.mirror = true;
this.setRotation(this.part1, 0.0f, 0.0f, 0.0f);
(this.part2 = new ModelRenderer((ModelBase) this, 0, 20))
.addBox(0.0f, -1.0f, -3.0f, 1, 2, 1);
this.part2.setRotationPoint(-8.0f, 14.0f, 0.0f);
this.part2.setTextureSize(128, 128);
this.part2.mirror = true;
this.setRotation(this.part2, 0.0f, 0.0f, 0.0f);
(this.part3 = new ModelRenderer((ModelBase) this, 0, 20))
.addBox(0.0f, -2.0f, -1.0f, 1, 1, 2);
this.part3.setRotationPoint(-8.0f, 14.0f, -1.0f);
this.part3.setTextureSize(128, 128);
this.part3.mirror = true;
this.setRotation(this.part3, 0.0f, 0.0f, 0.0f);
(this.part4 = new ModelRenderer((ModelBase) this, 0, 20))
.addBox(0.0f, 1.0f, -1.0f, 1, 1, 2);
this.part4.setRotationPoint(-8.0f, 14.0f, -1.0f);
this.part4.setTextureSize(128, 128);
this.part4.mirror = true;
this.setRotation(this.part4, 0.0f, 0.0f, 0.0f);
(this.support = new ModelRenderer((ModelBase) this, 0, 46))
.addBox(0.0f, 0.0f, 0.0f, 5, 5, 4);
this.support.setRotationPoint(-7.0f, 18.0f, -8.0f);
this.support.setTextureSize(128, 128);
this.support.mirror = true;
this.setRotation(this.support, 0.0f, 0.0f, 0.0f);
(this.support2 = new ModelRenderer((ModelBase) this, 19, 46))
.addBox(0.0f, 0.0f, 0.0f, 5, 8, 4);
this.support2.setRotationPoint(-7.0f, 11.0f, -4.0f);
this.support2.setTextureSize(128, 128);
this.support2.mirror = true;
this.setRotation(this.support2, -0.5235988f, 0.0f, 0.0f);
(this.container = new ModelRenderer((ModelBase) this, 48, 36))
.addBox(0.0f, 0.0f, 0.0f, 10, 15, 5);
this.container.setRotationPoint(-2.0f, 8.0f, 3.0f);
this.container.setTextureSize(128, 128);
this.container.mirror = true;
this.setRotation(this.container, 0.0f, 0.0f, 0.0f);
(this.support3 = new ModelRenderer((ModelBase) this, 80, 20))
.addBox(0.0f, 0.0f, 0.0f, 2, 12, 4);
this.support3.setRotationPoint(6.0f, 11.0f, -1.0f);
this.support3.setTextureSize(128, 128);
this.support3.mirror = true;
this.setRotation(this.support3, 0.0f, 0.0f, 0.0f);
(this.support4 = new ModelRenderer((ModelBase) this, 80, 20))
.addBox(0.0f, 0.0f, 0.0f, 2, 12, 4);
this.support4.setRotationPoint(-2.0f, 11.0f, -1.0f);
this.support4.setTextureSize(128, 128);
this.support4.mirror = true;
this.setRotation(this.support4, 0.0f, 0.0f, 0.0f);
(this.gear1rot = new ModelRenderer((ModelBase) this, 67, 13))
.addBox(0.0f, -1.0f, -1.0f, 6, 2, 2);
this.gear1rot.setRotationPoint(0.0f, 14.0f, 1.0f);
this.gear1rot.setTextureSize(128, 128);
this.gear1rot.mirror = true;
this.setRotation(this.gear1rot, 0.7853982f, 0.0f, 0.0f);
(this.gear2rot = new ModelRenderer((ModelBase) this, 67, 13))
.addBox(0.0f, -1.0f, -1.0f, 6, 2, 2);
this.gear2rot.setRotationPoint(0.0f, 17.0f, 1.0f);
this.gear2rot.setTextureSize(128, 128);
this.gear2rot.mirror = true;
this.setRotation(this.gear2rot, 0.7853982f, 0.0f, 0.0f);
(this.output = new ModelRenderer((ModelBase) this, 36, 20))
.addBox(0.0f, 0.0f, 0.0f, 10, 4, 11);
this.output.setRotationPoint(-2.0f, 19.0f, -8.0f);
this.output.setTextureSize(128, 128);
this.output.mirror = true;
this.setRotation(this.output, 0.0f, 0.0f, 0.0f);
}
public void render(final Entity entity, final float f, final float f1,
final float f2, final float f3, final float f4,
final float f5) {
super.render(entity, f, f1, f2, f3, f4, f5);
this.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
this.base.render(f5);
this.plug.render(f5);
this.part1.render(f5);
this.part2.render(f5);
this.part3.render(f5);
this.part4.render(f5);
this.support.render(f5);
this.support2.render(f5);
this.container.render(f5);
this.support3.render(f5);
this.support4.render(f5);
this.gear1rot.render(f5);
this.gear2rot.render(f5);
this.output.render(f5);
}
private void setRotation(final ModelRenderer model, final float x,
final float y, final float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(final float f, final float f1, final float f2,
final float f3, final float f4, final float f5,
final Entity entity) {
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
}

View file

@ -0,0 +1,60 @@
package electricexpansion.client.render;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderManager;
import org.lwjgl.opengl.GL11;
public class RenderFloatingText {
public static void renderFloatingText(final String text, final float x,
final float y, final float z) {
renderFloatingText(text, x, y, z, 16777215);
}
public static void renderFloatingText(final String text, final float x,
final float y, final float z,
final int color) {
final RenderManager renderManager = RenderManager.instance;
final FontRenderer fontRenderer = renderManager.getFontRenderer();
final float scale = 0.027f;
GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
GL11.glPushMatrix();
GL11.glTranslatef(x + 0.0f, y + 2.3f, z);
GL11.glNormal3f(0.0f, 1.0f, 0.0f);
GL11.glRotatef(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f);
GL11.glRotatef(renderManager.playerViewX, 1.0f, 0.0f, 0.0f);
GL11.glScalef(-scale, -scale, scale);
GL11.glDisable(2896);
GL11.glDepthMask(false);
GL11.glDisable(2929);
GL11.glEnable(3042);
GL11.glBlendFunc(770, 771);
final Tessellator tessellator = Tessellator.instance;
final int yOffset = 0;
GL11.glDisable(3553);
tessellator.startDrawingQuads();
final int stringMiddle = fontRenderer.getStringWidth(text) / 2;
tessellator.setColorRGBA_F(0.0f, 0.0f, 0.0f, 0.5f);
tessellator.addVertex((double) (-stringMiddle - 1), (double) (-1 + yOffset),
0.0);
tessellator.addVertex((double) (-stringMiddle - 1), (double) (8 + yOffset),
0.0);
tessellator.addVertex((double) (stringMiddle + 1), (double) (8 + yOffset),
0.0);
tessellator.addVertex((double) (stringMiddle + 1), (double) (-1 + yOffset),
0.0);
tessellator.draw();
GL11.glEnable(3553);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2,
yOffset, color);
GL11.glEnable(2929);
GL11.glDepthMask(true);
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2,
yOffset, color);
GL11.glEnable(2896);
GL11.glDisable(3042);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glPopMatrix();
}
}

View file

@ -0,0 +1,88 @@
package electricexpansion.client.render;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.api.ElectricExpansionItems;
import electricexpansion.client.ClientProxy;
import electricexpansion.client.model.ModelTransformer;
import electricexpansion.client.model.ModelWireMill;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderHandler implements ISimpleBlockRenderingHandler {
public ModelWireMill wireMill;
public ModelTransformer transformer;
public RenderHandler() {
this.wireMill = new ModelWireMill();
this.transformer = new ModelTransformer();
}
@Override
public void renderInventoryBlock(final Block block, final int metadata,
final int modelID,
final RenderBlocks renderer) {
GL11.glPushMatrix();
if (block == ElectricExpansionItems.blockWireMill) {
FMLClientHandler.instance().getClient().renderEngine.bindTexture(
new ResourceLocation("electricexpansion",
"textures/models/wiremill.png"));
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
GL11.glTranslatef(0.5f, 0.8f, 0.5f);
GL11.glScalef(1.0f, -1.0f, -1.0f);
this.wireMill.render(null, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0625f);
GL11.glPopMatrix();
}
if (block == ElectricExpansionItems.blockTransformer) {
switch (metadata / 4) {
case 0: {
FMLClientHandler.instance().getClient().renderEngine.bindTexture(
new ResourceLocation("electricexpansion",
"textures/models/transformer1.png"));
break;
}
case 1: {
FMLClientHandler.instance().getClient().renderEngine.bindTexture(
new ResourceLocation("electricexpansion",
"textures/models/transformer2.png"));
break;
}
case 2: {
FMLClientHandler.instance().getClient().renderEngine.bindTexture(
new ResourceLocation("electricexpansion",
"textures/models/transformer3.png"));
break;
}
}
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
GL11.glTranslatef(0.5f, 0.8f, 0.5f);
GL11.glScalef(1.0f, -1.0f, -1.0f);
this.transformer.render(null, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0625f);
GL11.glPopMatrix();
}
}
@Override
public boolean renderWorldBlock(final IBlockAccess world, final int x,
final int y, final int z, final Block block,
final int modelId,
final RenderBlocks renderer) {
return false;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public int getRenderId() {
return ClientProxy.RENDER_ID;
}
}

View file

@ -0,0 +1,309 @@
package electricexpansion.client.render;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.api.ElectricExpansionItems;
import electricexpansion.client.model.ModelInsulatedWire;
import electricexpansion.common.cables.TileEntityInsulatedWire;
import electricexpansion.common.cables.TileEntitySwitchWire;
import electricexpansion.common.helpers.TileEntityConductorBase;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderInsulatedWire extends TileEntitySpecialRenderer {
private static final ModelInsulatedWire model;
public void renderAModelAt(final TileEntity t, final double x, final double y,
final double z, final float f) {
String textureToUse = "textures/models/";
final Block block = t.getWorldObj().getBlock(t.xCoord, t.yCoord, t.zCoord);
final int metadata = t.getWorldObj().getBlockMetadata(t.xCoord, t.yCoord, t.zCoord);
if (metadata != -1) {
if (block == ElectricExpansionItems.blockInsulatedWire) {
switch (metadata) {
case 0: {
textureToUse += "InsulatedCopperWire.png";
break;
}
case 1: {
textureToUse += "InsulatedTinWire.png";
break;
}
case 2: {
textureToUse += "InsulatedSilverWire.png";
break;
}
case 3: {
textureToUse += "InsulatedHVWire.png";
break;
}
case 4: {
textureToUse += "InsulatedSCWire.png";
break;
}
}
} else if (block == ElectricExpansionItems.blockLogisticsWire) {
switch (metadata) {
case 0: {
textureToUse += "CopperLogisticsWire.png";
break;
}
case 1: {
textureToUse += "TinLogisticsWire.png";
break;
}
case 2: {
textureToUse += "SilverLogisticsWire.png";
break;
}
case 3: {
textureToUse += "HVLogisticsWire.png";
break;
}
case 4: {
textureToUse += "SCLogisticsWire.png";
break;
}
}
} else if (block == ElectricExpansionItems.blockSwitchWire) {
if (t.getWorldObj().isBlockIndirectlyGettingPowered(t.xCoord, t.yCoord,
t.zCoord)) {
switch (metadata) {
case 0: {
textureToUse += "CopperSwitchWireOn.png";
break;
}
case 1: {
textureToUse += "TinSwitchWireOn.png";
break;
}
case 2: {
textureToUse += "SilverSwitchWireOn.png";
break;
}
case 3: {
textureToUse += "HVSwitchWireOn.png";
break;
}
case 4: {
textureToUse += "SCSwitchWireOn.png";
break;
}
}
} else {
switch (metadata) {
case 0: {
textureToUse += "CopperSwitchWireOff.png";
break;
}
case 1: {
textureToUse += "TinSwitchWireOff.png";
break;
}
case 2: {
textureToUse += "SilverSwitchWireOff.png";
break;
}
case 3: {
textureToUse += "HVSwitchWireOff.png";
break;
}
case 4: {
textureToUse += "SCSwitchWireOff.png";
break;
}
}
}
} else if (block == ElectricExpansionItems.blockRedstonePaintedWire) {
switch (metadata) {
case 0: {
textureToUse += "CopperRSWire.png";
break;
}
case 1: {
textureToUse += "TinRSWire.png";
break;
}
case 2: {
textureToUse += "SilverRSWire.png";
break;
}
case 3: {
textureToUse += "HVRSWire.png";
break;
}
case 4: {
textureToUse += "SCRSWire.png";
break;
}
}
}
}
final TileEntityConductorBase tileEntity = (TileEntityConductorBase) t;
final boolean[] connectedSides = tileEntity.visuallyConnected;
if (textureToUse != null && textureToUse != "" &&
!textureToUse.equals("textures/models/")) {
this.bindTexture(new ResourceLocation("electricexpansion", textureToUse));
}
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5f, (float) y + 1.5f, (float) z + 0.5f);
GL11.glScalef(1.0f, -1.0f, -1.0f);
if (tileEntity instanceof TileEntitySwitchWire) {
if (tileEntity.getWorldObj().isBlockIndirectlyGettingPowered(
t.xCoord, t.yCoord, t.zCoord)) {
if (connectedSides[0]) {
RenderInsulatedWire.model.renderBottom();
}
if (connectedSides[1]) {
RenderInsulatedWire.model.renderTop();
}
if (connectedSides[2]) {
RenderInsulatedWire.model.renderBack();
}
if (connectedSides[3]) {
RenderInsulatedWire.model.renderFront();
}
if (connectedSides[4]) {
RenderInsulatedWire.model.renderLeft();
}
if (connectedSides[5]) {
RenderInsulatedWire.model.renderRight();
}
}
} else {
if (connectedSides[0]) {
RenderInsulatedWire.model.renderBottom();
}
if (connectedSides[1]) {
RenderInsulatedWire.model.renderTop();
}
if (connectedSides[2]) {
RenderInsulatedWire.model.renderBack();
}
if (connectedSides[3]) {
RenderInsulatedWire.model.renderFront();
}
if (connectedSides[4]) {
RenderInsulatedWire.model.renderLeft();
}
if (connectedSides[5]) {
RenderInsulatedWire.model.renderRight();
}
}
RenderInsulatedWire.model.renderMiddle();
GL11.glPopMatrix();
if (tileEntity instanceof TileEntityInsulatedWire) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5f, (float) y + 1.5f, (float) z + 0.5f);
GL11.glScalef(1.0f, -1.0f, -1.0f);
this.bindTexture(new ResourceLocation(
"electricexpansion", "textures/models/WirePaintOverlay.png"));
final byte colorByte = ((TileEntityInsulatedWire) tileEntity).colorByte;
switch (colorByte) {
case -1: {
GL11.glColor4f(0.2f, 0.2f, 0.2f, 1.0f);
break;
}
case 0: {
GL11.glColor4f(0.1f, 0.1f, 0.1f, 1.0f);
break;
}
case 1: {
GL11.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
break;
}
case 2: {
GL11.glColor4f(0.0f, 0.2f, 0.0f, 1.0f);
break;
}
case 3: {
GL11.glColor4f(0.2f, 0.0f, 0.0f, 1.0f);
break;
}
case 4: {
GL11.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
break;
}
case 5: {
GL11.glColor4f(0.6f, 0.0f, 0.4f, 1.0f);
break;
}
case 6: {
GL11.glColor4f(0.2f, 0.8f, 1.0f, 1.0f);
break;
}
case 7: {
GL11.glColor4f(0.6f, 0.6f, 0.6f, 1.0f);
break;
}
case 8: {
GL11.glColor4f(0.4f, 0.4f, 0.4f, 1.0f);
break;
}
case 9: {
GL11.glColor4f(1.0f, 0.2f, 0.6f, 1.0f);
break;
}
case 10: {
GL11.glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
break;
}
case 11: {
GL11.glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
break;
}
case 12: {
GL11.glColor4f(0.3f, 0.3f, 0.8f, 1.0f);
break;
}
case 13: {
GL11.glColor4f(0.8f, 0.2f, 0.4f, 1.0f);
break;
}
case 14: {
GL11.glColor4f(0.8f, 0.3f, 0.0f, 1.0f);
break;
}
case 15: {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
break;
}
}
if (connectedSides[0]) {
RenderInsulatedWire.model.renderBottom();
}
if (connectedSides[1]) {
RenderInsulatedWire.model.renderTop();
}
if (connectedSides[2]) {
RenderInsulatedWire.model.renderBack();
}
if (connectedSides[3]) {
RenderInsulatedWire.model.renderFront();
}
if (connectedSides[4]) {
RenderInsulatedWire.model.renderLeft();
}
if (connectedSides[5]) {
RenderInsulatedWire.model.renderRight();
}
RenderInsulatedWire.model.renderMiddle();
GL11.glPopMatrix();
}
}
@Override
public void renderTileEntityAt(final TileEntity tileEntity, final double var2,
final double var4, final double var6,
final float var8) {
this.renderAModelAt(tileEntity, var2, var4, var6, var8);
}
static {
model = new ModelInsulatedWire();
}
}

View file

@ -0,0 +1,120 @@
package electricexpansion.client.render;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.tile.TileEntityMultimeter;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.electricity.ElectricityDisplay;
import universalelectricity.core.vector.VectorHelper;
@SideOnly(Side.CLIENT)
public class RenderMultimeter extends TileEntitySpecialRenderer {
@Override
public void renderTileEntityAt(final TileEntity var1, final double x,
final double y, final double z,
final float var8) {
final TileEntityMultimeter te = (TileEntityMultimeter) var1;
final ForgeDirection direction = te.getDirection(
(IBlockAccess) te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);
for (int side = 0; side < 6; ++side) {
final ForgeDirection relativeSide = VectorHelper.getOrientationFromSide(
direction, ForgeDirection.getOrientation(side));
if (relativeSide == ForgeDirection.EAST ||
relativeSide == ForgeDirection.WEST ||
relativeSide == ForgeDirection.UP ||
relativeSide == ForgeDirection.DOWN ||
relativeSide == ForgeDirection.SOUTH) {
GL11.glPushMatrix();
GL11.glPolygonOffset(-10.0f, -10.0f);
GL11.glEnable(32823);
final float dx = 0.0625f;
final float dz = 0.0625f;
final float displayWidth = 0.875f;
final float displayHeight = 0.875f;
GL11.glTranslatef((float) x, (float) y, (float) z);
switch (side) {
case 0: {
GL11.glTranslatef(1.0f, 1.0f, 0.0f);
GL11.glRotatef(180.0f, 1.0f, 0.0f, 0.0f);
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
break;
}
case 3: {
GL11.glTranslatef(0.0f, 1.0f, 0.0f);
GL11.glRotatef(0.0f, 0.0f, 1.0f, 0.0f);
GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
break;
}
case 2: {
GL11.glTranslatef(1.0f, 1.0f, 1.0f);
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
break;
}
case 5: {
GL11.glTranslatef(0.0f, 1.0f, 1.0f);
GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
break;
}
case 4: {
GL11.glTranslatef(1.0f, 1.0f, 0.0f);
GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
break;
}
}
GL11.glTranslatef(dx + displayWidth / 2.0f, 1.0f,
dz + displayHeight / 2.0f);
GL11.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
final FontRenderer fontRenderer = this.func_147498_b();
int maxWidth = 1;
final String amperes = ElectricityDisplay.getDisplay(
te.electricityReading.amperes,
ElectricityDisplay.ElectricUnit.AMPERE);
final String voltage = ElectricityDisplay.getDisplay(
te.electricityReading.voltage,
ElectricityDisplay.ElectricUnit.VOLTAGE);
final String watt = ElectricityDisplay.getDisplay(te.electricityReading.getWatts(),
ElectricityDisplay.ElectricUnit.WATT);
maxWidth = Math.max(fontRenderer.getStringWidth(amperes), maxWidth);
maxWidth = Math.max(fontRenderer.getStringWidth(voltage), maxWidth);
maxWidth = Math.max(fontRenderer.getStringWidth(watt), maxWidth);
maxWidth += 4;
final int lineHeight = fontRenderer.FONT_HEIGHT + 2;
final int requiredHeight = lineHeight * 1;
final float scaleX = displayWidth / maxWidth;
final float scaleY = displayHeight / requiredHeight;
final float scale = (float) (Math.min(scaleX, scaleY) * 0.8);
GL11.glScalef(scale, -scale, scale);
GL11.glDepthMask(false);
final int realHeight = (int) Math.floor(displayHeight / scale);
final int realWidth = (int) Math.floor(displayWidth / scale);
final int offsetY = (realHeight - requiredHeight) / 2;
final int offsetX = (realWidth - maxWidth) / 2 + 2 + 5;
GL11.glDisable(2896);
fontRenderer.drawString(amperes, offsetX - realWidth / 2,
1 + offsetY - realHeight / 2 - 1 * lineHeight,
1);
fontRenderer.drawString(voltage, offsetX - realWidth / 2,
1 + offsetY - realHeight / 2 + 0 * lineHeight,
1);
fontRenderer.drawString(watt, offsetX - realWidth / 2,
1 + offsetY - realHeight / 2 + 1 * lineHeight,
1);
GL11.glEnable(2896);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glDepthMask(true);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glDisable(32823);
GL11.glPopMatrix();
}
}
}
}

View file

@ -0,0 +1,73 @@
package electricexpansion.client.render;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.client.model.ModelRawWire;
import electricexpansion.common.cables.TileEntityRawWire;
import electricexpansion.common.helpers.TileEntityConductorBase;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderRawWire extends TileEntitySpecialRenderer {
private ModelRawWire model;
public RenderRawWire() {
this.model = new ModelRawWire();
}
public void renderAModelAt(final TileEntityRawWire t, final double x,
final double y, final double z, final float f) {
String textureToUse = "textures/models/";
final int meta = t.getBlockMetadata();
if (meta != -1) {
if (meta == 0) {
textureToUse += "RawCopperWire.png";
} else if (meta == 1) {
textureToUse += "RawTinWire.png";
} else if (meta == 2) {
textureToUse += "RawSilverWire.png";
} else if (meta == 3) {
textureToUse += "RawHVWire.png";
} else if (meta == 4) {
textureToUse += "RawSCWire.png";
}
}
this.bindTexture(new ResourceLocation("electricexpansion", textureToUse));
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5f, (float) y + 1.5f, (float) z + 0.5f);
GL11.glScalef(1.0f, -1.0f, -1.0f);
final TileEntityConductorBase tileEntity = t;
final boolean[] connectedSides = tileEntity.visuallyConnected;
if (connectedSides[0]) {
this.model.renderBottom();
}
if (connectedSides[1]) {
this.model.renderTop();
}
if (connectedSides[2]) {
this.model.renderBack();
}
if (connectedSides[3]) {
this.model.renderFront();
}
if (connectedSides[4]) {
this.model.renderLeft();
}
if (connectedSides[5]) {
this.model.renderRight();
}
this.model.renderMiddle();
GL11.glPopMatrix();
}
@Override
public void renderTileEntityAt(final TileEntity tileEntity, final double var2,
final double var4, final double var6,
final float var8) {
this.renderAModelAt((TileEntityRawWire) tileEntity, var2, var4, var6, var8);
}
}

View file

@ -0,0 +1,91 @@
package electricexpansion.client.render;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.client.model.ModelTransformer;
import electricexpansion.common.tile.TileEntityTransformer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import universalelectricity.core.vector.Vector3;
@SideOnly(Side.CLIENT)
public class RenderTransformer extends TileEntitySpecialRenderer {
private ModelTransformer model;
private String textureToUse;
public RenderTransformer() {
this.model = new ModelTransformer();
}
@Override
public void renderTileEntityAt(final TileEntity tileEntity, final double x,
final double y, final double z,
final float var5) {
this.textureToUse = "textures/models/";
final String status = ((TileEntityTransformer) tileEntity).stepUp ? "Step Up" : "Step Down";
final EntityPlayer player = (EntityPlayer) Minecraft.getMinecraft().thePlayer;
final MovingObjectPosition movingPosition = player.rayTrace(5.0, 1.0f);
if (movingPosition != null &&
new Vector3(tileEntity).equals(new Vector3(movingPosition))) {
RenderFloatingText.renderFloatingText(status, (float) ((float) x + 0.5),
(float) y - 1.0f,
(float) ((float) z + 0.5));
}
final int metadata = tileEntity.getWorldObj().getBlockMetadata(
tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
switch (metadata) {
case 0:
case 1:
case 2:
case 3:
this.textureToUse += "transformer1.png";
break;
case 4:
case 5:
case 6:
case 7:
// case 8:
this.textureToUse += "transformer2.png";
break;
case 8:
case 9:
case 10:
case 11:
// case 12:
this.textureToUse += "transformer3.png";
break;
}
this.bindTexture(
new ResourceLocation("electricexpansion", this.textureToUse));
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5f, (float) y + 1.5f, (float) z + 0.5f);
switch (metadata % 4) {
case 0: {
GL11.glRotatef(270.0f, 0.0f, 1.0f, 0.0f);
break;
}
case 1: {
GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
break;
}
case 2: {
GL11.glRotatef(0.0f, 0.0f, 1.0f, 0.0f);
break;
}
case 3: {
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
break;
}
}
GL11.glScalef(1.0f, -1.0f, -1.0f);
this.model.render(null, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0625f);
GL11.glPopMatrix();
}
}

View file

@ -0,0 +1,51 @@
package electricexpansion.client.render;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.client.model.ModelWireMill;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderWireMill extends TileEntitySpecialRenderer {
private ModelWireMill model;
public RenderWireMill() {
this.model = new ModelWireMill();
}
@Override
public void renderTileEntityAt(final TileEntity var1, final double var2,
final double var3, final double var4,
final float var5) {
this.bindTexture(new ResourceLocation("electricexpansion", "textures/models/wiremill.png"));
GL11.glPushMatrix();
GL11.glTranslatef((float) var2 + 0.5f, (float) var3 + 1.5f,
(float) var4 + 0.5f);
switch (var1.getWorldObj().getBlockMetadata(var1.xCoord, var1.yCoord,
var1.zCoord)) {
case 0: {
GL11.glRotatef(0.0f, 0.0f, 1.0f, 0.0f);
break;
}
case 1: {
GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
break;
}
case 2: {
GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
break;
}
case 3: {
GL11.glRotatef(270.0f, 0.0f, 1.0f, 0.0f);
break;
}
}
GL11.glScalef(1.0f, -1.0f, -1.0f);
this.model.render(null, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0625f);
GL11.glPopMatrix();
}
}

View file

@ -0,0 +1,99 @@
package electricexpansion.common;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import electricexpansion.common.cables.TileEntityInsulatedWire;
import electricexpansion.common.cables.TileEntityLogisticsWire;
import electricexpansion.common.cables.TileEntityRawWire;
import electricexpansion.common.cables.TileEntityRedstonePaintedWire;
import electricexpansion.common.cables.TileEntitySwitchWire;
import electricexpansion.common.cables.TileEntitySwitchWireBlock;
import electricexpansion.common.cables.TileEntityWireBlock;
import electricexpansion.common.containers.ContainerAdvBatteryBox;
import electricexpansion.common.containers.ContainerDistribution;
import electricexpansion.common.containers.ContainerFuseBox;
import electricexpansion.common.containers.ContainerInsulationMachine;
import electricexpansion.common.containers.ContainerWireMill;
import electricexpansion.common.tile.TileEntityAdvancedBatteryBox;
import electricexpansion.common.tile.TileEntityFuseBox;
import electricexpansion.common.tile.TileEntityInsulatingMachine;
import electricexpansion.common.tile.TileEntityMultimeter;
import electricexpansion.common.tile.TileEntityQuantumBatteryBox;
import electricexpansion.common.tile.TileEntityRedstoneNetworkCore;
import electricexpansion.common.tile.TileEntityTransformer;
import electricexpansion.common.tile.TileEntityWireMill;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CommonProxy implements IGuiHandler {
public void init() {
GameRegistry.registerTileEntity(TileEntityRawWire.class,
"TileEntityRawWire");
GameRegistry.registerTileEntity(TileEntityInsulatedWire.class,
"TileEntityInsulatedWire");
GameRegistry.registerTileEntity(TileEntityWireBlock.class,
"TileEntityWireBlock");
GameRegistry.registerTileEntity(TileEntitySwitchWire.class,
"TileEntitySwitchWire");
GameRegistry.registerTileEntity(TileEntitySwitchWireBlock.class,
"TileEntitySwitchWireBlock");
GameRegistry.registerTileEntity(TileEntityLogisticsWire.class,
"TileEntityLogisticsWire");
GameRegistry.registerTileEntity(TileEntityWireMill.class,
"TileEntityWireMill");
GameRegistry.registerTileEntity(TileEntityRedstonePaintedWire.class,
"TileEntityRedstonePaintedWire");
GameRegistry.registerTileEntity(TileEntityAdvancedBatteryBox.class,
"TileEntityAdvBox");
GameRegistry.registerTileEntity(TileEntityMultimeter.class,
"TileEntityVoltDet");
GameRegistry.registerTileEntity(TileEntityTransformer.class,
"TileEntityTransformer");
GameRegistry.registerTileEntity(TileEntityQuantumBatteryBox.class,
"TileEntityDistribution");
GameRegistry.registerTileEntity(TileEntityInsulatingMachine.class,
"TileEntityInsulatingMachine");
GameRegistry.registerTileEntity(TileEntityRedstoneNetworkCore.class,
"TileEntityRedstoneNetworkCore");
GameRegistry.registerTileEntity(TileEntityFuseBox.class,
"TileEntityFuseBox");
}
public Object getClientGuiElement(final int ID, final EntityPlayer player,
final World world, final int x, final int y,
final int z) {
return null;
}
public Object getServerGuiElement(final int ID, final EntityPlayer player,
final World world, final int x, final int y,
final int z) {
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null) {
switch (ID) {
case 0: {
return new ContainerAdvBatteryBox(
player.inventory, (TileEntityAdvancedBatteryBox)tileEntity);
}
case 2: {
return new ContainerWireMill(player.inventory,
(TileEntityWireMill)tileEntity);
}
case 4: {
return new ContainerDistribution(
player.inventory, (TileEntityQuantumBatteryBox)tileEntity);
}
case 5: {
return new ContainerInsulationMachine(
player.inventory, (TileEntityInsulatingMachine)tileEntity);
}
case 6: {
return new ContainerFuseBox(player.inventory,
(TileEntityFuseBox)tileEntity);
}
}
}
return null;
}
}

View file

@ -0,0 +1,337 @@
package electricexpansion.common;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.ModMetadata;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import electricexpansion.api.ElectricExpansionItems;
import electricexpansion.common.blocks.BlockAdvancedBatteryBox;
import electricexpansion.common.blocks.BlockBasic;
import electricexpansion.common.blocks.BlockInsulatedWire;
import electricexpansion.common.blocks.BlockInsulationMachine;
import electricexpansion.common.blocks.BlockLogisticsWire;
import electricexpansion.common.blocks.BlockMultimeter;
import electricexpansion.common.blocks.BlockQuantumBatteryBox;
import electricexpansion.common.blocks.BlockRawWire;
import electricexpansion.common.blocks.BlockRedstoneNetworkCore;
import electricexpansion.common.blocks.BlockRedstonePaintedWire;
import electricexpansion.common.blocks.BlockSwitchWire;
import electricexpansion.common.blocks.BlockSwitchWireBlock;
import electricexpansion.common.blocks.BlockTransformer;
import electricexpansion.common.blocks.BlockWireBlock;
import electricexpansion.common.blocks.BlockWireMill;
import electricexpansion.common.helpers.PacketHandlerLogisticsWireButton;
import electricexpansion.common.helpers.PacketHandlerUpdateQuantumBatteryBoxFrequency;
import electricexpansion.common.helpers.PacketLogisticsWireButton;
import electricexpansion.common.helpers.PacketUpdateQuantumBatteryBoxFrequency;
import electricexpansion.common.itemblocks.ItemBlockInsulatedWire;
import electricexpansion.common.itemblocks.ItemBlockLogisticsWire;
import electricexpansion.common.itemblocks.ItemBlockRawWire;
import electricexpansion.common.itemblocks.ItemBlockRedstonePaintedWire;
import electricexpansion.common.itemblocks.ItemBlockSwitchWire;
import electricexpansion.common.itemblocks.ItemBlockSwitchWireBlock;
import electricexpansion.common.itemblocks.ItemBlockTransformer;
import electricexpansion.common.itemblocks.ItemBlockWireBlock;
import electricexpansion.common.items.ItemAdvancedBattery;
import electricexpansion.common.items.ItemEliteBattery;
import electricexpansion.common.items.ItemMultimeter;
import electricexpansion.common.items.ItemParts;
import electricexpansion.common.items.ItemUltimateBattery;
import electricexpansion.common.items.ItemUpgrade;
import electricexpansion.common.misc.DistributionNetworks;
import electricexpansion.common.misc.EETab;
import electricexpansion.common.misc.EventHandler;
import java.io.File;
import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.oredict.OreDictionary;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.ore.OreGenBase;
import universalelectricity.prefab.ore.OreGenReplaceStone;
import universalelectricity.prefab.ore.OreGenerator;
@Mod(
modid = "ElectricExpansion", name = "Electric Expansion", version = "2.1.0",
dependencies =
"after:basiccomponents;after:AtomicScience;after:ICBM|Contraption;after:MineFactoryReloaded;after:IC2",
useMetadata = true)
public class ElectricExpansion {
public static final String MAJOR_VERSION = "2";
public static final String MINOR_VERSION = "1";
public static final String REVIS_VERSION = "0";
public static final String BUILD_VERSION = "43";
public static final String MOD_ID = "ElectricExpansion";
public static final String MOD_NAME = "Electric Expansion";
public static final String VERSION = "2.1.0";
public static final boolean USE_METADATA = true;
public static final boolean USES_CLIENT = true;
public static final boolean USES_SERVER = false;
@Mod.Metadata("ElectricExpansion") public static ModMetadata meta;
public static final String TEXTURE_NAME_PREFIX = "electricexpansion:";
private static final String[] LANGUAGES_SUPPORTED;
public static OreGenBase silverOreGeneration;
public static final Configuration CONFIG;
public static boolean configLoaded;
static boolean debugRecipes;
public static boolean useHashCodes;
private static boolean useUeVoltageSensitivity;
public static DistributionNetworks DistributionNetworksInstance;
public static Logger eeLogger;
@Mod.Instance("ElectricExpansion") public static ElectricExpansion instance;
@SidedProxy(clientSide = "electricexpansion.client.ClientProxy",
serverSide = "electricexpansion.common.CommonProxy")
public static CommonProxy proxy;
public static SimpleNetworkWrapper channel;
public static void log(final Level level, String msg,
final String... replacements) {
for (final String replace : replacements) {
msg = msg.replace("%s", replace);
}
ElectricExpansion.eeLogger.log(level, msg);
}
public static boolean configLoad(final Configuration config) {
config.load();
ElectricExpansionItems.blockRawWire = (Block) new BlockRawWire();
ElectricExpansionItems.blockInsulatedWire =
(Block) new BlockInsulatedWire();
ElectricExpansionItems.blockWireBlock = (Block) new BlockWireBlock();
ElectricExpansionItems.blockSwitchWire = (Block) new BlockSwitchWire();
ElectricExpansionItems.blockSwitchWireBlock =
(Block) new BlockSwitchWireBlock();
ElectricExpansionItems.blockRedstonePaintedWire =
new BlockRedstonePaintedWire();
ElectricExpansionItems.blockAdvBatteryBox =
(Block) new BlockAdvancedBatteryBox();
ElectricExpansionItems.blockMultimeter = (Block) new BlockMultimeter();
ElectricExpansionItems.blockSilverOre =
new BlockBasic(Material.rock, EETab.INSTANCE, 2.0f, "SilverOre");
ElectricExpansionItems.blockInsulationMachine =
(Block) new BlockInsulationMachine();
ElectricExpansionItems.blockWireMill = (Block) new BlockWireMill();
ElectricExpansionItems.blockTransformer = (Block) new BlockTransformer();
ElectricExpansionItems.blockDistribution =
(Block) new BlockQuantumBatteryBox();
ElectricExpansionItems.blockLead =
new BlockBasic(Material.iron, EETab.INSTANCE, 2.0f, "LeadBlock");
ElectricExpansionItems.blockLogisticsWire =
(Block) new BlockLogisticsWire(0);
ElectricExpansionItems.blockRedstoneNetworkCore =
(Block) new BlockRedstoneNetworkCore();
ElectricExpansionItems.itemUpgrade = new ItemUpgrade(0);
ElectricExpansionItems.itemEliteBat = new ItemEliteBattery();
ElectricExpansionItems.itemUltimateBat = new ItemUltimateBattery();
ElectricExpansionItems.itemParts = new ItemParts();
ElectricExpansionItems.itemAdvBat = new ItemAdvancedBattery();
ElectricExpansionItems.itemMultimeter = new ItemMultimeter();
GameRegistry.registerItem(ElectricExpansionItems.itemUpgrade,
"itemUpgrade");
GameRegistry.registerItem(ElectricExpansionItems.itemEliteBat,
"itemEliteBat");
GameRegistry.registerItem(ElectricExpansionItems.itemUltimateBat,
"itemUltimateBat");
GameRegistry.registerItem(ElectricExpansionItems.itemParts, "itemParts");
GameRegistry.registerItem(ElectricExpansionItems.itemAdvBat, "itemAdvBat");
GameRegistry.registerItem(ElectricExpansionItems.itemMultimeter,
"itemMultimeter");
GameRegistry.registerBlock(ElectricExpansionItems.blockSilverOre,
ItemBlock.class, "blockSilverOre");
ElectricExpansion.silverOreGeneration =
new OreGenReplaceStone(
"Silver Ore", "oreSilver",
new ItemStack(ElectricExpansionItems.blockSilverOre), 36, 10, 3)
.enable(config);
ElectricExpansion.debugRecipes =
config
.get("General", "Debug_Recipes", false,
"Set to true for debug Recipes. This is considdered cheating.")
.getBoolean(false);
ElectricExpansion.useHashCodes =
config
.get(
"General", "Use_Hashcodes", true,
"Set to true to make clients use hash codes for the Quantum Battery Box Owner data.")
.getBoolean(true);
ElectricExpansion.useUeVoltageSensitivity =
config
.get(
"General", "Use_UeVoltageSensitivity", false,
"Set to true to use the setting in the UE config file for Voltage Sensitivity.")
.getBoolean(false);
if (config.hasChanged()) {
config.save();
}
return ElectricExpansion.configLoaded = true;
}
@Mod.EventHandler
public void preInit(final FMLPreInitializationEvent event) {
ElectricExpansion.meta.modId = "ElectricExpansion";
ElectricExpansion.meta.name = "Electric Expansion";
ElectricExpansion.meta.description =
"Electric Expansion is a Universal Electricity mod that focuses mainly on energy storage and transfer as well as adding more cables for better energy transfer. This mod will make Universal Electricity more complex and realistic. We try to make all aspects as realistic as possible, whether that means the items and block names or the processes and materials for each aspect of Electric Expansion.";
ElectricExpansion.meta.url =
"http://universalelectricity.com/electric%20expansion";
ElectricExpansion.meta.logoFile = "/EELogo.png";
ElectricExpansion.meta.version = "2.1.0.43";
ElectricExpansion.meta.authorList =
Arrays.asList("Mattredsox & Alex_hawks");
ElectricExpansion.meta.credits = "Please see the website.";
ElectricExpansion.meta.autogenerated = false;
if (!ElectricExpansion.configLoaded) {
configLoad(ElectricExpansion.CONFIG);
}
log(Level.INFO, "PreInitializing ElectricExpansion v.2.1.0", new String[0]);
GameRegistry.registerBlock(ElectricExpansionItems.blockAdvBatteryBox,
ItemBlock.class, "blockAdvBatteryBox");
GameRegistry.registerBlock(ElectricExpansionItems.blockWireMill,
ItemBlock.class, "blockWireMill");
GameRegistry.registerBlock(ElectricExpansionItems.blockInsulationMachine,
ItemBlock.class, "blockInsulationMachine");
GameRegistry.registerBlock(ElectricExpansionItems.blockMultimeter,
ItemBlock.class, "blockMultimeter");
GameRegistry.registerBlock(ElectricExpansionItems.blockLead,
ItemBlock.class, "blockLead");
GameRegistry.registerBlock(ElectricExpansionItems.blockTransformer,
ItemBlockTransformer.class, "blockTransformer");
GameRegistry.registerBlock(ElectricExpansionItems.blockDistribution,
ItemBlock.class, "blockDistribution");
GameRegistry.registerBlock(ElectricExpansionItems.blockRedstoneNetworkCore,
ItemBlock.class, "blockRsNetworkCore");
GameRegistry.registerBlock(ElectricExpansionItems.blockRawWire,
ItemBlockRawWire.class, "blockRawWire");
GameRegistry.registerBlock(ElectricExpansionItems.blockInsulatedWire,
ItemBlockInsulatedWire.class,
"blockInsulatedWire");
GameRegistry.registerBlock(ElectricExpansionItems.blockSwitchWire,
ItemBlockSwitchWire.class, "blockSwitchWire");
GameRegistry.registerBlock(ElectricExpansionItems.blockSwitchWireBlock,
ItemBlockSwitchWireBlock.class,
"blockSwitchWireBlock");
GameRegistry.registerBlock(ElectricExpansionItems.blockWireBlock,
ItemBlockWireBlock.class, "blockWireBlock");
GameRegistry.registerBlock(ElectricExpansionItems.blockLogisticsWire,
ItemBlockLogisticsWire.class,
"blockLogisticsWire");
GameRegistry.registerBlock(ElectricExpansionItems.blockRedstonePaintedWire,
ItemBlockRedstonePaintedWire.class,
"blockRedstonePaintedWire");
OreDictionary.registerOre("blockLead", ElectricExpansionItems.blockLead);
OreDictionary.registerOre("advancedBattery",
(Item)ElectricExpansionItems.itemAdvBat);
OreDictionary.registerOre("eliteBattery",
(Item)ElectricExpansionItems.itemEliteBat);
OreDictionary.registerOre("advancedBattery",
(Item)ElectricExpansionItems.itemAdvBat);
OreDictionary.registerOre("transformer",
ElectricExpansionItems.blockTransformer);
OreDictionary.registerOre("wireMill", ElectricExpansionItems.blockWireMill);
OreDictionary.registerOre("multimeter",
ElectricExpansionItems.blockMultimeter);
OreDictionary.registerOre("itemMultimeter",
ElectricExpansionItems.itemMultimeter);
OreDictionary.registerOre(
"ingotElectrum", new ItemStack(ElectricExpansionItems.itemParts, 1, 2));
OreDictionary.registerOre(
"ingotLead", new ItemStack(ElectricExpansionItems.itemParts, 1, 7));
OreDictionary.registerOre(
"coil", new ItemStack(ElectricExpansionItems.itemParts, 1, 8));
OreDictionary.registerOre(
"ingotSilver", new ItemStack(ElectricExpansionItems.itemParts, 1, 9));
OreDictionary.registerOre(
"copperWire",
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0));
OreDictionary.registerOre(
"tinWire",
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 1));
OreDictionary.registerOre(
"silverWire",
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 2));
OreDictionary.registerOre(
"aluminumWire",
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 3));
OreDictionary.registerOre(
"superconductor",
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 4));
OreDictionary.registerOre("insulation", RecipeRegistery.getInsulationIS());
NetworkRegistry.INSTANCE.registerGuiHandler(
(Object)this, (IGuiHandler)ElectricExpansion.proxy);
if (!Loader.isModLoaded("BasicComponents")) {
ElectricExpansion.eeLogger.fine(
"Basic Components NOT detected! Basic Components is REQUIRED for survival crafting and gameplay!");
}
channel = NetworkRegistry.INSTANCE.newSimpleChannel("ElectricExpansion");
int pkgId = 0;
channel.registerMessage(PacketHandlerUpdateQuantumBatteryBoxFrequency.class,
PacketUpdateQuantumBatteryBoxFrequency.class,
pkgId++, Side.SERVER);
channel.registerMessage(PacketHandlerLogisticsWireButton.class,
PacketLogisticsWireButton.class, pkgId++,
Side.SERVER);
}
@Mod.EventHandler
public void load(final FMLInitializationEvent event) {
log(Level.INFO, "Initializing ElectricExpansion v.2.1.0", new String[0]);
ElectricExpansion.proxy.init();
RecipeRegistery.crafting();
EETab.INSTANCE.setItemStack(
new ItemStack(ElectricExpansionItems.blockTransformer));
TranslationHelper.loadLanguages("/assets/electricexpansion/lang/",
ElectricExpansion.LANGUAGES_SUPPORTED);
ElectricExpansion.eeLogger.info("Loaded languages");
if (!ElectricExpansion.useUeVoltageSensitivity) {
UniversalElectricity.isVoltageSensitive = true;
ElectricExpansion.eeLogger.finest(
"Successfully toggled Voltage Sensitivity!");
}
OreGenerator.addOre(ElectricExpansion.silverOreGeneration);
UniversalElectricity.isNetworkActive = true;
}
@Mod.EventHandler
public void postInit(final FMLPostInitializationEvent event) {
log(Level.INFO, "PostInitializing ElectricExpansion v.2.1.0",
new String[0]);
MinecraftForge.EVENT_BUS.register((Object) new EventHandler());
RecipeRegistery.drawing();
RecipeRegistery.insulation();
}
@Mod.EventHandler
public void onServerStarting(final FMLServerStartingEvent event) {
ElectricExpansion.DistributionNetworksInstance = new DistributionNetworks();
}
static {
LANGUAGES_SUPPORTED = new String[] {"en_US", "pl_PL"};
CONFIG = new Configuration(
new File(Loader.instance().getConfigDir(),
"UniversalElectricity/ElectricExpansion.cfg"));
ElectricExpansion.configLoaded = false;
ElectricExpansion.eeLogger = Logger.getLogger("ElectricExpansion");
}
}

View file

@ -0,0 +1,639 @@
package electricexpansion.common;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
import electricexpansion.api.ElectricExpansionItems;
import electricexpansion.common.misc.InsulationRecipes;
import electricexpansion.common.misc.WireMillRecipes;
import java.util.logging.Level;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import universalelectricity.prefab.RecipeHelper;
public class RecipeRegistery {
private static ItemStack camo;
private static final ItemStack insulationIS;
public static void crafting() {
if (Loader.isModLoaded("BasicComponents")) {
for (final ItemStack wire : OreDictionary.getOres("copperWire")) {
RecipeHelper.removeRecipe(wire);
}
}
FurnaceRecipes.smelting().func_151396_a(
ElectricExpansionItems.itemParts, // 3,
new ItemStack(ElectricExpansionItems.itemParts, 4, 4), 0.0f);
try {
RecipeRegistery.camo =
GameRegistry.findItemStack("ICBM|Contraption", "camouflage", 1);
} catch (final NullPointerException ex) {
}
if (RecipeRegistery.camo == null) {
ElectricExpansion.log(Level.INFO, "Failed to detect ICBM|Contraption",
new String[0]);
ElectricExpansion.log(Level.INFO, "Using %s's items instead.",
"Electric Expansion");
RecipeRegistery.camo = new ItemStack(ElectricExpansionItems.itemParts, 1, 5);
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
RecipeRegistery.camo,
new Object[] {Blocks.wool, Items.bucket, Items.slime_ball,
Items.redstone, "dyeRed", "dyeBlue", "dyeYellow",
"dyeBlack", "dyeWhite"}));
}
registerRawCables();
registerInsulatedCables();
registerSwitchCables();
registerLogisticsCables();
registerCamoCables();
registerCamoSwitchCables();
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockWireMill),
new Object[] {"#$#", "!%!", "@!@", '!', "motor", '#', "plateSteel", '@',
"plateBronze", '$', "circuitBasic", '%',
new ItemStack(ElectricExpansionItems.itemParts, 1, 0)}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockMultimeter),
new Object[] {"$^$", "!@!", "$%$", '!', "plateCopper", '$',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0),
'%', "circuitBasic", '^', Blocks.glass, '@',
Items.stick}));
System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALEC " + ElectricExpansionItems.blockInsulatedWire);
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockAdvBatteryBox),
new Object[] {"!!!", "@@@", "!#!", '!', "battery", '@', "copperWire",
'#', "circuitBasic"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockInsulationMachine),
new Object[] {"!@!", "@#@", "!$!", '!', "plateSteel", '@',
Blocks.obsidian, '#', Items.lava_bucket, '$',
Blocks.furnace}));
if (OreDictionary.getOres("antimatterGram").size() > 0) {
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockDistribution),
new Object[] {"!!!", "!@!", "!!!", '@',
new ItemStack(ElectricExpansionItems.blockAdvBatteryBox), '!',
"antimatterGram"}));
} else {
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockDistribution),
new Object[] {"!!!", "!@!", "!!!", '@',
new ItemStack(ElectricExpansionItems.blockAdvBatteryBox), '!',
new ItemStack(ElectricExpansionItems.itemParts, 1, 1)}));
}
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockTransformer, 1, 0),
new Object[] {"$&$", "#x#", "@@@", '@', "plateSteel", '#',
new ItemStack(ElectricExpansionItems.itemParts, 1, 6),
'$',
new ItemStack(ElectricExpansionItems.itemParts, 1, 8),
'&', "ingotCopper", 'x', "dyeGreen"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockTransformer, 1, 4),
new Object[] {
"$&$", "#x#", "@!@", '!',
new ItemStack(ElectricExpansionItems.blockTransformer, 1, 0), '@',
"plateSteel", '#',
new ItemStack(ElectricExpansionItems.itemParts, 1, 6), '$',
new ItemStack(ElectricExpansionItems.itemParts, 1, 8), '&',
"ingotCopper", 'x', "dyeRed"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockTransformer, 1, 8),
new Object[] {
"$&$", "#x#", "@!@", '!',
new ItemStack(ElectricExpansionItems.blockTransformer, 1, 4), '@',
"plateSteel", '#',
new ItemStack(ElectricExpansionItems.itemParts, 1, 6), '$',
new ItemStack(ElectricExpansionItems.itemParts, 1, 8), '&',
"ingotCopper", 'x', "dyeBlue"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.itemUpgrade, 1, 0),
new Object[] {"$!$", "!@!", "#!#", '!',
new ItemStack((Item)ElectricExpansionItems.itemAdvBat, 1,
Integer.MIN_VALUE),
'@', new ItemStack(ElectricExpansionItems.itemUpgrade, 1, 0),
'#', "circuitAdvanced", '$', "plateSteel"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.itemUpgrade, 1, 1),
new Object[] {"$!$", "!@!", "#!#", '!',
new ItemStack((Item)ElectricExpansionItems.itemAdvBat, 1,
Integer.MIN_VALUE),
'@', new ItemStack(ElectricExpansionItems.itemUpgrade, 1, 0),
'#', "circuitAdvanced", '$', "plateSteel"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.itemUpgrade, 1, 2),
new Object[] {"#!#", "!@!", "#!#", '!',
new ItemStack((Item)ElectricExpansionItems.itemEliteBat,
1, Integer.MIN_VALUE),
'@', new ItemStack(ElectricExpansionItems.itemUpgrade, 1, 1),
'#', "circuitElite"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.itemUpgrade, 1, 3),
new Object[] {"#!#", "!@!", "#!#", '!', "antimatterMilligram", '@',
new ItemStack((Item)ElectricExpansionItems.itemUltimateBat, 1,
Integer.MIN_VALUE),
'#', "circuitElite"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.itemUpgrade, 1, 4),
new Object[] {
"#$#", "#!#", "#$#", '!',
new ItemStack(ElectricExpansionItems.blockTransformer, 1, 4), '#',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0), '$',
"circuitBasic"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.itemUpgrade, 1, 5),
new Object[] {
"#$#", "#!#", "#$#", '!',
new ItemStack(ElectricExpansionItems.blockTransformer, 1, 8), '#',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 3), '$',
"circuitElite"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.itemUpgrade, 1, 6),
new Object[] {
"@$#", "@!#", "@$#", '!',
new ItemStack(ElectricExpansionItems.blockTransformer, 1, 4), '#',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 3), '@',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0), '$',
"circuitAdvanced"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack((Item)ElectricExpansionItems.itemAdvBat),
new Object[] {" T ", "TRT", "TRT", 'T', "ingotSilver", 'R',
Items.glowstone_dust}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack((Item)ElectricExpansionItems.itemEliteBat),
new Object[] {"!@!", "#$#", "!@!", '!', "plateSteel", '@',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0),
'#', "ingotLead", '$', Items.ghast_tear}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack((Item)ElectricExpansionItems.itemUltimateBat),
new Object[] {"!@!", "#$#", "!@!", '!', "plateGold", '@',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 4),
'#', "antimatterMilligram", '$', "strangeMatter"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.itemParts, 1, 0),
new Object[] {" # ", "! !", " ! ", '!', Items.iron_ingot, '#',
Items.diamond}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.itemParts, 1, 1),
new Object[] {"!#!", "#@#", "!#!", '!', Items.gold_ingot, '#',
"ingotSilver", '@', Items.ender_eye}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.itemParts, 1, 1),
new Object[] {"!#!", "#@#", "!#!", '#', Items.gold_ingot, '!',
"ingotSilver", '@', Items.ender_eye}));
FurnaceRecipes.smelting().func_151396_a(
ElectricExpansionItems.itemParts, // 1,
new ItemStack(ElectricExpansionItems.itemParts, 4, 2), 0.0f);
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.itemParts, 9, 7),
new Object[] {ElectricExpansionItems.blockLead});
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.itemParts, 1, 8),
new Object[] {
"AAA", "ABA", "AAA", 'B', Items.iron_ingot, 'A',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0)}));
GameRegistry.addSmelting(
ElectricExpansionItems.blockSilverOre,
new ItemStack(ElectricExpansionItems.itemParts, 1, 9), 0.8f);
GameRegistry.addRecipe(
new ItemStack(ElectricExpansionItems.blockLead, 1),
new Object[] {"@@@", "@@@", "@@@", '@',
new ItemStack(ElectricExpansionItems.itemParts, 1, 7)});
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.itemMultimeter),
new Object[] {"$^$", "!@!", "$%$", '!', "plateCopper", '$',
"copperWire", '%', "circuitAdvanced", '^', Blocks.glass,
'@', "battery"}));
}
public static void drawing() {
if (!ElectricExpansion.debugRecipes) {
WireMillRecipes.INSTANCE.addProcessing(
"ingotCopper", new ItemStack(ElectricExpansionItems.blockRawWire, 3, 0), 60);
WireMillRecipes.INSTANCE.addProcessing(
"ingotTin", new ItemStack(ElectricExpansionItems.blockRawWire, 3, 1), 60);
WireMillRecipes.INSTANCE.addProcessing(
"ingotSilver", new ItemStack(ElectricExpansionItems.blockRawWire, 3, 2), 60);
WireMillRecipes.INSTANCE.addProcessing(
"ingotAluminum", new ItemStack(ElectricExpansionItems.blockRawWire, 3, 3),
60);
WireMillRecipes.INSTANCE.addProcessing(
new ItemStack(ElectricExpansionItems.itemParts, 64, 2),
new ItemStack(ElectricExpansionItems.blockRawWire, 64, 4), 24000);
for (int i = 0; i < 16; ++i) {
WireMillRecipes.INSTANCE.addProcessing(
new ItemStack(Blocks.wool, 10, i), new ItemStack(Items.string, 40),
300);
}
} else {
WireMillRecipes.INSTANCE.addProcessing(
"ingotCopper", new ItemStack(ElectricExpansionItems.blockRawWire, 3, 0), 20);
WireMillRecipes.INSTANCE.addProcessing(
"ingotTin", new ItemStack(ElectricExpansionItems.blockRawWire, 3, 1), 20);
WireMillRecipes.INSTANCE.addProcessing(
"ingotSilver", new ItemStack(ElectricExpansionItems.blockRawWire, 3, 2), 20);
WireMillRecipes.INSTANCE.addProcessing(
"ingotAluminum", new ItemStack(ElectricExpansionItems.blockRawWire, 3, 3),
20);
WireMillRecipes.INSTANCE.addProcessing(
new ItemStack(ElectricExpansionItems.itemParts, 64, 2),
new ItemStack(ElectricExpansionItems.blockRawWire, 64, 4), 20);
for (int i = 0; i < 16; ++i) {
WireMillRecipes.INSTANCE.addProcessing(
new ItemStack(Blocks.wool, 10, i), new ItemStack(Items.string, 40),
30);
}
}
}
public static void insulation() {
final int ticks = ElectricExpansion.debugRecipes ? 1 : 8;
for (int i = 0; i < 16; ++i) {
InsulationRecipes.INSTANCE.addProcessing(
new ItemStack(Blocks.wool, 32, i), 32, ticks * 80);
}
InsulationRecipes.INSTANCE.addProcessing(new ItemStack(Items.leather, 8),
24, ticks * 25);
InsulationRecipes.INSTANCE.addProcessing(
new ItemStack(Items.rotten_flesh, 8), 16, ticks * 25);
FurnaceRecipes.smelting().func_151396_a(Items.leather,
RecipeRegistery.insulationIS, 0.7f);
GameRegistry.addShapelessRecipe(
RecipeRegistery.insulationIS,
new Object[] {Blocks.wool, Blocks.wool, Blocks.wool, Blocks.wool});
for (final ItemStack is : OreDictionary.getOres("itemRubber")) {
if (!is.isItemEqual(RecipeRegistery.insulationIS)) {
final ItemStack is2 = is.copy();
is2.stackSize = 8;
InsulationRecipes.INSTANCE.addProcessing(
is2, is2.stackSize,
(int)Math.floor(is2.stackSize * ticks * 10.0 / 8.0 + 0.5));
}
}
}
public static void registerRawCables() {
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRawWire, 6, 0),
new Object[] {" @ ", " @ ", " @ ", '@', "ingotCopper"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRawWire, 6, 1),
new Object[] {" @ ", " @ ", " @ ", '@', "ingotTin"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRawWire, 6, 2),
new Object[] {" @ ", " @ ", " @ ", '@', "ingotSilver"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRawWire, 6, 3),
new Object[] {" @ ", " @ ", " @ ", '@', "ingotAluminum"}));
}
public static void registerInsulatedCables() {
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 6, 0),
new Object[] {"#@#", "#@#", "#@#", '#', RecipeRegistery.insulationIS,
'@', "ingotCopper"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 6, 1),
new Object[] {"#@#", "#@#", "#@#", '#', RecipeRegistery.insulationIS,
'@', "ingotTin"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 6, 2),
new Object[] {"#@#", "#@#", "#@#", '#', RecipeRegistery.insulationIS,
'@', "ingotSilver"}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 6, 3),
new Object[] {"#@#", "#@#", "#@#", '#', RecipeRegistery.insulationIS,
'@', "ingotAluminum"}));
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 0),
RecipeRegistery.insulationIS});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 1),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 1),
RecipeRegistery.insulationIS});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 2),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 2),
RecipeRegistery.insulationIS});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 3),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 3),
RecipeRegistery.insulationIS});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 4),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 4),
new ItemStack(ElectricExpansionItems.itemParts, 3, 7)});
}
public static void registerSwitchCables() {
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 0),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 0),
RecipeRegistery.insulationIS, Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 1),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 1),
RecipeRegistery.insulationIS, Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 2),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 2),
RecipeRegistery.insulationIS, Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 3),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 3),
RecipeRegistery.insulationIS, Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 4),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 4),
new ItemStack(ElectricExpansionItems.itemParts, 3, 7),
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 0),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0),
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 1),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 1),
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 2),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 2),
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 3),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 3),
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 4),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 4),
Blocks.lever});
}
public static void registerLogisticsCables() {
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 0),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 0),
RecipeRegistery.insulationIS, Blocks.lever,
Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 1),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 1),
RecipeRegistery.insulationIS, Blocks.lever,
Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 2),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 2),
RecipeRegistery.insulationIS, Blocks.lever,
Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 3),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 3),
RecipeRegistery.insulationIS, Blocks.lever,
Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 4),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 4),
new ItemStack(ElectricExpansionItems.itemParts, 3, 7),
Blocks.lever, Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 0),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0),
Blocks.lever, Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 1),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 1),
Blocks.lever, Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 2),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 2),
Blocks.lever, Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 3),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 3),
Blocks.lever, Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 4),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 4),
Blocks.lever, Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 0),
new Object[] {new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 0),
Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 1),
new Object[] {new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 1),
Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 2),
new Object[] {new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 2),
Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 3),
new Object[] {new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 3),
Items.redstone}));
GameRegistry.addRecipe((IRecipe) new ShapelessOreRecipe(
new ItemStack(ElectricExpansionItems.blockLogisticsWire, 1, 4),
new Object[] {new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 4),
Items.redstone}));
}
public static void registerCamoCables() {
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 0),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 0),
RecipeRegistery.insulationIS, RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 1),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 1),
RecipeRegistery.insulationIS, RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 2),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 2),
RecipeRegistery.insulationIS, RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 3),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 3),
RecipeRegistery.insulationIS, RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 4),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 4),
new ItemStack(ElectricExpansionItems.itemParts, 3, 7),
RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 0),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0),
RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 1),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 1),
RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 2),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 2),
RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 3),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 3),
RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 4),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 4),
RecipeRegistery.camo});
}
public static void registerCamoSwitchCables() {
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 0),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 0),
RecipeRegistery.insulationIS, RecipeRegistery.camo,
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 1),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 1),
RecipeRegistery.insulationIS, RecipeRegistery.camo,
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 2),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 2),
RecipeRegistery.insulationIS, RecipeRegistery.camo,
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 3),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 3),
RecipeRegistery.insulationIS, RecipeRegistery.camo,
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 4),
new Object[] {new ItemStack(ElectricExpansionItems.blockRawWire, 1, 4),
new ItemStack(ElectricExpansionItems.itemParts, 3, 7),
RecipeRegistery.camo, Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 0),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0),
RecipeRegistery.camo, Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 1),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 1),
RecipeRegistery.camo, Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 2),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 2),
RecipeRegistery.camo, Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 3),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 3),
RecipeRegistery.camo, Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 4),
new Object[] {new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 4),
RecipeRegistery.camo, Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 0),
new Object[] {new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 0),
RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 1),
new Object[] {new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 1),
RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 2),
new Object[] {new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 2),
RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 3),
new Object[] {new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 3),
RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 4),
new Object[] {new ItemStack(ElectricExpansionItems.blockSwitchWire, 1, 4),
RecipeRegistery.camo});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 0),
new Object[] {new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 0),
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 1),
new Object[] {new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 1),
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 2),
new Object[] {new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 2),
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 3),
new Object[] {new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 3),
Blocks.lever});
GameRegistry.addShapelessRecipe(
new ItemStack(ElectricExpansionItems.blockSwitchWireBlock, 1, 4),
new Object[] {new ItemStack(ElectricExpansionItems.blockWireBlock, 1, 4),
Blocks.lever});
}
public static void registerRedstoneCables() {
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRedstonePaintedWire, 4, 0),
new Object[] {"!@!", "@#@", "!@!", '!',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0),
'@', Items.redstone, '#', Items.slime_ball}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRedstonePaintedWire, 4, 1),
new Object[] {"!@!", "@#@", "!@!", '!',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 1),
'@', Items.redstone, '#', Items.slime_ball}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRedstonePaintedWire, 4, 2),
new Object[] {"!@!", "@#@", "!@!", '!',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 2),
'@', Items.redstone, '#', Items.slime_ball}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRedstonePaintedWire, 4, 3),
new Object[] {"!@!", "@#@", "!@!", '!',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 3),
'@', Items.redstone, '#', Items.slime_ball}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRedstonePaintedWire, 4, 4),
new Object[] {"!@!", "@#@", "!@!", '!',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 4),
'@', Items.redstone, '#', Items.slime_ball}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRedstonePaintedWire, 4, 0),
new Object[] {"!@!", "@#@", "!@!", '@',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 0),
'!', Items.redstone, '#', Items.slime_ball}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRedstonePaintedWire, 4, 1),
new Object[] {"!@!", "@#@", "!@!", '@',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 1),
'!', Items.redstone, '#', Items.slime_ball}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRedstonePaintedWire, 4, 2),
new Object[] {"!@!", "@#@", "!@!", '@',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 2),
'!', Items.redstone, '#', Items.slime_ball}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRedstonePaintedWire, 4, 3),
new Object[] {"!@!", "@#@", "!@!", '@',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 3),
'!', Items.redstone, '#', Items.slime_ball}));
GameRegistry.addRecipe((IRecipe) new ShapedOreRecipe(
new ItemStack(ElectricExpansionItems.blockRedstonePaintedWire, 4, 4),
new Object[] {"!@!", "@#@", "!@!", '@',
new ItemStack(ElectricExpansionItems.blockInsulatedWire, 1, 4),
'!', Items.redstone, '#', Items.slime_ball}));
}
public static ItemStack getInsulationIS() {
return RecipeRegistery.insulationIS;
}
static {
insulationIS = new ItemStack(ElectricExpansionItems.itemParts, 1, 6);
}
}

View file

@ -0,0 +1,226 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.ElectricExpansion;
import electricexpansion.common.misc.EETab;
import electricexpansion.common.tile.TileEntityAdvancedBatteryBox;
import java.util.HashMap;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.block.BlockAdvanced;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public class BlockAdvancedBatteryBox extends BlockAdvanced {
private HashMap<String, IIcon> icons;
public BlockAdvancedBatteryBox() {
super(UniversalElectricity.machine);
this.icons = new HashMap<>();
this.setStepSound(BlockAdvancedBatteryBox.soundTypeMetal);
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
this.setBlockName("advbatbox");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
this.icons.put(
"top", par1IconRegister.registerIcon("electricexpansion:machineTop"));
this.icons.put("out", par1IconRegister.registerIcon(
"electricexpansion:machineOutput"));
this.icons.put("input", par1IconRegister.registerIcon(
"electricexpansion:machineInput"));
this.icons.put("tier1",
par1IconRegister.registerIcon("electricexpansion:batBoxT1"));
this.icons.put("tier2",
par1IconRegister.registerIcon("electricexpansion:batBoxT2"));
this.icons.put("tier3",
par1IconRegister.registerIcon("electricexpansion:batBoxT3"));
this.icons.put("tier4",
par1IconRegister.registerIcon("electricexpansion:batBoxT4"));
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(final IBlockAccess iBlockAccess, final int x,
final int y, final int z, final int side) {
final int metadata = iBlockAccess.getBlockMetadata(x, y, z);
final TileEntityAdvancedBatteryBox tileEntity = (TileEntityAdvancedBatteryBox) iBlockAccess.getTileEntity(x, y,
z);
if (side == 0 || side == 1) {
return this.icons.get("top");
}
if (side == metadata + 2) {
return this.icons.get("out");
}
if (side == ForgeDirection.getOrientation(metadata + 2).getOpposite().ordinal()) {
return this.icons.get("input");
}
if (tileEntity.getMaxJoules() <= 8000000.0) {
return this.icons.get("tier1");
}
if (tileEntity.getMaxJoules() > 8000000.0 &&
tileEntity.getMaxJoules() <= 1.2E7) {
return this.icons.get("tier2");
}
if (tileEntity.getMaxJoules() > 1.2E7 &&
tileEntity.getMaxJoules() <= 1.6E7) {
return this.icons.get("tier3");
}
if (tileEntity.getMaxJoules() > 1.6E7) {
return this.icons.get("tier4");
}
return this.icons.get("tier1");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(final int side, final int metadata) {
if (side == 0 || side == 1) {
return this.icons.get("top");
}
if (side == metadata + 2) {
return this.icons.get("out");
}
if (side == ForgeDirection.getOrientation(metadata + 2).getOpposite().ordinal()) {
return this.icons.get("input");
}
return this.icons.get("tier1");
}
@Override
public void onBlockPlacedBy(final World par1World, final int x, final int y,
final int z, final EntityLivingBase entity,
final ItemStack itemStack) {
final int angle = MathHelper.floor_double(
((Entity) entity).rotationYaw * 4.0f / 360.0f + 0.5) &
0x3;
switch (angle) {
case 0: {
par1World.setBlock(x, y, z, this, 3, 0);
break;
}
case 1: {
par1World.setBlock(x, y, z, this, 1, 0);
break;
}
case 2: {
par1World.setBlock(x, y, z, this, 2, 0);
break;
}
case 3: {
par1World.setBlock(x, y, z, this, 0, 0);
break;
}
}
((TileEntityAdvanced) par1World.getTileEntity(x, y, z)).initiate();
par1World.notifyBlocksOfNeighborChange(x, y, z, this);
}
@Override
public boolean onUseWrench(final World par1World, final int x, final int y,
final int z, final EntityPlayer par5EntityPlayer,
final int side, final float hitX, final float hitY,
final float hitZ) {
final int metadata = par1World.getBlockMetadata(x, y, z);
int change = 0;
switch (metadata) {
case 0: {
change = 3;
break;
}
case 3: {
change = 1;
break;
}
case 1: {
change = 2;
break;
}
case 2: {
change = 0;
break;
}
}
par1World.setBlock(x, y, z, this, change, 0);
par1World.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
((TileEntityAdvanced) par1World.getTileEntity(x, y, z)).initiate();
return true;
}
@Override
public boolean onMachineActivated(final World par1World, final int x,
final int y, final int z,
final EntityPlayer par5EntityPlayer,
final int side, final float hitX,
final float hitY, final float hitZ) {
if (!par1World.isRemote) {
par5EntityPlayer.openGui((Object) ElectricExpansion.instance, 0, par1World,
x, y, z);
return true;
}
return true;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public TileEntity createNewTileEntity(final World world, final int metadata) {
return new TileEntityAdvancedBatteryBox();
}
// TODO: WTF
// @Override
// public ItemStack getPickBlock(final MovingObjectPosition target,
// final World world, final int x, final int y,
// final int z) {
// final int id = this.func_71922_a(world, x, y, z);
// if (id == 0) {
// return null;
// }
// final Item item = Item.field_77698_e[id];
// if (item == null) {
// return null;
// }
// return new ItemStack(id, 1, 0);
// }
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@Override
public int getComparatorInputOverride(final World par1World, final int x,
final int y, final int z,
final int meta) {
final TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityAdvancedBatteryBox) {
final TileEntityAdvancedBatteryBox te = (TileEntityAdvancedBatteryBox) tileEntity;
final double max = te.getMaxJoules();
final double current = te.getJoules();
return (int) (current / max * 15.0);
}
return 0;
}
}

View file

@ -0,0 +1,64 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
public class BlockBasic extends Block {
public BlockBasic(final Material material, final CreativeTabs tab,
final float hardness, final float resistance,
final String name, final float lightValue,
final SoundType sound) {
super(material);
this.setCreativeTab(tab);
this.setHardness(hardness);
this.setResistance(resistance);
this.setBlockName(name);
this.setStepSound(sound);
this.setLightLevel(lightValue);
}
public BlockBasic(final Material material, final CreativeTabs tab,
final float hardness, final float resistance,
final String name, final float lightValue) {
this(material, tab, hardness, resistance, name, lightValue,
BlockBasic.soundTypeMetal);
}
public BlockBasic(final Material material, final CreativeTabs tab,
final float hardness, final float resistance,
final String name) {
this(material, tab, hardness, resistance, name, 0.0f,
BlockBasic.soundTypeMetal);
}
public BlockBasic(final Material material, final CreativeTabs tab,
final float hardness, final String name) {
this(material, tab, hardness, 1.0f, name, 0.0f, BlockBasic.soundTypeMetal);
}
public BlockBasic(final CreativeTabs tab, final float hardness,
final float resistance, final String name) {
this(Material.iron, tab, hardness, resistance, name, 0.0f,
BlockBasic.soundTypeMetal);
}
public BlockBasic(final CreativeTabs tab, final float hardness,
final String name) {
this(Material.iron, tab, hardness, 1.0f, name, 0.0f,
BlockBasic.soundTypeMetal);
}
public BlockBasic(final CreativeTabs tab, final String name) {
this(Material.iron, tab, 1.0f, 1.0f, name, 0.0f, BlockBasic.soundTypeMetal);
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister reg) {
this.blockIcon = reg.registerIcon(
this.getUnlocalizedName().replace("tile.", "electricexpansion:"));
}
}

View file

@ -0,0 +1,186 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.ElectricExpansion;
import electricexpansion.common.misc.EETab;
import electricexpansion.common.tile.TileEntityFuseBox;
import java.util.HashMap;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.block.BlockAdvanced;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public class BlockFuseBox extends BlockAdvanced {
private HashMap<String, IIcon> icons;
public BlockFuseBox() {
super(UniversalElectricity.machine);
this.icons = new HashMap<>();
this.setBlockName("FuseBox");
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
this.setStepSound(BlockFuseBox.soundTypeMetal);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(final IBlockAccess iBlockAccess, final int x,
final int y, final int z, final int side) {
final int metadata = iBlockAccess.getBlockMetadata(x, y, z);
if (side == 0 || side == 1) {
return this.icons.get("top");
}
if (side == metadata + 2) {
return this.icons.get("output");
}
if (side == ForgeDirection.getOrientation(metadata + 2).getOpposite().ordinal()) {
return this.icons.get("input");
}
return this.icons.get("side");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
this.icons.put(
"top", par1IconRegister.registerIcon("electricexpansion:machineTop"));
this.icons.put("output", par1IconRegister.registerIcon(
"electricexpansion:machineOutput"));
this.icons.put("input", par1IconRegister.registerIcon(
"electricexpansion:machineInput"));
this.icons.put("side",
par1IconRegister.registerIcon("electricexpansion:fusebox"));
}
@Override
public void onBlockPlacedBy(final World world, final int x, final int y,
final int z, final EntityLivingBase player,
final ItemStack itemStack) {
final int angle = MathHelper.floor_double(
((Entity) player).rotationYaw * 4.0f / 360.0f + 0.5) &
0x3;
switch (angle) {
case 0: {
world.setBlock(x, y, z, this, 3, 0);
break;
}
case 1: {
world.setBlock(x, y, z, this, 1, 0);
break;
}
case 2: {
world.setBlock(x, y, z, this, 2, 0);
break;
}
case 3: {
world.setBlock(x, y, z, this, 0, 0);
break;
}
}
((TileEntityAdvanced) world.getTileEntity(x, y, z)).initiate();
world.notifyBlocksOfNeighborChange(x, y, z, this);
}
@Override
public boolean onUseWrench(final World par1World, final int x, final int y,
final int z, final EntityPlayer par5EntityPlayer,
final int side, final float hitX, final float hitY,
final float hitZ) {
final int original = par1World.getBlockMetadata(x, y, z);
int change = 0;
switch (original) {
case 0: {
change = 3;
break;
}
case 3: {
change = 1;
break;
}
case 1: {
change = 2;
break;
}
case 2: {
change = 0;
break;
}
}
par1World.setBlock(x, y, z, this, change, 0);
par1World.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
((TileEntityAdvanced) par1World.getTileEntity(x, y, z)).initiate();
return true;
}
@Override
public boolean onSneakUseWrench(final World par1World, final int x, final int y, final int z,
final EntityPlayer par5EntityPlayer, final int side,
final float hitX, final float hitY, final float hitZ) {
return false;
}
@Override
public boolean isOpaqueCube() {
return true;
}
public boolean isBlockSolidOnSide(final World world, final int x, final int y,
final int z, final ForgeDirection side) {
return true;
}
@Override
public boolean renderAsNormalBlock() {
return true;
}
@Override
public TileEntity createNewTileEntity(final World var1, final int metadata) {
return new TileEntityFuseBox();
}
@Override
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs,
final List par3List) {
par3List.add(new ItemStack(this, 1, 0));
}
// TODO: WTF
// @Override
// public ItemStack getPickBlock(final MovingObjectPosition target,
// final World world, final int x, final int y,
// final int z) {
// final int id = this.func_71922_a(world, x, y, z);
// if (id == 0) {
// return null;
// }
// return new ItemStack(id, 1, 0);
// }
@Override
public boolean onMachineActivated(final World par1World, final int x,
final int y, final int z,
final EntityPlayer par5EntityPlayer,
final int side, final float hitX,
final float hitY, final float hitZ) {
if (!par1World.isRemote) {
par5EntityPlayer.openGui((Object) ElectricExpansion.instance, 6, par1World,
x, y, z);
return true;
}
return true;
}
}

View file

@ -0,0 +1,164 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.cables.TileEntityInsulatedWire;
import electricexpansion.common.helpers.TileEntityConductorBase;
import electricexpansion.common.misc.EETab;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.core.block.IConductor;
import universalelectricity.prefab.block.BlockConductor;
public class BlockInsulatedWire extends BlockConductor {
public BlockInsulatedWire() {
super(Material.cloth);
this.setBlockName("InsulatedWire");
this.setStepSound(BlockInsulatedWire.soundTypeCloth);
this.setResistance(0.2f);
this.setHardness(0.1f);
this.setBlockBounds(0.3f, 0.3f, 0.3f, 0.7f, 0.7f, 0.7f);
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int damageDropped(final int i) {
return i;
}
@Override
public int getRenderType() {
return -1;
}
@Override
public TileEntity createNewTileEntity(final World var1, int meta) {
return new TileEntityInsulatedWire();
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs,
final List par3List) {
for (int var4 = 0; var4 < 5; ++var4) {
par3List.add(new ItemStack(par1, 1, var4));
}
}
@Override
public void onBlockAdded(final World world, final int x, final int y,
final int z) {
super.onBlockAdded(world, x, y, z);
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null && tileEntity instanceof IConductor) {
((IConductor) tileEntity).updateAdjacentConnections();
this.updateWireSwitch(world, x, y, z);
}
}
@Override
public boolean onBlockActivated(final World par1World, final int x, final int y, final int z,
final EntityPlayer par5EntityPlayer, final int par6,
final float par7, final float par8, final float par9) {
final TileEntityInsulatedWire tileEntity = (TileEntityInsulatedWire) par1World.getTileEntity(x, y, z);
if (!par1World.isRemote &&
par5EntityPlayer.inventory.getCurrentItem() != null &&
par5EntityPlayer.inventory.getCurrentItem().getItem() instanceof ItemDye) {
final int dyeColor = par5EntityPlayer.inventory.getCurrentItem().getItemDamageForDisplay();
tileEntity.colorByte = (byte) dyeColor;
--par5EntityPlayer.inventory.getCurrentItem().stackSize;
// TODO: WTF
// PacketManager.sendPacketToClients(PacketManager.getPacket(
// "ElecEx", tileEntity, 0, tileEntity.colorByte));
tileEntity.updateAdjacentConnections();
this.updateWireSwitch(par1World, x, y, z);
return true;
}
return false;
}
private void updateWireSwitch(final World world, final int x, final int y,
final int z) {
final TileEntityInsulatedWire tileEntity = (TileEntityInsulatedWire) world.getTileEntity(x, y, z);
if (!world.isRemote && tileEntity != null) {
for (byte i = 0; i < 6; ++i) {
TileEntity tileEntity2 = null;
switch (i) {
case 0: {
tileEntity2 = world.getTileEntity(x + 1, y, z);
break;
}
case 1: {
tileEntity2 = world.getTileEntity(x - 1, y, z);
break;
}
case 2: {
tileEntity2 = world.getTileEntity(x, y + 1, z);
break;
}
case 3: {
tileEntity2 = world.getTileEntity(x, y - 1, z);
break;
}
case 4: {
tileEntity2 = world.getTileEntity(x, y, z + 1);
break;
}
case 5: {
tileEntity2 = world.getTileEntity(x, y, z - 1);
break;
}
default: {
tileEntity2 = world.getTileEntity(x, y, z);
break;
}
}
if (tileEntity2 instanceof IConductor) {
((IConductor) tileEntity2).updateAdjacentConnections();
tileEntity2.getWorldObj().markBlockForUpdate(
tileEntity2.xCoord, tileEntity2.yCoord, tileEntity2.zCoord);
}
}
}
}
@Override
public void setBlockBoundsBasedOnState(final IBlockAccess par1IBlockAccess,
final int x, final int y,
final int z) {
final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityConductorBase) {
final TileEntityConductorBase te = (TileEntityConductorBase) tileEntity;
this.minX = ((te.connectedBlocks[4] != null) ? 0.0 : 0.30000001192092896);
this.minY = ((te.connectedBlocks[0] != null) ? 0.0 : 0.30000001192092896);
this.minZ = ((te.connectedBlocks[2] != null) ? 0.0 : 0.30000001192092896);
this.maxX = ((te.connectedBlocks[5] != null) ? 1.0 : 0.699999988079071);
this.maxY = ((te.connectedBlocks[1] != null) ? 1.0 : 0.699999988079071);
this.maxZ = ((te.connectedBlocks[3] != null) ? 1.0 : 0.699999988079071);
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
}
}

View file

@ -0,0 +1,179 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.ElectricExpansion;
import electricexpansion.common.misc.EETab;
import electricexpansion.common.tile.TileEntityInsulatingMachine;
import java.util.HashMap;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.block.BlockAdvanced;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public class BlockInsulationMachine extends BlockAdvanced {
private HashMap<String, IIcon> icons;
public BlockInsulationMachine() {
super(UniversalElectricity.machine);
this.icons = new HashMap<>();
this.setStepSound(BlockInsulationMachine.soundTypeMetal);
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
this.setBlockName("insulator");
}
@Override
public void onBlockPlacedBy(final World par1World, final int x, final int y,
final int z,
final EntityLivingBase par5EntityLiving,
final ItemStack itemStack) {
final int angle = MathHelper.floor_double(
((Entity) par5EntityLiving).rotationYaw * 4.0f / 360.0f + 0.5) &
0x3;
switch (angle) {
case 0: {
par1World.setBlock(x, y, z, this, 1, 0);
break;
}
case 1: {
par1World.setBlock(x, y, z, this, 2, 0);
break;
}
case 2: {
par1World.setBlock(x, y, z, this, 0, 0);
break;
}
case 3: {
par1World.setBlock(x, y, z, this, 3, 0);
break;
}
}
((TileEntityAdvanced) par1World.getTileEntity(x, y, z)).initiate();
par1World.notifyBlocksOfNeighborChange(x, y, z, this);
}
@Override
public boolean onUseWrench(final World par1World, final int x, final int y,
final int z, final EntityPlayer par5EntityPlayer,
final int side, final float hitX, final float hitY,
final float hitZ) {
final int metadata = par1World.getBlockMetadata(x, y, z);
int change = 0;
switch (metadata) {
case 0: {
change = 3;
break;
}
case 3: {
change = 1;
break;
}
case 1: {
change = 2;
break;
}
case 2: {
change = 0;
break;
}
}
par1World.setBlock(x, y, z, this, change, 0);
par1World.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
((TileEntityAdvanced) par1World.getTileEntity(x, y, z)).initiate();
return true;
}
@Override
public boolean onMachineActivated(final World par1World, final int x,
final int y, final int z,
final EntityPlayer par5EntityPlayer,
final int side, final float hitX,
final float hitY, final float hitZ) {
if (!par1World.isRemote) {
par5EntityPlayer.openGui((Object) ElectricExpansion.instance, 5, par1World,
x, y, z);
return true;
}
return true;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public TileEntity createNewTileEntity(final World var1, final int metadata) {
return new TileEntityInsulatingMachine();
}
// TODO: WTF
// @Override
// public ItemStack getPickBlock(final MovingObjectPosition target,
// final World world, final int x, final int y,
// final int z) {
// final int id = this.func_71922_a(world, x, y, z);
// if (id == 0) {
// return null;
// }
// final Item item = Item.field_77698_e[id];
// if (item == null) {
// return null;
// }
// return new ItemStack(id, 1, 0);
// }
@Override
public boolean hasTileEntity(final int metadata) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderType() {
return 0;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
this.icons.put(
"top", par1IconRegister.registerIcon("electricexpansion:insulatorTop"));
this.icons.put("input", par1IconRegister.registerIcon(
"electricexpansion:machineInput"));
this.icons.put("insulator", par1IconRegister.registerIcon(
"electricexpansion:insulatorFront"));
this.icons.put(
"", par1IconRegister.registerIcon("electricexpansion:machineTop"));
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(final int side, final int metadata) {
if (side == 1) {
return this.icons.get("top");
}
if (side == metadata + 2) {
return this.icons.get("input");
}
if (ForgeDirection.getOrientation(side).getOpposite().ordinal() == metadata + 2) {
return this.icons.get("insulator");
}
return this.icons.get("");
}
}

View file

@ -0,0 +1,144 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.cables.TileEntityLogisticsWire;
import electricexpansion.common.helpers.TileEntityConductorBase;
import electricexpansion.common.misc.EETab;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.block.BlockConductor;
import universalelectricity.prefab.implement.IRedstoneProvider;
public class BlockLogisticsWire extends BlockConductor {
public BlockLogisticsWire(final int meta) {
super(Material.cloth);
this.setBlockName("LogisticsWire");
this.setStepSound(BlockLogisticsWire.soundTypeCloth);
this.setResistance(0.2f);
this.setHardness(0.1f);
this.setBlockBounds(0.3f, 0.3f, 0.3f, 0.7f, 0.7f, 0.7f);
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int damageDropped(final int i) {
return i;
}
@Override
public int getRenderType() {
return -1;
}
@Override
public TileEntity createNewTileEntity(final World var1, int meta) {
return new TileEntityLogisticsWire();
}
@Override
public boolean canProvidePower() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs,
final List par3List) {
for (int var4 = 0; var4 < 5; ++var4) {
par3List.add(new ItemStack(par1, 1, var4));
}
}
// TODO: WTF
// @Override
// public boolean onBlockActivated(final World par1World, final int par2,
// final int par3, final int par4,
// final EntityPlayer par5EntityPlayer,
// final int par6, final float par7,
// final float par8, final float par9) {
// final TileEntityLogisticsWire tileEntity =
// (TileEntityLogisticsWire)par1World.getTileEntity(par2, par3, par4);
// if (!par1World.isRemote) {
// PacketManager.sendPacketToClients(
// PacketManager.getPacket(
// "ElecEx", tileEntity, 3, tileEntity.buttonStatus0,
// tileEntity.buttonStatus1, tileEntity.buttonStatus2),
// tileEntity.field_70331_k, new Vector3(tileEntity), 12.0);
// return true;
// }
// PacketDispatcher.sendPacketToServer(
// PacketManager.getPacket("ElecEx", tileEntity, 7, true));
// par5EntityPlayer.openGui((Object)ElectricExpansion.instance, 3,
// par1World,
// par2, par3, par4);
// return true;
// }
@Override
public int isProvidingStrongPower(final IBlockAccess par1IBlockAccess,
final int x, final int y, final int z,
final int side) {
final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof IRedstoneProvider) {
return ((IRedstoneProvider) tileEntity)
.isPoweringTo(ForgeDirection.getOrientation(side))
? 15
: 0;
}
return 0;
}
@Override
public int isProvidingWeakPower(final IBlockAccess par1IBlockAccess,
final int x, final int y, final int z,
final int side) {
final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof IRedstoneProvider) {
return ((IRedstoneProvider) tileEntity)
.isIndirectlyPoweringTo(ForgeDirection.getOrientation(side))
? 15
: 0;
}
return 0;
}
@Override
public void setBlockBoundsBasedOnState(final IBlockAccess par1IBlockAccess,
final int x, final int y,
final int z) {
final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityConductorBase) {
final TileEntityConductorBase te = (TileEntityConductorBase) tileEntity;
this.minX = ((te.connectedBlocks[4] != null) ? 0.0 : 0.30000001192092896);
this.minY = ((te.connectedBlocks[0] != null) ? 0.0 : 0.30000001192092896);
this.minZ = ((te.connectedBlocks[2] != null) ? 0.0 : 0.30000001192092896);
this.maxX = ((te.connectedBlocks[5] != null) ? 1.0 : 0.699999988079071);
this.maxY = ((te.connectedBlocks[1] != null) ? 1.0 : 0.699999988079071);
this.maxZ = ((te.connectedBlocks[3] != null) ? 1.0 : 0.699999988079071);
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
}
}

View file

@ -0,0 +1,163 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.misc.EETab;
import electricexpansion.common.tile.TileEntityMultimeter;
import java.util.HashMap;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.block.BlockAdvanced;
import universalelectricity.prefab.implement.IRedstoneProvider;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public class BlockMultimeter extends BlockAdvanced {
private HashMap<String, IIcon> icons;
public BlockMultimeter() {
super(UniversalElectricity.machine);
this.icons = new HashMap<>();
this.setStepSound(Block.soundTypeMetal);
this.setCreativeTab((CreativeTabs)EETab.INSTANCE);
this.setBlockName("multimeter");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(final int side, final int metadata) {
if (side == 3) {
return this.icons.get("front");
}
return this.icons.get("top");
}
@Override
public IIcon getIcon(final IBlockAccess par1IBlockAccess, final int x,
final int y, final int z, final int side) {
final int metadata = par1IBlockAccess.getBlockMetadata(x, y, z);
if (side ==
ForgeDirection.getOrientation(metadata).getOpposite().ordinal()) {
return this.icons.get("output");
}
return this.icons.get("top");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
this.icons.put(
"top", par1IconRegister.registerIcon("electricexpansion:machineTop"));
this.icons.put("output", par1IconRegister.registerIcon(
"electricexpansion:machineOutput"));
this.icons.put("machine",
par1IconRegister.registerIcon("electricexpansion:machine"));
this.icons.put(
"front", par1IconRegister.registerIcon("electricexpansion:multimeter"));
}
@Override
public void onBlockPlacedBy(final World world, final int x, final int y,
final int z,
final EntityLivingBase par5EntityLiving,
final ItemStack itemStack) {
final int angle =
MathHelper.floor_double(
((Entity)par5EntityLiving).rotationYaw * 4.0f / 360.0f + 0.5) &
0x3;
int change = 2;
switch (angle) {
case 0: {
change = 2;
break;
}
case 1: {
change = 5;
break;
}
case 2: {
change = 3;
break;
}
case 3: {
change = 4;
break;
}
}
world.setBlock(x, y, z, this, change, 0);
((TileEntityAdvanced)world.getTileEntity(x, y, z)).initiate();
world.notifyBlocksOfNeighborChange(x, y, z, this);
}
@Override
public boolean onUseWrench(final World world, final int x, final int y,
final int z, final EntityPlayer par5EntityPlayer,
final int side, final float hitX, final float hitY,
final float hitZ) {
final int original = world.getBlockMetadata(x, y, z);
int change = 2;
switch (original) {
case 2: {
change = 5;
break;
}
case 5: {
change = 4;
break;
}
case 4: {
change = 3;
break;
}
case 3: {
change = 2;
break;
}
}
world.setBlock(x, y, z, this, change, 0);
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
((TileEntityAdvanced)world.getTileEntity(x, y, z)).initiate();
world.notifyBlocksOfNeighborChange(x, y, z, this);
return true;
}
@Override
public int isProvidingStrongPower(final IBlockAccess par1IBlockAccess,
final int x, final int y, final int z,
final int side) {
final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof IRedstoneProvider) {
return ((IRedstoneProvider)tileEntity)
.isPoweringTo(ForgeDirection.getOrientation(side))
? 15
: 0;
}
return 0;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public TileEntity createNewTileEntity(final World var1, final int metadata) {
return new TileEntityMultimeter();
}
}

View file

@ -0,0 +1,205 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.ElectricExpansion;
import electricexpansion.common.helpers.PlayerHelper;
import electricexpansion.common.misc.EETab;
import electricexpansion.common.tile.TileEntityAdvancedBatteryBox;
import electricexpansion.common.tile.TileEntityQuantumBatteryBox;
import java.util.HashMap;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.block.BlockAdvanced;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public class BlockQuantumBatteryBox extends BlockAdvanced {
private HashMap<String, IIcon> icons;
public BlockQuantumBatteryBox() {
super(Material.iron);
this.icons = new HashMap<>();
this.setBlockName("Distribution");
this.setStepSound(BlockQuantumBatteryBox.soundTypeMetal);
this.setHardness(1.5f);
this.setResistance(10.0f);
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
}
@Override
public boolean isOpaqueCube() {
return true;
}
@Override
public int damageDropped(final int i) {
return 0;
}
@Override
public boolean renderAsNormalBlock() {
return true;
}
@Override
public IIcon getIcon(final int side, final int metadata) {
if (side == metadata + 2) {
return this.icons.get("output");
}
if (side == ForgeDirection.getOrientation(metadata + 2).getOpposite().ordinal()) {
return this.icons.get("input");
}
return this.icons.get("default");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
this.icons.put("output", par1IconRegister.registerIcon(
"electricexpansion:darkMachineOutput"));
this.icons.put("input", par1IconRegister.registerIcon(
"electricexpansion:darkMachineInput"));
this.icons.put("default", par1IconRegister.registerIcon(
"electricexpansion:darkMachineTop"));
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs,
final List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
}
@Override
public TileEntity createNewTileEntity(final World var1, final int meta) {
return new TileEntityQuantumBatteryBox();
}
@Override
public boolean onBlockActivated(final World par1World, final int x, final int y, final int z,
final EntityPlayer player, final int par6, final float par7,
final float par8, final float par9) {
if (par1World.isRemote) {
return true;
}
if (player.getDisplayName() == ((TileEntityQuantumBatteryBox) par1World.getTileEntity(x, y, z))
.getOwningPlayer() ||
PlayerHelper.isPlayerOp(player.getDisplayName())) {
player.openGui((Object) ElectricExpansion.instance, 4, par1World, x, y, z);
return true;
}
return true;
}
@Override
public void onBlockPlacedBy(final World par1World, final int x, final int y,
final int z,
final EntityLivingBase par5EntityLiving,
final ItemStack itemStack) {
final int angle = MathHelper.floor_double(
((Entity) par5EntityLiving).rotationYaw * 4.0f / 360.0f + 0.5) &
0x3;
switch (angle) {
case 0: {
par1World.setBlock(x, y, z, this, 3, 0);
break;
}
case 1: {
par1World.setBlock(x, y, z, this, 1, 0);
break;
}
case 2: {
par1World.setBlock(x, y, z, this, 2, 0);
break;
}
case 3: {
par1World.setBlock(x, y, z, this, 0, 0);
break;
}
}
if (par5EntityLiving instanceof EntityPlayer &&
((TileEntityAdvanced) par1World.getTileEntity(x, y, z)) instanceof TileEntityQuantumBatteryBox) {
((TileEntityQuantumBatteryBox) par1World.getTileEntity(x, y, z))
.setPlayer((EntityPlayer) par5EntityLiving);
}
((TileEntityAdvanced) par1World.getTileEntity(x, y, z)).initiate();
par1World.notifyBlocksOfNeighborChange(x, y, z, this);
}
@Override
public boolean onUseWrench(final World par1World, final int x, final int y,
final int z, final EntityPlayer par5EntityPlayer,
final int side, final float hitX, final float hitY,
final float hitZ) {
final int metadata = par1World.getBlockMetadata(x, y, z);
int change = 0;
switch (metadata) {
case 0: {
change = 3;
break;
}
case 3: {
change = 1;
break;
}
case 1: {
change = 2;
break;
}
case 2: {
change = 0;
break;
}
}
par1World.setBlock(x, y, z, this, change, 0);
par1World.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
((TileEntityAdvanced) par1World.getTileEntity(x, y, z)).initiate();
return true;
}
// TODO: WTF
// @Override
// public ItemStack getPickBlock(final MovingObjectPosition target, final
// World world, final int x, final int y, final int z) {
// final int id = this.func_71922_a(world, x, y, z);
// if (id == 0) {
// return null;
// }
// final Item item = Item.field_77698_e[id];
// if (item == null) {
// return null;
// }
// return new ItemStack(id, 1, 0);
// }
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@Override
public int getComparatorInputOverride(final World par1World, final int x,
final int y, final int z,
final int meta) {
final TileEntity tileEntity = par1World.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityQuantumBatteryBox) {
final TileEntityAdvancedBatteryBox te = (TileEntityAdvancedBatteryBox) tileEntity;
final double max = te.getMaxJoules();
final double current = te.getJoules();
return (int) (current / max * 15.0);
}
return 0;
}
}

View file

@ -0,0 +1,105 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.api.EnumWireMaterial;
import electricexpansion.common.cables.TileEntityRawWire;
import electricexpansion.common.helpers.TileEntityConductorBase;
import electricexpansion.common.misc.EETab;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.prefab.CustomDamageSource;
import universalelectricity.prefab.block.BlockConductor;
public class BlockRawWire extends BlockConductor {
public BlockRawWire() {
super(Material.cloth);
this.setBlockName("RawWire");
this.setStepSound(BlockRawWire.soundTypeCloth);
this.setResistance(0.2f);
this.setHardness(0.1f);
this.setBlockBounds(0.3f, 0.3f, 0.3f, 0.7f, 0.7f, 0.7f);
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int damageDropped(final int i) {
return i;
}
@Override
public int getRenderType() {
return -1;
}
@Override
public void onEntityCollidedWithBlock(final World par1World, final int x,
final int y, final int z,
final Entity entity) {
if (entity instanceof EntityLivingBase) {
final TileEntityRawWire tileEntity = (TileEntityRawWire) par1World.getTileEntity(x, y, z);
if (tileEntity.getNetwork().getProduced(new TileEntity[0]).getWatts() > 0.0) {
((EntityLivingBase) entity)
.attackEntityFrom(
(DamageSource) CustomDamageSource.electrocution,
EnumWireMaterial.values()[par1World.getBlockMetadata(x, y, z)].electrocutionDamage);
}
}
}
@Override
public TileEntity createNewTileEntity(final World var1, int meta) {
return new TileEntityRawWire();
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs,
final List par3List) {
for (int var4 = 0; var4 < 5; ++var4) {
par3List.add(new ItemStack(par1, 1, var4));
}
}
@Override
public void setBlockBoundsBasedOnState(final IBlockAccess par1IBlockAccess,
final int x, final int y,
final int z) {
final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityConductorBase) {
final TileEntityConductorBase te = (TileEntityConductorBase) tileEntity;
this.minX = ((te.connectedBlocks[4] != null) ? 0.0 : 0.30000001192092896);
this.minY = ((te.connectedBlocks[0] != null) ? 0.0 : 0.30000001192092896);
this.minZ = ((te.connectedBlocks[2] != null) ? 0.0 : 0.30000001192092896);
this.maxX = ((te.connectedBlocks[5] != null) ? 1.0 : 0.699999988079071);
this.maxY = ((te.connectedBlocks[1] != null) ? 1.0 : 0.699999988079071);
this.maxZ = ((te.connectedBlocks[3] != null) ? 1.0 : 0.699999988079071);
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
}
}

View file

@ -0,0 +1,154 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.misc.EENetwork;
import electricexpansion.common.misc.EETab;
import electricexpansion.common.tile.TileEntityRedstoneNetworkCore;
import java.util.HashMap;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import universalelectricity.prefab.block.BlockAdvanced;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public class BlockRedstoneNetworkCore extends BlockAdvanced {
private HashMap<String, IIcon> icons;
public BlockRedstoneNetworkCore() {
super(Material.iron);
this.icons = new HashMap<>();
this.setStepSound(BlockRedstoneNetworkCore.soundTypeMetal);
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
this.setBlockName("RsNetCore");
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
this.icons.put(
"top", par1IconRegister.registerIcon("electricexpansion:rsMachine"));
this.icons.put("out", par1IconRegister.registerIcon(
"electricexpansion:rsMachineOutput"));
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(final int side, final int metadata) {
return (side == metadata) ? this.icons.get("out") : this.icons.get("top");
}
@Override
public void onBlockPlacedBy(final World par1World, final int x, final int y,
final int z,
final EntityLivingBase par5EntityLiving,
final ItemStack itemStack) {
final int angle = MathHelper.floor_double(
((Entity) par5EntityLiving).rotationYaw * 4.0f / 360.0f + 0.5) &
0x3;
switch (angle) {
case 0: {
par1World.setBlock(x, y, z, this, 5, 0);
break;
}
case 1: {
par1World.setBlock(x, y, z, this, 3, 0);
break;
}
case 2: {
par1World.setBlock(x, y, z, this, 4, 0);
break;
}
case 3: {
par1World.setBlock(x, y, z, this, 2, 0);
break;
}
}
((TileEntityAdvanced) par1World.getTileEntity(x, y, z)).initiate();
par1World.markBlockForUpdate(x, y, z);
}
@Override
public boolean onUseWrench(final World par1World, final int x, final int y,
final int z, final EntityPlayer par5EntityPlayer,
final int side, final float hitX, final float hitY,
final float hitZ) {
final int metadata = par1World.getBlockMetadata(x, y, z);
int change = 0;
switch (metadata) {
case 0: {
change = 1;
break;
}
case 1: {
change = 2;
break;
}
case 2: {
change = 5;
break;
}
case 3: {
change = 4;
break;
}
case 4: {
change = 0;
break;
}
case 5: {
change = 3;
break;
}
}
par1World.setBlock(x, y, z, this, change, 0);
par1World.markBlockForUpdate(x, y, z);
((TileEntityAdvanced) par1World.getTileEntity(x, y, z)).initiate();
return true;
}
@Override
public TileEntity createNewTileEntity(final World world, final int metadata) {
return new TileEntityRedstoneNetworkCore();
}
// TODO: WTF
// @Override
// public ItemStack getPickBlock(final MovingObjectPosition target, final
// World world, final int x, final int y, final int z) {
// final int id = this.func_71922_a(world, x, y, z);
// if (id == 0) {
// return null;
// }
// final Item item = Item.field_77698_e[id];
// if (item == null) {
// return null;
// }
// return new ItemStack(id, 1, 0);
// }
@Override
public boolean onMachineActivated(final World world, final int x, final int y,
final int z, final EntityPlayer player,
final int par6, final float par7,
final float par8, final float par9) {
final TileEntityRedstoneNetworkCore te = (TileEntityRedstoneNetworkCore) world.getTileEntity(x, y, z);
if (te.getNetwork() != null) {
player.addChatMessage(new ChatComponentText(
"NetRsLevel: " + ((EENetwork) te.getNetwork()).rsLevel));
} else {
player.addChatMessage(
new ChatComponentText("NetRsLevel: NETWORK INVALID"));
}
return true;
}
}

View file

@ -0,0 +1,198 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.cables.TileEntityRedstonePaintedWire;
import electricexpansion.common.helpers.TileEntityConductorBase;
import electricexpansion.common.misc.EETab;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.core.block.IConductor;
public class BlockRedstonePaintedWire
extends Block implements ITileEntityProvider {
public BlockRedstonePaintedWire() {
super(Material.cloth);
this.setBlockName("RedstonePaintedWire");
this.setStepSound(BlockRedstonePaintedWire.soundTypeCloth);
this.setResistance(0.2f);
this.setHardness(0.1f);
this.setBlockBounds(0.3f, 0.3f, 0.3f, 0.7f, 0.7f, 0.7f);
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
}
@Override
public boolean canConnectRedstone(final IBlockAccess world, final int x,
final int y, final int z, final int side) {
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityRedstonePaintedWire) {
final TileEntityRedstonePaintedWire te = (TileEntityRedstonePaintedWire) tileEntity;
return side > -1 && side < 6 && te.connectedBlocks[side] == null;
}
return false;
}
@Override
public int isProvidingStrongPower(final IBlockAccess world, final int x,
final int y, final int z, final int side) {
if (world.getTileEntity(x, y, z) instanceof TileEntityRedstonePaintedWire) {
final TileEntityRedstonePaintedWire te = (TileEntityRedstonePaintedWire) world.getTileEntity(x, y, z);
if (te.smartNetwork != null) {
return te.smartNetwork.rsLevel;
}
}
return 0;
}
@Override
public int isProvidingWeakPower(final IBlockAccess world, final int x,
final int y, final int z, final int side) {
if (world.getTileEntity(x, y, z) instanceof TileEntityRedstonePaintedWire) {
final TileEntityRedstonePaintedWire te = (TileEntityRedstonePaintedWire) world.getTileEntity(x, y, z);
if (te.smartNetwork != null) {
return te.smartNetwork.rsLevel;
}
}
return 0;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int damageDropped(final int i) {
return i;
}
@Override
public int getRenderType() {
return -1;
}
@Override
public TileEntity createNewTileEntity(final World world, int meta) {
return new TileEntityRedstonePaintedWire();
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs,
final List par3List) {
for (int var4 = 0; var4 < 5; ++var4) {
par3List.add(new ItemStack(par1, 1, var4));
}
}
@Override
public void onBlockAdded(final World world, final int x, final int y,
final int z) {
super.onBlockAdded(world, x, y, z);
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity != null && tileEntity instanceof IConductor) {
((IConductor) tileEntity).updateAdjacentConnections();
this.updateWireSwitch(world, x, y, z);
}
}
private void updateWireSwitch(final World world, final int x, final int y,
final int z) {
final TileEntityRedstonePaintedWire tileEntity = (TileEntityRedstonePaintedWire) world.getTileEntity(x, y, z);
if (!world.isRemote && tileEntity != null) {
for (byte i = 0; i < 6; ++i) {
TileEntity tileEntity2 = null;
switch (i) {
case 0: {
tileEntity2 = world.getTileEntity(x + 1, y, z);
break;
}
case 1: {
tileEntity2 = world.getTileEntity(x - 1, y, z);
break;
}
case 2: {
tileEntity2 = world.getTileEntity(x, y + 1, z);
break;
}
case 3: {
tileEntity2 = world.getTileEntity(x, y - 1, z);
break;
}
case 4: {
tileEntity2 = world.getTileEntity(x, y, z + 1);
break;
}
case 5: {
tileEntity2 = world.getTileEntity(x, y, z - 1);
break;
}
default: {
tileEntity2 = world.getTileEntity(x, y, z);
break;
}
}
if (tileEntity2 instanceof IConductor) {
((IConductor) tileEntity2).updateAdjacentConnections();
tileEntity2.getWorldObj().markBlockForUpdate(
tileEntity2.xCoord, tileEntity2.yCoord, tileEntity2.zCoord);
}
}
}
}
@Override
public void setBlockBoundsBasedOnState(final IBlockAccess par1IBlockAccess,
final int x, final int y,
final int z) {
final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityConductorBase) {
final TileEntityConductorBase te = (TileEntityConductorBase) tileEntity;
this.minX = ((te.connectedBlocks[4] != null) ? 0.0 : 0.30000001192092896);
this.minY = ((te.connectedBlocks[0] != null) ? 0.0 : 0.30000001192092896);
this.minZ = ((te.connectedBlocks[2] != null) ? 0.0 : 0.30000001192092896);
this.maxX = ((te.connectedBlocks[5] != null) ? 1.0 : 0.699999988079071);
this.maxY = ((te.connectedBlocks[1] != null) ? 1.0 : 0.699999988079071);
this.maxZ = ((te.connectedBlocks[3] != null) ? 1.0 : 0.699999988079071);
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
}
@Override
public boolean onBlockActivated(final World world, final int x, final int y,
final int z, final EntityPlayer player,
final int par6, final float par7,
final float par8, final float par9) {
final TileEntityRedstonePaintedWire te = (TileEntityRedstonePaintedWire) world.getTileEntity(x, y, z);
if (te.smartNetwork != null) {
player.addChatMessage(
new ChatComponentText("NetRsLevel: " + te.smartNetwork.rsLevel));
} else {
player.addChatMessage(
new ChatComponentText("NetRsLevel: NETWORK INVALID"));
}
player.addChatMessage(new ChatComponentText(
"WldRsLevel: " + world.getBlockPowerInput(x, y, z)));
return true;
}
}

View file

@ -0,0 +1,89 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.cables.TileEntitySwitchWire;
import electricexpansion.common.helpers.TileEntityConductorBase;
import electricexpansion.common.misc.EETab;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.prefab.block.BlockConductor;
public class BlockSwitchWire extends BlockConductor {
public BlockSwitchWire() {
super(Material.cloth);
this.setBlockName("SwitchWire");
this.setStepSound(BlockSwitchWire.soundTypeCloth);
this.setResistance(0.2f);
this.setHardness(0.1f);
this.setBlockBounds(0.3f, 0.3f, 0.3f, 0.7f, 0.7f, 0.7f);
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int damageDropped(final int i) {
return i;
}
@Override
public int getRenderType() {
return -1;
}
@Override
public TileEntity createNewTileEntity(final World var1, int meta) {
return new TileEntitySwitchWire();
}
@Override
public boolean canProvidePower() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs,
final List par3List) {
for (int var4 = 0; var4 < 5; ++var4) {
par3List.add(new ItemStack(par1, 1, var4));
}
}
@Override
public void setBlockBoundsBasedOnState(final IBlockAccess par1IBlockAccess,
final int x, final int y,
final int z) {
final TileEntity tileEntity = par1IBlockAccess.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityConductorBase) {
final TileEntityConductorBase te = (TileEntityConductorBase) tileEntity;
this.minX = ((te.connectedBlocks[4] != null) ? 0.0 : 0.30000001192092896);
this.minY = ((te.connectedBlocks[0] != null) ? 0.0 : 0.30000001192092896);
this.minZ = ((te.connectedBlocks[2] != null) ? 0.0 : 0.30000001192092896);
this.maxX = ((te.connectedBlocks[5] != null) ? 1.0 : 0.699999988079071);
this.maxY = ((te.connectedBlocks[1] != null) ? 1.0 : 0.699999988079071);
this.maxZ = ((te.connectedBlocks[3] != null) ? 1.0 : 0.699999988079071);
}
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
}
}

View file

@ -0,0 +1,106 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.cables.TileEntitySwitchWireBlock;
import electricexpansion.common.helpers.TileEntityConductorBase;
import electricexpansion.common.misc.EETab;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.prefab.block.BlockConductor;
public class BlockSwitchWireBlock extends BlockConductor {
public BlockSwitchWireBlock() {
super(Material.rock);
this.setBlockName("SwitchWireBlock");
this.setStepSound(BlockSwitchWireBlock.soundTypeStone);
this.setResistance(0.2f);
this.setHardness(1.5f);
this.setResistance(10.0f);
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return 0;
}
@Override
public boolean renderAsNormalBlock() {
return true;
}
@Override
public int damageDropped(final int i) {
return i;
}
@Override
public TileEntity createNewTileEntity(final World var1, int meta) {
return new TileEntitySwitchWireBlock();
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs,
final List par3List) {
for (int var4 = 0; var4 < 5; ++var4) {
par3List.add(new ItemStack(par1, 1, var4));
}
}
@Override
public boolean canConnectRedstone(final IBlockAccess world, final int x,
final int y, final int z, final int side) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(final IBlockAccess par1IBlockAccess, final int x,
final int y, final int z, final int side) {
return (((TileEntityConductorBase) par1IBlockAccess.getTileEntity(x, y, z)).textureItemStack == null)
? this.blockIcon
: ((TileEntityConductorBase) par1IBlockAccess.getTileEntity(x, y, z)).textureItemStack.getIconIndex();
}
@Override
public boolean onBlockActivated(final World world, final int x, final int y,
final int z, final EntityPlayer player,
final int par6, final float par7,
final float par8, final float par9) {
if (!(world.getTileEntity(x, y, z) instanceof TileEntityConductorBase)) {
return false;
}
if (player.inventory.getCurrentItem().getItem() != Item.getItemFromBlock(this)) {
((TileEntityConductorBase) world.getTileEntity(x, y, z)).textureItemStack = player.inventory
.getCurrentItem();
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
return true;
}
((TileEntityConductorBase) world.getTileEntity(x, y, z)).textureItemStack = null;
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
this.blockIcon = par1IconRegister.registerIcon("electricexpansion:CamoWire");
}
}

View file

@ -0,0 +1,177 @@
//
// Decompiled by Procyon v0.6.0
//
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.client.ClientProxy;
import electricexpansion.common.misc.EETab;
import electricexpansion.common.tile.TileEntityTransformer;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.block.BlockAdvanced;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public class BlockTransformer extends BlockAdvanced {
public BlockTransformer() {
super(UniversalElectricity.machine);
this.setStepSound(BlockTransformer.soundTypeMetal);
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
this.setBlockName("transformer");
}
@Override
public void onBlockPlacedBy(final World par1World, final int x, final int y,
final int z,
final EntityLivingBase par5EntityLiving,
final ItemStack itemStack) {
final int metadata = par1World.getBlockMetadata(x, y, z);
final int tierStart = metadata - (metadata & 0x3);
final int angle = MathHelper.floor_double(
((Entity) par5EntityLiving).rotationYaw * 4.0f / 360.0f + 0.5) &
0x3;
switch (angle) {
case 0: {
par1World.setBlock(x, y, z, this, tierStart + 3, 0);
break;
}
case 1: {
par1World.setBlock(x, y, z, this, tierStart + 1, 0);
break;
}
case 2: {
par1World.setBlock(x, y, z, this, tierStart + 2, 0);
break;
}
case 3: {
par1World.setBlock(x, y, z, this, tierStart + 0, 0);
break;
}
}
((TileEntityAdvanced) par1World.getTileEntity(x, y, z)).initiate();
par1World.notifyBlocksOfNeighborChange(x, y, z, this);
}
@Override
public boolean onUseWrench(final World par1World, final int x, final int y,
final int z, final EntityPlayer par5EntityPlayer,
final int side, final float hitX, final float hitY,
final float hitZ) {
final int metadata = par1World.getBlockMetadata(x, y, z);
final int tierStart = metadata - (metadata & 0x3);
final int original = metadata & 0x3;
int change = 0;
switch (original) {
case 0: {
change = 3;
break;
}
case 3: {
change = 1;
break;
}
case 1: {
change = 2;
break;
}
case 2: {
change = 0;
break;
}
}
par1World.setBlock(x, y, z, this, change + tierStart, 0);
par1World.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
((TileEntityAdvanced) par1World.getTileEntity(x, y, z)).initiate();
return true;
}
@Override
public boolean onSneakUseWrench(final World par1World, final int x, final int y, final int z,
final EntityPlayer par5EntityPlayer, final int side,
final float hitX, final float hitY, final float hitZ) {
if (!par1World.isRemote) {
final TileEntityTransformer tileEntity = (TileEntityTransformer) par1World.getTileEntity(x, y, z);
tileEntity.stepUp = !tileEntity.stepUp;
par1World.markBlockForUpdate(x, y, z);
}
return true;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isBlockSolid(final IBlockAccess world, final int x,
final int y, final int z, final int side) {
return side == ForgeDirection.DOWN.ordinal();
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderType() {
return ClientProxy.RENDER_ID;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public TileEntity createNewTileEntity(final World var1, final int metadata) {
return new TileEntityTransformer();
}
@Override
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs,
final List par3List) {
for (int i = 0; i < 9; i += 4) {
par3List.add(new ItemStack((Block) this, 1, i));
}
}
// TODO: WTF
// @Override
// public ItemStack getPickBlock(final MovingObjectPosition target,
// final World world, final int x, final int y,
// final int z) {
// final int id = this.func_71922_a(world, x, y, z);
// if (id == 0) {
// return null;
// }
// final Item item = Item.field_77698_e[id];
// if (item == null) {
// return null;
// }
// final int metadata = world.getBlockMetadata(x, y, z);
// final int tierStart = metadata - (metadata & 0x3);
// return new ItemStack(id, 1, tierStart);
// }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
}
@Override
public int damageDropped(final int metadata) {
return metadata - (metadata & 0x3);
}
}

View file

@ -0,0 +1,119 @@
package electricexpansion.common.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.common.cables.TileEntityWireBlock;
import electricexpansion.common.helpers.TileEntityConductorBase;
import electricexpansion.common.misc.EETab;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.prefab.block.BlockConductor;
public class BlockWireBlock extends BlockConductor {
public BlockWireBlock() {
super(Material.rock);
this.setBlockName("HiddenWire");
this.setStepSound(BlockWireBlock.soundTypeStone);
this.setResistance(0.2f);
this.setHardness(1.5f);
// TODO: WTF
// this.setResistance(10.0f);
this.setCreativeTab((CreativeTabs) EETab.INSTANCE);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
return 0;
}
@Override
public int damageDropped(final int i) {
return i;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType() {
return 0;
}
@Override
public TileEntity createNewTileEntity(final World var1, int meta) {
return new TileEntityWireBlock();
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs,
final List par3List) {
for (int var4 = 0; var4 < 5; ++var4) {
par3List.add(new ItemStack(par1, 1, var4));
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(final IBlockAccess par1IBlockAccess, final int x,
final int y, final int z, final int side) {
return (((TileEntityConductorBase) par1IBlockAccess.getTileEntity(x, y, z)).textureItemStack == null)
? this.blockIcon
: ((TileEntityConductorBase) par1IBlockAccess.getTileEntity(x, y, z)).textureItemStack.getIconIndex();
}
@Override
public boolean onBlockActivated(final World world, final int x, final int y,
final int z, final EntityPlayer player,
final int par6, final float par7,
final float par8, final float par9) {
final TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileEntityConductorBase) {
final TileEntityConductorBase te = (TileEntityConductorBase) tileEntity;
if (player.inventory.getCurrentItem() != null &&
player.inventory.getCurrentItem().getItem() instanceof ItemBlock) {
if (!te.isIconLocked &&
player.inventory.getCurrentItem().getItem() != Item.getItemFromBlock(this) &&
Block.getBlockFromItem(player.inventory.getCurrentItem().getItem())
.isNormalCube()) {
((TileEntityConductorBase) world.getTileEntity(x, y, z)).textureItemStack = player.inventory
.getCurrentItem();
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
return true;
}
((TileEntityConductorBase) world.getTileEntity(x, y, z)).textureItemStack = null;
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
return true;
} else if (player.isSneaking()) {
te.isIconLocked = !te.isIconLocked;
return true;
}
}
return false;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
this.blockIcon = par1IconRegister.registerIcon("electricexpansion:CamoWire");
}
}

View file

@ -0,0 +1,136 @@
package electricexpansion.common.blocks;
import net.minecraft.entity.Entity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.client.ClientProxy;
import electricexpansion.common.tile.TileEntityWireMill;
import net.minecraft.tileentity.TileEntity;
import electricexpansion.common.ElectricExpansion;
import net.minecraft.entity.player.EntityPlayer;
import universalelectricity.prefab.tile.TileEntityAdvanced;
import net.minecraft.util.MathHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.world.World;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import electricexpansion.common.misc.EETab;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.block.BlockAdvanced;
public class BlockWireMill extends BlockAdvanced
{
public BlockWireMill() {
super(UniversalElectricity.machine);
this.setStepSound(BlockWireMill.soundTypeMetal);
this.setBlockName("wiremill");
this.setCreativeTab((CreativeTabs)EETab.INSTANCE);
}
@Override
public void onBlockPlacedBy(final World par1World, final int x, final int y, final int z, final EntityLivingBase par5EntityLiving, final ItemStack itemStack) {
final int angle = MathHelper.floor_double(((Entity)par5EntityLiving).rotationYaw * 4.0f / 360.0f + 0.5) & 0x3;
switch (angle) {
case 0: {
par1World.setBlock(x, y, z, this, 1, 0);
break;
}
case 1: {
par1World.setBlock(x, y, z, this, 2, 0);
break;
}
case 2: {
par1World.setBlock(x, y, z, this, 0, 0);
break;
}
case 3: {
par1World.setBlock(x, y, z, this, 3, 0);
break;
}
}
((TileEntityAdvanced)par1World.getTileEntity(x, y, z)).initiate();
par1World.notifyBlocksOfNeighborChange(x, y, z, this);
}
@Override
public boolean onUseWrench(final World par1World, final int x, final int y, final int z, final EntityPlayer par5EntityPlayer, final int side, final float hitX, final float hitY, final float hitZ) {
final int metadata = par1World.getBlockMetadata(x, y, z);
int change = 0;
switch (metadata) {
case 0: {
change = 3;
break;
}
case 3: {
change = 1;
break;
}
case 1: {
change = 2;
break;
}
case 2: {
change = 0;
break;
}
}
par1World.setBlock(x, y, z, this, change, 0);
par1World.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
((TileEntityAdvanced)par1World.getTileEntity(x, y, z)).initiate();
return true;
}
@Override
public boolean onMachineActivated(final World par1World, final int x, final int y, final int z, final EntityPlayer par5EntityPlayer, final int side, final float hitX, final float hitY, final float hitZ) {
if (!par1World.isRemote) {
par5EntityPlayer.openGui((Object)ElectricExpansion.instance, 2, par1World, x, y, z);
return true;
}
return true;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public TileEntity createNewTileEntity(final World var1, final int metadata) {
return new TileEntityWireMill();
}
//TODO: WTF
//public ItemStack getPickBlock(final MovingObjectPosition target, final World world, final int x, final int y, final int z) {
// final int id = this.func_71922_a(world, x, y, z);
// if (id == 0) {
// return null;
// }
// final Item item = Item.field_77698_e[id];
// if (item == null) {
// return null;
// }
// return new ItemStack(id, 1, 0);
//}
@Override
public boolean hasTileEntity(final int metadata) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderType() {
return ClientProxy.RENDER_ID;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister par1IconRegister) {
}
}

View file

@ -0,0 +1,63 @@
package electricexpansion.common.cables;
import electricexpansion.api.ElectricExpansionItems;
import electricexpansion.common.helpers.TileEntityConductorBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
public class TileEntityInsulatedWire extends TileEntityConductorBase {
public byte colorByte;
public TileEntityInsulatedWire() {
this.colorByte = -1;
}
@Override
public void initiate() {
super.initiate();
this.getWorldObj().notifyBlocksOfNeighborChange(
this.xCoord, this.yCoord, this.zCoord,
ElectricExpansionItems.blockInsulatedWire);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
NBTTagCompound nbt = pkt.func_148857_g();
this.colorByte = nbt.getByte("colorByte");
this.visuallyConnected[0] = nbt.getBoolean("bottom");
this.visuallyConnected[1] = nbt.getBoolean("top");
this.visuallyConnected[2] = nbt.getBoolean("back");
this.visuallyConnected[3] = nbt.getBoolean("front");
this.visuallyConnected[4] = nbt.getBoolean("left");
this.visuallyConnected[5] = nbt.getBoolean("right");
}
@Override
public void readFromNBT(final NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.colorByte = nbt.getByte("colorByte");
}
@Override
public void writeToNBT(final NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setByte("colorByte", this.colorByte);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setByte("colorByte", this.colorByte);
nbt.setBoolean("bottom", this.visuallyConnected[0]);
nbt.setBoolean("top", this.visuallyConnected[1]);
nbt.setBoolean("back", this.visuallyConnected[2]);
nbt.setBoolean("front", this.visuallyConnected[3]);
nbt.setBoolean("left", this.visuallyConnected[4]);
nbt.setBoolean("right", this.visuallyConnected[5]);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord,
this.getBlockMetadata(), nbt);
}
}

View file

@ -0,0 +1,148 @@
package electricexpansion.common.cables;
import electricexpansion.api.ElectricExpansionItems;
import electricexpansion.common.helpers.TileEntityConductorBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.prefab.implement.IRedstoneProvider;
public class TileEntityLogisticsWire
extends TileEntityConductorBase implements IRedstoneProvider {
public boolean buttonStatus0;
public boolean buttonStatus1;
public boolean buttonStatus2;
private double networkProduced;
private byte tick;
public TileEntityLogisticsWire() {
this.buttonStatus0 = false;
this.buttonStatus1 = false;
this.buttonStatus2 = false;
this.networkProduced = 0.0;
this.tick = 0;
}
@Override
public void initiate() {
this.getWorldObj().notifyBlocksOfNeighborChange(
this.xCoord, this.yCoord, this.zCoord,
ElectricExpansionItems.blockLogisticsWire);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
NBTTagCompound nbt = pkt.func_148857_g();
this.visuallyConnected[0] = nbt.getBoolean("bottom");
this.visuallyConnected[1] = nbt.getBoolean("top");
this.visuallyConnected[2] = nbt.getBoolean("back");
this.visuallyConnected[3] = nbt.getBoolean("front");
this.visuallyConnected[4] = nbt.getBoolean("left");
this.visuallyConnected[5] = nbt.getBoolean("right");
this.buttonStatus0 = nbt.getBoolean("buttonStatus0");
this.buttonStatus1 = nbt.getBoolean("buttonStatus1");
this.buttonStatus2 = nbt.getBoolean("buttonStatus2");
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setBoolean("bottom", this.visuallyConnected[0]);
nbt.setBoolean("top", this.visuallyConnected[1]);
nbt.setBoolean("back", this.visuallyConnected[2]);
nbt.setBoolean("front", this.visuallyConnected[3]);
nbt.setBoolean("left", this.visuallyConnected[4]);
nbt.setBoolean("right", this.visuallyConnected[5]);
nbt.setBoolean("buttonStatus0", this.buttonStatus0);
nbt.setBoolean("buttonStatus1", this.buttonStatus1);
nbt.setBoolean("buttonStatus2", this.buttonStatus2);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord,
this.getBlockMetadata(), nbt);
}
public void onButtonPacket(int buttonId, boolean status) {
switch (buttonId) {
case 0:
this.buttonStatus0 = status;
break;
case 1:
this.buttonStatus1 = status;
break;
case 2:
this.buttonStatus2 = status;
break;
}
}
// TODO: WTF
// final byte id = dataStream.readByte();
// if (id == -1) {
// this.buttonStatus0 = dataStream.readBoolean();
// }
// if (id == 0) {
// this.buttonStatus1 = dataStream.readBoolean();
// }
// if (id == 1) {
// this.buttonStatus2 = dataStream.readBoolean();
// }
// if (id != 7 || dataStream.readBoolean()) {}
@Override
public void readFromNBT(final NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.buttonStatus0 = nbt.getBoolean("buttonStatus0");
this.buttonStatus1 = nbt.getBoolean("buttonStatus1");
this.buttonStatus2 = nbt.getBoolean("buttonStatus2");
}
@Override
public void writeToNBT(final NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setBoolean("buttonStatus0", this.buttonStatus0);
nbt.setBoolean("buttonStatus1", this.buttonStatus1);
nbt.setBoolean("buttonStatus2", this.buttonStatus2);
}
@Override
public void updateEntity() {
super.updateEntity();
if (!this.getWorldObj().isRemote) {
++this.tick;
if (this.tick == 20) {
this.tick = 0;
if (this.networkProduced == 0.0 &&
this.getNetwork().getProduced(new TileEntity[0]).getWatts() != 0.0) {
this.getWorldObj().notifyBlocksOfNeighborChange(
this.xCoord, this.yCoord, this.zCoord, this.blockType);
}
if (this.networkProduced != 0.0 &&
this.getNetwork().getProduced(new TileEntity[0]).getWatts() == 0.0) {
this.getWorldObj().notifyBlocksOfNeighborChange(
this.xCoord, this.yCoord, this.zCoord, this.blockType);
}
this.networkProduced = this.getNetwork().getProduced(new TileEntity[0]).getWatts();
}
}
}
@Override
public boolean isPoweringTo(final ForgeDirection side) {
return this.buttonStatus0 &&
this.getNetwork().getProduced(new TileEntity[0]).getWatts() > 0.0;
}
@Override
public boolean isIndirectlyPoweringTo(final ForgeDirection side) {
return this.isPoweringTo(side);
}
}

View file

@ -0,0 +1,11 @@
package electricexpansion.common.cables;
import electricexpansion.common.helpers.TileEntityConductorBase;
public class TileEntityRawWire extends TileEntityConductorBase {
// TODO: WTF
@Override
public double getResistance() {
return super.getResistance() * 2.0;
}
}

View file

@ -0,0 +1,48 @@
package electricexpansion.common.cables;
import electricexpansion.api.IRedstoneNetAccessor;
import electricexpansion.common.helpers.TileEntityConductorBase;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityRedstonePaintedWire
extends TileEntityConductorBase implements IRedstoneNetAccessor {
private boolean isRegistered;
public TileEntityRedstonePaintedWire() {
this.isRegistered = false;
}
@Override
public void initiate() {
super.initiate();
if (super.smartNetwork != null) {
super.smartNetwork.addRsInterfacer(this);
this.isRegistered = true;
}
}
@Override
public void updateEntity() {
super.updateEntity();
if (!this.isRegistered && super.smartNetwork != null) {
super.smartNetwork.addRsInterfacer(this);
this.isRegistered = true;
}
}
public boolean canUpdate() {
return true;
}
@Override
public int getRsSignalFromBlock() {
int i = 0;
for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
i = Math.max(
i, this.getWorldObj().getBlockPowerInput(this.xCoord + side.offsetX,
this.yCoord + side.offsetY,
this.zCoord + side.offsetZ));
}
return i;
}
}

View file

@ -0,0 +1,12 @@
package electricexpansion.common.cables;
import electricexpansion.common.helpers.TileEntityConductorBase;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntitySwitchWire extends TileEntityConductorBase {
@Override
public boolean canConnect(final ForgeDirection direction) {
return this.getWorldObj().isBlockIndirectlyGettingPowered(
this.xCoord, this.yCoord, this.zCoord);
}
}

View file

@ -0,0 +1,4 @@
package electricexpansion.common.cables;
public class TileEntitySwitchWireBlock extends TileEntitySwitchWire {
}

View file

@ -0,0 +1,6 @@
package electricexpansion.common.cables;
import electricexpansion.common.helpers.TileEntityConductorBase;
public class TileEntityWireBlock extends TileEntityConductorBase {
}

View file

@ -0,0 +1,90 @@
package electricexpansion.common.containers;
import electricexpansion.common.tile.TileEntityAdvancedBatteryBox;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import universalelectricity.core.item.IItemElectric;
public class ContainerAdvBatteryBox extends Container {
private TileEntityAdvancedBatteryBox tileEntity;
public ContainerAdvBatteryBox(final InventoryPlayer par1InventoryPlayer,
final TileEntityAdvancedBatteryBox advBatteryBox) {
this.tileEntity = advBatteryBox;
this.addSlotToContainer((Slot) new SlotUniversalElectricItem(
(IInventory) advBatteryBox, 0, 11, 24));
this.addSlotToContainer((Slot) new SlotUniversalElectricItem(
(IInventory) advBatteryBox, 1, 11, 48));
// TODO: WTF
// this.addSlotToContainer((Slot)new SlotModifier((IInventory)advBatteryBox,
// 2, 149, 7)); this.addSlotToContainer((Slot)new
// SlotModifier((IInventory)advBatteryBox, 3, 149, 31));
// this.addSlotToContainer((Slot)new SlotModifier((IInventory)advBatteryBox,
// 4, 149, 55));
this.addSlotToContainer(new Slot((IInventory) advBatteryBox, 2, 149, 7));
this.addSlotToContainer(new Slot((IInventory) advBatteryBox, 3, 149, 31));
this.addSlotToContainer(new Slot((IInventory) advBatteryBox, 4, 149, 55));
for (int var3 = 0; var3 < 3; ++var3) {
for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new Slot((IInventory) par1InventoryPlayer,
var4 + var3 * 9 + 9, 8 + var4 * 18,
84 + var3 * 18));
}
}
for (int var3 = 0; var3 < 9; ++var3) {
this.addSlotToContainer(
new Slot((IInventory) par1InventoryPlayer, var3, 8 + var3 * 18, 142));
}
this.tileEntity.openInventory();
}
public void onContainerClosed(final EntityPlayer entityplayer) {
super.onContainerClosed(entityplayer);
this.tileEntity.closeInventory();
}
public boolean canInteractWith(final EntityPlayer par1EntityPlayer) {
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
}
public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer,
final int par1) {
ItemStack var2 = null;
final Slot var3 = (Slot) super.inventorySlots.get(par1);
if (var3 != null && var3.getHasStack()) {
final ItemStack var4 = var3.getStack();
var2 = var4.copy();
if (par1 > 4) {
if (var4.getItem() instanceof IItemElectric) {
if (((IItemElectric) var4.getItem())
.getProvideRequest(var2)
.getWatts() > 0.0) {
if (!this.mergeItemStack(var4, 1, 2, false)) {
return null;
}
} else if (!this.mergeItemStack(var4, 0, 1, false)) {
return null;
}
} else if (!this.mergeItemStack(var4, 2, 4, false)) {
return null;
}
} else if (!this.mergeItemStack(var4, 5, 38, false)) {
return null;
}
if (var4.stackSize == 0) {
var3.putStack((ItemStack) null);
} else {
var3.onSlotChanged();
}
if (var4.stackSize == var2.stackSize) {
return null;
}
var3.onPickupFromSlot(par1EntityPlayer, var4);
}
return var2;
}
}

View file

@ -0,0 +1,46 @@
package electricexpansion.common.containers;
import electricexpansion.common.tile.TileEntityQuantumBatteryBox;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerDistribution extends Container {
private TileEntityQuantumBatteryBox tileEntity;
public ContainerDistribution(final InventoryPlayer par1InventoryPlayer,
final TileEntityQuantumBatteryBox tileEntity2) {
this.tileEntity = tileEntity2;
// TODO: WTF
//for (int var3 = 0; var3 < 3; ++var3) {
//for (int var4 = 0; var4 < 9; ++var4) {
//this.addSlotToContainer(new Slot((IInventory)
//par1InventoryPlayer,
//var4 + var3 * 9 + 9, 8 + var4 * 18,
//84 + var3 * 18));
//}
//}
//for (int var3 = 0; var3 < 9; ++var3) {
//this.addSlotToContainer(
//new Slot((IInventory) par1InventoryPlayer, var3, 8 + var3 *
//18, 142));
//}
tileEntity2.openInventory();
}
public void onContainerClosed(final EntityPlayer entityplayer) {
this.tileEntity.closeInventory();
}
public boolean canInteractWith(final EntityPlayer par1EntityPlayer) {
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
}
public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer,
final int par1) {
return null;
}
}

View file

@ -0,0 +1,88 @@
package electricexpansion.common.containers;
import electricexpansion.api.IItemFuse;
import electricexpansion.common.tile.TileEntityFuseBox;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import universalelectricity.prefab.SlotSpecific;
public class ContainerFuseBox extends Container {
private TileEntityFuseBox tileEntity;
public ContainerFuseBox(final InventoryPlayer par1InventoryPlayer,
final TileEntityFuseBox tileEntity) {
this.tileEntity = tileEntity;
this.addSlotToContainer((Slot) new SlotSpecific(
(IInventory) tileEntity, 0, 8, 16, new Class[] { IItemFuse.class }));
for (int var3 = 0; var3 < 3; ++var3) {
for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new Slot((IInventory) par1InventoryPlayer,
var4 + var3 * 9 + 9, 8 + var4 * 18,
84 + var3 * 18));
}
}
for (int var3 = 0; var3 < 9; ++var3) {
this.addSlotToContainer(
new Slot((IInventory) par1InventoryPlayer, var3, 8 + var3 * 18, 142));
}
tileEntity.openInventory();
}
public void onContainerClosed(final EntityPlayer entityplayer) {
super.onContainerClosed(entityplayer);
this.tileEntity.closeInventory();
}
public boolean canInteractWith(final EntityPlayer par1EntityPlayer) {
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
}
public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer,
final int par1) {
System.out.println("Slot: " + par1);
ItemStack var2 = null;
ItemStack var3 = null;
ItemStack var4 = null;
final Slot var5 = (Slot) super.inventorySlots.get(par1);
final Slot var6 = (Slot) super.inventorySlots.get(0);
if (var5 != null && var5.getHasStack()) {
var2 = var5.getStack();
var3 = var2.copy();
var4 = var2.copy();
--var4.stackSize;
var3.stackSize = 1;
System.out.println("StackSize: " + var4.stackSize);
if (par1 == 0) {
if (!this.mergeItemStack(var3, 1, 37, true)) {
return var4;
}
var5.onSlotChange(var3, var2);
} else if (par1 != 0 && !var6.getHasStack()) {
if (var3.getItem() instanceof IItemFuse) {
if (!this.mergeItemStack(var3, 0, 1, false)) {
return var4;
}
} else if (par1 >= 28 && par1 < 37 &&
!this.mergeItemStack(var3, 1, 28, false)) {
return var4;
}
} else if (!this.mergeItemStack(var3, 1, 37, false)) {
return var4;
}
if (var4.stackSize == 0) {
var5.putStack((ItemStack) null);
} else {
var5.onSlotChanged();
}
if (var3.stackSize == var2.stackSize) {
return null;
}
var5.onPickupFromSlot(par1EntityPlayer, var2);
}
return var2;
}
}

View file

@ -0,0 +1,92 @@
package electricexpansion.common.containers;
import electricexpansion.common.misc.InsulationRecipes;
import electricexpansion.common.tile.TileEntityInsulatingMachine;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import universalelectricity.core.item.IItemElectric;
import universalelectricity.prefab.SlotSpecific;
public class ContainerInsulationMachine extends Container {
private TileEntityInsulatingMachine tileEntity;
public ContainerInsulationMachine(final InventoryPlayer par1InventoryPlayer,
final TileEntityInsulatingMachine tileEntity) {
this.tileEntity = tileEntity;
this.addSlotToContainer((Slot) new SlotUniversalElectricItem(
(IInventory) tileEntity, 0, 55, 49));
this.addSlotToContainer(new Slot((IInventory) tileEntity, 1, 55, 25));
this.addSlotToContainer((Slot) new SlotSpecific(
(IInventory) tileEntity, 2, 108, 25, new ItemStack[] { null }));
for (int var3 = 0; var3 < 3; ++var3) {
for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new Slot((IInventory) par1InventoryPlayer,
var4 + var3 * 9 + 9, 8 + var4 * 18,
84 + var3 * 18));
}
}
for (int var3 = 0; var3 < 9; ++var3) {
this.addSlotToContainer(
new Slot((IInventory) par1InventoryPlayer, var3, 8 + var3 * 18, 142));
}
tileEntity.openInventory();
}
public void onContainerClosed(final EntityPlayer entityplayer) {
super.onContainerClosed(entityplayer);
this.tileEntity.closeInventory();
}
public boolean canInteractWith(final EntityPlayer par1EntityPlayer) {
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
}
public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer,
final int par1) {
ItemStack var2 = null;
final Slot var3 = (Slot) super.inventorySlots.get(par1);
if (var3 != null && var3.getHasStack()) {
final ItemStack var4 = var3.getStack();
var2 = var4.copy();
if (par1 == 2) {
if (!this.mergeItemStack(var4, 3, 39, true)) {
return null;
}
var3.onSlotChange(var4, var2);
} else if (par1 != 1 && par1 != 0) {
if (var4.getItem() instanceof IItemElectric) {
if (!this.mergeItemStack(var4, 0, 1, false)) {
return null;
}
} else if (InsulationRecipes.INSTANCE.getProcessResult(var4) > 0) {
if (!this.mergeItemStack(var4, 1, 2, false)) {
return null;
}
} else if (par1 >= 3 && par1 < 30) {
if (!this.mergeItemStack(var4, 30, 39, false)) {
return null;
}
} else if (par1 >= 30 && par1 < 39 &&
!this.mergeItemStack(var4, 3, 30, false)) {
return null;
}
} else if (!this.mergeItemStack(var4, 3, 39, false)) {
return null;
}
if (var4.stackSize == 0) {
var3.putStack((ItemStack) null);
} else {
var3.onSlotChanged();
}
if (var4.stackSize == var2.stackSize) {
return null;
}
var3.onPickupFromSlot(par1EntityPlayer, var4);
}
return var2;
}
}

View file

@ -0,0 +1,92 @@
package electricexpansion.common.containers;
import electricexpansion.common.misc.WireMillRecipes;
import electricexpansion.common.tile.TileEntityWireMill;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import universalelectricity.core.item.IItemElectric;
import universalelectricity.prefab.SlotSpecific;
public class ContainerWireMill extends Container {
private TileEntityWireMill tileEntity;
public ContainerWireMill(final InventoryPlayer par1InventoryPlayer,
final TileEntityWireMill tileEntity) {
this.tileEntity = tileEntity;
this.addSlotToContainer((Slot) new SlotUniversalElectricItem(
(IInventory) tileEntity, 0, 55, 49));
this.addSlotToContainer(new Slot((IInventory) tileEntity, 1, 55, 25));
this.addSlotToContainer((Slot) new SlotSpecific(
(IInventory) tileEntity, 2, 108, 25, new ItemStack[] { null }));
for (int var3 = 0; var3 < 3; ++var3) {
for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new Slot((IInventory) par1InventoryPlayer,
var4 + var3 * 9 + 9, 8 + var4 * 18,
84 + var3 * 18));
}
}
for (int var3 = 0; var3 < 9; ++var3) {
this.addSlotToContainer(
new Slot((IInventory) par1InventoryPlayer, var3, 8 + var3 * 18, 142));
}
tileEntity.openInventory();
}
public void onContainerClosed(final EntityPlayer entityplayer) {
super.onContainerClosed(entityplayer);
this.tileEntity.closeInventory();
}
public boolean canInteractWith(final EntityPlayer par1EntityPlayer) {
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
}
public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer,
final int par1) {
ItemStack var2 = null;
final Slot var3 = (Slot) super.inventorySlots.get(par1);
if (var3 != null && var3.getHasStack()) {
final ItemStack var4 = var3.getStack();
var2 = var4.copy();
if (par1 == 2) {
if (!this.mergeItemStack(var4, 3, 39, true)) {
return null;
}
var3.onSlotChange(var4, var2);
} else if (par1 != 1 && par1 != 0) {
if (var4.getItem() instanceof IItemElectric) {
if (!this.mergeItemStack(var4, 0, 1, false)) {
return null;
}
} else if (WireMillRecipes.INSTANCE.getDrawingResult(var4) != null) {
if (!this.mergeItemStack(var4, 1, 2, false)) {
return null;
}
} else if (par1 >= 3 && par1 < 30) {
if (!this.mergeItemStack(var4, 30, 39, false)) {
return null;
}
} else if (par1 >= 30 && par1 < 39 &&
!this.mergeItemStack(var4, 3, 30, false)) {
return null;
}
} else if (!this.mergeItemStack(var4, 3, 39, false)) {
return null;
}
if (var4.stackSize == 0) {
var3.putStack((ItemStack) null);
} else {
var3.onSlotChanged();
}
if (var4.stackSize == var2.stackSize) {
return null;
}
var3.onPickupFromSlot(par1EntityPlayer, var4);
}
return var2;
}
}

View file

@ -0,0 +1,18 @@
package electricexpansion.common.containers;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import universalelectricity.core.item.IItemElectric;
public class SlotUniversalElectricItem extends Slot {
public SlotUniversalElectricItem(final IInventory par2IInventory,
final int par3, final int par4,
final int par5) {
super(par2IInventory, par3, par4, par5);
}
public boolean isItemValid(final ItemStack par1ItemStack) {
return par1ItemStack.getItem() instanceof IItemElectric;
}
}

View file

@ -0,0 +1,70 @@
package electricexpansion.common.helpers;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.api.EnumWireMaterial;
import java.util.HashMap;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import universalelectricity.core.electricity.ElectricityDisplay;
public abstract class ItemBlockCableHelper extends ItemBlock {
protected HashMap<String, IIcon> icons;
public ItemBlockCableHelper(final Block id) {
super(id);
this.icons = new HashMap<>();
this.setHasSubtypes(true);
this.setMaxDamage(0);
}
public int getMetadata(final int damage) {
return damage;
}
public String getUnlocalizedName(final ItemStack itemStack) {
return this.getUnlocalizedName() + "." +
EnumWireMaterial.values()[itemStack.getItemDamage()].name;
}
@SideOnly(Side.CLIENT)
public void addInformation(final ItemStack itemstack,
final EntityPlayer player, final List par3List,
final boolean par4) {
par3List.add(
"Resistance: " +
ElectricityDisplay.getDisplay(
EnumWireMaterial.values()[itemstack.getItemDamage()].resistance,
ElectricityDisplay.ElectricUnit.RESISTANCE));
par3List.add(
"Max Amps: " +
ElectricityDisplay.getDisplay(
EnumWireMaterial.values()[itemstack.getItemDamage()].maxAmps,
ElectricityDisplay.ElectricUnit.AMPERE));
}
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister par1IconRegister) {
if (this.getUnlocalizedName().equals("tile.HiddenWire") ||
this.getUnlocalizedName().equals("tile.SwitchWireBlock")) {
return;
}
for (int i = 0; i < EnumWireMaterial.values().length - 1; ++i) {
this.icons.put(this.getUnlocalizedName(new ItemStack(this, 1, i)),
par1IconRegister.registerIcon(
this.getUnlocalizedName(new ItemStack(this, 1, i))
.replaceAll("tile.", "electricexpansion:")));
}
}
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(final int meta) {
return this.icons.get(
this.getUnlocalizedName(new ItemStack(this, 1, meta)));
}
}

View file

@ -0,0 +1,26 @@
package electricexpansion.common.helpers;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import electricexpansion.common.cables.TileEntityLogisticsWire;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class PacketHandlerLogisticsWireButton
implements IMessageHandler<PacketLogisticsWireButton, IMessage> {
@Override
public IMessage onMessage(PacketLogisticsWireButton message,
MessageContext ctx) {
World world = ctx.getServerHandler().playerEntity.worldObj;
TileEntity te = message.pos.getTileEntity(world);
if (te instanceof TileEntityLogisticsWire) {
((TileEntityLogisticsWire) te)
.onButtonPacket(message.buttonId, message.status);
}
return null;
}
}

View file

@ -0,0 +1,25 @@
package electricexpansion.common.helpers;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import electricexpansion.common.tile.TileEntityQuantumBatteryBox;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class PacketHandlerUpdateQuantumBatteryBoxFrequency
implements IMessageHandler<PacketUpdateQuantumBatteryBoxFrequency, IMessage> {
@Override
public IMessage onMessage(PacketUpdateQuantumBatteryBoxFrequency message,
MessageContext ctx) {
World world = ctx.getServerHandler().playerEntity.worldObj;
TileEntity te = message.pos.getTileEntity(world);
if (te instanceof TileEntityQuantumBatteryBox) {
((TileEntityQuantumBatteryBox) te).setFrequency(message.freq);
}
return null;
}
}

View file

@ -0,0 +1,37 @@
package electricexpansion.common.helpers;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import io.netty.buffer.ByteBuf;
import universalelectricity.core.vector.Vector3;
public class PacketLogisticsWireButton implements IMessage {
Vector3 pos;
int buttonId;
boolean status;
public PacketLogisticsWireButton(Vector3 pos, int buttonId, boolean status) {
this.pos = pos;
this.buttonId = buttonId;
this.status = status;
}
public PacketLogisticsWireButton() {
this(null, 0, false);
}
@Override
public void fromBytes(ByteBuf buf) {
this.pos = new Vector3(buf.readInt(), buf.readInt(), buf.readInt());
this.buttonId = buf.readInt();
this.status = buf.readBoolean();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(this.pos.intX());
buf.writeInt(this.pos.intY());
buf.writeInt(this.pos.intZ());
buf.writeInt(this.buttonId);
buf.writeBoolean(this.status);
}
}

View file

@ -0,0 +1,33 @@
package electricexpansion.common.helpers;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import io.netty.buffer.ByteBuf;
import universalelectricity.core.vector.Vector3;
public class PacketUpdateQuantumBatteryBoxFrequency implements IMessage {
Vector3 pos;
byte freq;
public PacketUpdateQuantumBatteryBoxFrequency() {
this(null, (byte) 0);
}
public PacketUpdateQuantumBatteryBoxFrequency(Vector3 pos, byte freq) {
this.pos = pos;
this.freq = freq;
}
@Override
public void fromBytes(ByteBuf buf) {
this.pos = new Vector3(buf.readInt(), buf.readInt(), buf.readInt());
this.freq = buf.readByte();
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(this.pos.intX());
buf.writeInt(this.pos.intY());
buf.writeInt(this.pos.intZ());
buf.writeByte(this.freq);
}
}

View file

@ -0,0 +1,18 @@
package electricexpansion.common.helpers;
import cpw.mods.fml.common.FMLCommonHandler;
public class PlayerHelper {
public static boolean isPlayerOp(String playerName) {
String[] ops = FMLCommonHandler.instance()
.getMinecraftServerInstance()
.getConfigurationManager()
.func_152606_n();
for (String op : ops) {
if (playerName.equalsIgnoreCase(op))
return true;
}
return false;
}
}

View file

@ -0,0 +1,249 @@
package electricexpansion.common.helpers;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import electricexpansion.api.EnumWireMaterial;
import electricexpansion.api.EnumWireType;
import electricexpansion.api.IAdvancedConductor;
import electricexpansion.common.cables.TileEntityInsulatedWire;
import electricexpansion.common.misc.EENetwork;
import java.util.Arrays;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.block.IConductor;
import universalelectricity.core.block.IConnector;
import universalelectricity.core.block.INetworkProvider;
import universalelectricity.core.electricity.IElectricityNetwork;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import universalelectricity.prefab.tile.TileEntityAdvanced;
public abstract class TileEntityConductorBase
extends TileEntityAdvanced implements IAdvancedConductor {
public ItemStack textureItemStack;
public boolean isIconLocked;
public EENetwork smartNetwork;
protected final String channel;
public boolean[] visuallyConnected;
public TileEntity[] connectedBlocks;
@Override
public IElectricityNetwork getNetwork() {
if (this.smartNetwork == null) {
this.setNetwork(new EENetwork(new IConductor[] { this }));
}
return this.smartNetwork;
}
@Override
public void setNetwork(final IElectricityNetwork network) {
if (network instanceof EENetwork) {
this.smartNetwork = (EENetwork) network;
} else {
this.smartNetwork = new EENetwork(network);
}
}
public TileEntityConductorBase() {
this.isIconLocked = false;
this.visuallyConnected = new boolean[] { false, false, false, false, false, false };
this.connectedBlocks = new TileEntity[] { null, null, null, null, null, null };
this.channel = "ElecEx";
}
@Override
public void initiate() {
super.initiate();
this.updateAdjacentConnections();
this.getWorldObj().markBlockRangeForRenderUpdate(this.xCoord, this.yCoord,
this.zCoord, this.xCoord,
this.yCoord, this.zCoord);
}
@Override
public double getResistance() {
return this
.getWireMaterial(this.getWorldObj().getBlockMetadata(
this.xCoord, this.yCoord, this.zCoord)).resistance;
}
@Override
public void writeToNBT(final NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setBoolean("isIconLocked", this.isIconLocked);
if (this.textureItemStack != null) {
this.textureItemStack.writeToNBT(tag);
}
}
@Override
public void readFromNBT(final NBTTagCompound tag) {
super.readFromNBT(tag);
try {
this.textureItemStack = ItemStack.loadItemStackFromNBT(tag);
} catch (final Exception e) {
this.textureItemStack = null;
}
try {
this.isIconLocked = tag.getBoolean("isIconLocked");
} catch (final Exception e) {
this.isIconLocked = false;
}
}
@Override
public double getCurrentCapcity() {
final int meta = this.getWorldObj().getBlockMetadata(
this.xCoord, this.yCoord, this.zCoord);
if (meta < EnumWireMaterial.values().length - 1) {
return EnumWireMaterial.values()[meta].maxAmps;
}
return EnumWireMaterial.UNKNOWN.maxAmps;
}
@Override
public EnumWireType getWireType(final int metadata) {
return EnumWireType.values()[metadata];
}
@Override
public EnumWireMaterial getWireMaterial(final int metadata) {
if (metadata < EnumWireMaterial.values().length - 1) {
return EnumWireMaterial.values()[metadata];
}
return EnumWireMaterial.UNKNOWN;
}
public void updateConnection(final TileEntity tileEntity,
final ForgeDirection side) {
if (!this.getWorldObj().isRemote && tileEntity != null) {
if (tileEntity instanceof TileEntityInsulatedWire &&
this instanceof TileEntityInsulatedWire) {
final TileEntityInsulatedWire tileEntityIns = (TileEntityInsulatedWire) tileEntity;
if ((tileEntityIns.colorByte == ((TileEntityInsulatedWire) this).colorByte ||
((TileEntityInsulatedWire) this).colorByte == -1 ||
tileEntityIns.colorByte == -1) &&
tileEntityIns.getWireMaterial(tileEntity.getBlockMetadata()) == this
.getWireMaterial(this.getBlockMetadata())
&&
((IConnector) tileEntity).canConnect(side.getOpposite())) {
this.connectedBlocks[side.ordinal()] = tileEntity;
this.visuallyConnected[side.ordinal()] = true;
if (tileEntity.getClass() == this.getClass() &&
tileEntity instanceof INetworkProvider) {
this.getNetwork().mergeConnection(
((INetworkProvider) tileEntity).getNetwork());
}
return;
}
} else if (tileEntity instanceof IAdvancedConductor) {
final IAdvancedConductor tileEntityWire = (IAdvancedConductor) tileEntity;
if (tileEntityWire.getWireMaterial(tileEntity.getBlockMetadata()) == this
.getWireMaterial(this.getBlockMetadata()) &&
((IConnector) tileEntity).canConnect(side.getOpposite())) {
this.connectedBlocks[side.ordinal()] = tileEntity;
this.visuallyConnected[side.ordinal()] = true;
if (tileEntity.getClass() == this.getClass() &&
tileEntity instanceof INetworkProvider) {
this.getNetwork().mergeConnection(
((INetworkProvider) tileEntity).getNetwork());
}
return;
}
} else if (((IConnector) tileEntity).canConnect(side.getOpposite())) {
this.connectedBlocks[side.ordinal()] = tileEntity;
this.visuallyConnected[side.ordinal()] = true;
if (tileEntity.getClass() == this.getClass() && tileEntity instanceof INetworkProvider) {
this.getNetwork().mergeConnection(
((INetworkProvider) tileEntity).getNetwork());
}
return;
}
}
this.connectedBlocks[side.ordinal()] = null;
this.visuallyConnected[side.ordinal()] = false;
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
NBTTagCompound nbt = pkt.func_148857_g();
this.visuallyConnected[0] = nbt.getBoolean("bottom");
this.visuallyConnected[1] = nbt.getBoolean("top");
this.visuallyConnected[2] = nbt.getBoolean("back");
this.visuallyConnected[3] = nbt.getBoolean("front");
this.visuallyConnected[4] = nbt.getBoolean("left");
this.visuallyConnected[5] = nbt.getBoolean("right");
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setBoolean("bottom", this.visuallyConnected[0]);
nbt.setBoolean("top", this.visuallyConnected[1]);
nbt.setBoolean("back", this.visuallyConnected[2]);
nbt.setBoolean("front", this.visuallyConnected[3]);
nbt.setBoolean("left", this.visuallyConnected[4]);
nbt.setBoolean("right", this.visuallyConnected[5]);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord,
this.getBlockMetadata(), nbt);
}
@Override
public void invalidate() {
if (!this.getWorldObj().isRemote) {
this.getNetwork().splitNetwork(this);
}
super.invalidate();
}
@Override
public void updateEntity() {
super.updateEntity();
if (!this.getWorldObj().isRemote && super.ticks % 300L == 0L) {
this.updateAdjacentConnections();
}
}
@Override
public boolean canConnect(final ForgeDirection direction) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
return AxisAlignedBB.getBoundingBox(
(double) this.xCoord, (double) this.yCoord, (double) this.zCoord,
(double) (this.xCoord + 1), (double) (this.yCoord + 1),
(double) (this.zCoord + 1));
}
@Override
public TileEntity[] getAdjacentConnections() {
return this.connectedBlocks;
}
public void updateAdjacentConnections() {
if (this.getWorldObj() != null && !this.worldObj.isRemote) {
final boolean[] previousConnections = this.visuallyConnected.clone();
for (byte i = 0; i < 6; ++i) {
this.updateConnection(VectorHelper.getConnectorFromSide(
this.getWorldObj(), new Vector3(this),
ForgeDirection.getOrientation((int) i)),
ForgeDirection.getOrientation((int) i));
}
if (!Arrays.equals(previousConnections, this.visuallyConnected)) {
this.getWorldObj().markBlockForUpdate(this.xCoord, this.yCoord,
this.zCoord);
}
}
}
}

View file

@ -0,0 +1,21 @@
package electricexpansion.common.itemblocks;
import electricexpansion.common.helpers.ItemBlockCableHelper;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class ItemBlockInsulatedWire extends ItemBlockCableHelper {
public ItemBlockInsulatedWire(final Block block) {
super(block);
}
@Override
public void addInformation(final ItemStack par1ItemStack,
final EntityPlayer par2EntityPlayer,
final List par3List, final boolean par4) {
super.addInformation(par1ItemStack, par2EntityPlayer, par3List, par4);
par3List.add("Normal wire, does not shock you");
}
}

Some files were not shown because too many files have changed in this diff Show more