Rewritten cable render, removed hard dep of QLIb :)

This commit is contained in:
modmuss50 2015-07-02 19:49:30 +01:00
parent d795d81fba
commit 33898edf7c
20 changed files with 1460 additions and 1471 deletions

View file

@ -4,8 +4,6 @@
package techreborn.partSystem;
import java.lang.reflect.InvocationTargetException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -14,35 +12,37 @@ import net.minecraftforge.common.util.ForgeDirection;
import techreborn.partSystem.parts.CablePart;
import uk.co.qmunity.lib.ref.Names;
import java.lang.reflect.InvocationTargetException;
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_) {
ForgeDirection dir = ForgeDirection.getOrientation(face);
if(ModPartUtils.hasPart(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, modPart.getName())){
x = x + dir.offsetX;
y = y + dir.offsetY;
z = z + dir.offsetZ;
}
if(ModPartUtils.hasPart(world, x, y, z, modPart.getName())){
return false;
}
if (ModPartRegistry.masterProvider != null) {
try {
if(modPart instanceof CablePart){
@Override
public boolean onItemUse(ItemStack item, EntityPlayer player, World world,
int x, int y, int z, int face, float x_, float y_, float z_) {
ForgeDirection dir = ForgeDirection.getOrientation(face);
if (ModPartUtils.hasPart(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, modPart.getName())) {
x = x + dir.offsetX;
y = y + dir.offsetY;
z = z + dir.offsetZ;
}
if (ModPartUtils.hasPart(world, x, y, z, modPart.getName())) {
return false;
}
if (ModPartRegistry.masterProvider != null) {
try {
if (modPart instanceof CablePart) {
if (ModPartRegistry.masterProvider.placePart(item, player, world, x, y, z, face, x_, y_, z_, modPart.getClass().getDeclaredConstructor(int.class).newInstance(((CablePart) modPart).type))) {
player.swingItem();
return true;
}
}else{
} else {
if (ModPartRegistry.masterProvider.placePart(item, player,
world, x, y, z, face, x_, y_, z_, modPart.getClass()
.newInstance())) {
@ -50,53 +50,53 @@ public class ModPartItem extends Item {
return true;
}
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
{
for (IPartProvider partProvider : ModPartRegistry.providers) {
try {
if(modPart instanceof CablePart){
try {
if (partProvider.placePart(item, player, world, x, y, z, face, x_, y_, z_, modPart.getClass().getDeclaredConstructor(int.class).newInstance(((CablePart) modPart).type))) {
for (IPartProvider partProvider : ModPartRegistry.providers) {
try {
if (modPart instanceof CablePart) {
try {
if (partProvider.placePart(item, player, world, x, y, z, face, x_, y_, z_, modPart.getClass().getDeclaredConstructor(int.class).newInstance(((CablePart) modPart).type))) {
player.swingItem();
return true;
}
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
} else {
if (partProvider.placePart(item, player, world, x, y, z, face, x_, y_, z_, modPart.getClass().newInstance())) {
}
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
} else {
if (partProvider.placePart(item, player, world, x, y, z, face, x_, y_, z_, modPart.getClass().newInstance())) {
player.swingItem();
return true;
}
}
}
}
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
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;
}
}