Now the multipart system depends on Qlib, wont load if not installed.

Also a code format of the system
This commit is contained in:
Modmuss50 2015-04-24 19:46:01 +01:00
parent d6797868fb
commit e2467caede
22 changed files with 1542 additions and 1852 deletions

View file

@ -12,67 +12,52 @@ import uk.co.qmunity.lib.ref.Names;
public class ModPartItem extends Item {
ModPart modPart;
ModPart modPart;
public ModPartItem(ModPart part)
{
modPart = part;
setUnlocalizedName(Names.Unlocalized.Items.MULTIPART);
}
public ModPartItem(ModPart part) {
modPart = part;
setUnlocalizedName(Names.Unlocalized.Items.MULTIPART);
}
@Override
public boolean onItemUse(ItemStack item, EntityPlayer player, World world,
int x, int y, int z, int face, float x_, float y_, float z_)
{
if (ModPartRegistry.masterProvider != null)
{
try
{
if (ModPartRegistry.masterProvider.placePart(item, player,
world, x, y, z, face, x_, y_, z_, modPart.getClass()
.newInstance()))
{
return true;
}
} catch (InstantiationException e)
{
e.printStackTrace();
} catch (IllegalAccessException e)
{
e.printStackTrace();
}
return false;
} else
{
for (IPartProvider partProvider : ModPartRegistry.providers)
{
try
{
if (partProvider.placePart(item, player, world, x, y, z,
face, x_, y_, z_, modPart.getClass().newInstance()))
{
return true;
}
} catch (InstantiationException e)
{
e.printStackTrace();
} catch (IllegalAccessException e)
{
e.printStackTrace();
}
}
return true;
}
}
@Override
public boolean onItemUse(ItemStack item, EntityPlayer player, World world,
int x, int y, int z, int face, float x_, float y_, float z_) {
if (ModPartRegistry.masterProvider != null) {
try {
if (ModPartRegistry.masterProvider.placePart(item, player,
world, x, y, z, face, x_, y_, z_, modPart.getClass()
.newInstance())) {
return true;
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return false;
} else {
for (IPartProvider partProvider : ModPartRegistry.providers) {
try {
if (partProvider.placePart(item, player, world, x, y, z,
face, x_, y_, z_, modPart.getClass().newInstance())) {
return true;
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
return true;
}
}
@Override
public String getUnlocalizedName(ItemStack stack)
{
return modPart.getName();
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return modPart.getName();
}
public ModPart getModPart()
{
return modPart;
}
public ModPart getModPart() {
return modPart;
}
}