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 ItemPartBase<E extends Enum<E> & IEnumPartFactory> extends Item { | |
private final Class<E> enumClass; | |
public ItemPartBase(Class<E> enumClass) { | |
this.enumClass = enumClass; | |
setHasSubtypes(true); | |
} | |
public E getPartConstructor(ItemStack stack) { | |
return enumClass.getEnumConstants()[stack.getItemDamage()]; |
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 ItemPeripherals extends ItemPartBase<PartFactoryPeripherals> { | |
public ItemPeripherals() { | |
super(PartFactoryPeripherals.class); | |
} | |
@Override | |
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { | |
BlockCoord pos = new BlockCoord(x, y, z); | |
double hitDepth = new Vector3(hitX, hitY, hitZ).scalarProject(Rotation.axes[side]) + (side % 2 ^ 1); |
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> { | |
... | |
@Override | |
public void writeDesc(MCDataOutput packet) { | |
super.writeDesc(packet); | |
packet.writeByte(direction.ordinal()); | |
} |
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> implements TSlottedPart { | |
... | |
@Override | |
public int getSlotMask() { | |
return 1 << direction.ordinal(); | |
} | |
} |
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 { | |
// Get the part constructor for this part | |
public abstract E getPartConstructor(); | |
// The type that FMP correlates with this part | |
@Override | |
public String getType() { | |
return getPartConstructor().getPartType(); | |
} | |
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 { | |
... | |
@Override | |
public Iterable<IndexedCuboid6> getSubParts() { | |
List<IndexedCuboid6> cubes = new ArrayList<IndexedCuboid6>(); | |
int i = 0; | |
for (Cuboid6 cuboid : getCollisionBoxes()) { | |
cubes.add(new IndexedCuboid6(i, cuboid)); |
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 JIconHitEffects { | |
... | |
@Override | |
public Cuboid6 getBounds() { | |
return getRenderBounds(); | |
} | |
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 { | |
... | |
@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 abstract class PartBase<E extends Enum<E> & IEnumPartFactory> | |
extends TMultiPart implements JNormalOcclusion, JIconHitEffects, IWorldPosition { | |
... | |
@Override | |
public IBlockAccess getWorld() { | |
return world(); | |
} |
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> implements TSlottedPart { | |
public static final List<Cuboid6> boxes = new ArrayList<Cuboid6>(2); // We know there are two boxes | |
static { | |
boxes.add(new Cuboid6(0.125, 0, 0.125, 0.875, 0.0625, 0.875)); | |
boxes.add(new Cuboid6(0.3125, 0.0625, 0.3125, 0.6875, 0.125, 0.6875)); | |
} | |
... | |