Fix multipart checking with Qlib, initial fix of checkOcclusion
This commit is contained in:
parent
083c24c901
commit
60141026ec
5 changed files with 28 additions and 28 deletions
|
@ -27,18 +27,28 @@ public class ModPartItem extends Item {
|
|||
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;
|
||||
}
|
||||
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))) {
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
{
|
||||
for (IPartProvider partProvider : ModPartRegistry.providers) {
|
||||
try {
|
||||
if(modPart instanceof CablePart){
|
||||
|
|
|
@ -62,6 +62,10 @@ public class ModPartRegistry {
|
|||
iPartProvider = (IPartProvider) Class.forName(className)
|
||||
.newInstance();
|
||||
providers.add(iPartProvider);
|
||||
//I am doing this because the qlibProvider is the most stable
|
||||
if(modid.equals("qmunitylib")){
|
||||
masterProvider = iPartProvider;
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
LogHelper.error("Failed to load " + className
|
||||
|
|
|
@ -27,7 +27,7 @@ public class ModPartUtils {
|
|||
|
||||
public static boolean checkOcclusion(World world, int x, int y, int z,
|
||||
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,
|
||||
|
|
|
@ -111,21 +111,6 @@ public class QModPartFactory implements IPartFactory, IPartProvider {
|
|||
|
||||
@Override
|
||||
public boolean hasPart(World world, Location location, String name) {
|
||||
TileEntity tileEntity = world.getTileEntity(location.getX(),
|
||||
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;
|
||||
return MultipartCompatibility.getPart(world, location.getX(), location.getY(), location.getZ(), name) == null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public class CablePart extends ModPart implements IEnergyConductor {
|
|||
entityCable.setWorldObj(new fakeWorld());
|
||||
entityCable.changeType((short) type);
|
||||
}
|
||||
refreshBounding();
|
||||
}
|
||||
|
||||
public void refreshBounding() {
|
||||
|
@ -249,10 +250,10 @@ public class CablePart extends ModPart implements IEnergyConductor {
|
|||
TileEntity te = world.getTileEntity(getX() + dir.offsetX, getY()
|
||||
+ dir.offsetY, getZ() + dir.offsetZ);
|
||||
if (shouldConnectTo(te, dir)) {
|
||||
// TODO if (ModPartUtils.checkOcclusion(getWorld(), getX(),
|
||||
// getY(), getZ(), boundingBoxes[d])) {
|
||||
if (ModPartUtils.checkOcclusion(getWorld(), getX(),
|
||||
getY(), getZ(), boundingBoxes[d])) {
|
||||
connectedSides.put(dir, te);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
checkConnections(world, getX(), getY(), getZ());
|
||||
|
|
Loading…
Reference in a new issue