codechicken.multipart.TileMultipart Java Examples

The following examples show how to use codechicken.multipart.TileMultipart. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FrameMovementRegistry.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
public List<IFrame> findFrames(World world, int x, int y, int z) {

    if (world == null)
        return null;

    List<IFrame> l = new ArrayList<IFrame>();

    Block b = world.getBlock(x, y, z);
    if (b instanceof IFrame)
        l.add((IFrame) b);

    TileEntity te = world.getTileEntity(x, y, z);
    if (te != null && te instanceof IFrame)
        l.add((IFrame) te);

    TileMultipart tmp = TileMultipart.getTile(world, new BlockCoord(x, y, z));
    if (tmp != null)
        for (TMultiPart p : tmp.jPartList())
            if (p instanceof IFrame)
                l.add((IFrame) p);// FIXME actual multipart handling

    return l;
}
 
Example #2
Source File: MovementHandlerFMP.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Priority(PriorityEnum.OVERRIDE)
public BlockMovementType getMovementType(World world, int x, int y, int z, ForgeDirection side, IMovement movement) {

    TileMultipart tmp = TileMultipart.getTile(world, new BlockCoord(x, y, z));
    if (tmp == null)
        return null;

    for (TMultiPart p : tmp.jPartList()) {
        if (p instanceof TSlottedPart) {
            int slot = ((TSlottedPart) p).getSlotMask();
            if (slot == PartMap.face(side.ordinal()).mask && (p instanceof FaceMicroblock || p instanceof HollowMicroblock)) {
                if (((CommonMicroblock) p).getSize() == 1)
                    return BlockMovementType.UNMOVABLE;
            }
        }
    }

    return null;
}
 
Example #3
Source File: ModInteractionUtilImplementation.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
@Optional.Method(modid = ModIds.FMP)
public void removeTube(TileEntity te){
    if(te instanceof TileMultipart) {
        PartPressureTube tube = FMP.getMultiPart((TileMultipart)te, PartPressureTube.class);
        if(tube != null) {
            List<ItemStack> drops = BlockPressureTube.getModuleDrops(tube.getTube());
            for(ItemStack drop : drops) {
                EntityItem entity = new EntityItem(te.getWorldObj(), te.xCoord + 0.5, te.yCoord + 0.5, te.zCoord + 0.5);
                entity.setEntityItemStack(drop);
                te.getWorldObj().spawnEntityInWorld(entity);
            }
            ((TileMultipart)te).remPart(tube);
        }
    } else {
        super.removeTube(te);
    }
}
 
Example #4
Source File: ItemBlockChiselTorchPart.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
public boolean placePart(World world, BlockCoord pos, ItemStack item, int side, boolean doPlace) {
	TileMultipart tile = TileMultipart.getOrConvertTile(world, pos);
	if (tile == null) {
		return false;
	}
	TMultiPart part = createMultiPart(world, pos, item, side);
	if (part == null) {
		return false;
	}
	if (tile.canAddPart(part)) {
		if (doPlace) {
			TileMultipart.addPart(world, pos, part);
		}
		return true;
	}
	return false;
}
 
Example #5
Source File: FMP.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static <T> Iterable<T> getMultiParts(TileMultipart t, Class<T> searchedClass){
    List<T> parts = new ArrayList<T>();
    for(TMultiPart part : t.jPartList()) {
        if(searchedClass.isAssignableFrom(part.getClass())) parts.add((T)part);
    }
    return parts;
}
 
Example #6
Source File: FluidPipeNet.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Method(modid = GTValues.MODID_FMP)
private static void removeMultipartPipePartFromTile(TileEntity tileEntity) {
    if (tileEntity instanceof TileMultipart) {
        TileMultipart tileMultipart = (TileMultipart) tileEntity;
        List<TMultiPart> partList = tileMultipart.jPartList();
        for (TMultiPart tMultiPart : partList) {
            if (tMultiPart instanceof IPipeTile) {
                tileMultipart.remPart(tMultiPart);
            }
        }
    }
}
 
