Fixed placing parts inside other parts
This commit is contained in:
parent
98427bbe8a
commit
d70038b77f
4 changed files with 17 additions and 8 deletions
|
@ -8,6 +8,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import techreborn.partSystem.parts.CablePart;
|
||||
import uk.co.qmunity.lib.ref.Names;
|
||||
|
||||
|
@ -25,6 +26,16 @@ public class ModPartItem extends Item {
|
|||
@Override
|
||||
public boolean onItemUse(ItemStack item, EntityPlayer player, World world,
|
||||
int x, int y, int z, int face, float x_, float y_, float z_) {
|
||||
System.out.println(ModPartUtils.hasPart(world, x, y, z, modPart.getName()));
|
||||
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){
|
||||
|
|
|
@ -13,10 +13,7 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import techreborn.lib.Location;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.IModPart;
|
||||
import techreborn.partSystem.IPartProvider;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import techreborn.partSystem.ModPartRegistry;
|
||||
import techreborn.partSystem.*;
|
||||
import techreborn.partSystem.parts.CablePart;
|
||||
import uk.co.qmunity.lib.QLModInfo;
|
||||
import uk.co.qmunity.lib.part.IPart;
|
||||
|
@ -123,6 +120,9 @@ public class QModPartFactory implements IPartFactory, IPartProvider {
|
|||
|
||||
@Override
|
||||
public boolean hasPart(World world, Location location, String name) {
|
||||
if(MultipartCompatibility.getPartHolder(world, location.getX(), location.getY(), location.getZ()) == null){
|
||||
return false;
|
||||
}
|
||||
return MultipartCompatibility.getPart(world, location.getX(), location.getY(), location.getZ(), name) == null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.world.World;
|
||||
import techreborn.lib.Location;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.IModPart;
|
||||
import techreborn.partSystem.IPartProvider;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import techreborn.partSystem.ModPartRegistry;
|
||||
import techreborn.partSystem.*;
|
||||
import techreborn.partSystem.parts.CablePart;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import techreborn.partSystem.ModPartUtils;
|
||||
|
||||
/**
|
||||
* This item is never added into the game, it is only used to add the part to
|
||||
|
|
Loading…
Reference in a new issue