This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
enum JSON { | |
case JString(String) | |
case JNumber(Double) | |
case JBool(Bool) | |
case JArray([JSON]) | |
case JObject([String: JSON]) | |
case Null | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Mod(modid = CCTransport.MODID, dependencies = "required-after:CCTweaks@[0.2,);required-after:ForgeMultipart;") | |
public class CCTransport { | |
public static final String MODID = "cctransport"; | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait IPartFactory2 | |
{ | |
/** | |
* Create a new server instance of the part with the specified type name identifier | |
* @param nbt The tag compound that will be passed to part.load, can be used to change the class of part returned | |
*/ | |
def createPart(name: String, nbt: NBTTagCompound): TMultiPart | |
/** | |
* Create a new client instance of the part with the specified type name identifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Register a part factory with an array of types it is capable of instantiating. Must be called before postInit | |
*/ | |
def registerParts(partFactory: IPartFactory2, types: Array[String]) { | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IEnumPartFactory { | |
/** | |
* @return The string type that FMP correlates with this type of part. | |
*/ | |
String getPartType(); | |
/** | |
* @see {@link codechicken.multipart.MultiPartRegistry.IPartFactory2#createPart(String, NBTTagCompound)} | |
*/ | |
TMultiPart createPart(NBTTagCompound nbt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<E extends Enum<E> & IEnumPartFactory> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PartFactoryOfEnum<E extends Enum<E> & IEnumPartFactory> implements MultiPartRegistry.IPartFactory2 { | |
private final Class<E> enumClass; | |
private final String[] types; | |
private final Map<String, E> typesToParts = new HashMap<String, E>(); | |
public PartFactoryOfEnum(Class<E> enumClass) { | |
this.enumClass = enumClass; | |
E[] enumConstants = enumClass.getEnumConstants(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sided peripheral parts | |
public enum PartFactoryPeripherals implements IEnumPartFactory { | |
Storage("storage") { | |
@Override | |
public TMultiPart createPart(ForgeDirection direction) { | |
return new StoragePart(direction); // Get to this in a minute | |
} | |
}; | |
private final String type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class PartBase<E extends Enum<E> & IEnumPartFactory> | |
extends TMultiPart implements JNormalOcclusion, JIconHitEffects, IWorldPosition { | |
public abstract E getPartConstructor(); | |
@Override | |
public Iterable<Cuboid6> getOcclusionBoxes() { | |
return getCollisionBoxes(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StoragePart extends PartBase<PartFactoryPeripherals> { | |
private ForgeDirection direction; | |
public StoragePart(ForgeDirection direction) { | |
this.direction = direction; | |
} | |
@Override | |
public PartFactoryPeripherals getPartConstructor() { | |
return PartFactoryPeripherals.Storage; |
OlderNewer