Example #7
Source File: ModInteractionUtilImplementation.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Optional.Method(modid = ModIds.FMP)
public boolean occlusionTest(AxisAlignedBB aabb, TileEntity te){
    if(te instanceof TileMultipart) {
        return ((TileMultipart)te).occlusionTest(((TileMultipart)te).partList(), new NormallyOccludedPart(new Cuboid6(aabb)));
    } else {
        return super.occlusionTest(aabb, te);
    }
}
 
Example #8
Source File: ModInteractionUtilImplementation.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Optional.Method(modid = ModIds.FMP)
public TileEntityPressureTube getTube(Object potentialTube){
    if(potentialTube instanceof PartPressureTube) {
        return ((PartPressureTube)potentialTube).getTube();
    } else if(potentialTube instanceof TileMultipart) {
        PartPressureTube tube = FMP.getMultiPart((TileMultipart)potentialTube, PartPressureTube.class);
        return tube != null ? tube.getTube() : null;
    } else {
        return super.getTube(potentialTube);
    }
}
 
Example #9
Source File: ModInteractionUtilImplementation.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Optional.Method(modid = ModIds.FMP)
public IPneumaticWrenchable getWrenchable(TileEntity te){
    if(te instanceof TileMultipart) {
        return FMP.getMultiPart((TileMultipart)te, IPneumaticWrenchable.class);
    } else {
        return super.getWrenchable(te);
    }
}
 
Example #10
Source File: ModInteractionUtilImplementation.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 *  ForgeMultipart
 */

@Override
@Optional.Method(modid = ModIds.FMP)
public IPneumaticMachine getMachine(TileEntity te){
    if(te instanceof TileMultipart) {
        return FMP.getMultiPart((TileMultipart)te, IPneumaticMachine.class);
    } else {
        return super.getMachine(te);
    }
}
 
Example #11
Source File: MOPHelper.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onRenderHighlight(DrawBlockHighlightEvent event) {

    if (!(event.target instanceof ExtendedMOP)
            && event.player.worldObj.getTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ) instanceof TileMultipart)
        event.setCanceled(true);
}
 
Example #12
Source File: StickyHandlerFMP.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean isSideSticky(World world, int x, int y, int z, ForgeDirection side, IMovement movement) {

    TileMultipart tmp = TileMultipart.getTile(world, new BlockCoord(x, y, z));
    if (tmp == null)
        return false;

    boolean is = false;

    for (TMultiPart p : tmp.jPartList()) {
        if (p instanceof TSlottedPart) {
            int slot = ((TSlottedPart) p).getSlotMask();
            if (PartMap.face(side.ordinal()).mask == slot) {
                if (p instanceof ISticky) {
                    return ((ISticky) p).isSideSticky(world, x, y, z, side, movement);
                } else if (p instanceof FaceMicroblock || p instanceof HollowMicroblock) {
                    if (((CommonMicroblock) p).getSize() == 1)
                        return false;
                }
            } else if (slot == PartMap.CENTER.mask && p instanceof ISticky)
                return ((ISticky) p).isSideSticky(world, x, y, z, side, movement);
        } else if (p instanceof ISticky)
            is |= ((ISticky) p).isSideSticky(world, x, y, z, side, movement);
    }

    return is;
}
 
Example #13
Source File: MovementHandlerFMP.java    From Framez with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ISticky getStickyAt(World world, int x, int y, int z) {

    TileMultipart tmp = TileMultipart.getTile(world, new BlockCoord(x, y, z));
    if (tmp != null)
        return StickyHandlerFMP.instance();
    return null;
}
 
Example #14
Source File: WirelessPart.java    From WirelessRedstone with MIT License 4 votes vote down vote up
public void drop() {
    TileMultipart.dropItem(getItem(), world(), Vector3.fromTileEntityCenter(tile()));
    tile().remPart(this);
}
 
