Fix multipart checking with Qlib, initial fix of checkOcclusion

This commit is contained in:
modmuss50 2015-04-25 07:38:00 +01:00
parent 083c24c901
commit 60141026ec
5 changed files with 28 additions and 28 deletions

View file

@ -27,18 +27,28 @@ public class ModPartItem extends Item {
int x, int y, int z, int face, float x_, float y_, float z_) { int x, int y, int z, int face, float x_, float y_, float z_) {
if (ModPartRegistry.masterProvider != null) { if (ModPartRegistry.masterProvider != null) {
try { try {
if (ModPartRegistry.masterProvider.placePart(item, player, if(modPart instanceof CablePart){
world, x, y, z, face, x_, y_, z_, modPart.getClass() if (ModPartRegistry.masterProvider.placePart(item, player, world, x, y, z, face, x_, y_, z_, modPart.getClass().getDeclaredConstructor(int.class).newInstance(((CablePart) modPart).type))) {
.newInstance())) { return true;
return true; }
} }else{
if (ModPartRegistry.masterProvider.placePart(item, player,
world, x, y, z, face, x_, y_, z_, modPart.getClass()
.newInstance())) {
return true;
}
}
} catch (InstantiationException e) { } catch (InstantiationException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} } catch (NoSuchMethodException e) {
return false; e.printStackTrace();
} else { } catch (InvocationTargetException e) {
e.printStackTrace();
}
}
{
for (IPartProvider partProvider : ModPartRegistry.providers) { for (IPartProvider partProvider : ModPartRegistry.providers) {
try { try {
if(modPart instanceof CablePart){ if(modPart instanceof CablePart){

View file

@ -62,6 +62,10 @@ public class ModPartRegistry {
iPartProvider = (IPartProvider) Class.forName(className) iPartProvider = (IPartProvider) Class.forName(className)
.newInstance(); .newInstance();
providers.add(iPartProvider); providers.add(iPartProvider);
//I am doing this because the qlibProvider is the most stable
if(modid.equals("qmunitylib")){
masterProvider = iPartProvider;
}
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
LogHelper.error("Failed to load " + className LogHelper.error("Failed to load " + className

View file

@ -27,7 +27,7 @@ public class ModPartUtils {
public static boolean checkOcclusion(World world, int x, int y, int z, public static boolean checkOcclusion(World world, int x, int y, int z,
Vecs3dCube cube) { Vecs3dCube cube) {
return checkOcclusion(world, new Location(x, y, z), cube); return !checkOcclusion(world, new Location(x, y, z), cube);
} }
public static boolean checkOcclusionInvert(World world, Location location, public static boolean checkOcclusionInvert(World world, Location location,

View file

@ -111,21 +111,6 @@ public class QModPartFactory implements IPartFactory, IPartProvider {
@Override @Override
public boolean hasPart(World world, Location location, String name) { public boolean hasPart(World world, Location location, String name) {
TileEntity tileEntity = world.getTileEntity(location.getX(), return MultipartCompatibility.getPart(world, location.getX(), location.getY(), location.getZ(), name) == null;
location.getY(), location.getZ());
if (tileEntity instanceof TileMultipart) {
TileMultipart mp = (TileMultipart) tileEntity;
boolean ret = false;
List<IPart> t = mp.getParts();
for (IPart p : t) {
if (ret == false) {
if (p.getType().equals(name)) {
ret = true;
}
}
}
return ret;
}
return false;
} }
} }

View file

@ -55,6 +55,7 @@ public class CablePart extends ModPart implements IEnergyConductor {
entityCable.setWorldObj(new fakeWorld()); entityCable.setWorldObj(new fakeWorld());
entityCable.changeType((short) type); entityCable.changeType((short) type);
} }
refreshBounding();
} }
public void refreshBounding() { public void refreshBounding() {
@ -249,10 +250,10 @@ public class CablePart extends ModPart implements IEnergyConductor {
TileEntity te = world.getTileEntity(getX() + dir.offsetX, getY() TileEntity te = world.getTileEntity(getX() + dir.offsetX, getY()
+ dir.offsetY, getZ() + dir.offsetZ); + dir.offsetY, getZ() + dir.offsetZ);
if (shouldConnectTo(te, dir)) { if (shouldConnectTo(te, dir)) {
// TODO if (ModPartUtils.checkOcclusion(getWorld(), getX(), if (ModPartUtils.checkOcclusion(getWorld(), getX(),
// getY(), getZ(), boundingBoxes[d])) { getY(), getZ(), boundingBoxes[d])) {
connectedSides.put(dir, te); connectedSides.put(dir, te);
// } }
} }
} }
checkConnections(world, getX(), getY(), getZ()); checkConnections(world, getX(), getY(), getZ());