Example #15
Source File: ModInteractionUtilImplementation.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Optional.Method(modid = ModIds.FMP)
public boolean isMultipart(TileEntity te){
    return te instanceof TileMultipart;
}
 
Example #16
Source File: FMPPlacementListener.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public static boolean place(EntityPlayer player, World world){
    MovingObjectPosition hit = RayTracer.reTrace(world, player);
    if(hit == null) return false;

    BlockCoord pos = new BlockCoord(hit.blockX, hit.blockY, hit.blockZ);
    ItemStack held = player.getHeldItem();
    PartPressureTube part = null;
    if(held == null) return false;

    Block heldBlock = Block.getBlockFromItem(held.getItem());
    if(heldBlock == Blockss.pressureTube) {
        part = new PartPressureTube();
    } else if(heldBlock == Blockss.advancedPressureTube) {
        part = new PartAdvancedPressureTube();
    }

    if(part == null) return false;

    if(world.isRemote && !player.isSneaking())//attempt to use block activated like normal and tell the server the right stuff
    {
        Vector3 f = new Vector3(hit.hitVec).add(-hit.blockX, -hit.blockY, -hit.blockZ);
        Block block = world.getBlock(hit.blockX, hit.blockY, hit.blockZ);
        if(!ignoreActivate(block) && block.onBlockActivated(world, hit.blockX, hit.blockY, hit.blockZ, player, hit.sideHit, (float)f.x, (float)f.y, (float)f.z)) {
            player.swingItem();
            PacketCustom.sendToServer(new C08PacketPlayerBlockPlacement(hit.blockX, hit.blockY, hit.blockZ, hit.sideHit, player.inventory.getCurrentItem(), (float)f.x, (float)f.y, (float)f.z));
            return true;
        }
    }

    TileMultipart tile = TileMultipart.getOrConvertTile(world, pos);
    if(tile == null || !tile.canAddPart(part)) {
        pos = pos.offset(hit.sideHit);
        tile = TileMultipart.getOrConvertTile(world, pos);
        if(tile == null || !tile.canAddPart(part)) return false;
    }

    if(!world.isRemote) {
        TileMultipart.addPart(world, pos, part);
        world.playSoundEffect(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, Blockss.pressureTube.stepSound.func_150496_b(), (Blockss.pressureTube.stepSound.getVolume() + 1.0F) / 2.0F, Blockss.pressureTube.stepSound.getPitch() * 0.8F);
        if(!player.capabilities.isCreativeMode) {
            held.stackSize--;
            if(held.stackSize == 0) {
                player.inventory.mainInventory[player.inventory.currentItem] = null;
                MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, held));
            }
        }
    } else {
        player.swingItem();
        NetworkHandler.sendToServer(new PacketFMPPlacePart());
    }
    return true;
}
 
Example #17
Source File: FMP.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
private static TileMultipart getMultipartTile(IBlockAccess access, ChunkPosition pos){
    TileEntity te = access.getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
    return te instanceof TileMultipart ? (TileMultipart)te : null;
}
 
Example #18
Source File: FMP.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public static <T> T getMultiPart(IBlockAccess access, ChunkPosition pos, Class<T> searchedClass){
    TileMultipart t = getMultipartTile(access, pos);
    return t == null ? null : getMultiPart(t, searchedClass);
}
 
Example #19
Source File: FMP.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public static <T> T getMultiPart(TileMultipart t, Class<T> searchedClass){
    for(TMultiPart part : t.jPartList()) {
        if(searchedClass.isAssignableFrom(part.getClass())) return (T)part;
    }
    return null;
}
 
Example #20
Source File: MovementHandlerFMP.java    From Framez with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canHandle(World world, int x, int y, int z) {

    return TileMultipart.getTile(world, new BlockCoord(x, y, z)) != null;
}